diff options
author | Mike Crute <mcrute@gmail.com> | 2016-08-16 20:36:59 -0700 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2016-08-16 20:36:59 -0700 |
commit | 39961246ae3c2c770e7dcd40f014510b9560c624 (patch) | |
tree | 4d0b7d2dd1c97796f5ef340848b8e8bd872eb114 | |
parent | 0eff7800aeb524f490ddaf58282fed46a4d933b5 (diff) | |
download | ubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.tar.bz2 ubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.tar.xz ubntmfi-39961246ae3c2c770e7dcd40f014510b9560c624.zip |
Add flow capture parsing
-rwxr-xr-x | reversing_tools/parse_mitm.py | 36 | ||||
-rwxr-xr-x | reversing_tools/parse_pcap.py | 3 |
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 | |||
3 | import sys, os | ||
4 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python')) | ||
5 | |||
6 | import json | ||
7 | from cStringIO import StringIO | ||
8 | from libmproxy.flow import FlowReader | ||
9 | from inform import InformSerializer | ||
10 | |||
11 | |||
12 | def 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 | |||
19 | def dumps_pretty(obj): | ||
20 | return json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': ')) | ||
21 | |||
22 | |||
23 | if __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 | |||
36 | |||
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 | ||
3 | import sys, os | ||
4 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python')) | ||
5 | |||
3 | import dpkt | 6 | import dpkt |
4 | import json | 7 | import json |
5 | from cStringIO import StringIO | 8 | from cStringIO import StringIO |