2014-02-04 18:10:55 +00:00
|
|
|
#!/usr/bin/env python
|
2020-06-22 23:53:39 +00:00
|
|
|
"""
|
|
|
|
Read a mitmproxy dump file.
|
|
|
|
"""
|
2021-02-03 22:00:41 +00:00
|
|
|
from mitmproxy import io, http
|
2016-04-29 18:17:49 +00:00
|
|
|
from mitmproxy.exceptions import FlowReadException
|
2015-08-19 08:05:33 +00:00
|
|
|
import pprint
|
2015-05-30 00:03:28 +00:00
|
|
|
import sys
|
2014-02-04 18:10:55 +00:00
|
|
|
|
2015-08-16 23:29:24 +00:00
|
|
|
with open(sys.argv[1], "rb") as logfile:
|
2016-10-19 02:08:35 +00:00
|
|
|
freader = io.FlowReader(logfile)
|
2015-08-19 08:05:33 +00:00
|
|
|
pp = pprint.PrettyPrinter(indent=4)
|
2014-02-04 18:10:55 +00:00
|
|
|
try:
|
2014-09-08 14:02:31 +00:00
|
|
|
for f in freader.stream():
|
|
|
|
print(f)
|
2021-02-03 22:00:41 +00:00
|
|
|
if isinstance(f, http.HTTPFlow):
|
|
|
|
print(f.request.host)
|
2015-08-19 08:05:33 +00:00
|
|
|
pp.pprint(f.get_state())
|
2015-05-30 03:17:48 +00:00
|
|
|
print("")
|
2016-04-29 18:17:49 +00:00
|
|
|
except FlowReadException as e:
|
2020-11-20 18:25:26 +00:00
|
|
|
print(f"Flow file corrupted: {e}")
|