惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
I
InfoQ
D
DataBreaches.Net
Simon Willison's Weblog
Simon Willison's Weblog
F
Fortinet All Blogs
Help Net Security
Help Net Security
P
Proofpoint News Feed
F
Full Disclosure
G
GRAHAM CLULEY
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
G
Google Developers Blog
T
The Blog of Author Tim Ferriss
P
Palo Alto Networks Blog
T
Threat Research - Cisco Blogs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
T
Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Register - Security
The Register - Security
The Hacker News
The Hacker News
Scott Helme
Scott Helme
T
Tor Project blog
Recorded Future
Recorded Future
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
C
Cybersecurity and Infrastructure Security Agency CISA
V
Vulnerabilities – Threatpost
Vercel News
Vercel News
L
Lohrmann on Cybersecurity
Know Your Adversary
Know Your Adversary
T
The Exploit Database - CXSecurity.com
IT之家
IT之家
C
Check Point Blog
NISL@THU
NISL@THU
Engineering at Meta
Engineering at Meta
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LangChain Blog
S
Schneier on Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
CERT Recently Published Vulnerability Notes
博客园 - 三生石上(FineUI控件)
Spread Privacy
Spread Privacy
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
The Cloudflare Blog

博客园 - Mojies

Prompt 相关 T-Lite 简介 CRC 计算 C 语言例子 一个 python 拆解文本文件的工具 UNIX 环境编程 Note ( UPDATING ) 航模.fs.ia6b 接收机记录 线程同步 STM32 Note Linux FrameBuffer note VIM Note Android 开发笔记(更新中....) Effective C++ (暂停更新) Linux 命令行对比二进制文件脚本 Linux Note (Updateing) 自制树莓派 3D 模型,附 STL 文件 《重构改善既有代码的设计》Tips 翻译: buildroot 用户手册 (更新中...) Some view of engineers 地球地址
关于 HID 你可能需要知道的几件事 (更新中...)
Mojies · 2022-01-11 · via 博客园 - Mojies

  1. 《HID 1.11》 主要描述 report desc 的一些规则,以及如何进行通讯
  2. 《HUT 1.22》 则主要说明一些通用的 HID 设备类型具备的 Usage page, Usage
  3. 关于 HID 的文档请从该网页获取:https://www.usb.org/hid

  1. 关于 HID 的库可以使用 libusb 直接操作 USB HID 节点,也可通过 libhidapi 来操作,libhidapi 集成度更高,而且最近也开始重新维护了。都由 libusb 维护:
  2. libusb 仓库地址:https://github.com/libusb/libusb
  3. libhidapi 仓库地址:https://github.com/libusb/hidapi
  4. 如果你比较纠结到底是选择 libusb 好还是 libhidapi 好,则可以看一下这个帖子:https://stackoverflow.com/questions/55272593/hidapi-vs-libusb-for-linux

  1. HID 规范文档中设备描述的 input 和 output 都是站在 Host 端角度描述的
  2. HID 中的 report desc 主要是为了向 Host 描述设备具备何种功能,以及如何使用设备的。而 HID 从协议上并没有严格的绑定传输过程中的数据与 report desc 的对应关系。这需要设备和 PC 端的驱动和应用程序来保证。因此,这也造成了是市面很多不规范的产品 dump 出来一个设备描述自己支持很多的功能,但可能其中只有一小部分的功能是支持的原因。

  1. HID report descriptor 描述了HID 设备的没一笔数据的数据标签(Tag)类型,大小,比如:

    1. 定义了 HID 的 input 事件应该被当作 mouse 事件还是 Keyboard 事件
    2. 定义了一个 output 事件或者 input 事件应该被如何传输(数据结构,类型)

  1. HID 的 ClassCode 恒定为 0x03

  2. HID 的 SubClass 有两个值

    1. 0 代表无 SubClass
    2. 1 代表 Boot Interface Subclass
  3. HID 的 Protocol Codes 定义了三个值:(只有当 SubClass 为 1 的时候才会有 Interface Desc,并且 ProtocolCode 才有 非零值)

    1. 0 - None
    2. 1 - Keyboard
    3. 2 - Mouse

六: 关于 HID 的 Endpoint 说明如下:

  1. Control pipe de Endpoint0 是作为一个 USB 设备一定存在的,其也传输了包含以下内容:USB Control, Class request code, polled data(Message Data)
  2. Interrupt In, 用于承载 HID Input 类型数据(device to host)
  3. Interrupt Out,用于承载 HID output 类型数据(Host to devices),该 Endpoint 可不实现,此时 Output 数据通过 Endpoint0 传输

七 Report Descript

  1. HID Report Desc 中包含许多格式相近的 item,而分析这些 item 的上下文可以得知,一个 HID 的设备包含哪些能力。

  2. Report Desc 上下文的格式大致如下图所示:

  3. 其中 item 的格式:

    短 item 主要包含以下几个部分:bTag,bType,bSize,bData,如下所示
    ShortItems

    1. bTag 和 bType 一起标识该 Item 的属性,其中 bType 主要指定属性范围,占用两个位:
      00 - Main Items
      01 - Global Items
      10 - Local Items
      11 - 保留(实际上可看成和特殊的 bTag(1111), bSize(10) 搭配标识该 Item 为长 Items)

    2. 而对于短 Item 来说, bSize 标识该 item 的 bData 长度,短 Item 大致有 0,1,2,4 这几种长度,分别用 00, 01, 10, 11 表示

    长 item 主要包含 特殊头,bDataSize,bLongItemTag, Data,如下所示:
    LongItems

posted @ 2022-01-11 22:57  Mojies  阅读(2236)  评论()    收藏  举报