-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import json | ||
import logging | ||
import random | ||
import traceback | ||
from lxml import objectify | ||
from lxml import etree | ||
|
||
|
||
logging.basicConfig(filename='middleware.log', level=logging.DEBUG) | ||
logging.debug('Middleware "modify_request" called') | ||
|
||
|
||
def main(): | ||
data = sys.stdin.readlines() | ||
payload = data[0] | ||
payload_dict = json.loads(payload) | ||
|
||
if "response" in payload_dict and "body" in payload_dict["response"]: | ||
body = payload_dict["response"]["body"] | ||
try: | ||
root = objectify.fromstring(str(body)) | ||
ns = "{http://ws.cdyne.com/}" | ||
logging.debug("transforming") | ||
root.Body[ | ||
ns + | ||
"ResolveIPResponse"][ | ||
ns + | ||
"ResolveIPResult"].City = "New York" | ||
|
||
objectify.deannotate( | ||
root.Body[ | ||
ns + | ||
"ResolveIPResponse"][ | ||
ns + | ||
"ResolveIPResult"].City) | ||
etree.cleanup_namespaces( | ||
root.Body[ | ||
ns + | ||
"ResolveIPResponse"][ | ||
ns + | ||
"ResolveIPResult"].City) | ||
|
||
payload_dict["response"]["body"] = etree.tostring(root) | ||
|
||
logging.debug(etree.tostring(root)) | ||
|
||
except Exception: | ||
pass | ||
# logging.debug(traceback.format_exc()) | ||
|
||
print(json.dumps(payload_dict)) | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/python | ||
|
||
from hoverpy import HoverPy | ||
import pysimplesoap | ||
import requests | ||
|
||
from argparse import ArgumentParser | ||
|
||
parser = ArgumentParser(description="Perform proxy testing/URL list creation") | ||
parser.add_argument("--capture", help="capture the data", action="store_true") | ||
args = parser.parse_args() | ||
|
||
|
||
with HoverPy(modify=True, middleware="python examples/soap/modify_payload.py"): | ||
ipAddress = requests.get("http://ip.jsontest.com/myip").json()["ip"] | ||
pysimplesoap.transport.set_http_wrapper("urllib2") | ||
|
||
client = pysimplesoap.client.SoapClient( | ||
wsdl='http://ws.cdyne.com/ip2geo/ip2geo.asmx?WSDL' | ||
) | ||
|
||
print(client.ResolveIP(ipAddress=ipAddress, licenseKey="0")) |