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?
You can extract any header fields you need, e.g., with mitmdump and the flow object (python inline scripts). Inline scripts are documented here: https://mitmproxy.org/doc/scripting/inlinescripts.html
To extract all headers, I used the following command:
The parse_headers.py inline script is as follows:
U was using @rvaneijk, but I was getting the following error:
I found a solution at 'too many values to unpack', iterating over a dict. key=>string, value=>list and changed the code as follows:
The output of this is as follows:
You can use Docker as follows:
Make sure you have read permission on the file.
Yet another derived snippet based on previous responses and updated to python3:
Command line:
mitmdump -q -v -s parse_headers.py -R http://localhost:9200 -p 30001
Output: