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

  1. Identify the target architecture and OS (Linux x86-64, Windows x64)
  2. Write or generate the shellcode (hand-crafted assembly or msfvenom)
  3. Avoid bad characters that the vulnerability filters (null bytes, newlines)
  4. Test the shellcode standalone before integrating into an exploit
  5. Encode or encrypt if needed to bypass input filters or detection