I have been able to capture the HTTP(s) traffic from a smartphone and also stored this traffic using mitmdump using the command
mitmdump -w outfile
This seems to dump the HTTP body
along with the headers
as well. I am interested in capturing only the headers, prefarably as a single csv row (or json string). How can I do that?
Yet another derived snippet based on previous responses and updated to python3:
def response(flow):
print("")
print("="*50)
#print("FOR: " + flow.request.url)
print(flow.request.method + " " + flow.request.path + " " + flow.request.http_version)
print("-"*50 + "request headers:")
for k, v in flow.request.headers.items():
print("%-20s: %s" % (k.upper(), v))
print("-"*50 + "response headers:")
for k, v in flow.response.headers.items():
print("%-20s: %s" % (k.upper(), v))
print("-"*50 + "request headers:")
Command line:
mitmdump -q -v -s parse_headers.py -R http://localhost:9200 -p 30001
Output:
==================================================
GET / HTTP/1.1
--------------------------------------------------request headers:
CONTENT-TYPE : application/json
ACCEPT : application/json
USER-AGENT : Jakarta Commons-HttpClient/3.1
HOST : localhost
--------------------------------------------------response headers:
CONTENT-TYPE : application/json; charset=UTF-8
CONTENT-LENGTH : 327
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With