blob: ef6129873e86cc7fd95aa8ac560a8f313ea8a454 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/usr/bin/env python
import sys, os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'python'))
import json
from cStringIO import StringIO
from libmproxy.flow import FlowReader
from inform import InformSerializer
def make_serializer(from_file):
with open(from_file) as fp:
keystore = { i['mac']: i['x_authkey'] for i in json.load(fp) }
return InformSerializer("", keystore)
def dumps_pretty(obj):
return json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': '))
if __name__ == "__main__":
ser = make_serializer("data/devices.json")
with open('data/mitm/reboot.txt', 'rb') as fp, open('test.out', 'w') as fp2:
read = FlowReader(fp)
for rec in read.stream():
res = ser.parse(StringIO(rec.response.content))
req = ser.parse(StringIO(rec.request.content))
print dumps_pretty(req.payload)
print dumps_pretty(res.payload)
print
print
|