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.
Overview
Demon supports multiple process injection techniques for executing shellcode or DLLs in remote processes. The injection system offers flexibility in choosing between stealthy syscall-based methods and faster Win32 API approaches.Injection Methods
Demon distinguishes between two primary injection scenarios:Inject
Inject code into an existing process by PID.Requires:
- Target process ID
- Sufficient permissions
- Compatible architecture
Spawn
Create a new sacrificial process and inject code (fork & run).Advantages:
- Controlled process environment
- No target process required
- Cleaner OPSEC
Injection Techniques
Technique 1: Win32 API
Value:INJECTION_TECHNIQUE_WIN32 (1)
Uses high-level Win32 APIs for injection operations.
API Call Flow
API Call Flow
For Spawn:
CreateProcessA- Create suspended process
VirtualAllocEx - Allocate memory
3. WriteProcessMemory - Write shellcode
4. VirtualProtectEx - Change to RX protectionThread Creation:
5. CreateRemoteThread - Start execution
6. ResumeThread - Resume main thread (if spawned)- ✅ Fast and stable
- ✅ Simple implementation
- ✅ Compatible with all targets
- ❌ Heavily hooked by EDR
- ❌ High detection rate
- ❌ Leaves obvious forensic traces
- Testing environments
- No EDR present
- Speed prioritized over stealth
Technique 2: Syscall
Value:INJECTION_TECHNIQUE_SYSCALL (2)
Recommended - Uses indirect syscalls to bypass userland hooks.
API Call Flow
API Call Flow
For Spawn:
4.
CreateProcessA- Create suspended process (no syscall alternative)
NtAllocateVirtualMemory* - Allocate memory
3. NtWriteVirtualMemory* - Write shellcode4.
NtProtectVirtualMemory* - Change to RX protectionThread Creation:
5. NtCreateThreadEx* - Start execution
6. NtResumeThread* - Resume thread* = Indirect syscall- ✅ Bypasses userland EDR hooks
- ✅ Stealthy execution
- ✅ Production-ready
- ✅ Return address spoofing available
- ❌ Slightly slower than Win32
- ❌ More complex implementation
- Production operations
- EDR present
- Stealth prioritized
Technique 3: APC Injection
Value:INJECTION_TECHNIQUE_APC (3)
Queues Asynchronous Procedure Calls (APCs) to existing threads.
API Call Flow
API Call Flow
NtAllocateVirtualMemory*- Allocate memoryNtWriteVirtualMemory*- Write shellcodeNtProtectVirtualMemory*- Set RX protection- Enumerate threads in target process
- For each thread:
NtOpenThread*- Open threadNtQueueApcThread*- Queue APC pointing to shellcode
- APCs execute when threads enter alertable wait state
- ✅ No new thread creation
- ✅ Stealthy (uses existing threads)
- ✅ Bypasses some thread creation monitoring
- ❌ Requires alertable wait state
- ❌ Execution timing unpredictable
- ❌ May not execute immediately
- Target has alertable threads
- Thread creation is monitored
- Delayed execution acceptable
Thread Creation Methods
When creating threads in remote processes, Demon supports multiple methods:DX_THREAD_WIN32
UsesCreateRemoteThread API.
Cons: Heavily monitored by EDR
DX_THREAD_SYSCALL
Recommended - UsesNtCreateThreadEx via indirect syscall.
Cons: Requires syscall infrastructure
DX_THREAD_APC
Queues an APC instead of creating a thread.Cons: Unreliable execution timing
Memory Allocation Methods
DX_MEM_WIN32
UsesVirtualAllocEx for memory operations.
DX_MEM_SYSCALL
Recommended - UsesNtAllocateVirtualMemory via indirect syscall.
Spawn Process Configuration
When using fork & run (spawn) techniques, Demon spawns a sacrificial process. Configure these in the profile or at runtime:Profile Configuration
Runtime Configuration
Recommended Spawn Processes
- General Purpose
- Background Service
- System Process
- Error Reporting
notepad.exe
- ✅ Always available
- ✅ Commonly spawned
- ❌ GUI application (creates window)
Command Usage
Shellcode Injection
Inject shellcode into an existing process:- Open handle to target process (PID 1234)
- Verify architecture matches
- Allocate memory based on configured method
- Write shellcode to allocated memory
- Change protection to PAGE_EXECUTE_READ
- Create thread at shellcode entry point
Shellcode Spawn
Spawn a new process and inject shellcode:- Create configured spawn process in suspended state
- Allocate memory in new process
- Write shellcode
- Change protection to PAGE_EXECUTE_READ
- Create remote thread
- Resume main thread
DLL Injection
Inject a reflective DLL:- Uses reflective loader
- Supports DLL arguments
- Returns output from DLL
OPSEC Considerations
Architecture Mismatch
Demon validates architecture before injection:x86 Demon → x86 Process
x86 Demon → x86 Process
✅ SupportedBoth same architecture, full compatibility.
x64 Demon → x64 Process
x64 Demon → x64 Process
✅ SupportedBoth same architecture, full compatibility.
x64 Demon → x86 Process (WoW64)
x64 Demon → x86 Process (WoW64)
⚠️ Supported with limitationsRequires Heaven’s Gate technique for 64→32-bit transitions.
Not all injection methods work reliably.
x86 Demon → x64 Process
x86 Demon → x64 Process
❌ Not Supported32-bit process cannot inject into 64-bit process.
Error:
INJECT_ERROR_PROCESS_ARCH_MISMATCHProcess Permissions
Injection requires specific permissions: Minimum required:PROCESS_VM_OPERATION- Memory operationsPROCESS_VM_WRITE- Write shellcodePROCESS_CREATE_THREAD- Create execution thread
- Steal token with
SeDebugPrivilege - Impersonate SYSTEM or high-privileged user
- Retry injection
Detection Vectors
- Memory Scanning
- API Monitoring
- Behavioral Analysis
- Thread Start Addresses
Risk: EDR scans for suspicious memory patternsIndicators:
- Unbacked memory regions (not from files)
- RWX memory pages
- Known shellcode signatures
- Anomalous memory allocations
- Use RW during write, then change to RX
- Encrypt shellcode before writing
- Use existing executable memory regions
- Avoid large contiguous allocations
Best Practices
Choose Appropriate Technique
- Low security: Win32 (speed)
- Medium security: Syscall
- High security: Syscall + APC
Select Context-Appropriate Target
Match spawn process to environment:
- Corporate: Business applications
- Server: Service processes
- Developer: Development tools
Error Handling
Common Errors
INJECT_ERROR_INVALID_PARAM
INJECT_ERROR_INVALID_PARAM
Cause: Missing or invalid parametersCheck:
- PID specified and valid
- Shellcode path exists
- Architecture specified correctly
INJECT_ERROR_PROCESS_ARCH_MISMATCH
INJECT_ERROR_PROCESS_ARCH_MISMATCH
Cause: Architecture incompatibilitySolutions:
- Use matching architecture payload
- Target different process
- Use x64 Demon for flexibility
INJECT_ERROR_FAILED
INJECT_ERROR_FAILED
Cause: Generic injection failureCommon reasons:
- Insufficient permissions
- Protected process (PPL)
- Memory allocation failed
- EDR blocked operation
Advanced Techniques
Module Stomping
Overwrite existing module memory instead of allocating new regions. Advantages:- No suspicious unbacked memory
- Appears as part of legitimate module
- Thread starts in known module
Process Hollowing
Create process in suspended state, unmap original image, map payload. Advantages:- Process appears legitimate
- No remote memory allocation
- Complex to detect
Thread Hijacking
Suspend thread, modify context to point to shellcode, resume. Advantages:- No thread creation
- Uses existing thread
- Stealthy
Configuration Reference
Profile Configuration
Runtime Configuration
Next Steps
Sleep Obfuscation
Configure memory encryption during sleep
Features Overview
Explore all Demon capabilities
Command Reference
Complete command documentation
Generate Payloads
Create configured Demon agents
