-
Notifications
You must be signed in to change notification settings - Fork 311
USB Capture Setup
To create a USB capture, follow the steps from one of the two sections below. A Wireshark USB capture is preferred.
These instructions work both for native packet captures with ckb-next-daemon, and with Windows software running inside a VirtualBox VM with USB passthrough.
The following three steps need to be followed only once.
-
Install Wireshark through your package manager.
- On Debian/Ubuntu based distributions:
sudo apt install wireshark
- On Debian/Ubuntu based distributions:
-
Add yourself to the
wiresharkgroupsudo usermod -aG wireshark $USER
-
IMPORTANT: Log out of your desktop session and log back in.
The following steps need to be followed after every system boot to perform a capture.
-
Load the
usbmonkernel modulesudo modprobe usbmon
-
Set the appropriate permissions
sudo setfacl -m u:$USER:r /dev/usbmon*
-
Identify the USB bus the device is attached to by running
lsusb- For example:
Bus 001 Device 002: ID 1b1c:1b5c Corsair CORSAIR NIGHTSWORD RGB Gaming Mouse
- For example:
-
Run Wireshark
-
Double click on the correct usbmonX option in Wireshark, where X is the bus number
- In the above example, it would be usbmon1
-
WARNING:
⚠️ All devices reported bylsusbon the same bus will be captured. Iflsusbreports USB headphones/headset, a webcam, or other sensitive device on the bus that will be captured, unplug it or make sure it is not running at the time of the capture. Make sure to not type any passwords while capturing.
-
Perform the requested or necessary actions on the USB device that need to be captured
-
Click on the stop button in Wireshark
-
Save and share the capture
- Enable "Compress with gzip" in the save dialogue if you intend to attach the file on GitHub issues.
-
Recommended: Ensure Wireshark is not running and unload the
usbmonmodulesudo modprobe -r usbmon
To collect a raw text trace, execute following steps.
-
Load the
usbmonkernel modulesudo modprobe usbmon
-
Set the appropriate permissions
sudo setfacl -m u:$USER:r /dev/usbmon*
-
Identify the USB bus the device is attached to by running
lsusb- For example:
Bus 001 Device 002: ID 1b1c:1b5c Corsair CORSAIR NIGHTSWORD RGB Gaming Mouse
- For example:
-
Verify that bus sockets are present.
sudo ls /sys/kernel/debug/usb/usbmon- Example output:
0s 0u 1s 1t 1u 2s 2t 2u 3s 3t 3u 4s 4t 4u
-
Run
caton the correctXupath, where X is the bus number from step #3, and pipe to a file- Example for Bus 001:
sudo cat /sys/kernel/debug/usb/usbmon/1u > /tmp/usbmon.out -
WARNING:
⚠️ All devices reported bylsusbon the same bus will be captured. Iflsusbreports USB headphones/headset, a webcam, or other sensitive device on the bus that will be captured, unplug it or make sure it is not running at the time of the capture. Make sure to not type any passwords while capturing.
- Example for Bus 001:
-
Perform the requested or necessary actions on the USB device that need to be captured
-
Stop the capture
- Press Ctrl + C in the terminal running the
catcommand above.
- Press Ctrl + C in the terminal running the
-
Share the capture
- It is located at
/tmp/usbmon.out.
- It is located at
-
Recommended: Unload the
usbmonmodulesudo modprobe -r usbmon
Some instructions have been copied from The official Wireshark USB Capture guide.
Context on using usbmon and Wireshark to capture USB traffic on Linux can be found in the following issue comments:
#543 K95 RGB Platinum XT / New Protocol
#81 Void headset support
The most exhaustive example can be found in Nightsword RGB support #656.