如何逆向工程USB / HID /蓝牙适配器。用什么工具? [英] How to reverse engineering USB/HID/BlueTooth dongle. What tools to use?

查看:1726
本文介绍了如何逆向工程USB / HID /蓝牙适配器。用什么工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  

需要逆向工程蓝牙USB加密狗鼠标,并用鼠标板测量距离,并与他们绘制 matplotlib


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


  

的Linux



  • 的lsusb

  • usbmon

  • USBHID突降

  • RFCOMM

  • hidrd-转换

  • XXD

  • hcitool

  • 了evdev突降


  

的Windows




  

参考书目:



  1. https://www.silabs.com/Support
    文件/ TechnicalDocs / AN249.pdf

  2. www.usb.org/developers/devclass_docs/HID1_11.pdf

  3. USBHID突降 - digimend

  4. 的Linux,HID和PyUSB

  5. 的MagTek信用卡读卡器在Linux中

  6. 了evdev突降 - digimend



  

例如:


  LNX#> -s的lsusb 2公交005设备002:ID 0a12:0001剑桥硅无线电有限公司蓝牙适配器(HCI模式)
公交003设备002:ID 192f:0716安华高科技,私人。
公交002设备002:ID 1bcf:053A凌阳创新科技股份有限公司的Targa银冠OMC807-C光学仪器Funkmaus


  LNX#>须藤-s的lsusb 2:4 -v公交002设备004:ID 1bcf:053A凌阳创新科技股份有限公司的Targa银冠OMC807-C光学仪器Funkmaus
设备描述符:
  bLength 18
  bDescriptorType 1
  bcdUSB 2.00
  形式bDeviceClass 0(在接口级别定义)
  bDeviceSubClass 0
  bDeviceProtocol 0
  bMaxPacketSize0 8
  idVendor 0x1bcf凌阳创新科技股份有限公司
  idProduct 0x053a的Targa银冠OMC807-C光学仪器Funkmaus
  bcdDevice a0.31
  iManufacturer 0
  iProduct 2 2.4GHz的2路RF接收器
  iSerial 0
  bNumConfigurations指定1
  配置描述符:
    bLength 9
    bDescriptorType 2
    wTotalLength 34
    bNumInterfaces 1
    1的bConfiguration Value
    iConfiguration 0
    bmAttributes 0XA0
      (总线供电)
      远程唤醒
    牛魔王46毫安
    接口描述:
      bLength 9
      bDescriptorType 4
      bInterfaceNumber 1
      bAlternateSetting 0
      bNumEndpoints 1
      bInterfaceClass 3人机接口设备
      bInterfaceSubClass 1开机界面子类
      bInterfaceProtocol 2鼠标
      iInterface 0
        HID设备描述符:
          bLength 9
          bDescriptorType 33
          bcdHID 1.00
          bCountry code 0不支持
          bNumDescriptors 1
          bDescriptorType 34报告
          wDescriptorLength 179
         报告描述符:
           ** ** UNAVAILABLE
      端点描述:
        bLength 7
        bDescriptorType 5
        bEndpointAddress端点0×81 EP 1 IN
        bmAttributes 3
          传输类型中断
          同步类型无
          用法类型数据
        wMaxPacketSize×0008 1X 8个字节
        bInterval 10
设备状态:为0x0000
  (总线供电)


  LNX#> -t的lsusb
/:公交05.Port 1:1开发,CLASS = root_hub,驱动程序= uhci_hcd / 2P,12M
    | __端口2:2开发,如果为0,CLASS =无线,驱动程序= btusb,12M
    | __端口2:2开发,如果是1,类=无线,驱动程序= btusb,12M
/:公交04.Port 1:1开发,CLASS = root_hub,驱动程序= uhci_hcd / 2P,12M
/:公交03.Port 1:1开发,CLASS = root_hub,驱动程序= uhci_hcd / 2P,12M
    | __端口2:2开发,如果为0,CLASS =人机接口设备,驱动程序= USBHID,1.5M
/:公交02.Port 1:1开发,CLASS = root_hub,驱动程序= uhci_hcd / 2P,12M
    | __端口1:4开发,如果是1,类=人机接口设备,驱动程序= USBHID,1.5M
    | __端口2:3开发,如果为0,CLASS =人机接口设备,驱动程序= USBHID,12M
    | __端口2:3开发,如果是1,类=人机接口设备,驱动程序= USBHID,12M
    | __端口2:3开发,如果2,CLASS =人机接口设备,驱动程序= USBHID,12M
/:公交01.Port 1:1开发,CLASS = root_hub,驱动程序= EHCI-PCI / 8P,480M
    | __端口3:开发4,如果为0,CLASS =视频驱动程序= uvcvideo,480M
    | __端口3:开发4,如果是1,类=视频,驱动程序= uvcvideo,480M
    | __端口3:开发4,如果2,CLASS =音频驱动程序= SND-USB音频,480M
    | __端口3:开发4,如果3级=音频驱动程序= SND-USB音频,480M


  LNX#>须藤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 LT;
ffff880076464a80 4026010207 C II:004:01 0 6 = 0100ff00 0000
ffff880076464a80 4026010238 S II:004:01 -115 7 LT;
ffff880076464a80 4026018204 C II:004:01 0 6 = 0100ff00 0000
ffff880076464a80 4026018225 S II:004:01 -115 7 LT;
ffff880076464a80 4026026199 C II:004:01 0 6 = 0100ff00 0000


  LNX#>须藤USBHID转储-s 2:4
002:004:001:DESCRIPTOR 1393614919.941888
 05 01 09 02 01 A1 85 01 05 09 19 01 29 08 15 00
 25 01 95 08 75 01 81 02 05 01 09 01 00 A1 09 30
 09 31 09 38 15 81 25 75 7F 08 95 03 81 06 05 0℃
 0A 38 02 95 01 81 06 06 C0 FF 00 09 01 15 00 26
 FF 00 75 08 95 07 02 B1 C0 06 F3 F1 0A F3 F1 A1
 01 85 02 09 00 95 01 75 08 15 00 26 00 FF 81 02
 C0 05 0C 09 01 A1 01 85 03 15 00 26 03 FF 19 00
 2A FF 03 75 10 95 03 81 00 05 C0 09 01 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 06 C0 FF公元前09 88 A1 01
 85 05 19 00 2A FF 00 15 00 26 00 FF 75 08 95 01
 81 00 C0


  LNX#>须藤USBHID转储-s 2:4 |尾-n +2 | XXD -r -p | hidrd-转换-o规范
用量信息页(桌面);通用桌面控件(01H)
用法(鼠标);鼠标(02H,应用集合)
集合(应用程序),
    报告ID(1)
    使用页面(按钮);按钮(09H)
    用法最小(01H)
    使用最大(08H)
    逻辑最小(0),
    逻辑最大值(1),
    报告计数(8),
    报告尺寸(1)
    输入(变量),
    用量信息页(桌面);通用桌面控件(01H)
    用法(指针);指针(01H,物理集合)
    集合(物理)
        用法(X); X(30H,动态值)
        使用(Y); Y(31​​H,动态值)
        用法(轮);轮(38H,动态值)
        逻辑最小(-127),
        逻辑最大(127)
        报告尺寸(8)
        报告计数(3),
        输入(可变,相对)
        用量信息页(消费者);消费者(0CH)
        用法(AC潘); AC平移(0238h,线性控制)
        报告计数(1),
        输入(可变,相对)
    结束收集,
    用量信息页(FF00H); FF00H,厂商定义
    用法(01H)
    逻辑最小(0),
    逻辑最大(255),
    报告尺寸(8)
    报告计数(7),
    功能(可变)
结束收集,
用量信息页(F1F3h); F1F3h,保留
用法(F1F3h)
集合(应用程序),
    报告ID(2)
    用法(00H)
    报告计数(1),
    报告尺寸(8)
    逻辑最小(0),
    逻辑最大(255),
    输入(变量),
结束收集,
用量信息页(消费者);消费者(0CH)
使用(消费控制);消费者控制(01H,应用集合)
集合(应用程序),
    报告ID(3)
    逻辑最小(0),
    逻辑最大值(1023),
    用法最小(00H)
    使用最大(03FFh单元),
    报告尺寸(16)
    报告计数(3),
    输入,
结束收集,
用量信息页(桌面);通用桌面控件(01H)
用法(系统控制);系统控制(80H,应用集合)
集合(应用程序),
    报告ID(4)
    用量信息页(桌面);通用桌面控件(01H)
    用法最小(系统关机);系统掉电(81H,单次控制)
    使用最大(系统唤醒);系统唤醒(83H,单次控制)
    逻辑最小(0),
    逻辑最大值(1),
    报告计数(3),
    报告尺寸(1)
    输入(可变,相对)
    报告计数(1),
    报告尺寸(5)
    输入(常量),
结束收集,
用量信息页(FFBCH); FFBCH,厂商定义
用法(88H)
集合(应用程序),
    报告ID(5)
    用法最小(00H)
    使用最大(FFH)
    逻辑最小(0),
    逻辑最大(255),
    报告尺寸(8)
    报告计数(1),
    输入,
收集完


  LNX#>须藤USBHID转储-s 2:4 -es
开始倾销中断传输流
1分钟超时。002:004:001:STREAM 1393615361.032412
 01 00 01 00 FF 00002:004:001:STREAM 1393615361.392401
 01 00 FF 00 00 00002:004:001:STREAM 1393615361.400380
 01 00 02 FC 00 00002:004:001:STREAM 1393615361.424382
 01 00 01 FF 00 00002:004:001:STREAM 1393615361.432377
 01 00 FE 00 00 00002:004:001:STREAM 1393615361.440378
 01 00 01 FF 00 00002:004:001:STREAM 1393615361.592374
 01 00 FF 00 00 00002:004:001:STREAM 1393615361.608392
 01 00 FF 00 00 00002:004:001:STREAM 1393615361.616373
 01 00 FF 00 00 00


解决方案

我有成功阅读我的鼠标与此code:
orangecoat

Need to reverse engineering bluetooth usb mouse dongle, and use mouse board to measure distance, and plot them with matplotlib

I've found these tools that can help with this task:

Linux

  • lsusb
  • usbmon
  • usbhid-dump
  • rfcomm
  • hidrd-convert
  • xxd
  • hcitool
  • evdev-dump

Windows


Bibliography:

  1. https://www.silabs.com/Support Documents/TechnicalDocs/AN249.pdf
  2. www.usb.org/developers/devclass_docs/HID1_11.pdf
  3. Usbhid-dump - digimend
  4. Linux, HID and PyUSB
  5. MagTek Credit Card Reader in Linux
  6. Evdev-dump - digimend


Examples:

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

解决方案

I had success reading my mouse with this code: orangecoat

这篇关于如何逆向工程USB / HID /蓝牙适配器。用什么工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆