This repository contains a simple demonstration of process hollowing, an advanced technique where a legitimate process is started in suspended mode and its contents are replaced with custom code (a "shellcode" payload). It is intended for educational use only and should never be deployed on systems without explicit permission.
- Create a target process suspended (e.g.
svchost.exe). - Query process information via
NtQueryInformationProcessto retrieve the PEB. - Allocate memory inside the target with
VirtualAllocExusingPAGE_EXECUTE_READWRITE. - Write your payload (PE image) into the remote process, section by section.
- Update the PEB.ImageBaseAddress to point at the new image.
- Start a remote thread at the payload's entry point using
CreateRemoteThread. - Resume execution so the hollowed process runs your code in its address space.
This project contains two minimal injectors (x64 and x86) plus a helper to convert arbitrary executables into C arrays.
You don’t need a C++ compiler to read or modify the code, but the steps below assume a Windows development environment with Visual Studio.
git clone https://github.com/mateethedesigner/process-hollowing-main.git
cd process-hollowing-mainUse the provided converter to transform any PE file (DLL/EXE) into a C header:
cd shellcode-converter/shellcode-converter
# build the converter or use prebuilt binary
# run it and choose an executable when promptedThe tool will save shellcode.h alongside the selected file. This header defines:
unsigned char shellcode[] = { ... };
const size_t shellcodeSize = ...;For the x86 project the array is named rawData/rawDataSize.
You can also run the converter non-interactively:
shellcode-converter.exe --input C:\path\payload.exeSupported options:
-i, --input <path>input binary path-o, --output <path>output header path-s, --symbol <name>data symbol name (default:shellcode)--size-symbol <name>size symbol name (default:shellcodeSize)--bytes-per-line <n>bytes per line in generated array (default:16)-h, --helpprint help
Example with custom symbol names:
shellcode-converter.exe --input C:\payload.exe --output C:\payload_header.h --symbol rawData --size-symbol rawDataSize- Copy the generated header into:
x64/process_hollowing/src/hdr(for 64‑bit payloads)x86/process_hollowing/src/hdr(for 32‑bit payloads)
hdr/shellcode.hin each project already declares the array asextern, so you can swap payloads easily.
Open the appropriate solution and select the correct platform & configuration:
x64/process_hollowing/process_hollowing.sln→ Release | x64x86/process_hollowing/process_hollowing.sln→ Release | Win32
You can also compile from the command line using msbuild or cl.exe if desired.
Execute the compiled injector; it will log its progress and payload size to the console. The target process (svchost.exe by default) will be hollowed with your code.
/README.md ← this file
/shellcode-converter/ ← converter app and source
/x64/ ← 64‑bit injector
/x86/ ← 32‑bit injector
Each hdr directory contains shellcode.h which declares the payload array.
- Matching subsystems (console vs GUI) between shellcode and injector improves reliability.
- Both injectors log helpful diagnostics (errors, shellcode size, success messages).
- The code is intentionally minimal; extend it at your own risk!
- Use only in controlled environments and for learning.
- What is process hollowing by bmdyy
- Malware Theory – Process Injection by MalwareAnalysisForHedgehogs
Disclaimer: This repository is provided "as is" for educational purposes. The author assumes no responsibility for misuse.
🌟 Star the repo if you found it useful!