How carlosg13/process-hypnosis-debugger-assisted-control-flow-hijack works
Project type and purpose
• Project type: A single-executable Windows command-line security tool written in native C++/Win32.
• Purpose: Demonstrates a novel “Process Hypnosis” technique—using the Windows debugging APIs to hijack a target process’s control flow and inject code without classic APIs like VirtualAllocEx or CreateRemoteThread.
File structure
• Top-level files:
– ProcessHypnosis.sln (Visual Studio solution)
– README.md (explanation of attack technique)
• Project folder ProcessHypnosis/ProcessHypnosis:
– ProcessHypnosis.cpp (all core logic lives here)
– ProcessHypnosis.vcxproj* (build configuration)
– x64/Debug output folder with built executable, logs, symbol PDBs
• No separate frontend/backend; no external service components—just one native process.
Key insights from the README
• Core components it interacts with:
– Windows Debugging API (CreateProcessW with DEBUG_ONLY_THIS_PROCESS, WaitForDebugEvent, DebugActiveProcessStop)
– Kernel functions under the hood (PsFreezeProcess/PsThawProcess via NtSetInformationJobObject)
– Memory-write routines (WriteProcessMemory internally calls NtProtectVirtualMemory)
– Symbol lookup APIs (SymFromName)
• Sequence of operations:
1. Spawn target in debug-only mode
2. Handle debug events (CREATE_PROCESS, LOAD_DLL, CREATE_THREAD)
3. Patch target’s entry point via WriteProcessMemory
4. Detach debugger to unfreeze and resume target
Detail but avoid overcomplication
• Break the attacker tool into as many logical subcomponents as it helps clarity.
• Frozen/unfrozen state transitions of the target’s main thread around the DebugActiveProcessStop call.