JohnDMcMaster / usbrply

Replay USB messages from Wireshark (.cap) files
ISC License
306 stars 37 forks source link

usbrply

Convert a .pcap file (captured USB packets) to Python or C code that replays the captured USB commands.

Supported packet sources are:

Supported output formats are:

Example applications:

Questions? Please reach out on github or join #usbrply on Freenode IRC

Linux installation

# Do one of these
# Easier to setup, but slower
sudo pip install python-pcapng
# Much faster, but no longer maintained
sudo apt-get install -y python-libpcap
git clone https://github.com/JohnDMcMaster/usbrply.git
cd usbrply
sudo python setup.py install

Windows installation

There is probably an easier way to do this but this is what I got to work. Tested on Windows 7 x64

Setup python and pip

Install libusb1

Install usb drivers

Install

Test

Sample workflows

Capturing Windows traffic and replaying traffic in Python:

Capturing Windows VM traffic from Linux host and replaying traffic in Python:

Example: program a Xilinx dev board under Linux without knowing anything about the JTAG adapter USB protocol

Capturing from Linux Terminal

Command Line Options

You may need to filter out USB devices. There are two ways to do this:

Other useful switches:

Version history

v0.0.0

v0.0.1

v1.0.0

v2.0.0

v2.0.1

v2.1.0

v2.1.1

JSON output

use -j switch to output a parsing intermediate representation that should resemble original USB requests along with associated metadata. This can be used in more advanced applications, such as if you need to decode a complicated protocol or convert USB output to higher level API calls. An example can be found here: https://github.com/ProgHQ/bpmicro/blob/master/scrape.py This example first aggregates USB packets into application specific packets, and then decodes these into API calls

USB serial decoder

usbrply-serial supported adapters:

TODO: write doc