aboutsummaryrefslogtreecommitdiff
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
parent0eff7800aeb524f490ddaf58282fed46a4d933b5 (diff)
downloadubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.tar.bz2
ubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.tar.xz
ubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.zip
Add flow capture parsing
-rwxr-xr-xreversing_tools/parse_mitm.py36
-rwxr-xr-xreversing_tools/parse_pcap.py3
2 files changed, 39 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
diff --git a/reversing_tools/parse_pcap.py b/reversing_tools/parse_pcap.py
index c29c1d2..ed6f465 100755
--- a/reversing_tools/parse_pcap.py
+++ b/reversing_tools/parse_pcap.py
@@ -1,5 +1,8 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2 2
3import sys, os
4sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python'))
5
3import dpkt 6import dpkt
4import json 7import json
5from cStringIO import StringIO 8from cStringIO import StringIO