decode: add some python tools to decode SniffUSB dumps
decode.py will read SniffUSB logs of communication with QMUX or WMC speaking devices. It will dump the packets in both hex and ASCII. If you know something about the device then you can tell it to decode the packets. For example, we know the Pantech UML290's WMC port speaks WMC using Bulk Transfers, so we can: decode.py --transfer=wmc <path to sniffusb logs> or we know the UML290's "rmnet" port speaks raw IP in the Bulk Transfers and QMUX in the Control Transfers, so: decode.py --control=qmux <path to sniffusb logs> qmiprotgen.py takes a path to an Entities.txt file and dumps out the protocol entities and services in Python code which is used by qmux.py. xml2ascii.py and analyze.py dump out UsbSnoopy XML logs but these are not as usable as the SniffUSB logs (they do not provide good direction information). http://www.wingmanteam.com/usbsnoopy/ http://www.pcausa.com/Utilities/UsbSnoop/
This commit is contained in:
71
decode/decode.py
Executable file
71
decode/decode.py
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/python
|
||||
# -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details:
|
||||
#
|
||||
# Copyright (C) 2011 Red Hat, Inc.
|
||||
#
|
||||
|
||||
import binascii
|
||||
import string
|
||||
import sys
|
||||
import defs
|
||||
from packet import Packet
|
||||
|
||||
packets = []
|
||||
control = None
|
||||
transfer = None
|
||||
|
||||
def get_protocol(arg):
|
||||
return arg[arg.index("=") + 1:]
|
||||
|
||||
if __name__ == "__main__":
|
||||
i = 1
|
||||
if sys.argv[i].startswith("--control="):
|
||||
control = get_protocol(sys.argv[i])
|
||||
i = i + 1
|
||||
if sys.argv[i].startswith("--transfer="):
|
||||
transfer = get_protocol(sys.argv[i])
|
||||
i = i + 1
|
||||
|
||||
path = sys.argv[i]
|
||||
f = open(path, 'r')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
|
||||
in_packet = False
|
||||
finish_packet = False
|
||||
pkt_lines = []
|
||||
for l in lines:
|
||||
if l[0] == '[':
|
||||
# Start of a packet
|
||||
if "] >>> URB" in l or "] <<< URB" in l:
|
||||
if in_packet == True:
|
||||
in_packet = False
|
||||
finish_packet = True
|
||||
else:
|
||||
in_packet = True
|
||||
elif "] UsbSnoop - " in l:
|
||||
# Packet done?
|
||||
if in_packet == True:
|
||||
in_packet = False
|
||||
finish_packet = True
|
||||
|
||||
if finish_packet == True:
|
||||
packets.append(Packet(pkt_lines, control, transfer))
|
||||
pkt_lines = []
|
||||
finish_packet = False
|
||||
|
||||
if in_packet == True:
|
||||
pkt_lines.append(l)
|
||||
|
||||
for p in packets:
|
||||
p.show()
|
Reference in New Issue
Block a user