aboutsummaryrefslogtreecommitdiff
path: root/reversing_tools/parse_pcap.py
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2017-07-18 03:51:43 +0000
committerMike Crute <mike@crute.us>2017-08-16 18:30:39 +0000
commit963517b79eeb794bace8545a8e7f9c3d10f1f869 (patch)
tree1f41eb87839162277aa8d3ed14b8e2734f99dd11 /reversing_tools/parse_pcap.py
parent5daa556568096364462f57531a27deef969fcdf5 (diff)
downloadubntmfi-963517b79eeb794bace8545a8e7f9c3d10f1f869.tar.bz2
ubntmfi-963517b79eeb794bace8545a8e7f9c3d10f1f869.tar.xz
ubntmfi-963517b79eeb794bace8545a8e7f9c3d10f1f869.zip
Commit lingering notesHEADmaster
Diffstat (limited to 'reversing_tools/parse_pcap.py')
-rwxr-xr-xreversing_tools/parse_pcap.py31
1 files changed, 21 insertions, 10 deletions
diff --git a/reversing_tools/parse_pcap.py b/reversing_tools/parse_pcap.py
index ed6f465..3668379 100755
--- a/reversing_tools/parse_pcap.py
+++ b/reversing_tools/parse_pcap.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 dpkt 7import dpkt
@@ -47,17 +48,27 @@ def collect_records(from_file):
47 48
48def make_serializer(from_file): 49def make_serializer(from_file):
49 with open(from_file) as fp: 50 with open(from_file) as fp:
50 keystore = { i['mac']: i['x_authkey'] for i in json.load(fp) } 51 keystore = {i['mac']: i['x_authkey'] for i in json.load(fp)}
51 52
52 return InformSerializer("", keystore) 53 return InformSerializer("", keystore)
53 54
54 55
55if __name__ == "__main__": 56if __name__ == "__main__":
56 ser = make_serializer("devices.json") 57 import glob
57 58 ser = make_serializer("data/devices.json")
58 for i, data in enumerate(collect_records("mfi.out")): 59
59 try: 60 for file in glob.glob("data/test_files/*.bin"):
60 packet = ser.parse(StringIO(data)) 61 fn, ext = os.path.splitext(file)
61 print packet.raw_payload 62 path = os.path.dirname(fn)
62 except ValueError: 63 fn = os.path.basename(fn)
63 pass 64
65 with open(file) as fin, open(os.path.join(path, fn + ".txt"), 'w') as fout:
66 json.dump(json.loads(ser.parse(fin).raw_payload), fout, sort_keys=True,
67 indent=4, separators=(',', ': '))
68
69# for i, data in enumerate(collect_records("mfi.out")):
70# try:
71# packet = ser.parse(StringIO(data))
72# print packet.raw_payload
73# except ValueError:
74# pass