Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I intercept messages from a USB device on Linux?

I have a popular drawing tablet that I connect to my PC with USB. Once connected, the tablet detects hand movements and manipulates the pointer accordingly. Somewhere, the tablet is transmitting this data to my computer.

My goal is to intercept these transmissions and manipulate the mouse after I process the data. The buzzwords I have found are: device drivers and HID, but I haven't been able to piece together much more than that.

Assuming this is possible, I have a few questions:

  1. How is this done if the data format is known?
  2. How is this done if the data format is unknown/proprietary?

My computer is running Ubuntu (but answers related to any form of a Linux OS are greatly appreciated!).


Note: This question is similar but intended for Windows.

like image 412
sdasdadas Avatar asked Aug 08 '13 22:08

sdasdadas


People also ask

How do I capture data from a USB?

To start analyzing a device, check the box near the device name in the USB View and click the 'Start Capture' button (See Capture menu). Once you start capture, captured USB protocol data will be displayed in the Log View as shown below.

Can Wireshark capture USB traffic?

Accepted Reply. With macOS High Sierra you can use Wireshark to capture USB traffic. The interface needs to be manually brought up/down to enable/disable packet capture for the specific controller via ifconfig (where you can also see a list of available interfaces).

How does Linux handle USB devices?

The Linux kernel supports two main types of USB drivers: drivers on a host system and drivers on a device. The USB drivers for a host system control the USB devices that are plugged into it, from the host's point of view (a common USB host is a desktop computer.)


1 Answers

Actually you missed a buzzword "USB sniffing". ;-)

Here are a few tutorials on USB sniffing on Linux, to get you started.

  • Official Wireshark wiki for USB monitoring
  • biot.com/blog/usb-sniffing-on-linux (InternetArchive)
  • tjworld.net/wiki/Linux/Ubuntu/USBmonitoring

Essentially you use the usbmon Linux kernel module to capture the USB-packets and Wireshark as a front-end to display and analyse the captured USB stream.

like image 121
TheCodeArtist Avatar answered Oct 02 '22 17:10

TheCodeArtist