aboutsummaryrefslogtreecommitdiff
path: root/reversing_tools/parse_mitm.py
diff options
context:
space:
mode:
Diffstat (limited to 'reversing_tools/parse_mitm.py')
-rwxr-xr-xreversing_tools/parse_mitm.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/reversing_tools/parse_mitm.py b/reversing_tools/parse_mitm.py
index ef61298..e59ce73 100755
--- a/reversing_tools/parse_mitm.py
+++ b/reversing_tools/parse_mitm.py
@@ -1,6 +1,7 @@
1#!/usr/bin/env python 1#!/usr/bin/env python
2 2
3import sys, os 3import sys
4import os
4sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python')) 5sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python'))
5 6
6import json 7import json
@@ -11,7 +12,7 @@ from inform import InformSerializer
11 12
12def make_serializer(from_file): 13def make_serializer(from_file):
13 with open(from_file) as fp: 14 with open(from_file) as fp:
14 keystore = { i['mac']: i['x_authkey'] for i in json.load(fp) } 15 keystore = {i['mac']: i['x_authkey'] for i in json.load(fp)}
15 16
16 return InformSerializer("", keystore) 17 return InformSerializer("", keystore)
17 18
@@ -23,14 +24,16 @@ def dumps_pretty(obj):
23if __name__ == "__main__": 24if __name__ == "__main__":
24 ser = make_serializer("data/devices.json") 25 ser = make_serializer("data/devices.json")
25 26
26 with open('data/mitm/reboot.txt', 'rb') as fp, open('test.out', 'w') as fp2: 27 with open('data/mitm/onoff.txt', 'rb') as fp, open('test.out', 'w') as fp2:
27 read = FlowReader(fp) 28 read = FlowReader(fp)
28 29
29 for rec in read.stream(): 30 for rec in read.stream():
30 res = ser.parse(StringIO(rec.response.content)) 31 res = ser.parse(StringIO(rec.response.content))
31 req = ser.parse(StringIO(rec.request.content)) 32 req = ser.parse(StringIO(rec.request.content))
32 33
33 print dumps_pretty(req.payload) 34 # print req.payload
34 print dumps_pretty(res.payload) 35 if res.payload['_type'] == 'cmd':
35 print 36 print dumps_pretty(res.payload)
37 # print dumps_pretty(req.payload)
38 # print dumps_pretty(res.payload)
36 print 39 print