Shellcode Development
Overview
Shellcode is position-independent machine code injected into a process to perform arbitrary actions — typically spawning a shell, connecting back to an attacker, or downloading a second-stage payload. Writing shellcode requires understanding the target OS syscall interface, CPU instruction encoding, and constraints like null-byte avoidance and size limits.
Topics in This Section
- Linux Shellcode — x86-64 Linux syscalls, NASM assembly, msfvenom, pwntools shellcraft
- Windows Shellcode — Windows API resolution, PEB walking, msfvenom Windows payloads
General Approach
- Identify the target architecture and OS (Linux x86-64, Windows x64)
- Write or generate the shellcode (hand-crafted assembly or msfvenom)
- Avoid bad characters that the vulnerability filters (null bytes, newlines)
- Test the shellcode standalone before integrating into an exploit
- Encode or encrypt if needed to bypass input filters or detection