aboutsummaryrefslogtreecommitdiff
path: root/reversing_tools/parse_mitm.py
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2016-08-16 20:36:59 -0700
committerMike Crute <mcrute@gmail.com>2016-08-16 20:36:59 -0700
commit39961246ae3c2c770e7dcd40f014510b9560c624 (patch)
tree4d0b7d2dd1c97796f5ef340848b8e8bd872eb114 /reversing_tools/parse_mitm.py
parent0eff7800aeb524f490ddaf58282fed46a4d933b5 (diff)
downloadubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.tar.bz2
ubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.tar.xz
ubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.zip
Add flow capture parsing
Diffstat (limited to 'reversing_tools/parse_mitm.py')
-rwxr-xr-xreversing_tools/parse_mitm.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/reversing_tools/parse_mitm.py b/reversing_tools/parse_mitm.py
new file mode 100755
index 0000000..ef61298
--- /dev/null
+++ b/reversing_tools/parse_mitm.py
@@ -0,0 +1,36 @@
1#!/usr/bin/env python
2
3import sys, os
4sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python'))
5
6import json
7from cStringIO import StringIO
8from libmproxy.flow import FlowReader
9from inform import InformSerializer
10
11
12def make_serializer(from_file):
13 with open(from_file) as fp:
14 keystore = { i['mac']: i['x_authkey'] for i in json.load(fp) }
15
16 return InformSerializer("", keystore)
17
18
19def dumps_pretty(obj):
20 return json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': '))
21
22
23if __name__ == "__main__":
24 ser = make_serializer("data/devices.json")
25
26 with open('data/mitm/reboot.txt', 'rb') as fp, open('test.out', 'w') as fp2:
27 read = FlowReader(fp)
28
29 for rec in read.stream():
30 res = ser.parse(StringIO(rec.response.content))
31 req = ser.parse(StringIO(rec.request.content))
32
33 print dumps_pretty(req.payload)
34 print dumps_pretty(res.payload)
35 print
36 print