Documentation Index
Fetch the complete documentation index at: https://mintlify.com/HavocFramework/Havoc/llms.txt
Use this file to discover all available pages before exploring further.
Evasion Features
Indirect Syscalls
Demon implements indirect syscall execution to bypass userland hooks placed by EDR solutions.How It Works
How It Works
Traditional malware uses Win32 APIs like
VirtualAllocEx or CreateRemoteThread, which jump into ntdll.dll functions. EDR solutions hook these functions to intercept malicious calls.Demon’s Approach:- Parse
ntdll.dllfrom disk to find syscall stubs - Extract syscall Service Numbers (SSN) for each Nt* function
- Dynamically craft syscall stubs in memory
- Execute syscalls directly without going through hooked functions
- Spoof the return address to point within
ntdll.dllmodule
- Process operations:
NtOpenProcess,NtTerminateProcess - Memory operations:
NtAllocateVirtualMemory,NtWriteVirtualMemory,NtProtectVirtualMemory - Thread operations:
NtCreateThreadEx,NtSuspendThread,NtResumeThread - Object operations:
NtDuplicateObject,NtClose - Token operations:
NtOpenProcessToken,NtDuplicateToken
Return Address Spoofing
On x64 systems, Demon implements call stack spoofing to hide malicious call chains.Technical Details
Technical Details
The Problem:
When malicious code calls sensitive APIs, the call stack reveals the true origin of the call, potentially pointing to unbacked memory regions or suspicious modules.Demon’s Solution:Uses assembly trampolines to manipulate the call stack before invoking functions:
- Save current RBX register
- Set up trampoline address pointing to legitimate code
- Execute target function through trampoline
- Return address appears to originate from legitimate module
Return address spoofing is implemented in
src/asm/Spoof.x64.asm and automatically applied when the StackSpoof configuration option is enabled.AMSI Bypass
AMSI (Anti-Malware Scan Interface) integration in PowerShell and .NET blocks malicious scripts. Demon patches AMSI to bypass scanning.- Hardware Breakpoints
- Memory Patching
Most Stealthy MethodUses Vectored Exception Handling (VEH) with hardware breakpoints:
- Register VEH handler
- Set hardware breakpoint on
AmsiScanBuffer - When AMSI tries to scan, exception fires
- VEH handler modifies return value to indicate clean content
- No memory modifications required
- No suspicious memory writes
- Harder to detect
- Bypasses memory integrity checks
ETW Bypass
ETW (Event Tracing for Windows) provides telemetry to EDR solutions. Demon can disable ETW for its process. Method: PatchesNtTraceEvent to prevent ETW event generation
Impact: Reduces visibility to EDR solutions that rely on ETW telemetry
Execution Features
BOF/COFF Loader
Demon includes a COFF (Common Object File Format) loader for executing Beacon Object Files (BOFs).BOF Execution
BOF Execution
Features:
- In-memory COFF parsing and linking
- Beacon API compatibility layer
- Support for BOF arguments
- Output capture and relay to teamserver
- Inline: Execute in current process (fast, less OPSEC-safe)
- Threaded: Execute in separate thread with job management
- VEH Protected: Use vectored exception handling for crash protection
BeaconPrintf- Output textBeaconOutput- Send binary outputBeaconDataParse- Parse argumentsBeaconGetValue- Retrieve beacon information- Win32 API stubs through Demon’s import table
.NET Assembly Execution
Demon can host the CLR (Common Language Runtime) to execute .NET assemblies in-memory.AMSI Patching
Before loading assemblies,
amsi.dll is loaded and patched to bypass AMSI scanning of the assembly.Shellcode Injection
Multiple shellcode injection techniques with configurable API usage. See Injection Techniques for detailed documentation.Defense Evasion
Dynamic API Resolution
Demon resolves Win32 APIs dynamically at runtime to avoid static import tables.PEB Walking
PEB Walking
Process:
- Access Thread Environment Block (TEB)
- Traverse to Process Environment Block (PEB)
- Walk
InLoadOrderModuleListto find loaded DLLs - Parse PE headers to locate export tables
- Match function names by hash
- Cache resolved addresses for performance
- No suspicious imports in PE header
- Can resolve functions from any loaded module
- Evades basic static analysis
Proxy Loading
Demon can load and execute code through legitimate Windows APIs to appear as normal system activity.RtlRegisterWait
Registers a wait operation that executes code when signaled.
RtlCreateTimer
Creates a timer callback that executes code at specified intervals.
RtlQueueWorkItem
Queues a work item to the thread pool for execution.
Stack Duplication
During sleep obfuscation (Ekko/Zilean), Demon can duplicate the stack from another thread. Purpose: When sleeping with stack spoofing enabled, the NT_TIB (Thread Information Block) is duplicated from a legitimate thread to make the sleeping thread’s stack appear normal during inspection. Configuration:Configuration Management
Runtime Configuration
Many Demon settings can be modified at runtime without recompiling:Use the
config command without arguments to display current configuration.Process Features
Process Enumeration
Demon provides detailed process information:- Process Name
- Process ID (PID)
- Parent Process ID (PPID)
- Process Architecture (x86/x64)
- Username (if accessible)
- Session ID
Module Enumeration
List loaded modules in a target process:- Module name
- Base address
- Module size
- Full path
Memory Enumeration
Query process memory regions:PAGE_EXECUTE_READ(RX)PAGE_EXECUTE_READWRITE(RWX)PAGE_READWRITE(RW)
Token Features
Token Vault
Demon maintains a token vault for storing stolen tokens:Token Management
Token Management
Workflow:
- Enumerate tokens:
token find-tokens- Scan system for accessible tokens - Steal token:
token steal [pid]- Duplicate token from process - Store in vault: Token automatically added to vault with unique ID
- List vault:
token list- View all stolen tokens - Impersonate:
token impersonate [id]- Apply token to current thread - Revert:
token revert- Return to default process token
- Username
- Domain
- Token type (Primary/Impersonation)
- Integrity level
- Session ID
Privilege Escalation
SeDebugPrivilege- Debug programsSeImpersonatePrivilege- Impersonate tokensSeLoadDriverPrivilege- Load kernel driversSeTcbPrivilege- Act as part of OS
Token Creation
Create tokens from credentials:LogonUserW- Standard logon- Network logon (Type 3) - No profile load
Next Steps
Command Reference
Complete documentation of all commands
Sleep Obfuscation
Configure advanced sleep techniques
Injection Methods
Deep dive into process injection
Generate Payloads
Create configured Demon agents
