Challenge 28: Hardware Breakpoint ETW Hook
Hard ETW Bypass
Objective
Use hardware breakpoints (debug registers) and a Vectored Exception Handler to intercept EtwEventWrite calls without modifying any code bytes — completely evading Rule 8’s memory integrity check.
Background
Hardware breakpoints use the CPU’s debug registers (DR0-DR3) to trigger exceptions when specific addresses are executed. Combined with a Vectored Exception Handler (VEH), you can intercept function calls without writing to code memory.
This technique is used in advanced EDR bypass tools for “patchless” hooking:
- Set DR0 to point to
EtwEventWrite - Register a VEH that catches
EXCEPTION_SINGLE_STEP - When the breakpoint fires, modify the return value and skip the function
- No code bytes are modified — memory integrity checks pass
This is essentially the same principle behind ETW-TI’s NtContinue monitoring — the kernel watches for debug register manipulation via NtSetContextThread.
The Weakness
Rule 8’s integrity check:
- Reads bytes at
EtwEventWrite— unchanged, no patch detected - Queries the trace session — still running
- Does not monitor debug registers (DR0-DR3)
- Does not detect VEH installation
- Has no kernel-mode component (no ETW-TI to catch
NtSetContextThread)
Rules
- The EDR agent must be running with ETW enabled
- Hook
EtwEventWriteusing only hardware breakpoints + VEH - No code bytes at
EtwEventWritemay be modified - Rule 8 must not detect the hook
- ETW events must be silently dropped
Hints
Hint 1
UseGetThreadContext and SetThreadContext to read/write debug registers. Set DR0 to the address of EtwEventWrite and enable the local breakpoint in DR7.
Hint 2
Register a Vectored Exception Handler withAddVectoredExceptionHandler. In the handler, check for EXCEPTION_SINGLE_STEP and verify the exception address matches EtwEventWrite.
Hint 3
In the VEH handler, setRIP to the return address (read from [RSP]), set RAX to 0 (STATUS_SUCCESS), adjust RSP += 8, and return EXCEPTION_CONTINUE_EXECUTION. The function is "called" but never actually runs.
Further Reading
- ETW-TI Deep Dive — How kernel-mode ETW-TI detects
NtSetContextThreadfor debug register manipulation - Hell’s Gate, Heaven’s Gate & Tartarus Gate — Related syscall-level bypass techniques
MostShittyEDR