Solve SQL Injection Lab
Solve SQL Injection Lab
To solve this lab we need to visit the homepage and intercept the request. We then need to
replace the tracking cookie with the following value:
TrackingId=x'||pg_sleep(10)--
Since we are talking about blind SQLi we will not be receiving information from the server to
even confirm wheter or not we have a SQLi on our hands. In these cases we have several options
that allow us to create a noticeable delay (for example a sleep of 10 seconds), however this sleep
command will differ from database system to database system.
Oracledbms_pipe.receive_message(('a'),10)
PostgreSQLSELECT pg_sleep(10)
MySQLSELECT sleep(10)
TrackingId=x'||dbms_pipe.receive_message(('a'),10)
TrackingId=x'||pg_sleep(10)
TrackingId=x'||sleep(10)
What is happening here is that the server is executing a query in the background. By entering the
single quote, we are closing that query, we can then add an OR statement (||). The last step would
be to execute our command (see list above).
When the page loads for much longer than the other requests, we know we might have a blind
SQLi.
Other options
We might want to try our SQLi with several other options besides our sleep command and
maybe with a combination of single and double quote items. I think you can imagine how this
can get confusing fast?
To not have to do this manually for every single request, we can send that request to the intruder.
Right click on the request and click "Send to Intruder". Ones in the intruder select the payload
location that you want to test for. In our case we left the x'|| since it will be the same for all
requests that we send:
We can then fill our payload options with whatever attack vector we wish.
We will then have to study every request to see if we can find requests that are different from the
rest in any way.
Resources for this lecture
https://portswigger.net/web-security/sql-injection/blind/lab-time-delays