Windows&Linux USB抓包方法总结

您所在的位置:网站首页 能抓包的软件 Windows&Linux USB抓包方法总结

Windows&Linux USB抓包方法总结

2023-03-24 12:49| 来源: 网络整理| 查看: 265

USB抓包方法总结

Linux 和 Windows 环境上 都能通过wireshark 软件分析USB报文。

Windows 抓包

Windows 上 必须要在wireshark 软件安装时勾选这个USBPcap,否则无法抓取USB的数据

安装后通过选择下图中的USBPcap 进行抓包

同时需要注意这个旁边有个齿轮的按钮可以指定抓取哪个USB总线,哪个USB设备

如下图,我勾选了华为设备接入的USB1 这个总线。

配置完成后点击开始就能抓包了,可以看到报文信息,包括传输的内容都能获取。

特别注意windows上RNDIS模式的USB网卡经过实测部分报文抓不到,将卡模式改为NCM模式后能正常抓取。原因在官网其实已有描述链接如下CaptureSetup/USB - The Wireshark Wiki

下面是摘取的官网说明

USB attached network interfaces

A special case are network interfaces connected to a host computer through an USB cable. The operating system "converts" the raw USB packets into the network traffic (e.g. Ethernet packets) and provides a network interface that looks like an ordinary network interface. So you can capture from:

the USB device for raw USB traffic (if supported)the network device for "normal" network packets

The USB bus will add additional overhead, so the raw USB traffic will have higher volume than the network traffic, even if the only active USB devices on the system are network adapters. (If there are other active USB devices, the raw USB traffic will include traffic to and from those devices, so it will obviously have higher volume than Ethernet traffic.)

Linux抓包

Linux 下 对USB抓包是 使用USBMON 即 usb monitor模组来进行抓包操作。需要Linux在编译时打开CONFIG_USB_MON

详细描述可以参考 https://www.kernel.org/doc/html/latest/usb/usbmon.html

挂载debugfs文件系统sudo mount -t debugfs none_debugs /sys/kernel/debug 确认内核中是否有加载usbmon模块lsmod | grep usbmon

或者

ls /sys/module/usbmon

如果发现没有对应的目录或者模块,则表示需要加载usbmon

modprobe usbmon抓取USB日志

最好先用lsusb –t 查看一下需要抓哪个USB总线的数据

如果要抓所有总线的数据就指定usbmon0,其他usbmon设备一一对应USB的各个总线

采用如下命令可以抓取 usb通信过程数据

sudo tcpdump -i usbmon1 -w usbmon11.pcap

对应文件导出后用wireshark 打开就能看到数据

当然也可以直接cat usbmon1 设备,但是全是数据需要自己解析 比较繁琐。

通用查看部分

如下图所示,可以抓到USB通信的流程,但不包括握手的部分。

可以通过流图看到与谁做了交互

协议分析统计可以看到数据量



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3