Time based Blind SQL Injection
Blind SQL Injection happens when:
There is a SQL injection vulnerability,
BUT the application does not show any SQL errors or query outputs directly.
In this case, an attacker has to ask questions to the database and observe how the server behaves to extract information bit by bit.
There are two main types:
Boolean-based blind SQLi (based on true/false responses)
Time-based blind SQLi (based on delay in server response)
When the server behaves the same way for both True and False, we use Time delays to detect it!
Example:
Inject:
bash Copy Edit http://victim.com/product.php?id=5' AND IF(1=1, SLEEP(5), 0) -- If the server pauses for 5 seconds, 1=1 condition is true.
Inject:
bash Copy Edit http://victim.com/product.php?id=5' AND IF(1=2, SLEEP(5), 0) -- If no delay, then 1=2 condition is false.
Thus, based on the response time, we infer the truth of the injected statement.
Similarly, we can extract one character at a time by checking:
sql Copy Edit IF(SUBSTRING(database(),1,1)='a', SLEEP(5), 0)