From 66da73d8a9ad8f7a137375ce392c68729c385347 Mon Sep 17 00:00:00 2001 From: Steven Van Acker Date: Tue, 4 Feb 2014 14:49:51 +0100 Subject: [PATCH 1/3] fixing bug: AttributeError: DumpMaster instance has no attribute 'unload_script' --- libmproxy/dump.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libmproxy/dump.py b/libmproxy/dump.py index e76ea1ce3..39da8eb3d 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -223,8 +223,7 @@ class DumpMaster(flow.FlowMaster): def run(self): # pragma: no cover if self.o.rfile and not self.o.keepserving: - for script in self.scripts: - self.unload_script(script) + self.unload_scripts() return try: return flow.FlowMaster.run(self) From fd828bf95981780f5cce300e389c18ca43bfddce Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 4 Feb 2014 18:40:12 +0100 Subject: [PATCH 2/3] shutdown properly if we dont keep serving --- libmproxy/dump.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmproxy/dump.py b/libmproxy/dump.py index 39da8eb3d..8bd29ae5a 100644 --- a/libmproxy/dump.py +++ b/libmproxy/dump.py @@ -223,7 +223,7 @@ class DumpMaster(flow.FlowMaster): def run(self): # pragma: no cover if self.o.rfile and not self.o.keepserving: - self.unload_scripts() + self.shutdown() return try: return flow.FlowMaster.run(self) From 6d9b28f2ea07d61a856cf6fddf0bbe0b61e0bdb2 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 4 Feb 2014 19:10:55 +0100 Subject: [PATCH 3/3] add example to show how to read mitmproxy dump files, refs #207 --- examples/read_dumpfile.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 examples/read_dumpfile.py diff --git a/examples/read_dumpfile.py b/examples/read_dumpfile.py new file mode 100644 index 000000000..547f3c17f --- /dev/null +++ b/examples/read_dumpfile.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python +# +# Simple script showing how to read a mitmproxy dump file +# + +from libmproxy import flow +import json, sys + +with open("logfile", "rb") as f: + freader = flow.FlowReader(f) + try: + for i in freader.stream(): + print i.request.host + json.dump(i._get_state(), sys.stdout, indent=4) + print "" + except flow.FlowReadError, v: + print "Flow file corrupted. Stopped loading." \ No newline at end of file