Last active
November 29, 2016 14:20
-
-
Save dol/5721334 to your computer and use it in GitHub Desktop.
Store mitmdump raw requests and responses instead of internal format
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
/tmp/ |
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
# Print flow request in raw format. This can be used to record request fixtures | |
import datetime | |
import os | |
def response(context, flow): | |
timestr = datetime.datetime.utcnow().strftime('%Y%m%d-%H%M%S-%f') | |
with open('tmp/raw-%s.mitm' % timestr, "a") as f: | |
f.write("-------------- REQUEST START --------------\n") | |
f.write(flow.request._assemble()) | |
f.write("\n-------------- REQUEST END --------------\n") | |
if "MITMPROXY_RESPONSE" in os.environ: | |
f.write("-------------- RESPONSE START --------------\n") | |
f.write(flow.response._assemble()) | |
f.write("\n-------------- RESPONSE END --------------\n") |
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
#!/usr/bin/env sh | |
# Note: Start script with 'MITMPROXY_RESPONSE=1 ./start_mitmproxy.sh' to enable response capturing | |
mitmdump -s raw_dump.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment