██╗ ██╗████████╗██╗ ██╗██╗██╗ ██╗███╗ ███╗
██║ ██║╚══██╔══╝██║ ██║██║██║ ██║████╗ ████║
██║ ██║ ██║ ███████║██║██║ ██║██╔████╔██║
██║ ██║ ██║ ██╔══██║██║██║ ██║██║╚██╔╝██║
███████╗██║ ██║ ██║ ██║██║╚██████╔╝██║ ╚═╝ ██║
╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝
Windows 内核模式驱动框架,带用户模式客户端
[!IMPORTANT]
获取完整项目
解决方案文件可通过 Discord 服务器获取。
有兴趣购买完整源代码?请通过 Telegram 或 Discord 联系我:@tonythimself。
Lithium 是一个 Windows 内核模式驱动(lithium-kernel),搭配一个用户模式客户端(lithium-usermode)。它通过自定义 IOCTL 接口进行通信,并暴露底层内存操作、页表遍历和输入设备控制原语。
| 功能 | 描述 |
|---|---|
| 物理内存读写 | 通过 MmCopyMemory 直接读写物理地址 |
| 虚拟内存读写 | 通过 MmCopyVirtualMemory 进行跨进程虚拟内存访问 |
| DTB 解析 | 通过 PFN 数据库枚举提取目录表基址 |
| 页表遍历 | 线性地址转换,带 PML4/PDPT/PD/PT 层级缓存 |
| 模式扫描 | 跨进程内存的 IDA 风格签名扫描 |
| 内存分配 | 在目标进程上下文中执行 ZwAllocateVirtualMemory |
| 内存保护 | 在目标进程上下文中执行 ZwProtectVirtualMemory |
| 鼠标模拟 | 通过 MouClass 服务回调钩子实现内核级鼠标输入 |
| 线程隐藏 | ETHREAD 字段伪造(起始地址、CID、创建时间等) |
| NMI 回调禁用 | 用于调试器规避的 NMI 回调抑制 |
| 池清理 | 从内核池跟踪器中移除大池表项 |
lithium/
├── lithium-kernel/ # Kernel-mode driver (KMDF)
│ ├── entry.cpp # DriverEntry entry point
│ ├── core/
│ │ ├── dispatch/ # IOCTL dispatch and request routing
│ │ ├── requests/
│ │ │ ├── directory-table-base/ # DTB resolution & page table walk
│ │ │ ├── image-base/ # Process module base retrieval
│ │ │ ├── mouse/ # Mouse input emulation via MouClass
│ │ │ ├── read-write/ # Physical and virtual memory R/W
│ │ │ └── virtual-memory/ # Allocate, protect, query, pattern scan
│ │ └── utilities/
│ │ ├── kernel/ # Module enumeration, NMI, thread ops
│ │ └── ... # Pool cleaner, CRT shim
│ └── dependencies/
│ ├── additional/
│ │ ├── crt/ # Minimal CRT implementation
│ │ ├── security/ # skCrypter string encryption, oxorany
│ │ └── structures/ # Shared invoke data structures
│ └── includes.hpp # Master include header
│
└── lithium-usermode/ # User-mode client
├── entry.cpp # Client entry point
├── core/
│ └── driver/ # IOCTL communication layer
└── dependencies/
├── additional/
│ └── structs.hpp # Page table entry unions & helpers
└── includes.hpp
通信通过挂钩现有驱动(ProcObsrvesx.sys)的 IOCTL 分发例程来建立。加载时,内核模块定位目标驱动,扫描其 IRP 分发处理程序,并用跳板覆盖它,跳转到 lithium 自己的 hooked_ioctl。用户模式客户端打开 \\.\ProcObsrvesx,所有 IOCTL 都通过该钩子透明重定向。
| 代码 | 输入结构体 | 操作 |
|---|---|---|
invoke_base | base_invoke { pid, handle } | 获取进程映像基址 |
invoke_dtb | dtb_invoke { pid, dtb } | 解析目录表基址 |
invoke_read | read_invoke { pid, directory_table, address, buffer, size } | 读取物理内存 |
invoke_write | write_invoke { pid, directory_table, address, buffer, size } | 写入物理内存 |
invoke_read_virtual | read_virtual_invoke { pid, address, buffer, size } | 读取虚拟内存 |
invoke_write_virtual | write_virtual_invoke { pid, address, buffer, size } | 写入虚拟内存 |
invoke_allocate | allocate_invoke { pid, type, protection, address, size } | 分配虚拟内存 |
invoke_protect | protect_invoke { pid, protection, address, size } | 更改内存保护 |
invoke_virtual_query | query_virtual_invoke { pid, address, mbi } | 查询虚拟内存信息 |
invoke_pattern_scan | pattern_invoke { pid, signature, address, pattern_address } | 模式扫描内存 |
invoke_move_mouse | mouse_invoke { x, y, flags, button_flags } | 模拟鼠标输入 |
驱动遍历 MmGetPhysicalMemoryRanges 返回的物理内存范围,遍历 PFN 数据库以定位自引用 PML4 表项,并验证每个页表层,以确认给定进程的正确目录表基址。
线性到物理地址转换遍历四级 x64 页表层次结构(PML4 → PDPT → PD → PT),并带有逐级缓存。大页(2MB / 1GB)支持以尽力而为的方式包含在内。
驱动定位 MouClass 和 MouHID 驱动对象,从 HID 设备扩展中解析 MouseClassServiceCallback,并将 MOUSE_INPUT_DATA 数据包直接注入回调链。
关键的 ETHREAD 字段——创建时间、起始地址、Win32 起始地址、内核栈、CID 和退出状态——被保存并替换为无害或空值。在拆除时,在线程终止前恢复原始值。
lithium.slnlithium-kernel → lithium-kernel.syslithium-usermode → lithium-usermode.exe或通过 MSBuild:
msbuild lithium.sln /p:Configuration=Release /p:Platform=x64
#include <core/driver/driver.hpp>
g_driver->initialize_handle();
DWORD pid = g_driver->get_process_id(L"target.exe");
g_driver->attach(pid);
g_driver->image_base = g_driver->get_image_base(0);
g_driver->dtb = g_driver->resolve_directory_table_base();
auto value = g_driver->read<uintptr_t>(g_driver->image_base + 0xOFFSET);
g_driver->mouse_event(-10, -10, 0, 0);
本项目仅供教育和研究目的使用。
仅可在您拥有或获得明确测试许可的系统上使用。
作者不对本软件造成的任何误用或损害负责。