Hacktricks-skills blobrunner
How to use Blobrunner to load and execute shellcode/blobs in memory for reverse engineering and malware analysis. Use this skill whenever the user needs to execute raw shellcode, analyze PE files, run binary blobs in memory, or debug shellcode execution. Also use when the user mentions shellcode execution, memory-based code execution, or needs to run compiled binaries without traditional loading.
git clone https://github.com/abelrguezr/hacktricks-skills
skills/reversing/reversing-tools-basic-methods/blobrunner/SKILL.MDBlobrunner
Blobrunner is a C program that loads binary files (shellcode, PE files, or raw blobs) into memory and executes them. It's useful for reverse engineering, malware analysis, and shellcode testing.
What Blobrunner Does
- Reads a binary file from disk
- Allocates executable memory using
VirtualAlloc - Copies the file contents into that memory
- Executes the code at a specified offset
This bypasses traditional file execution, making it valuable for:
- Testing shellcode without creating executable files
- Analyzing malware behavior in a controlled environment
- Running PE files in memory for debugging
- Reverse engineering exercises
Compilation
Prerequisites
- Visual Studio Code with C/C++ extension
- MinGW-w64 or Visual Studio compiler (Windows)
Steps
- Create a new C/C++ project in VS Code
- Copy the source code from
references/blobrunner.c - Build the project
Note: The only modification from the original code is line 10 (Windows header inclusion).
Usage
blobrunner.exe <inputfile> [options]
Required Arguments
: Path to the binary file to load and execute<inputfile>
Optional Arguments
| Flag | Description |
|---|---|
| The offset within the file to jump to (hex or decimal) |
| Don't pause before executing (dangerous - use with caution) |
| Force an exception by removing EXECUTE permission from allocated memory |
| Enable verbose logging |
| Print version and exit |
Examples
Basic execution:
blobrunner.exe shellcode.bin
Execute at specific offset:
blobrunner.exe malware.exe --offset 0x1000
Run without pause (for automation):
blobrunner.exe payload.bin --nopause
Trigger JIT exception for debugging:
blobrunner.exe shellcode.bin --jit
Verbose debugging:
blobrunner.exe sample.bin --debug --offset 0x401000
How It Works
Memory Allocation
Blobrunner uses
VirtualAlloc with these flags:
=0x3000MEM_COMMIT | MEM_RESERVE
=0x40PAGE_EXECUTE_READWRITE
This creates executable memory where the binary is loaded.
Execution Methods
32-bit:
- Uses inline assembly
to jump directly to the codejmp shell_entry
64-bit:
- Creates a suspended thread with
CreateThread - Allows you to set breakpoints before resuming
- Resumes with
ResumeThread
JIT Mode
When
--jit is used:
- Memory is allocated as executable
- First byte's execute permission is removed with
VirtualProtect - This triggers an exception when execution reaches that point
- Useful for debugging and analysis
Safety Warnings
⚠️ Use with extreme caution:
- Only run trusted binaries - Malicious code will execute with your privileges
- Use in a VM or sandbox - Never run unknown binaries on your main system
- Understand the code - Review the source before using
is dangerous - Execution happens immediately without warning--nopause
Common Use Cases
1. Shellcode Testing
# Test shellcode without creating an executable file blobrunner.exe shellcode.bin --debug
2. PE File Analysis
# Load a PE file and jump to its entry point blobrunner.exe suspicious.exe --offset 0x1000 --debug
3. Malware Analysis
# Run malware in memory with JIT exception for debugging blobrunner.exe malware.bin --jit --debug
4. Offset Discovery
# Test different offsets to find the correct entry point blobrunner.exe blob.bin --offset 0x0 blobrunner.exe blob.bin --offset 0x100 blobrunner.exe blob.bin --offset 0x200
Troubleshooting
"Unable to open file"
- Check the file path is correct
- Ensure the file exists and is readable
- Try using absolute paths
"Error Creating thread" (64-bit)
- Run as administrator if needed
- Check if the binary is valid
- Verify the offset is within file bounds
Nothing happens after execution
- The code may have exited silently
- Use
for more information--debug - Check if the code requires specific conditions
Source Code Reference
The complete source code is available in
references/blobrunner.c. Key sections:
: Reads file and allocates memoryprocess_file()
: Handles execution (different for 32/64-bit)execute()
: Parses arguments and orchestrates executionmain()
Related Tools
- x64dbg/x32dbg: For detailed debugging
- Process Hacker: For monitoring memory allocations
- Cuckoo Sandbox: For automated malware analysis
- Ghidra: For static analysis before execution
Next Steps
- Compile the tool following the steps above
- Start with simple shellcode to test basic functionality
- Use a VM for any unknown binaries
- Enable debug mode when learning
- Review the source code to understand the mechanics
Remember: This tool executes arbitrary code in memory. Always use it responsibly and in appropriate environments.