format-string-exploitation
Agent skill fromyaklang/hack-skills
Format string exploitation playbook. Use when printf-family functions receive user-controlled format strings, enabling arbitrary stack reads (%p/%s), arbitrary memory writes (%n/%hn/%hhn), GOT/hook overwrites, and canary/libc/PIE leaks.
How to install format-string-exploitation
install format-string-exploitation
# install the hack-skills pack with the skills CLI
npx skills add yaklang/hack-skills# or add only this skill to Claude Code: copy the folder
skills/format-string-exploitation/
# into
~/.claude/skills/format-string-exploitation/ (all projects)
.claude/skills/format-string-exploitation/ (one project)
1# SKILL: Format String Exploitation — Expert Attack Playbook23> **AI LOAD INSTRUCTION**: Expert format string techniques. Covers stack reading, arbitrary write via %n, GOT overwrite, __malloc_hook overwrite, pointer chain exploitation, blind format string, FORTIFY_SOURCE bypass, 64-bit null byte handling, and pwntools automation. Distilled from ctf-wiki fmtstr, CTF patterns, and real-world scenarios. Base models often miscalculate positional parameter offsets or forget 64-bit address placement after format string.45## 0. RELATED ROUTING67- [stack-overflow-and-rop](../stack-overflow-and-rop/SKILL.md) — combine format string leak with stack overflow for full exploit8- [binary-protection-bypass](../binary-protection-bypass/SKILL.md) — format string is the primary canary/PIE/ASLR leak method9- [arbitrary-write-to-rce](../arbitrary-write-to-rce/SKILL.md) — convert format string write primitive to code execution targets10- [heap-exploitation](../heap-exploitation/SKILL.md) — heap address leak via format string for heap exploitation1112---1314## 1. VULNERABILITY IDENTIFICATION1516### Vulnerable Pattern1718```c19printf(user_input); // VULNERABLE: user controls format string20fprintf(fp, user_input); // VULNERABLE21sprintf(buf, user_input); // VULNERABLE22snprintf(buf, sz, user_input); // VULNERABLE2324printf("%s", user_input); // SAFE: format string is fixed25```2627### Quick Test2829```30Input: AAAA%p%p%p%p%p%p%p%p31If output shows stack values (hex addresses): format string confirmed32…
Excerpt shown under the repository's MIT license.
