如何在 Linux 上拦截来自 USB 设备的消息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18137206/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:30:46  来源:igfitidea点击:

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

linuxusblinux-device-drivertablet

提问by sdasdadas

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.

我有一个流行的绘图板,我通过 USB 连接到我的 PC。连接后,平板电脑会检测手部动作并相应地操纵指针。某处,平板电脑正在将这些数据传输到我的电脑。

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

我的目标是在处理数据后拦截这些传输并操纵鼠标。我发现的流行词是:设备驱动程序HID,但除此之外我还没有能够拼凑出更多的东西。

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?
  1. 如果数据格式已知,这是如何完成的?
  2. 如果数据格式未知/专有,这是如何完成的?

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

我的计算机正在运行 Ubuntu(但非常感谢与任何形式的 Linux 操作系统相关的答案!)。



Note: This questionis similar but intended for Windows.

注意:此问题类似,但适用于 Windows。

采纳答案by TheCodeArtist

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

实际上,您错过了一个流行词“ USB 嗅探”。;-)

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

这里有一些关于 Linux 上 USB 嗅探的教程,可以帮助您入门。

Essentially you use the usbmonLinux kernel module to capture the USB-packets and Wiresharkas a front-end to display and analyse the captured USB stream.

本质上,您使用usbmonLinux 内核模块来捕获 USB 数据包,并使用Wireshark作为前端来显示和分析捕获的 USB 流。