Skip to content
RCE Write-up Advanced

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…

S12 - 0x12Dark Development, on medium.com

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

  1. Obtain arbitrary kernel read/write through the vulnerable driver.
  2. Allocate and lock a user-mode page holding the shellcode.
  3. Locate MmPteBase by scanning MiGetPteAddress in ntoskrnl.
  4. Rewrite the shellcode page's PTE to clear the user/supervisor bit and set writable and dirty.
  5. Walk the object manager namespace to find the target driver object.
  6. 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.

More by S12 - 0x12Dark Development

View all

13 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.