我正在尝试对USB(HID)设备进行逆向工程,但无法真正弄清我在Wireshark(Linux或Windows上的Usbmon + Wireshark)上看到的与USB协议之间的关系吗?我从www.usb.org看过USB协议。
Wireshark显示了什么?
1)每包一行?(令牌,数据,握手)
2)每笔交易一行?(令牌+ [数据] +握手)(我的猜测)
3)每次控制传输一行?
事务的方向(到/从字段)也很奇怪。至少,它不符合我的期望:-) ...枚举,隐藏报告等的数据部分似乎有时与设置数据(8字节)一起显示,有时却不显示...我不知道我真的不知道URB是什么...据我所知,在usb协议中没有提及...在我看来,wireshark / usbmon在更高的堆栈级别上进行跟踪并试图推断出什么从那...
下面提供了一个我可以看到的示例,我们在这里看到了什么?
a)我什至无法在规格中找到bmtype = 0x20(设置编号为599)。
b)因为我有一个HID设备,所以我认为这可能是一个报告/功能配置(此阶段已通过枚举)。所以我可以同意这个方向(主机->设备)。但是数据在哪里?还是这里没有数据阶段?那么600帧是什么?
c)600框架是什么?数据?
d)601是什么?状态ACK?...但是数据和ACK具有相同的来源?
No. Time Source Destination Protocol Length Info
599 67.996889 host 2.0 USB 36 URB_CONTROL out
Frame 599: 36 bytes on wire (288 bits), 36 bytes captured (288 bits)
USB URB
USBPcap pseudoheader length: 28
IRP ID: 0xfffffa800a1e2610
IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
URB Function: URB_FUNCTION_CLASS_DEVICE (0x001a)
IRP information: 0x00, Direction: FDO -> PDO
URB bus id: 1
Device address: 2
Endpoint: 0x00, Direction: OUT
URB transfer type: URB_CONTROL (0x02)
Packet Data Length: 8
Control transfer stage: Setup (0)
[Response in: 601]
[bInterfaceClass: Unknown (0xffff)]
URB setup
bmRequestType: 0x20
0... .... = Direction: Host-to-device
.01. .... = Type: Class (0x01)
...0 0000 = Recipient: Device (0x00)
bRequest: 0
wValue: 0x0000
wIndex: 0
wLength: 16
0000 1c 00 10 26 1e 0a 80 fa ff ff 00 00 00 00 1a 00 ...&............
0010 00 01 00 02 00 00 02 08 00 00 00 00 20 00 00 00 ............ ...
0020 00 00 10 00 ....
No. Time Source Destination Protocol Length Info
600 67.997889 2.0 host USB 44 URB_CONTROL out
Frame 600: 44 bytes on wire (352 bits), 44 bytes captured (352 bits)
USB URB
USBPcap pseudoheader length: 28
IRP ID: 0xfffffa800a1e2610
IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
IRP information: 0x01, Direction: PDO -> FDO
URB bus id: 1
Device address: 2
Endpoint: 0x00, Direction: OUT
URB transfer type: URB_CONTROL (0x02)
Packet Data Length: 16
Control transfer stage: Data (1)
[Request in: 599]
[Time from request: 0.001000000 seconds]
[bInterfaceClass: Unknown (0xffff)]
CONTROL response data
0000 1c 00 10 26 1e 0a 80 fa ff ff 00 00 00 00 08 00 ...&............
0010 01 01 00 02 00 00 02 10 00 00 00 01 05 04 0d 56 ...............V
0020 fb 82 c0 1d 10 18 cc 02 00 00 00 01 ............
No. Time Source Destination Protocol Length Info
601 67.997889 2.0 host USB 28 GET STATUS Status
Frame 601: 28 bytes on wire (224 bits), 28 bytes captured (224 bits)
USB URB
USBPcap pseudoheader length: 28
IRP ID: 0xfffffa800a1e2610
IRP USBD_STATUS: USBD_STATUS_SUCCESS (0x00000000)
URB Function: URB_FUNCTION_CONTROL_TRANSFER (0x0008)
IRP information: 0x01, Direction: PDO -> FDO
URB bus id: 1
Device address: 2
Endpoint: 0x00, Direction: OUT
URB transfer type: URB_CONTROL (0x02)
Packet Data Length: 0
Control transfer stage: Status (2)
[Request in: 599]
[Time from request: 0.001000000 seconds]
0000 1c 00 10 26 1e 0a 80 fa ff ff 00 00 00 00 08 00 ...&............
0010 01 01 00 02 00 00 02 00 00 00 00 02 ............
显然我缺少了一些东西。关于wireshark显示与协议以及(基于该协议)协议之间关系的一般说明,欢迎您!
我最初将此内容发布在Stack Overflow上,但被告知这不是直接的编程问题。希望它适合这里。