aboutsummaryrefslogtreecommitdiffstats
path: root/examples/simple/io_read_dumpfile.py
blob: 87d37c0ffd752638d2b9e50abfdbc5df6b9a9be2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python
#
# Simple script showing how to read a mitmproxy dump file
#

from mitmproxy import io
from mitmproxy.exceptions import FlowReadException
import pprint
import sys


with open(sys.argv[1], "rb") as logfile:
    freader = io.FlowReader(logfile)
    pp = pprint.PrettyPrinter(indent=4)
    try:
        for f in freader.stream():
            print(f)
            print(f.request.host)
            pp.pprint(f.get_state())
            print("")
    except FlowReadException as e:
        print("Flow file corrupted: {}".format(e))