This project demonstrates what SQL Injection is, how attackers exploit it, and how to prevent it using secure coding techniques.
- Vulnerable login system (for educational purposes)
- Secure login system using prepared statements
- SQL Injection detection & logging
- Input validation
- Folder structure for clear separation
- Tested on Ubuntu/WSL using LAMP stack
To see the vulnerable system:
- Go to
/vulnerable/index.html - Try:
- Username:
admin' -- - Password:
anything
- Username:
- You will be logged in without a valid password!
To see the secure system:
- Go to
/secure/index.html - Try the same SQL injection β it will be blocked
- The attempt will be logged in
logs.txt
- PHP
- MySQL/MariaDB
- Apache
- HTML + Bootstrap
- Ubuntu on WSL
sqli-project/ βββ vulnerable/ β βββ index.html # Unsafe login form β βββ login.php # Vulnerable to SQLi βββ secure/ β βββ index.html # Safe login form β βββ login_secure.php # Uses prepared statements βββ logs.txt # Records SQLi attempts βββ .gitignore βββ README.md
Navigate to: http://localhost:8080/sqli-project/vulnerable/index.html Try: Username: admin' -- Password: anything
Expected: Logged in β the password is bypassed due to SQL injection.
Navigate to: http://localhost:8080/sqli-project/secure/index.html
Same attempt: Username: admin' -- Password: anything
Expected: Login fails, input is logged in logs.txt, and the system is safe.
cd /var/www/html/sqli-project
git clone https://github.com/YOUR_USERNAME/sqli-project.gitEnsure your Apache is running on port 8080.
http://localhost:8080/secure/index.html
Prepared Statements to prevent query tampering
Regex Validation to restrict harmful input
Logging for all suspected SQLi attempts
How SQL injection works from the ground up
How to break a system and secure it again
How to build cybersecurity projects for GitHub + blog
Why simple code structure helps with learning and sharing
Read the full blog post: How I Broke and Fixed My Own Login System to Learn SQL Injection
MIT License β use for personal or educational projects.
Pull requests are welcome β especially for extra validation layers, logging improvements, or UI enhancements.
This project is for educational purposes only. Never deploy the vulnerable version publicly. Always secure your database queries.