How to capture HTTP request / response headers with mitmproxy?

前端 未结 3 827
孤独总比滥情好
孤独总比滥情好 2021-02-09 12:41

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
3条回答
  •  心在旅途
    2021-02-09 13:33

    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:

    $ mitmdump -n -q -s parse_headers.py -r .mitm
    

    The parse_headers.py inline script is as follows:

    def response(context, flow):
        request_headers = [{"name": k, "value": v} for k, v in flow.request.headers]
        response_headers = [{"name": k, "value": v} for k, v in flow.response.headers]
        print request_headers
        print response_headers
    

提交回复
热议问题