Lab10 Blind SQL injection - Timebase SQL Injection
Lab10 Blind SQL injection - Timebase SQL Injection
Objective:
- This lab is dedicated to exploring Time-Based SQL Injection, a subtype of SQL injection
attacks where the attacker can infer information from a database by observing the response
time of the web application. Participants will interact with a simulated web application that
has a time-based SQL injection vulnerability. The goal is to understand the mechanics of this
attack, identify vulnerabilities, exploit them, and learn effective mitigation strategies.
Time-Based SQL Injection is a type of blind SQL injection technique that relies on
deliberate time delays to infer information from a database. Unlike other SQL injection
methods that directly retrieve data (such as Union-Based SQL Injection), Time-Based
SQL Injection is particularly useful when the application does not return visible database
errors or output (hence, "blind" SQL injection).
How It Works:
1. Injecting a Time Delay:
The attacker crafts an SQL query that includes a conditional delay, typically using
database-specific functions such as:
MySQL: SLEEP(seconds)
Microsoft SQL Server: WAITFOR DELAY 'hh:mm:ss'
PostgreSQL: pg_sleep(seconds)
2. Observing Response Time:
If the condition in the query is true, the database executes the delay, causing a
noticeable slowdown in the web application's response.
If the condition is false, the response is returned immediately.
3. Extracting Data Bit by Bit:
By crafting boolean conditions inside the SQL query, the attacker can systematically
test individual characters or bits of data.
Example (MySQL-based injection):
SELECT IF(SUBSTRING((SELECT database()),1,1)='a', SLEEP(5), 0);
If the first character of the database name is 'a', the response is delayed by 5
seconds.
If not, the response is immediate.
Repeating this process for each character allows the attacker to reconstruct the
entire database name.
Why Is This Useful in Blind SQL Injection
No Direct Data Exposure: Many modern web applications suppress error messages
and prevent direct data retrieval via UNION queries.
Bypassing Security Filters: Since no explicit data is returned, simple filters that block
error-based or union-based injections may not detect this method.
Reliable Even in Restricted Environments: As long as the application’s response time
can be observed, this attack can be executed without needing visible database
errors.
Once an attacker extracts database names, table names, and credentials, they can:
Dump user data (e.g., & columns).usernamepassword
Gain privileged access to the system.
Escalate the attack to remote code execution (RCE) in some cases.
Perform challenge:
o Blind SQL injection with time delays
Explain and capture all steps (full windows screen capture).