Script output usage?

Hello,

I’m a bit confused on how to use the example scripts provided with mitmproxy. Could someone provide me an example of how a script is supposed to be outputting data?

According to: https://docs.mitmproxy.org/stable/overview-tools/#scripted-data-transformation
I should be able to run a script with mitmdump and receive output from the script in the following manner:

mitmdump  -ns mitmproxy/examples/complex/har_dump.py  -r traffic.mitm -w traffic.har

har_dump.py is the script doing the transformation of the mitmdump.

traffic.mitm is a previously generated file using this command: mitmdump -s mitmproxy/examples/complex/har_dump.py -w traffic.mitm

traffic.har is (from what I understand) supposed to be the output of the script.


What I get instead is just a straight copy of the traffic.mitm into traffic.har.

Hi,

-w is always used to indicate a mitmproxy dump file as output. The har_dump script defines a (not very convincingly named) hardump option, which is the -w equivalent for har files. For example, you can run mitmproxy like this:

mitmdump -s examples/complex/har_dump.py -w dump.mitm --set hardump=dump.har

This would produce both a mitmproxy capture and a HAR dump.

1 Like