简体   繁体   English

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

[英]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.我有一个流行的绘图板,我通过 USB 连接到我的 PC。 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.我发现的流行词是:设备驱动程序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?如果数据格式未知/专有,这是如何完成的?

My computer is running Ubuntu (but answers related to any form of a Linux OS are greatly appreciated!).我的计算机正在运行 Ubuntu(但非常感谢与任何形式的 Linux 操作系统相关的答案!)。


Note: This question is similar but intended for Windows.注意:此问题类似,但适用于 Windows。

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 usbmon Linux kernel module to capture the USB-packets and Wireshark as a front-end to display and analyse the captured USB stream.本质上,您使用usbmon Linux 内核模块来捕获 USB 数据包,并使用Wireshark作为前端来显示和分析捕获的 USB 流。

To add another useful resource: Kernel manual for usbmon添加另一个有用的资源: usbmon 的内核手册

You can use the following commands on Debian Linux to view debug log for usbmon in text format using usbmon Kernel's built in usb monitoring:您可以在 Debian Linux 上使用以下命令使用 usbmon 内核的内置 usb 监控以文本格式查看 usbmon 的调试日志:

  • $sudo -i to use root $sudo -i使用 root
  • #modprobe usbmon
  • #ls /sys/kernel/debug/usb/usbmon to view bus sockets #ls /sys/kernel/debug/usb/usbmon查看总线套接字
  • #cat /sys/kernel/debug/usb/devices to view devices at each bus socket #cat /sys/kernel/debug/usb/devices查看每个总线套接字的设备
  • #cat /sys/kernel/debug/usb/usbmon/<bus socket> to view or you can route stdout to a file using > #cat /sys/kernel/debug/usb/usbmon/<bus socket>查看或者您可以使用>标准输出路由到文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Linux 中启动“init”进程之前,如何确保已连接的 USB 设备被枚举? - How do I make sure that a connected USB device gets enumerated before starting "init" process in Linux? 如何确定连接的USB设备是否为USB闪存盘? - How do I determine if a connected USB device is a USB flash drive? 如何在Linux上使用带有ffmpeg的C ++从USB音频设备录制音频? - How can I record an audio from USB audio device using C++ with ffmpeg on Linux? 如何在Linux中通过USB从i2c设备检索数据 - How to retrieve data from an i2c device over usb in linux 如何在 Linux、Python 中侦听“插入 USB 设备”事件? - How can I listen for 'usb device inserted' events in Linux, in Python? 如何在Linux设备驱动程序中从USB端点接收连续数据 - How to receive continuous data from usb endpoint in Linux device driver 如何拦截Linux内核中发送到USB闪存驱动器的数据? - How to intercept data sent to a USB flash drive in the Linux kernel? 在Linux系统中连接/分离USB设备并从USB读取文件后如何通知 - How could be notified once USB device is attached/detached in linux system and read the file from USB 在Linux中捕获来自usb设备的输入 - Capturing input from usb device in Linux 我如何跟踪将数据从任何外部USB传输到PC(Linux)的过程? - How do i track the process of transferringt data from any external usb to PC (linux) ?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM