skills/binary-exploitation/arbitrary-write-2-exec/arbitrary-write-2-exec/SKILL.md
Binary exploitation skill for arbitrary write to code execution attacks. Use this skill whenever the user mentions arbitrary write vulnerabilities, write primitives, GOT overwrites, function pointer overwrites, or needs to convert a write primitive into code execution. Also trigger for CTF challenges involving memory corruption, heap exploits, or when the user asks about turning write access into shellcode execution.
npx skillsauth add abelrguezr/hacktricks-skills arbitrary-write-2-execInstall 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 helps you convert arbitrary write primitives into code execution in binary exploitation challenges. An arbitrary write vulnerability lets you write any value to any memory address - this skill shows you how to weaponize that into RCE.
An arbitrary write primitive is dangerous because you can overwrite:
When you can write to the Global Offset Table, overwrite a function's entry to point to your shellcode or system().
Steps:
puts, printf)system() or your shellcodeExample:
# Overwrite puts@GOT with system@plt
write(puts_got_addr, system_plt_addr)
puts(";id;#") # Now calls system(";id;#")
If the binary has global function pointers, overwrite them directly.
Steps:
call [addr] instructions)Classic stack smashing - if you can write to the stack, overwrite the return address.
Steps:
Look for these vulnerability patterns:
| Vulnerability | Write Primitive |
|--------------|------------------|
| Format string | %n writes to stack |
| Heap overflow | Can corrupt adjacent data |
| Use-after-free | Can control freed chunk metadata |
| Integer overflow | Can cause out-of-bounds writes |
| Off-by-one | Can corrupt next structure |
You need a place to put your shellcode:
Making memory executable:
// Use mprotect via ROP
mprotect(addr & ~0xfff, 0x2000, PROT_READ | PROT_WRITE | PROT_EXEC)
When you can't execute shellcode directly, use Return-Oriented Programming:
ret)system()Common gadgets:
pop rdi; ret - Set first argumentpop rsi; ret - Set second argumentpop rax; ret - Set syscall numbermov rax, 0x3b; ret - execve syscall# Check protections
checksec --file vulnerable_binary
# Find GOT entries
objdump -R vulnerable_binary | grep puts
# Find function pointers
radare2 -c "afl" vulnerable_binary
Use the scripts in this skill to generate payloads:
scripts/got_overwrite.py - GOT overwrite payloadsscripts/rop_chain.py - ROP chain generationscripts/find_gadgets.py - Gadget discovery# Set breakpoints on GOT entries
break *puts@GOT
# Watch for writes to specific addresses
watch *(long*)0x404000
# Trace execution
traceexec ./vulnerable
Use this skill when:
After mastering arbitrary write to exec:
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.