mitmproxy/examples/read_dumpfile

20 lines
484 B
Plaintext
Raw Normal View History

#!/usr/bin/env python
#
# Simple script showing how to read a mitmproxy dump file
#
from libmproxy import flow
2015-05-30 00:03:28 +00:00
import json
import sys
2014-09-08 14:02:31 +00:00
with open("logfile", "rb") as logfile:
freader = flow.FlowReader(logfile)
try:
2014-09-08 14:02:31 +00:00
for f in freader.stream():
print(f)
print(f.request.host)
json.dump(f.get_state(), sys.stdout, indent=4)
print("")
2015-05-30 00:03:28 +00:00
except flow.FlowReadError as v:
print "Flow file corrupted. Stopped loading."