一个Windows内核驱动程序,通过比较IOCTL路径(可能被挂钩)与TPM.sys内部的缓存响应,检测TPM 2.0响应是否被篡改。

Stars

30

7 天增长

暂无数据

Fork 数

6

开放 Issue

1

开源协议

暂无数据

最近更新

2026-07-14

AI 仓库情报摘要
FR-AI / ANALYSIS

为什么值得关注

它引入了一种新颖的低级技术来绕过TPM设备栈上的内核钩子,直接读取缓存的TPM数据以验证硬件身份,这对反作弊和认证系统至关重要。

适合谁使用

  • 研究TPM篡改和内核级欺骗的安全研究人员
  • 构建基于硬件的身份验证的反作弊和反篡改开发者
  • 对WDF驱动程序内部和逆向工程感兴趣的Windows内核开发者
  • 需要为安全启动或远程验证提供强硬件认证的系统管理员

典型使用场景

  • 检测通过伪造TPM公钥绕过基于硬件的身份检查的作弊软件或恶意软件
  • 在依赖TPM响应进行认证或授权之前验证其完整性
  • 取证分析:确定系统的TPM是否已被内核驱动程序钩子篡改
  • 为游戏或企业安全开发更强大的反欺骗机制的研究与开发

项目优势

  • 使用双路径比较(IOCTL vs 缓存)来检测基于钩子的欺骗,IOCTL路径无法绕过
  • 直接读取内部TPM驱动程序结构(TPM_STACK/TPM_RESMGR)以获得真实数据
  • 体积小:一个专注于特定功能的WDM/WDF式内核驱动程序
  • 提供了一个清晰的概念验证,可适用于其他反篡改场景

使用前须知

  • 依赖于逆向工程的TPM.sys偏移量,可能需要根据Windows版本更新
  • 仅适用于带有硬件TPM 2.0及Windows TPM驱动程序栈的系统
  • 需要签名的内核驱动程序,并为加载配置适当的测试签名或安全启动

README 快速开始

DetectTpmSpoofing

Small WDM/WDF-style kernel driver that checks whether TPM 2.0 responses on a machine have been tampered with, i.e. spoofed by a driver that hooks IRP_MJ_DEVICE_CONTROL / DeviceIoControl on \Driver\TPM.

Why

Some cheats/spoofers install a filter or hook on the TPM device stack so that TPM2_ReadPublic (and similar commands) return a forged public key/EK instead of the real one, letting them fake hardware identity to anti-cheat or attestation checks. The forged data only shows up on the IOCTL path, because the hook sits between the caller and the real TPM.

How it works

The driver gets the same TPM2_ReadPublic result two different ways and compares them:

  1. HashTpmIoctl — opens \??\TPM directly and sends a raw TPM2_ReadPublic command via ZwDeviceIoControlFile, exactly like a userland caller would through DeviceIoControl. This is the path a hook would intercept.
  2. HashTpmCached — walks the TPM.sys driver object, follows its WDF device context to the internal TPM_STACK / resource manager structures, and reads the cached response buffer the TPM driver already stored for handle 0x81010001 (the EK). This bypasses the IOCTL path entirely, so a hook on DeviceIoControl has no way to touch it.

Both responses get parsed (IsReadPublicRSA2048) and hashed with a small FNV-1a implementation. If both hashes come back non-zero, the driver logs whether they match. If a hook is spoofing the IOCTL response, the two hashes will differ — the IOCTL path shows the fake key, the cached path still holds the real one.

Note: the offsets into TPM_STACK / TPM_RESMGR are reverse engineered from TPM.sys and will need to be re-checked against the target Windows build if they stop matching. The WDF context type-info (_WDF_TpmStack_TYPE_INFO) is located by walking TPM.sys's PE section table for .data and assuming it sits at the start of that section — also hacky, same caveat applies.

Files

  • src/Driver.cpp — the driver itself (entry point, IOCTL path, cached-buffer path, comparison).
  • src/tpm12.h, src/tpm20.h — TCG TPM 1.2/2.0 spec structures and constants used to build/parse the ReadPublic command.

Building

Requires the WDK and Ninja/cl.exe (see CMakePresets.json).

cmake --preset x64-debug
cmake --build --preset x64-debug

Sign the resulting driver with

相关仓库与替代方案

根据分类、Topic 和编程语言匹配的相似项目。

Infatoshi
精选
Infatoshi GitHub avatar

netherite

A from-scratch C/CUDA reimplementation of Minecraft 1.11.2 that is bit-verified against the original Java game and includes batched CUDA reinforcement learning support.

AI 与机器学习大语言模型
251
nsdkinx
精选
nsdkinx GitHub avatar

twell

Twell is a tiny, embeddable, zero-allocation physics engine for interruptible, Apple-style UI animations, available as a single-header C library with Python bindings.

移动开发设计与创意
17
sqliteai
精选
sqliteai GitHub avatar

waste

WASTE is a C-based inference engine that streams MoE experts from disk to run a 2.78 trillion-parameter model on a consumer laptop with 64 GB RAM.

数据与数据库数据工程
14