OSEE Exam Cheat Sheet (EXP-401): Complete Windows Kernel Exploitation Study Guide

Updated 2026-11-20· 29 min read· 141 views
Share:

EXP-401: Advanced Windows Exploitation - OffSec Exploitation Expert (OSEE)

OSEE Exam Cheat Sheet (EXP-401): Complete Windows Kernel Exploitation Study Guide

OSEE / EXP-401 — Exam Cheat Sheet

The Complete 150-Minute Study Guide

This document covers everything the OffSec Exploitation Expert (OSEE) exam will throw at you — kernel structures, mitigation bypasses, heap grooming, exploit chains, and exam strategy. It is written for people short on time and long on determination. Read it once slowly. Then read the tables again the night before.

Total read time: about 150 minutes. The reading plan below splits it into chunks so you can spread it across a week or binge it in one sitting.


Reading Plan

Section

Minutes

What it covers

1. Phase overview & methodology

8

Exam structure, execution order, machine spec

2. OSINT & external recon

12

Symbol recon, IOCTL surface, mitigation fingerprinting

3. Kernel structures

12

EPROCESS, ETHREAD, TOKEN, POOL_HEADER

4. Exploitation primitives

10

UAF, type confusion, pool corruption, races

5. Mitigation bypass matrix

25

DEP through HVCI, every bypass explained

6. Worked examples

20

Three real exploit chains, step by step

7. WinDbg command reference

15

Debugging under time pressure

8. Heap & pool internals

15

kLFH, buckets, pool header, coalescing

9. Kernel exploit chain template

12

Info leak to SYSTEM shell

10. Data-only & version independence

15

What to do when HVCI blocks code execution

11. Exam strategy & report

15

What the grader actually reads

12. OpSec considerations

8

Detection artifacts, avoidance

13. Tooling quick reference

5

Tools and install

14. Quick-reference tables

8

Bugchecks, mitigation status by Windows version


1. Phase Overview & Methodology

Why the exam is structured this way

The OSEE is not a memory test. It is a 72-hour practical where you are handed a hardened target and expected to produce a working exploit. Not a proof-of-concept that crashes the box — a working exploit that demonstrates control. The course that prepares you for it is EXP-401, formerly Advanced Windows Exploitation (AWE). The exam challenges are derived from EXP-401 topics but are not identical to course labs. Expect to find the vulnerability yourself, not just exploit one that is already identified.

  1. Recon the target binary and driver — strings, imports, IOCTL surface.

  2. Identify the vulnerability class — overflow, UAF, type confusion, race.

  3. Map the mitigations in play — DEP, ASLR, CFG, ACG, CIG, SMEP, SMAP, HVCI.

  4. Build the info leak — KASLR, pool cookie, token cookie.

  5. Groom the heap or pool to shape allocations.

  6. Trigger the vulnerability to corrupt the target.

  7. Convert the bug to an arbitrary read/write primitive.

  8. Escalate to SYSTEM — token stealing or data-only.

  9. Stabilize the exploit for reliability across reboots.

  10. Document the chain in the report.

Always exhaust the leak and grooming steps before triggering. Ordering matters for reliability.

Exam machine spec

Requirement

Spec

Host OS

Windows 10 only (supported)

VM software

VMware Workstation 15+

CPU

64-bit, 4 cores minimum, NX/SMEP/VT-x/EPT support

RAM

16 GB minimum

Disk

160 GB free

Monitors

Up to 4, all shared with proctor

Comms

Chat client only, no audio

Grace period

1 hour from scheduled start

Breaks work like this: notify the proctor in chat, leave the session active, and the webcam can be paused. Do not close the session.


2. OSINT & External Recon Before Touching the Target

Every minute spent reading the target's symbols before writing a single line of exploit code saves an hour of debugging. This phase generates zero kernel crashes.

2.1 Symbol and structure recon

Every offset is build-dependent. Re-derive against the target's symbols before you trust any number.

dt nt!_EPROCESS
dt nt!_ETHREAD
dt nt!_TOKEN
dt nt!_KPROCESS
dt nt!_POOL_HEADER
dt nt!_OBJECT_HEADER
dt nt!_MDL
dt nt!_CM_CALLBACK_ENTRY

What each structure gives you:

  • _EPROCESS — token pointer, ActiveProcessLinks, PID

  • _ETHREAD — thread context, APC state

  • _TOKEN — Privileges.Enabled, TokenType, IntegrityLevel

  • _POOL_HEADER — PreviousSize, PoolIndex, BlockSize, PoolType, PoolTag

  • _OBJECT_HEADER — TypeIndex, Body, SecurityDescriptor

  • _MDL — MappedSystemVa, StartVa, ByteCount

2.2 Driver and IOCTL surface recon

!object \Device
!object \GLOBAL??

dt nt!_DRIVER_OBJECT <driver_addr>

Look at MajorFunction[14] (IRP_MJ_DEVICE_CONTROL). That is your IOCTL entry. Enumerate IOCTL codes from the binary with IDA or Ghidra by finding the switch on IoControlCode in the dispatch handler. Or break on the handler in WinDbg and inspect Parameters.DeviceIoControl.IoControlCode.

What to look for in the IOCTL handler:

  • User-controlled buffer sizes — METHOD_NEITHER is the classic bug.

  • ProbeForRead and ProbeForWrite calls, or their absence.

  • Direct dereference of user pointers without probing.

  • Integer arithmetic on user-supplied sizes.

2.3 Mitigation fingerprinting

!process 0 0 <target.exe>
!verifier 0x80
reg query "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard" /v EnableVirtualizationBasedSecurity
reg query "HKLM\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" /v Enabled

Check for:

  • kASLR — is ntoskrnl base randomized across reboots?

  • SMEP — CR4 bit 20

  • SMAP — CR4 bit 21

  • HVCI — registry and SystemInformation

  • CFG — process load config directory


3. Kernel Structures You Will Touch

Every offset here is build-dependent. Re-derive against your target's symbols with dt nt!_EPROCESS before you trust any number.

Structure

Size (x64)

Why you care

_EPROCESS

about 2 KB

Token manipulation, ACL bypass

_ETHREAD

about 0x800

Thread hijacking, APC injection

_OBJECT_HEADER

about 0x30

Type confusion, object sprays

_TOKEN

about 0x40

Privilege escalation via token replacement

_KPROCESS

about 0x2F0

Kernel process manipulation

_HEAP / _HEAP_ENTRY

varies

Pool corruption, heap feng shui

_MDL

0x30

Arbitrary R/W via MDL manipulation

_CM_CALLBACK_ENTRY

varies

Registry callback corruption


4. Exploitation Primitives

These are the building blocks. Every kernel exploit you write is some combination of these.

Primitive

Technique

Mitigations bypassed

Pool corruption

Overflow into an adjacent object

Pool validation (partial)

UAF → object reuse

Free, then reallocate a controlled object

None directly

Type confusion

Swap vtable pointer to a fake object

CFG (needs an extra bypass)

Integer overflow → heap overflow

Size miscalculation causes an overflow

DEP (no heap impact)

Race condition

Double-fetch or TOCTOU

Varies

Stack overflow → ROP

Stack pivot plus ROP chain

DEP

Token replacement

Overwrite _TOKEN privileges

None — inherent kernel primitive

Arbitrary write → token overwrite

Write directly to _EPROCESS.Token

None, if the write primitive exists


5. Mitigation Bypass Matrix

This is the heart of the exam. Know every row cold.

Mitigation

Introduced

Bypass approaches

DEP (NX)

XP SP2

ROP chains, ret2libc, JIT spraying

ASLR

Vista

Info leak, partial overwrite, JIT spray

CFG

Win8.1+

Fake dispatch, indirect call abuse, JIT mitigation

ACG

Win10 RS1

Code reuse from legitimate modules, JIT abuse

CIG

Win10 RS1

Local process injection, extend existing code

Stack cookie (/GS)

MSVC

Info leak, exception handler overwrite

SEHOP

Vista

Info leak, SEH abuse

Heap validation

Win10

Pool corruption alternatives

VBS / HVCI

Win10 RS3

BootKit, EFI runtime exploitation

Kernel CET

Win10 21H2

ROP alternatives — JOP, data-only

SMEP

Win8+

ROP in kernel, CR4 manipulation, PTE overwrite

SMAP

Win10 RS1+

PTE manipulation, data-only attacks

kASLR

Vista+

Info leak, KASLR bypass

HVCI in plain English: it blocks RWX allocation, CR4 writes, and unsigned drivers. ROP chains in existing RX code still work. Data-only attacks are unaffected.

SMAP in plain English: your fake kernel objects cannot live in user space anymore — you have to spray them into kernel pools. PTE manipulation bypasses both SMEP and SMAP at the same time.


6. Worked Examples

Example 1 — Token stealing via an arbitrary write

Setup: a driver gives you a pool overflow that turns into an arbitrary write primitive. Goal: become SYSTEM.

  1. Leak the address of the current process's _EPROCESS using NtQuerySystemInformation or a handle leak.

  2. Find the SYSTEM process _EPROCESS by walking ActiveProcessLinks from a known kernel object.

  3. Read SystemEPROCESS.Token, then write it into CurrentEPROCESS.Token. The token is XOR'd with a cookie since Windows 10 1809, so leak the cookie first.

  4. Return to user mode and spawn a shell — it runs as SYSTEM.

The catch: modern builds XOR the token with a per-boot cookie. If you skip the cookie leak, your write gives you a garbage token and an instant bugcheck.

Example 2 — KASLR leak through a pool spray

Setup: no direct info leak, but you control a pool allocation that the driver later reads out.

  1. Spray controlled pool allocations with an object whose first 8 bytes are a pointer you want to leak — often a _POOL_HEADER with a known kernel pointer nearby.

  2. Trigger the driver to read the object and return it to user mode through an IOCTL.

  3. Calculate the kernel base by subtracting the known offset of the leaked symbol from the leaked address.

The catch: NonPagedPoolNx and kLFH change the spray reliability. Test your spray across reboots — if it succeeds one time in three, it is not ready for exam day.

Example 3 — HVCI-era data-only privilege escalation

Setup: HVCI blocks all the classic paths. You cannot execute shellcode, write to CR4, or load a driver.

  1. Find an arbitrary write.

  2. Rather than overwriting code, overwrite _TOKEN.Privileges.Enabled on the current process's token.

  3. Set all privilege bits to 1.

  4. Use SeDebugPrivilege to open a SYSTEM process and steal its token.

The catch: this works only if the target process still has a token and you can reach _EPROCESS.Token with the arbitrary write. Document the write primitive in your report — that is the part the grader reads.


7. WinDbg Command Reference

The commands you reach for under time pressure.

!process 0 0                    List all processes
!process 0 7 <name>             Detailed process info
!thread                         Current thread info
!object <addr>                  Object info
dt nt!_EPROCESS <addr>          Dump EPROCESS
dt nt!_TOKEN <addr>             Dump TOKEN
dt nt!_KPROCESS <addr>          Dump KPROCESS
dt nt!_ETHREAD <addr>           Dump ETHREAD
dt nt!_POOL_HEADER <addr>       Pool chunk header
.pool /v                        Pool allocation info
!poolfind <tag>                 Find pool by tag
!verifier                       Driver verifier status
.breakin                        Break into kernel debugger
ed <addr> <value>               Write dword
!handle <addr>                  Handle table info
!irp <addr>                     IRP info
k                               Stack trace
!exploitable                    Assess crash exploitability
.process /i /p <EPROCESS>       Switch process context (invasive)
.process /r /p <EPROCESS>       Switch context (reload symbols)
~* k                            All thread stacks
dps <addr>                      Display pointers with symbols
!address <addr>                 Memory region info
!vprot <addr>                   Virtual memory protection
s -q <start> L<len> <pattern>   Search memory for QWORD

8. Heap & Pool Internals

Pool header layout (x64)

dt nt!_POOL_HEADER
   +0x000 PreviousSize     : Pos 0, 8 Bits
   +0x000 PoolIndex        : Pos 8, 8 Bits
   +0x000 BlockSize        : Pos 16, 8 Bits
   +0x000 PoolType         : Pos 24, 8 Bits
   +0x004 PoolTag          : Uint4B
   +0x008 ProcessBilled    : Ptr64 _EPROCESS
   +0x008 AllocatorBackTraceIndex : Uint2B  (union when PoolQuota not set)
   +0x00a PoolTagHash      : Uint2B

ProcessBilled is XOR-encoded when PoolQuota is set, so you need a pool cookie leak first. An invalid header during free means a BAD_POOL_HEADER bugcheck, code 0x19.

kLFH facts worth memorizing

  • Activation: 16 consecutive allocations to the same size bucket.

  • 129 buckets, with granularity from 16 bytes (small) to 512 bytes (large).

  • No coalescing: free chunks are not merged, which preserves bucket integrity.

  • NonPagedPoolNx is the default NX pool since Windows 8. The legacy NonPagedPool (RWX) is deprecated.

  • ExAllocatePool2 on Windows 10 2004 and later defaults to NX.


9. Kernel Exploit Chain Template

Six steps from a bug to a SYSTEM shell. Every kernel exploit you write follows this shape.

  1. Info leak or KASLR bypass — leak the kernel base.

  2. Heap or pool grooming — shape allocations.

  3. Trigger the vulnerability — corrupt the target.

  4. Arbitrary read/write — convert the limited bug.

  5. Privilege escalation — token stealing, copy the SYSTEM token.

  6. Spawn elevated shell — SYSTEM.

Classic targets

Target

Relevance

nt!HalDispatchTable+0x8

Overwrite with a shellcode address, trigger via NtQueryIntervalProfile

KUSER_SHARED_DATA+0x800

Known writable kernel address, useful for shellcode staging

_TOKEN.Privileges.Enabled

Overwrite to grant SeDebugPrivilege or all privileges

_EPROCESS.Token

Replace with the SYSTEM token

PTE bits

Flip to make a page executable — bypasses DEP and SMEP


10. Data-Only Attacks & Version Independence

When HVCI blocks code execution, you pivot to data-only attacks:

  • Token stealing — copy the SYSTEM token to the current process.

  • Privilege bit manipulation — modify _TOKEN.Privileges.

  • Security descriptor modification — bypass access checks.

  • Job object manipulation — sandbox escape.

Real OSEE targets are large enterprise applications, not CTF binaries. Version-independent exploits resolve structure offsets dynamically rather than hardcoding. A good benchmark exercise: get a HEVD exploit working on Windows 10 1809, then make it run unchanged on 22H2.


11. Exam Strategy & the Report

The exam challenges are derived from EXP-401 topics but are not identical to course labs. Expect to find the vulnerability yourself, not just exploit one that is already identified.

Reliability matters. A one-off PoC that works one time in five fails. Screenshot everything with timestamps — the report is graded as much as the exploit. Document the technique, the tools, and the results.

The challenge categories are:

  • User-mode mitigation bypass.

  • Advanced heap manipulation.

  • 64-bit kernel exploitation.

  • Multi-step exploit chains.

  • Vulnerability research.


12. OpSec Considerations

Event log & detection artifacts

Technique

Detection artifact

Noise level

Driver load (test-signed)

Code Integrity event 3004 / 3033

High

Kernel crash (bugcheck)

Memory dump plus WER report

High

Pool spray

Pool allocations visible in poolmon

Low–Medium

Token manipulation

No direct event — data-only

Low

Process creation as SYSTEM

Event 4688, if auditing on

Medium

Debugger attach

DbgPrint output, KDNET traffic

Medium

Driver verifier

Bugcheck 0xC4 on violation

High

Avoiding detection

  • Do not leave the debugger attached during the final run.

  • Do not use test-signing mode on the target if HVCI is on — it will not load.

  • Remove crash dumps after a failed attempt.

  • Use a fresh VM snapshot per exploit attempt.

Signature avoidance

  • Custom exploit binaries trigger AV.

  • Compile with /MT, strip symbols, avoid known shellcode signatures.

  • If HVCI is on, you cannot use unsigned drivers — plan for data-only.


13. Tooling Quick Reference

Tool

Purpose

Install

WinDbg (Preview)

Kernel debugging

Microsoft Store

IDA Pro / Ghidra

Binary reverse engineering

Commercial / free

x64dbg

User-mode debugging

GitHub

HEVD

Practice kernel driver

GitHub

VMware Workstation

Exam VM host

Commercial

hashcat

Offline hash cracking

apt install hashcat

Process Hacker

Process and token inspection

GitHub

Sysinternals Suite

Procmon, Procexp, Autoruns

Microsoft


14. Quick-Reference Tables

Common bugchecks

Code

Name

Meaning

0x19

BAD_POOL_HEADER

Pool header corrupted

0x3B

SYSTEM_SERVICE_EXCEPTION

Kernel exception during a syscall

0x50

PAGE_FAULT_IN_NONPAGED_AREA

Invalid nonpaged address

0xC2

BAD_POOL_CALLER

Invalid pool request

0x139

KERNEL_SECURITY_CHECK_FAILURE

Fast fail or CFI violation

0x7E

SYSTEM_THREAD_EXCEPTION_NOT_HANDLED

Unhandled kernel thread exception

Mitigation status by Windows version

Version

Key additions

XP SP2

DEP

Vista

ASLR, SEHOP, kASLR

Win8

SMEP, NonPagedPoolNx

Win8.1

CFG

Win10 RS1

ACG, CIG, SMAP

Win10 RS3

VBS / HVCI

Win10 21H2

Kernel CET


Summary: What You Own After This Phase

Intelligence

Best source

Kernel base address

Info leak — pool spray, handle leak

Token cookie

Token leak, Windows 10 1809+

Pool layout and tags

poolmon, !poolfind

Driver IOCTL surface

IDA or Ghidra, WinDbg breakpoints

Mitigation state

!process, CR4, registry

Arbitrary R/W primitive

From the vulnerability

SYSTEM shell

Token stealing or data-only


15. User-Mode Exploitation Deep Dive

The exam tests user-mode mitigation bypass as much as kernel. This section covers the layer most candidates under-prepare.

DEP and why ROP still matters

DEP marks data pages non-executable. It does not stop code reuse. Every DEP bypass in the exam is a ROP chain, a ret2libc call, or a JIT spray. ROP survives because it executes existing executable pages — the mitigation was never designed to stop it.

The three ROP requirements:

  1. A stack pivot if the overflow does not land on the stack you control.

  2. A gadget set with enough coverage to call VirtualProtect or VirtualAlloc.

  3. A return path back into the shellcode or into a controlled function pointer.

Stack pivot patterns

xchg eax, esp ; ret
mov esp, ebp ; pop ebp ; ret
leave ; ret
add rsp, 0x?? ; ret
pop rsp ; ret

The classic x64 pattern: overwrite the return address with a gadget that loads rsp from a register you control, then the ROP chain lives in your buffer. Test the pivot in isolation before chaining it.

ASLR bypass on user mode

ASLR randomizes module bases per boot. The bypasses:

  • Info leak — any function that returns a pointer into a module, a heap address, or a stack address. Format strings, uninitialized memory reads, heap overflows that leak a vtable pointer.

  • Partial overwrite — overwrite only the low 2 bytes of a saved return address. The high bytes are shared across the module, so the target stays in the same module with high probability. Reliability drops on page boundaries.

  • Non-ASLR modules — check every loaded module with !address or Process Hacker. Legacy DLLs without /DYNAMICBASE still exist in enterprise software.

  • JIT spraying — predictable executable memory in JIT engines.

CFG bypass

Control Flow Guard validates indirect call targets against a bitmap. The bypasses:

  • Call-site analysis — find an indirect call where the target set includes a function you can reach with controlled arguments. CFG validates the target, not the arguments.

  • Fake object with valid vtable — CFG checks that the function pointer is a valid CFG target. If you can point the vtable at a legitimate function that does something useful with this, you win without breaking CFG.

  • JIT pages — JIT-compiled code is registered as valid CFG targets. If the target application has a JIT engine, spray there.

  • Return-oriented programming — CFG does not validate returns. ROP bypasses CFG by design.

ACG and CIG

ACG blocks dynamic code generation. CIG blocks unsigned module loading. The bypass approaches:

  • Code reuse from signed modules — you cannot allocate RWX, but you can call existing code.

  • JIT abuse — JIT engines get an ACG exemption. If the target has one, the JIT is the way in.

  • CIG bypass — local process injection into a process that already has the module loaded, or extend an existing signed module's code path.


16. Heap Exploitation: NT Heap and Segment Heap

NT Heap structures

The NT heap is the classic allocator. The structures:

_HEAP
  +0x000 SegmentList
  +0x010 FreeLists
  +0x058 FrontEndHeap
  +0x0?? BlocksIndex
  +0x0?? UCRSegmentList

_HEAP_ENTRY
  +0x000 Size          (low bits: BUSY, EXTRA_PRESENT, FILL_PATTERN, etc.)
  +0x008 PreviousSize
  +0x010 UnusedBytes
  +0x018 SegmentOffset (or user data)

The LFH (Low Fragmentation Heap) is the front-end allocator for small sizes. Activation requires 16 consecutive allocations to the same bucket. Buckets run from 16 bytes to 16 KB in NT heap LFH, though the 129-bucket count from the kernel pool is a different allocator — do not conflate them.

Segment Heap

Segment heap became the default for many processes in Windows 10 1803 and later. The structures differ:

_SEGMENT_HEAP
  +0x000 EnvHandle
  +0x0?? Signature
  +0x0?? SegmentList
  +0x0?? LargeAllocMetadata
  +0x0?? VsAllocator

_HEAP_VS_CHUNK_HEADER
  +0x000 Sizes
  +0x008 UnusedBytes

The VS (variable size) allocator handles small and medium allocations. The LFH exists inside the segment heap as well, but the chunk headers are different. Exploit primitives that work on NT heap do not transfer one-to-one.

Heap primitives

  • Heap overflow — overwrite the next chunk's header or user data. On NT heap, corrupting Size breaks unlinking on free.

  • UAF — free an object, reallocate a controlled object into the same slot, trigger a virtual call through the stale pointer.

  • Type confusion — two object types share a size class. Allocate type A, free it, allocate type B into the same slot, then use A's vtable through B's object.

  • Heap grooming — control the layout so the overflow lands on a target object. The pattern: allocate N fillers, allocate the target, allocate M more, free specific fillers, then trigger the overflow.


17. Kernel Pool Exploitation

Pool types

NonPagedPool        — always resident, can be RWX on legacy builds
NonPagedPoolNx      — always resident, NX since Windows 8 (default)
PagedPool           — pageable, cannot be referenced at high IRQL

The exam targets drivers that allocate from NonPagedPoolNx. Legacy drivers still allocate from NonPagedPool, and that difference changes the exploit.

Pool tag hunting

Every allocation carries a 4-byte tag. The tag identifies the object and the driver. Use it to find the target's allocations:

!poolfind <Tag>
!pool <addr> 2
dt nt!_POOL_HEADER <addr>

A driver that allocates with tag MyDr is visible in the pool with that tag. Count allocations, find the size class, and build the spray around it.

Pool sizes and buckets

Small allocations (<= 0x80 on some builds)   → lookaside lists
Medium allocations                           → pool buckets
Large allocations                            → direct pool allocations

The exact boundaries vary by build. Measure with !poolused and poolmon on the target.

Pool spraying

The goal of a pool spray is to place a controlled object at a predictable offset from the vulnerable allocation. Techniques:

  • Object size matching — allocate objects whose size lands in the same pool bucket as the vulnerable allocation.

  • Quota spraying — use _POOL_HEADER.ProcessBilled quota tracking to force predictable placement.

  • Handle spraying — open handles to objects whose kernel representation you control. Handles are cheap and predictable.

  • Pipe and Event spraying — NtCreateEvent and pipe buffers allocate pool blocks you can shape.

Each spray needs a reliability test across reboots. A spray that works after a cold boot but fails after a warm reboot is not reliable.

Pool corruption patterns

  • Overflow into the next chunk header — corrupt PoolType or BlockSize, then free and trigger a bugcheck or a controlled write.

  • Overflow into object data — corrupt a function pointer or a length field inside the next object.

  • UAF with reallocation — free the target, spray a controlled object into the slot, trigger the stale reference.

  • Pool header reuse — free a chunk, reallocate with controlled tag and size, corrupt the header from a UAF write.


18. SMEP, SMAP, and PTE Manipulation

What the mitigations do

SMEP blocks execution of user-mode pages from kernel mode. SMAP blocks access to user-mode pages from kernel mode. Both are CR4 bits.

CR4 bit 20  — SMEP
CR4 bit 21  — SMAP

The classic bypass: ROP to disable SMEP by clearing CR4 bit 20, then return to user-mode shellcode. SMAP complicates this because the ROP chain cannot read user-mode data directly.

CR4 manipulation via ROP

pop rax ; ret
mov cr4, rax ; ret

The chain: rax = current_cr4 & ~0x100000, then mov cr4, rax. After that the kernel can execute user pages. SMAP adds & ~0x200000 if you also want kernel access to user pages.

The modern problem: HVCI blocks CR4 writes. On HVCI-enabled targets, CR4 manipulation is not available.

PTE overwrite

The PTE overwrite makes a user page executable and kernel-accessible without touching CR4. The technique:

  1. Find the PTE for your shellcode page using the self-referencing PML4 entry.

  2. Flip the NX bit and the user/supervisor bit.

  3. Return into the shellcode.

x64 page table walk:

PML4  →  PDPT  →  PD  →  PT  →  page

Each entry is 8 bytes. The PML4 self-reference entry lets you map page tables into user space for direct editing.

Why PTE overwrite matters

PTE manipulation bypasses SMEP, SMAP, and sometimes HVCI because it changes the page's permissions rather than the CPU configuration. It is the most reliable technique on modern Windows.


19. Token and Privilege Structures

_TOKEN layout

_TOKEN
  +0x000 TokenSource
  +0x018 TokenId
  +0x020 AuthenticationId
  +0x028 ParentTokenId
  +0x030 ExpirationTime
  +0x038 TokenId (second)
  +0x040 Privileges
  +0x0?? IntegrityLevel
  +0x0?? UserAndGroupCount
  +0x0?? UserAndGroups

The exact offsets shift per build. Always re-derive.

_SEP_TOKEN_PRIVILEGES

_SEP_TOKEN_PRIVILEGES
  +0x000 Present
  +0x008 Enabled
  +0x010 EnabledByDefault

Each field is a 64-bit bitmask. The privilege bits:

SeCreateTokenPrivilege           bit 0
SeAssignPrimaryTokenPrivilege    bit 1
SeLockMemoryPrivilege            bit 2
SeIncreaseQuotaPrivilege         bit 3
SeUnsolicitedInputPrivilege      bit 4
SeMachineAccountPrivilege        bit 5
SeTcbPrivilege                   bit 6
SeSecurityPrivilege              bit 7
SeTakeOwnershipPrivilege         bit 8
SeLoadDriverPrivilege            bit 9
SeSystemProfilePrivilege         bit 10
SeSystemtimePrivilege            bit 11
SeProfileSingleProcessPrivilege  bit 12
SeIncreaseBasePriorityPrivilege  bit 13
SeCreatePagefilePrivilege        bit 14
SeCreatePermanentPrivilege       bit 15
SeBackupPrivilege                bit 16
SeRestorePrivilege               bit 17
SeShutdownPrivilege              bit 18
SeDebugPrivilege                 bit 19
SeAuditPrivilege                 bit 20
SeSystemEnvironmentPrivilege     bit 21
SeChangeNotifyPrivilege          bit 22
SeRemoteShutdownPrivilege        bit 23
SeUndockPrivilege                bit 24
SeSyncAgentPrivilege             bit 25
SeEnableDelegationPrivilege      bit 26
SeManageVolumePrivilege          bit 27
SeImpersonatePrivilege           bit 28
SeCreateGlobalPrivilege          bit 29
SeTrustedCredManAccessPrivilege  bit 30
SeRelabelPrivilege               bit 31
SeIncreaseWorkingSetPrivilege    bit 32
SeTimeZonePrivilege              bit 33
SeCreateSymbolicLinkPrivilege    bit 34

SeDebugPrivilege is the pivot. With it, you can open a SYSTEM process and duplicate its token.

Token stealing pattern

1.  current_eprocess = PsGetCurrentProcess()
2.  current_token    = current_eprocess->Token
3.  system_process   = find by PID 4 or by walking ActiveProcessLinks
4.  system_token     = system_process->Token
5.  current_eprocess->Token = system_token
6.  return to user mode — process now has SYSTEM token

Token values are XOR'd with a per-boot cookie stored at nt!SepCookie (also referenced as the token cookie in some symbols). Before you write a token, you must:

real_token = leaked_value ^ cookie
new_value  = system_token ^ cookie

If you write a raw token value, you get an invalid token and a bugcheck. The cookie leak is mandatory on modern builds.

Integrity levels

Untrusted      0x0000
Low            0x1000
Medium         0x2000
High           0x3000
System         0x4000
Protected      0x5000

The token's integrity level is a SID. Data-only escalation can modify it directly.


20. WDEG and Modern Mitigations

Windows Defender Exploit Guard is a set of process-level mitigations. The exam can target any of them.

CFG details

CFG builds a bitmap of valid indirect call targets at load time. The bitmap is in the process's load config directory. The call-site instrumentation checks target & mask against the bitmap before the call.

The bypass categories:

  • Target inside a legitimate function that does something useful.

  • Target inside a JIT page (JIT pages are registered as valid).

  • Return-oriented programming (returns are not checked).

  • Corrupting the CFG bitmap or the function table pointer.

ACG and CIG

ACG blocks VirtualAlloc(PAGE_EXECUTE_*) in the process. CIG blocks LoadLibrary of unsigned modules. Both apply per-process.

The bypasses are the same as CFG: code reuse from existing modules, JIT abuse, and process injection into a process that has the needed module loaded.

Export Address Filtering (EAF / EAF+)

EAF blocks reading the export table of loaded modules from a non-image region. EAF+ extends it to the module's headers and checks the caller. Shellcode that resolves exports from its own buffer breaks under EAF.

Bypass: resolve imports before the mitigation applies, use a legitimate loader path, or walk the PEB from a region EAF+ allows.

Return Flow Guard and shadow stacks

Return Flow Guard checks that each return address matches the value pushed onto a shadow stack. Bypass requires corrupting the shadow stack or using a call rather than a return. Kernel CET (Windows 10 21H2) applies the same idea to kernel returns.

Where WDEG meets kernel exploitation

Kernel exploits rarely touch WDEG directly. The interaction is at the transition: a kernel exploit that lands a user-mode shell must survive whatever WDEG policies the target process has. If the process is ACG-protected, your shellcode cannot be allocated after the exploit — it must already be mapped or you must pivot into an existing executable region.


21. Kernel Debugging Setup

The exam assumes you can attach a kernel debugger to a target VM. Set this up before exam day.

VMware network debugging

On target VM, as admin:
bcdedit /debug on
bcdedit /dbgsettings net hostip:<host_ip> port:50000 key:1.2.3.4
bcdedit /set testsigning on

On host:
windbg -k net:port=50000,key=1.2.3.4

If key is rejected, generate one with bcdedit /dbgsettings net hostip:<host_ip> port:50000 and use the generated key.

Serial pipe debugging

VMware: add serial port, output to named pipe \\.\pipe\debugpipe

Target:
bcdedit /dbgsettings serial debugport:1 baudrate:115200

Host:
windbg -k com:pipe,port=\\.\pipe\debugpipe,resets=0,reconnect

Serial is slower but survives network changes in the VM. Use it when the target's network stack is unreliable.

Symbols

.sympath srv*C:\symbols*https://msdl.microsoft.com/download/symbols
.symfix
.reload /f

Set the symbol path before every session. !analyze -v on a bugcheck is only useful with symbols loaded.

First commands on attach

vertarget
!process 0 0
lm
!drvobj <driver_name> 2

vertarget confirms the build. !drvobj on the target driver shows the dispatch table and the device object chain.


22. Reverse Engineering Workflow for Drivers

Static analysis with IDA or Ghidra

The workflow:

  1. Load the .sys file. Import the kernel type library if available.

  2. Find DriverEntry — the entry point the driver exports as GsDriverEntry or DriverEntry.

  3. Follow the DriverObject->MajorFunction assignment. IRP_MJ_DEVICE_CONTROL (index 14) is the IOCTL handler.

  4. Inside the IOCTL handler, find the switch or comparison on IoControlCode.

  5. For each IOCTL, identify the input and output buffer access pattern.

METHOD_BUFFERED    —  system buffer, safe by default
METHOD_IN_DIRECT  —  locked user buffer, MDL
METHOD_OUT_DIRECT —  locked user buffer, MDL
METHOD_NEITHER    —  raw user pointers, probe required

METHOD_NEITHER with no ProbeForRead is the classic vulnerability. It is also the most common exam bug.

Dynamic analysis

Set breakpoint on the IOCTL handler:
bp <driver>!<handler>
g

Inspect the IRP stack:
!irp <irp_addr>
dt nt!_IO_STACK_LOCATION <addr>

Compare Parameters.DeviceIoControl.InputBufferLength and OutputBufferLength against the actual dereferences. A handler that trusts the length is a candidate.

Fuzzing approach

Driver fuzzing in the exam is manual, not automated. The pattern: send a known-good IOCTL with valid data, confirm the handler path, then mutate one field at a time and watch for a bugcheck. The bugcheck is the vulnerability.


23. Exploit Reliability Engineering

The exam grades a working exploit, not a crash. Reliability is the difference.

Testing methodology

  • Run the exploit from a cold boot at least 10 times.

  • Run it after a warm reboot at least 10 times.

  • Run it with the target process at different memory layouts (fresh process versus long-running).

  • Run it with driver verifier enabled. The verifier catches pool corruption the exploit may otherwise trigger silently.

Common reliability failures

  • Heap spray that depends on layout — works on one boot, fails on the next. Fix by spraying more and adding a groom step.

  • Info leak that depends on uninitialized memory — returns the right value only sometimes. Fix by trying the leak in a loop until the value is plausible.

  • Race condition with no synchronization — works once. Fix by pinning the exploit to one CPU with SetThreadAffinityMask and repeating the trigger.

  • Pool cookie dependency — the cookie changes per boot. Leak it every time, never cache it across runs.

Error handling in the exploit

- Check every ReadProcessMemory/WriteProcessMemory return
- Verify the leaked base address against a plausible range before using it
- On a failed leak, retry up to N times before aborting
- On a successful token write, verify the new token with GetTokenInformation

An exploit that crashes on a failed leak fails the exam even if the correct path exists.


24. Report Writing Template

The report is graded. Structure it before you start the exploit, and fill it in as you go.

Report structure

1.  Executive summary
    - Target, vulnerability class, exploit result, reliability

2.  Target analysis
    - Binary name, version, hash
    - Mitigations present
    - Driver dispatch table and IOCTL surface

3.  Vulnerability analysis
    - Function, instruction address, root cause
    - User-controlled input and the missing check
    - Crash proof with WinDbg output

4.  Exploit design
    - Mitigations to bypass
    - Primitive built and how
    - Groom and spray strategy

5.  Exploit implementation
    - Code snippets
    - Offsets and why they are derived, not hardcoded

6.  Reliability testing
    - Cold boot and warm reboot results
    - Verifier results

7.  Conclusion and remediation
    - What the driver should check

What the grader reads

  • The vulnerability analysis — if the root cause is wrong, the report fails regardless of the exploit.

  • The exploit chain — each step must be explained, not just coded.

  • The reliability data — a one-off success is not a working exploit.

Screenshots

Timestamp every screenshot. The grader compares the screenshot timestamp against the exam timeline. A screenshot without a visible timestamp is weaker evidence than one with it.


25. Twelve-Week Study Plan

A realistic pre-exam plan for someone with the 300-level certifications already done.

Week 1-2    Kernel fundamentals
            - Windows internals: EPROCESS, ETHREAD, tokens
            - WinDbg setup and command fluency
            - HEVD driver: build, load, trigger each vulnerability

Week 3-4    User-mode exploitation
            - DEP and ASLR bypass on a Windows 10 target
            - ROP chain construction
            - CFG bypass on a sample application

Week 5-6    Heap exploitation
            - NT heap and LFH internals
            - Heap overflow and UAF labs
            - Segment heap differences

Week 7-8    Kernel pool exploitation
            - Pool header, tags, lookaside lists
            - Pool spraying and grooming
            - HVCI-aware exploitation

Week 9-10   Mitigation bypass
            - SMEP/SMAP bypass
            - PTE manipulation
            - Token stealing with cookie

Week 11      Exploit reliability and report writing
            - Re-run every lab across 10 reboots
            - Write a full report for one lab
            - Practice the report template

Week 12      Full practice run
            - Two-day timed exercise on a fresh target
            - Report graded against the rubric

Daily habit

- 30 minutes reading Windows internals
- 90 minutes in WinDbg or the debugger of choice
- 30 minutes writing up what was learned

Writing up is not optional. The exam grades the report.


26. Practice Labs and Resources

HEVD

HackSys Extreme Vulnerable Driver is the standard training target. It covers stack overflow, pool overflow, UAF, type confusion, and arbitrary write. Every OSEE candidate should have completed all HEVD vulnerabilities before the exam.

Additional lab targets

  • Custom drivers with METHOD_NEITHER handlers — write your own to practice finding the bug.

  • Older enterprise software with known kernel-mode components.

  • Public CTF kernel challenges — pwn2own archives and kernel exploitation CTFs.

Reading list

  • Windows Internals, Part 1 and Part 2 — the structure reference.

  • The Windows kernel exploitation writeups from public researchers.

  • The OffSec EXP-401 course material, reviewed nightly.


27. Exam Day Timeline

A 72-hour exam is an endurance event. Plan the blocks.

Hour 0-2      Setup, verify tools, read the challenge brief
Hour 2-6      Recon the target binary, identify the driver and IOCTL surface
Hour 6-10     Static analysis, find the vulnerability class
Hour 10-14    Dynamic analysis, confirm the crash and root cause
Hour 14-16    Write the vulnerability section of the report
Hour 16-24    Build the info leak and the exploit primitive
Hour 24-30    Sleep. Non-negotiable.
Hour 30-38    Heap or pool grooming, exploit chain first version
Hour 38-44    Stabilize across reboots, verifier testing
Hour 44-48    Sleep.
Hour 48-58    Second challenge or second vulnerability in the first target
Hour 58-64    Exploit and report for the second target
Hour 64-68    Final reliability runs, screenshots with timestamps
Hour 68-72    Report completion, submit

The sleep blocks are part of the plan, not a concession. Candidates who skip sleep ship a broken exploit in the last six hours.


28. Glossary

  • ACG — Arbitrary Code Guard. Blocks dynamic code generation in a process.

  • ASLR — Address Space Layout Randomization. Randomizes module bases.

  • Bugcheck — Kernel crash. Blue screen. Your exploit failed.

  • CFG — Control Flow Guard. Validates indirect call targets.

  • CIG — Code Integrity Guard. Blocks unsigned module loads.

  • DEP — Data Execution Prevention. Marks data pages non-executable.

  • EPROCESS — The kernel structure representing a process.

  • ETHREAD — The kernel structure representing a thread.

  • HVCI — Hypervisor-Enforced Code Integrity. Blocks unsigned kernel code, RWX allocation, and CR4 writes.

  • IOCTL — I/O Control. The interface a user-mode process uses to talk to a driver.

  • kASLR — Kernel ASLR. Randomizes the kernel base.

  • kLFH — Kernel Low Fragmentation Heap. The kernel pool's small-allocation front end.

  • NonPagedPoolNx — The NX pool. Default since Windows 8.

  • PTE — Page Table Entry. Controls page permissions.

  • ROP — Return-Oriented Programming. Code reuse via return addresses.

  • SMAP — Supervisor Mode Access Prevention. Blocks kernel access to user pages.

  • SMEP — Supervisor Mode Execution Prevention. Blocks kernel execution of user pages.

  • TOKEN — The kernel structure representing a security context.

  • UAF — Use-After-Free. Free an object, keep a reference, reuse it.

  • WDEG — Windows Defender Exploit Guard. The process-level mitigation set.


Final Word

The mitigation matrix is the exam. Every challenge is a mitigation problem wearing a vulnerability as a mask. Read the matrix twice, then read it a third time the night before. Everything else in this document supports those thirteen rows.

Good luck. Depth holds.

Leave a heart if you found this helpful

Comments

Sign in to leave a comment