Injection-BOF
Injection-BOF provides multiple shellcode injection techniques into remote processes. From classic section-based techniques to advanced PoolParty techniques that abuse Windows Thread Pool internals for EDR evasion.
Compatible agents: Beacon, Gopher, Kharon | Platform: Windows
inject-cfg
Configures default parameters for injection operations. These values apply to other injection commands when not explicitly specified.
inject-cfgAllows setting defaults such as memory allocation type, page protections, and other options that affect injection behavior.
Use case: Run before an injection campaign to establish optimal parameters for the target environment. Useful when performing multiple injections with the same configuration.
inject-sec
Injects shellcode into a remote process using the memory section-based technique (NtCreateSection/NtMapViewOfSection). This technique creates a shared memory section between the agent process and the target process.
inject-sec <pid> <shellcode>| Argument | Required | Description |
|---|---|---|
pid | Yes | Target process ID |
shellcode | Yes | Shellcode to inject (file path or inline data) |
Examples:
# Inject shellcode into process PID 3456
inject-sec 3456 /tmp/beacon_x64.bin
# Inject into an explorer.exe process
inject-sec 1892 /tmp/payload.binUse cases:
- Migrate an agent to another process for persistence or evasion.
- Deploy an additional agent in a process with a different security context.
- Simpler and more direct technique when advanced EDR evasion is not required.
How it works:
- Creates a shared memory section with NtCreateSection.
- Maps the section into the local process with write permissions.
- Writes the shellcode into the locally mapped section.
- Maps the section into the remote process with execute permissions.
- Creates a remote thread that executes the shellcode.
inject-poolparty
Advanced injection that abuses Windows Thread Pool internal mechanisms. Offers 8 different techniques, each with varying levels of evasion and compatibility. These techniques are highly evasive against most EDR solutions.
inject-poolparty <pid> <technique> <shellcode>| Argument | Required | Description |
|---|---|---|
pid | Yes | Target process ID |
technique | Yes | Technique number (1-8) |
shellcode | Yes | Shellcode to inject |
Available techniques
| # | Name | Mechanism | Description |
|---|---|---|---|
| 1 | Worker Factory | TP_WORK | Inserts a work item into the target process’s thread pool queue. Most reliable technique. |
| 2 | Timer | TP_TIMER | Abuses thread pool timers to execute shellcode when the timer fires. |
| 3 | Wait | TP_WAIT | Registers a wait callback in the thread pool that executes the shellcode. |
| 4 | IO Completion | TP_IO | Uses IO completion ports to trigger shellcode execution. |
| 5 | ALPC | TP_ALPC | Abuses Advanced Local Procedure Call ports of the thread pool. |
| 6 | Job | TP_JOB | Uses Job objects to trigger execution. |
| 7 | Direct | TP_DIRECT | Direct insertion into the thread pool queue. Fast but more detectable. |
| 8 | Alt Timer | NtAssociateWaitCompletionPacket | Variant using NtAssociateWaitCompletionPacket for stealthier execution. |
Examples:
# Inject with Worker Factory technique (most reliable)
inject-poolparty 4520 1 /tmp/beacon.bin
# Inject with ALPC technique (stealthiest)
inject-poolparty 4520 5 /tmp/beacon.bin
# Inject with alternative Timer technique
inject-poolparty 3112 8 /tmp/payload.binTechnique selection guide:
| Priority | Technique | When to use |
|---|---|---|
| High | 1 (Worker Factory) | First choice, most stable and reliable |
| High | 5 (ALPC) | When maximum evasion is needed |
| Medium | 2 (Timer) | Solid alternative if 1 and 5 fail |
| Medium | 8 (Alt Timer) | Variant for environments with advanced EDR |
| Low | 3-4, 6-7 | Use if primary techniques are detected |
Use cases:
- Environments with advanced EDR where traditional injection techniques are detected.
- Agent migration to a long-lived process (explorer.exe, svchost.exe).
- Stealthy deployment of additional payloads.
Note: PoolParty techniques work best with processes that have an active thread pool. Processes like explorer.exe, svchost.exe, and Windows services are the best candidates.
inject-32to64
Injects 64-bit shellcode from a 32-bit process (WoW64 transition). Solves the common problem of when the agent is running in a 32-bit process but needs to interact with native 64-bit processes.
inject-32to64 <pid> <shellcode>| Argument | Required | Description |
|---|---|---|
pid | Yes | Target 64-bit process ID |
shellcode | Yes | 64-bit shellcode to inject |
Examples:
# Inject an x64 beacon from an x86 process
inject-32to64 2340 /tmp/beacon_x64.binUse cases:
- The initial agent ran in a 32-bit process (such as a legacy application or x86 Office macro).
- You need to migrate to a 64-bit process to access 64-bit APIs and memory.
- Operations that require a 64-bit context (LSASS dumping, 64-bit registry access).
GUI integration
Injection-BOF integrates with the JustC2 graphical interface process browser. Right-clicking a process in the Process Browser displays the option to inject directly, providing a visual interface for selecting the target process without needing to know the PID manually.
Recommended workflow
- Use
findobj module(Process-BOF) to find candidate processes. - Configure injection with
inject-cfgif needed. - For environments without EDR or with basic EDR: use
inject-sec. - For environments with advanced EDR: use
inject-poolpartywith technique 1 or 5. - If you’re in a 32-bit process and need to inject into 64-bit: use
inject-32to64. - Verify successful injection with
process conn(Process-BOF) to confirm the new agent’s connections.