A proof-of-concept exploit for the ktapi.sys kernel driver, which exposes
arbitrary physical memory read/write to unprivileged user-mode processes.
The exploit converts physical memory access into virtual memory access and
achieves local privilege escalation to NT AUTHORITY\SYSTEM on Windows 10 22H2.
Educational purposes only. Do not run on systems you do not own.
The complete analysis is on my blog (gonna be published on 27.9.2026):
https://vojtechhron.dev/cs/article/ktapi-lpe
- Open the device
\\.\ktapiand map physical memory via IOCTL0x82007000. - Locate the Low Stub in physical memory and read
CR3. - Walk the page tables to translate virtual addresses to physical.
- Resolve
PsInitialSystemProcessfrom the ntoskrnl export table. - Walk the process list to find our own
EPROCESS. - Copy the
SYSTEMtoken into ourEPROCESS.Token. - Spawn a shell as
nt authority\system.
ktapi_exploit.c- the exploit sourcektapi.sys- the vulnerable driver binary (for testing only)LICENSE- MIT License
- Windows 10 Pro 22H2 (build 19045), x64
- Visual Studio 2022 with the x64 Native Tools toolchain
- Administrator privileges to load the driver
Load the driver from an elevated command prompt:
sc.exe create ktapi binPath=C:\path\to\driver\ktapi.sys type=kernel
sc.exe start ktapiThen run the exploit from any process:
ktapi_exploit.exeWhen finished, stop and delete the service:
sc.exe stop ktapi
sc.exe delete ktapiOpen x64 Native Tools Command Prompt for VS 2022 and run:
cl /O2 /Oi /GL /DNDEBUG /MD /GS /Gy /W4 /std:c17 ktapi_exploit.c /link /LTCG /OPT:REF /OPT:ICFCompiling as x86 will not work. The exploit checks sizeof(void*) == 8
at runtime and aborts if the check fails.
Build-specific constants for Windows 10 22H2 (build 19045):
| Symbol | Offset |
|---|---|
| nt!HalpLMStub - nt | 0x3F93E0 |
| _EPROCESS.UniqueProcessId | 0x440 |
| _EPROCESS.ActiveProcessLinks | 0x448 |
| _EPROCESS.Token | 0x4B8 |
| _EPROCESS.ImageFileName | 0x5A8 |
Other builds require updated offsets, see the blog post.
Screencast_20260920_232217.webm
This project is published for educational and research purposes only. Do not use it on systems you do not own or have explicit permission to test.
MIT. See LICENSE for details.