Lab 01: Blind SQL Injection

Objective

Extract a complete database password character-by-character from a live API that reveals nothing but true/false — no error messages, no data, just a boolean exists field. Master both boolean-based and numeric PIN inference techniques.

Attack chain:

  1. Confirm boolean-based blind SQLi using AND 1=1 vs AND 1=2

  2. Extract admin password one character at a time using SUBSTR(password,N,1)='X'

  3. Brute-force a numeric PIN using direct boolean comparison

  4. Automate the extraction with Python threading for speed


Background

Blind SQL injection is the most common form of SQLi in production applications. Developers often suppress error messages and limit output, believing this prevents injection — it doesn't. As long as the application's behaviour differs based on query results, an attacker can extract the entire database one bit at a time.

Real-world examples:

  • 2008 Heartland Payment Systems — blind SQLi against payment processor; 130M card numbers stolen. Albert Gonzalez used automated boolean inference.

  • 2012 LinkedIn — 6.5M password hashes exfiltrated via blind SQLi on a secondary endpoint that only returned status codes.

  • CVE-2023-23397 (Exchange) — combined with blind timing-based injection to enumerate internal email addresses.

OWASP: A03:2021 Injection


Architecture

Time

50 minutes


Lab Instructions

Step 1: Setup


Step 2: Launch Kali and Confirm Blind SQLi

📸 Verified Output:


Step 3: Extract Password Character by Character

📸 Verified Output:

💡 Each request leaks 1 bit of information: "is character at position N equal to X?" With ~70 characters in the charset, each position requires at most 70 requests. A 17-character password needs at most 1,190 requests. At 100 req/s, that's 12 seconds. This is why blind SQLi is still devastating — automation turns a "no data" endpoint into a full DB dump.


Step 4: PIN Brute-Force via Boolean Inference

📸 Verified Output:


Step 5: Automated sqlmap Attack

📸 Verified Output:


Step 6: Threaded Extraction (Speed Optimisation)


Step 7: Time-Based Blind SQLi (Alternative Technique)


Step 8: Cleanup


Remediation

Defence
Effect

Parameterised queries

Eliminates all SQLi — values never interpreted as SQL

Input allowlist

pin must be numeric; reject anything else

Rate limiting

Slow down brute-force enumeration

Constant-time response

Don't vary response time based on query result

Further Reading

Last updated