format-string-exploitation

Exploit format-string vulnerabilities for information disclosure and arbitrary memory writes.

5|2|Updated May 16, 2026
One-click install
npx skills add https://github.com/DorianGallo/hack-skills-local --skill format-string-exploitation-doriangallo
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: format-string-exploitation
Source: https://github.com/DorianGallo/hack-skills-local/tree/main/skills/format-string-exploitation
Command: npx skills add https://github.com/DorianGallo/hack-skills-local --skill format-string-exploitation-doriangallo

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of turning a format-string vulnerability in printf-family calls into practical exploitation steps, including stack leaks, arbitrary reads, and controlled memory writes.

Core Features & Use Cases

  • Leak primitives: Identify input offset and extract canary, PIE/code pointers, libc addresses, and heap-related pointers using %p/%N$p and %N$s.
  • Write primitives: Perform arbitrary writes with %n/%hn/%hhn/%ln, including 32-bit direct layouts and 64-bit “addresses-after-format” handling.
  • Real exploit paths: Overwrite GOT entries (e.g., printf@GOT → system), use pwntools automation (fmtstr_payload/FmtStr), and cover blind/remote scenarios and FORTIFY_SOURCE bypass approaches.

Quick Start

Use the format-string-exploitation skill to determine the correct positional offset by leaking pointers with inputs like AAAA%p%p..., then craft a %n-based payload to overwrite a chosen GOT entry for code execution.

Frequently Asked Questions about format-string-exploitation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I exploit a format string vulnerability to leak stack canaries and libc addresses?

To exploit a format string vulnerability, you leak stack canaries and libc addresses by using positional format specifiers like %p or %N$p to read values directly from the stack, identifying the correct input offset first. This discloses PIE code pointers and heap addresses.

What is the best way to overwrite a GOT entry using a format string bug?

The best way to overwrite a GOT entry using a format string bug is crafting a payload with %n, %hn, or %hhn specifiers to write controlled values, redirecting functions like printf@GOT to system for code execution. This includes handling 64-bit address layouts.

Can I use pwntools to automate format string exploitation and payload generation?

Yes, you can use pwntools to automate format string exploitation through the fmtstr_payload and FmtStr classes, which streamline offset discovery and automate the construction of arbitrary write payloads for both 32-bit and 64-bit targets.

Does FORTIFY_SOURCE prevent format string exploitation and how do I bypass it?

FORTIFY_SOURCE restricts certain format string writes, but format string exploitation can still bypass it using specific write techniques. The skill covers FORTIFY_SOURCE-constrained write approaches to achieve memory modification despite these compiler protections.

How do I find the correct stack offset for a blind remote format string attack?

To find the correct stack offset for a blind remote format string attack, you send positional parameters like AAAA%p%p... and analyze the leaked pointers. This discovers the exact offset needed for arbitrary reads and subsequent writes.

Why does my 64-bit format string payload fail to write to target memory addresses?

64-bit format string payloads fail to write to target memory addresses often due to null bytes in addresses terminating the string early. You must use null-byte-safe payload layouts, placing addresses after the format string to ensure successful %n writes.