PTE Manipulation and IRP Dispatch Hijacking to Execute Shellcode in Kernel
The write-up describes a kernel exploitation technique that uses a vulnerable driver for arbitrary kernel read/write, flips the user/supervisor bit in a page table entry so a user-mode page becomes ring 0 accessible, then overwrites a driver's IRP dispatch pointer so a DeviceIoControl call executes attacker shellcode in kernel context. The shellcode then steals the SYSTEM token and spawns a SYSTEM shell.
S12 - 0x12Dark Development Follow
Published on medium.com
Welcome to this new Medium post, in this one we will see an alternative to the previous post of how to execute arbitrary shellcode at ring 0. We will allocate a page in user mode, promote it to supervisor accessible (ring 0) by flipping its PTE U/S bit via a BYOVD primitive, then hijack a DRIVEROBJECT dispatch pointer…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the vulnerable third-party driver exposes arbitrary kernel memory read/write through its IOCTL interface, which lets an attacker edit page tables and kernel structures.
Impact
An attacker with the vulnerable driver loaded could execute arbitrary code at ring 0 and escalate to SYSTEM, though the chain depends on that driver being present and on the page remaining resident.
What the attacker needed
Vulnerable driver loaded (BYOVD); ability to load/use that driver; shellcode page stays resident
How it was found
- Obtain arbitrary kernel read/write through the vulnerable driver.
- Allocate and lock a user-mode page holding the shellcode.
- Locate MmPteBase by scanning MiGetPteAddress in ntoskrnl.
- Rewrite the shellcode page's PTE to clear the user/supervisor bit and set writable and dirty.
- Walk the object manager namespace to find the target driver object.
- Overwrite MajorFunction[14] with the shellcode address and trigger it with DeviceIoControl.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Windows keeps a small table entry for every memory page that records who may use it; one bit says whether only the kernel (the most privileged part of the system) can touch it. The author uses a buggy third-party driver to edit that bit so an ordinary program's page becomes usable by the kernel, then points a kernel function pointer at it. When a normal request arrives, the kernel jumps into that page and runs the author's code with the highest privileges.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.