BOOL
ABOUT
Exploiting blind SQL injection by triggering conditional responses. Consider an application that uses tracking cookies to gather analytics about usage. Requests to the application include a cookie header like this:
Cookie: TrackingId=u5YD3PapBcR4lN3e7Tj4
When a request containing a TrackingId cookie is processed, the application uses a SQL query to determine whether this is a known user:
SELECT TrackingId FROM TrackedUsers WHERE TrackingId = 'u5YD3PapBcR4lN3e7Tj4'This query is vulnerable to SQL injection, but the results from the query are not returned to the user. However, the application does behave differently depending on whether the query returns any data. If you submit a recognized TrackingId, the query returns data and you receive a "Welcome back" message in the response.
WHERE TO LOOK
The key difference between visible and blind SQL Injections is ability to see the output of your payloads, and where is it hidden. If there is some part of website which changes depending on the value your payload outputs (true / false), then you found the BLIND SQLi. But to exploit it you need to construct payload that way, so that indicator appearance is controlled.
APPROACH
Blind SQL injection enumeration proceeds by isolating a single boolean predicate per request and observing a binary signal in the application response. Order is fixed: confirm injection point, confirm data source, then enumerate structure, then enumerate values, then enumerate value lengths and characters.
Probing
Confirm control over the query by appending a tautology and confirming a positive signal:
' AND '1'='1Positive response proves injection.Append a contradiction and confirm loss of the signal:
' AND '1'='2Negative response proves boolean behavior.Confirm presence of a table:
' AND (SELECT 'a' FROM users LIMIT 1)='aIf true, table exists and is readable.Confirm presence of a row:
' AND (SELECT 'a' FROM users WHERE username='administrator')='aTrue indicates the row exists.Establish password length lower bound:
' AND (SELECT 'a' FROM users WHERE username='administrator' AND LENGTH(password)>1)='aTrue means length > 1.Increase the threshold monotonically:
>2>3Continue until the condition flips to false. That index is the length boundary.
Correct: the 'a' is just a constant chosen to turn a subquery into a simple boolean check — it makes the injected expression evaluate to either true (matches 'a') or false (does not), so the attacker gets a binary signal from the application’s response behavior.
CONDITIONAL ERROR SQLi
This is a hybrid of error-based and blind SQL injections. It can happen when we can't see the output, but we can provoke an error, or make it controllable. When we have payload and with manipulating boolean values to get certain information step by step, it means we've made Binary Oracle.
For understanding fully how this works you need to understand what is the order and logic behind SQL conditional operators. As simple example we'll use this payload:
Here it seems exactly same, but the output by the application, would be different, so what's the logic here?
Here condition1 (1=2 or 1=1) it's possible, that's where we put our command for searching certain parameters, but we should remember that output should be only true / false. If condition1 is TRUE, then request goes for THEN part, where we have unequivocal condition (1/0) which will always answer in ERROR. If our condition1 is FALSE, then we have 'a' so that request just has 'a' = 'a' part, which will always be true and gives SQL engine ignore of that operation and absence of error.
EXAMPLES
Different concatenation methods and operators usage
Here you can see that there is not only type of operators to use:
ANDand||are different, but both can be used.ANDinjects boolean logic and||concatenates different strings into one''andNULLConcatenation methods are different, in first payload we concate our request like:
value'AND (condition) -- asldkasldjasd, commented part of requestand in second payload it's less aggressive:value'||(condition)||'continuation of request, instead of commenting itwhich is less aggressive
Last updated


