如何对 USB/HID/蓝牙适配器进行逆向工程。使用什么工具?

2024-03-25

需要对蓝牙USB鼠标适配器进行逆向工程,并使用鼠标板测量距离,并用绘图库 http://matplotlib.org

我发现这些工具可以帮助完成此任务:

Linux

  • lsusb
  • usbmon
  • usbhid转储
  • rfcomm
  • hidrd 转换
  • xxd
  • hcitool
  • evdev转储

Windows

  • usblyser http://goo.gl/hG7lRk

参考书目:

  1. https://www.silabs.com/Support 文档/TechnicalDocs/AN249.pdf http://goo.gl/DAgukY
  2. www.usb.org/developers/devclass_docs/HID1_11.pdf http://goo.gl/KAX9c
  3. Usbhid 转储 - digimend http://goo.gl/rBl3Gf
  4. Linux、HID 和 PyUSB http://goo.gl/4XVPAO
  5. Linux 中的 MagTek 信用卡读卡器 http://goo.gl/X18QOi
  6. Evdev-dump - digimend http://goo.gl/4xgf3S

例子:

lnx#> lsusb -s 2

Bus 005 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Bus 003 Device 002: ID 192f:0716 Avago Technologies, Pte. 
Bus 002 Device 002: ID 1bcf:053a Sunplus Innovation Technology Inc. Targa Silvercrest OMC807-C optische Funkmaus

lnx#> sudo lsusb -s 2:4 -v

Bus 002 Device 004: ID 1bcf:053a Sunplus Innovation Technology Inc. Targa Silvercrest OMC807-C optische Funkmaus
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0         8
  idVendor           0x1bcf Sunplus Innovation Technology Inc.
  idProduct          0x053a Targa Silvercrest OMC807-C optische Funkmaus
  bcdDevice           a0.31
  iManufacturer           0 
  iProduct                2 2.4GHz 2way RF Receiver
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           34
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower               46mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           1
      bInterfaceClass         3 Human Interface Device
      bInterfaceSubClass      1 Boot Interface Subclass
      bInterfaceProtocol      2 Mouse
      iInterface              0 
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.00
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength     179
         Report Descriptors: 
           ** UNAVAILABLE **
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
Device Status:     0x0000
  (Bus Powered)

lnx#> lsusb -t     
/:  Bus 05.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 2: Dev 2, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 2: Dev 2, If 1, Class=Wireless, Driver=btusb, 12M
/:  Bus 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 2: Dev 2, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
    |__ Port 1: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 1.5M
    |__ Port 2: Dev 3, If 0, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 2: Dev 3, If 2, Class=Human Interface Device, Driver=usbhid, 12M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/8p, 480M
    |__ Port 3: Dev 4, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 3: Dev 4, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 3: Dev 4, If 2, Class=Audio, Driver=snd-usb-audio, 480M
    |__ Port 3: Dev 4, If 3, Class=Audio, Driver=snd-usb-audio, 480M

lnx#> sudo usbmon -f0
ffff8800764640c0 4022916298 C Ii:003:01 0 8 = 00000000 00000000
ffff8800764640c0 4022916321 S Ii:003:01 -115 8 <
ffff880076464a80 4025994204 C Ii:004:01 0 6 = 0100ff00 0000
ffff880076464a80 4025994229 S Ii:004:01 -115 7 <
ffff880076464a80 4026010207 C Ii:004:01 0 6 = 0100ff00 0000
ffff880076464a80 4026010238 S Ii:004:01 -115 7 <
ffff880076464a80 4026018204 C Ii:004:01 0 6 = 0100ff00 0000
ffff880076464a80 4026018225 S Ii:004:01 -115 7 <
ffff880076464a80 4026026199 C Ii:004:01 0 6 = 0100ff00 0000

lnx#> sudo usbhid-dump -s 2:4                                                 
002:004:001:DESCRIPTOR         1393614919.941888
 05 01 09 02 A1 01 85 01 05 09 19 01 29 08 15 00
 25 01 95 08 75 01 81 02 05 01 09 01 A1 00 09 30
 09 31 09 38 15 81 25 7F 75 08 95 03 81 06 05 0C
 0A 38 02 95 01 81 06 C0 06 00 FF 09 01 15 00 26
 FF 00 75 08 95 07 B1 02 C0 06 F3 F1 0A F3 F1 A1
 01 85 02 09 00 95 01 75 08 15 00 26 FF 00 81 02
 C0 05 0C 09 01 A1 01 85 03 15 00 26 FF 03 19 00
 2A FF 03 75 10 95 03 81 00 C0 05 01 09 80 A1 01
 85 04 05 01 19 81 29 83 15 00 25 01 95 03 75 01
 81 06 95 01 75 05 81 01 C0 06 BC FF 09 88 A1 01
 85 05 19 00 2A FF 00 15 00 26 FF 00 75 08 95 01
 81 00 C0

lnx#> sudo usbhid-dump -s 2:4 | tail -n +2 | xxd -r -p | hidrd-convert -o spec            
Usage Page (Desktop),               ; Generic desktop controls (01h)
Usage (Mouse),                      ; Mouse (02h, application collection)
Collection (Application),
    Report ID (1),
    Usage Page (Button),            ; Button (09h)
    Usage Minimum (01h),
    Usage Maximum (08h),
    Logical Minimum (0),
    Logical Maximum (1),
    Report Count (8),
    Report Size (1),
    Input (Variable),
    Usage Page (Desktop),           ; Generic desktop controls (01h)
    Usage (Pointer),                ; Pointer (01h, physical collection)
    Collection (Physical),
        Usage (X),                  ; X (30h, dynamic value)
        Usage (Y),                  ; Y (31h, dynamic value)
        Usage (Wheel),              ; Wheel (38h, dynamic value)
        Logical Minimum (-127),
        Logical Maximum (127),
        Report Size (8),
        Report Count (3),
        Input (Variable, Relative),
        Usage Page (Consumer),      ; Consumer (0Ch)
        Usage (AC Pan),             ; AC pan (0238h, linear control)
        Report Count (1),
        Input (Variable, Relative),
    End Collection,
    Usage Page (FF00h),             ; FF00h, vendor-defined
    Usage (01h),
    Logical Minimum (0),
    Logical Maximum (255),
    Report Size (8),
    Report Count (7),
    Feature (Variable),
End Collection,
Usage Page (F1F3h),                 ; F1F3h, reserved
Usage (F1F3h),
Collection (Application),
    Report ID (2),
    Usage (00h),
    Report Count (1),
    Report Size (8),
    Logical Minimum (0),
    Logical Maximum (255),
    Input (Variable),
End Collection,
Usage Page (Consumer),              ; Consumer (0Ch)
Usage (Consumer Control),           ; Consumer control (01h, application collection)
Collection (Application),
    Report ID (3),
    Logical Minimum (0),
    Logical Maximum (1023),
    Usage Minimum (00h),
    Usage Maximum (03FFh),
    Report Size (16),
    Report Count (3),
    Input,
End Collection,
Usage Page (Desktop),               ; Generic desktop controls (01h)
Usage (Sys Control),                ; System control (80h, application collection)
Collection (Application),
    Report ID (4),
    Usage Page (Desktop),           ; Generic desktop controls (01h)
    Usage Minimum (Sys Power Down), ; System power down (81h, one-shot control)
    Usage Maximum (Sys Wake Up),    ; System wake up (83h, one-shot control)
    Logical Minimum (0),
    Logical Maximum (1),
    Report Count (3),
    Report Size (1),
    Input (Variable, Relative),
    Report Count (1),
    Report Size (5),
    Input (Constant),
End Collection,
Usage Page (FFBCh),                 ; FFBCh, vendor-defined
Usage (88h),
Collection (Application),
    Report ID (5),
    Usage Minimum (00h),
    Usage Maximum (FFh),
    Logical Minimum (0),
    Logical Maximum (255),
    Report Size (8),
    Report Count (1),
    Input,
End Collection

lnx#> sudo usbhid-dump -s 2:4 -es
Starting dumping interrupt transfer stream
with 1 minute timeout.

002:004:001:STREAM             1393615361.032412
 01 00 01 FF 00 00

002:004:001:STREAM             1393615361.392401
 01 00 FF 00 00 00

002:004:001:STREAM             1393615361.400380
 01 00 FC 02 00 00

002:004:001:STREAM             1393615361.424382
 01 00 FF 01 00 00

002:004:001:STREAM             1393615361.432377
 01 00 FE 00 00 00

002:004:001:STREAM             1393615361.440378
 01 00 FF 01 00 00

002:004:001:STREAM             1393615361.592374
 01 00 FF 00 00 00

002:004:001:STREAM             1393615361.608392
 01 00 FF 00 00 00

002:004:001:STREAM             1393615361.616373
 01 00 FF 00 00 00

我用以下代码成功读取了鼠标:橙色外套 http://www.orangecoat.com/how-to/read-and-decode-data-from-your-mouse-using-this-pyusb-hack

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何对 USB/HID/蓝牙适配器进行逆向工程。使用什么工具? 的相关文章

  • 编写java代码时出现SIGSEGV

    我有一段代码在 HTC Desire HD v2 3 3 上运行得很好 但是在 HTC Desire v2 2 上运行时 关闭蓝牙套接字时会崩溃并出现 SIGSEGV 07 25 16 23 52 462 INFO DEBUG 64 07
  • 如何估算 BLE 模块的功耗?

    我正在为带有 BLE 模块的设备编写一个 iOS 应用程序 该模块在连接时一致地通告几个字节的数据 我们正在尝试估算 BLE 模块的功耗 以便估算设备的电池寿命 我已经在 SO 和 Google 上搜索过 寻找合适的方法来估计这一点 但我一
  • 如何在 Android 中强制蓝牙 LE“正常工作”配对

    我有一个运行 GATT 服务器的嵌入式系统 我尝试通过 Android 连接该服务器 任务很简单 连接到 GATT 服务器 导航特征并验证读 写功能 问题是当我尝试连接 Android 应用程序时 它尝试与 Passkey 而不是 Just
  • 没有 GameKit 的 iOS 蓝牙

    我已经知道使用 GameKit 我只能连接到运行相同应用程序的其他 iOS 设备 但我想连接到 Parallaz EasyBluetooth 芯片来发送和接收命令 因此我需要不同的解决方案 我想有一些针对越狱设备的库 但我不知道 你能给我一
  • USB 端口速度 Linux [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 如何以编程方式确定运行 Linux 内核的嵌入式设备中的 USB 端口速度 你可以阅读 sys bus usb devices usb s
  • Android BLE API:未收到 GATT 通知

    用于测试的设备 Nexus 4 Android 4 3 连接工作正常 但onCharacteristicChanged我的回调方法从未被调用 但是我正在使用注册通知setCharacteristicNotification char tru
  • 如何将 Android USB 连接模式更改为仅充电? [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 Locked 这个问题及其答案是locked help locked posts因为这个问题是题外话 但却具有历史意义 目前不接受新的答案
  • 在 Android 中读取蓝牙 RSSI 以获取 BLE 邻近配置文件

    我目前正在为 Android 开发低功耗蓝牙接近配置文件 并且偶然发现了有关 RSSI 的问题 为了使邻近配置文件起作用 我必须每隔很短的时间就通过已连接的设备接收 RSSI 数据 正如我所做的一些研究 我了解到在设备发现过程中可以获得蓝牙
  • 如何使用 python / pywinusb 将 hid 数据发送到设备?

    我正在尝试使用 pywinusb 将输出报告发送到 pic18f4550 该设备可以接收数据 我已经使用 C 应用程序对其进行了测试 效果很好 另外 我可以使用 pywinusb 从设备读取数据 但我在尝试发送数据时遇到问题 这是我正在运行
  • 蓝牙连接;无法正确发送字符串

    当我需要将字符串从服务器蓝牙套接字发送到客户端蓝牙套接字时 我的程序遇到了麻烦 只要我一次只发送一个字符串 例如聊天 一切都可以正常工作 但是如果我需要在短时间内编写更多字符串 以交换信息 则字符串将不会与客户端代码分离 例如 如果我发送
  • 获取已连接 USB 设备的端口名称

    当USB设备连接到计算机时 如何使用C 代码获取它所连接的端口名称 我找到了很多方法来查找 USB 何时连接 断开 驱动器号 路径 设备 ID 等 但没有找到任何明确的示例来说明如何知道它连接到哪个端口 我看到了一种可能的解释 但这涉及很多
  • libusb 和轮询/选择

    我正在使用 Linux 操作系统 想知道是否有任何文件描述符可以轮询 选择 当数据等待从 USB 设备读取时会触发这些文件描述符 我也在使用 libusb 库 但尚未找到可以使用的文件描述符 Use libusb 的轮询函数 http li
  • Android 两次请求 USB 许可

    我有一个运行 Android 4 0 4 的开发板 并将其用作 USB 配件 当我关闭板上的应用程序然后通过 USB 插入 Android 手机时 板会提示 连接此 USB 设备时打开 AppName 当我触摸 确定 时 应用程序启动并再次
  • Android Lollipop BLE 扫描 - 获取没有重复的外设

    Android Lollipop 引入了一种扫描 BLE 外设的新方法 通过蓝牙扫描仪 http developer android com reference android bluetooth le BluetoothLeScanner
  • Android 3.1 USB 主机 - BroadcastReceiver 未收到 USB_DEVICE_ATTACHED

    我经历过USB 主机的描述和示例位于developer android com http developer android com guide topics usb host html检测连接和分离的 USB 设备 如果我在清单文件中使用
  • 如何使用基于HM-10蓝牙模块的BLE Shield?

    我是 arduino 项目的新手 我想请你帮忙 我从 http imall iteadstudio com development platform arduino shields im130704001 html http imall i
  • 通过Python通过蓝牙发送消息或数据

    如何通过 python 通过蓝牙发送消息 而无需输入数字等密钥身份验证 我用过 pybluez 但我收到了这个错误 File send line 12 in
  • 蓝牙发送和接收文本数据

    我是 Android 开发新手 我想制作一个使用蓝牙发送和接收文本的应用程序 我得到了有关发送文本的所有内容逻辑工作 但是当我尝试在手机中测试它时 我看不到界面 这是Main Activity Code import android sup
  • 判断串口是普通COM还是SPP

    我正在寻找一种方法来确定 COM 是标准 COM 还是 SPP COM 也称为 COM 设备的电缆替换蓝牙适配器 我有一个可以在 USB COM gt USB 和蓝牙下工作的设备 并且蓝牙接口可以与 SPP 一起工作 我目前正在使用Syst
  • 连接到不可发现的蓝牙设备

    我正在开发一个安卓应用程序 只是一个一般性问题 是否可以连接到公开不可发现的设备 提前致谢 如果您之前已与该设备配对 则即使该设备未处于可发现模式 也可以再次连接到该设备 参见这篇文章 以编程方式连接到配对的蓝牙设备 https stack

随机推荐