基于 btbd/access 的更新分支,使用 Zydis 进行动态模式查找,以兼容 Windows 10/11
一个内核态系统调用封装器,无需句柄即可执行特权进程操作。通过 xKdEnumerateDebuggingDevices 指针挂钩实现内核与用户态通信。
PROCESS_ALL_ACCESS 操作.data 节挂钩,无内联补丁本分支对原始驱动进行了现代化改进:
[singular-access] 前缀的信息性调试输出驱动使用 Zydis 反汇编内核函数并提取:
User Mode (DLL)
↓ syscall with SYSCALL_UNIQUE
Kernel Hook (xKdEnumerateDebuggingDevices pointer)
↓ validates & dispatches
Kernel Syscall Handler
↓ performs privileged operation
Return to User Mode
cd Driver
msbuild Driver.vcxproj /p:Configuration=Release /p:Platform=x64
link_driver.bat
输出:Driver\x64\Release\Driver.sys
选项 1:kdmapper(推荐用于测试)
kdmapper.exe Driver.sys
选项 2:服务
sc create singular_access type= kernel binPath= C:\path\to\Driver.sys
sc start singular_access
[singular-access] Initializing driver...
[singular-access] Windows build: 26200
[singular-access] ntoskrnl.exe base: FFFFF80000000000
[singular-access] [*] Searching for PsResumeThread in PsRegisterPicoProvider...
[singular-access] [+] Found PsResumeThread at FFFFF803AAE331C0
[singular-access] [*] Searching for PsSuspendThread in PsRegisterPicoProvider...
[singular-access] [+] Found PsSuspendThread at FFFFF803AADFA1A0
[singular-access] [+] Found PreviousMode offset: 0x232
[singular-access] Searching for xKdEnumerateDebuggingDevices pointer...
[singular-access] xKdEnumerateDebuggingDevices pointer: FFFFF803AB200B68
[singular-access] Installing hook...
[singular-access] Driver initialized successfully
驱动会拦截并处理:
进程操作
NtOpenProcessNtSuspendProcess / NtResumeProcessNtQueryInformationProcess / NtSetInformationProcessNtQuerySystemInformationExNtFlushInstructionCache内存操作
NtAllocateVirtualMemory / NtFreeVirtualMemoryNtReadVirtualMemory / NtWriteVirtualMemoryNtProtectVirtualMemoryNtQueryVirtualMemoryNtLockVirtualMemory / NtUnlockVirtualMemoryNtFlushVirtualMemory线程操作
NtOpenThreadNtSuspendThread / NtResumeThreadNtGetContextThread / NtSetContextThreadNtQueryInformationThread / NtSetInformationThread同步
NtWaitForSingleObject经过测试并确认可用:
查找 PsResumeThread:
lea rcx, PsResumeThread ; Load function address
mov [rdx+40h], rcx ; Store in PICO provider table
查找 xKdEnumerateDebuggingDevices(Win11 24H2):
mov rax, cs:off_140E00B68 ; Pattern: 48 8B 05 ? ? ? ? 74 ? E8
; Resolve RIP-relative pointer
提取 PreviousMode 偏移:
mov rax, gs:188h ; Get KTHREAD
movzx eax, byte ptr [rax+232h] ; Extract PreviousMode
ret
Driver/
├── main.c # Entry point, initialization, hook installation
├── core.c # Syscall handlers
├── util.c # Pattern scanning, memory utilities
├── zydis_util.c # Zydis-based pattern finders
├── zydis_util.h # Zydis function declarations
├── syscall.h # Syscall definitions
├── stdafx.h # Precompiled header
└── Zydis/ # Zydis disassembler library
驱动无法加载:
bcdedit /set testsigning on找不到模式:
链接器错误:
ZYDIS_STATIC_BUILD 和 ZYCORE_STATIC_BUILDlink_driver.bat 是否使用了正确的 WDK 库路径syscall.h 中添加系统调用枚举core.c 中使用 HANDLE_SYSCALL 宏添加处理程序xKdEnumerateDebuggingDevices 指针的模式main.c 的 find_kd_enum_debug_devices_ptr() 中添加模式本项目沿用原始 btbd/access 仓库的许可证。
本软件仅用于教育和研究目的。请负责任地使用,并且只能在你自己拥有或得到明确测试许可的系统上使用。
| 目标 | 方法 | 偏移/地址 |
|---|
| KTHREAD.PreviousMode | 反汇编 ExGetPreviousMode | 0x232(所有版本) |
| PsResumeThread | 反汇编 PsRegisterPicoProvider | RIP 相对 LEA,位于 +0x40 |
| PsSuspendThread | 反汇编 PsRegisterPicoProvider | RIP 相对 LEA,位于 +0x50 |
| xKdEnumerateDebuggingDevices | 模式扫描 .text 节 | 特定于版本的模式 |
| 操作系统 | 内部版本 | 状态 |
|---|
| Windows 10 1607 | 14393 | ✅ |
| Windows 10 1709 | 16299 | ✅ |
| Windows 10 1809 | 17763 | ✅ |
| Windows 10 2004 | 19041 | ✅ |
| Windows 11 21H2 | 22000 | ✅ |
| Windows 11 22H2 | 22621 | ✅ |
| Windows 11 24H2 | 26100-26200 | ✅ |