<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
---
name: performing-format-string-exploitation
description: >-
  Exploit format string vulnerabilities to achieve arbitrary read/write primitives, leak stack data, and hijack control flow in C/C++ applications.
domain: cybersecurity
subdomain: binary-exploitation
tags:
  - format-string
  - printf
  - arbitrary-write
  - memory-corruption
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1203"]
  frameworks: ["MITRE ATT&CK", "CWE"]
  tools: ["gdb", "pwntools", "ghidra"]
---

# Performing Format String Exploitation

## Overview

Exploit format string vulnerabilities to achieve arbitrary read/write primitives, leak stack data, and hijack control flow in C/C++ applications.

## Prerequisites

| Tool / Requirement | Details |
|---|---|
| `gdb` | Security tooling |
| `pwntools` | Security tooling |
| `ghidra` | Security tooling |
| GDB with PEDA/GEF, pwntools, target binary with format string vuln | Environment requirement |

## Quick Reference

```bash
# Quick start commands
node scripts/agent.js --help
checksec --file=./target && strings ./target | grep -i printf
```

## Workflow

### Step 1: Identify Format String Sink

```bash
checksec --file=./target && strings ./target | grep -i printf
```

### Step 2: Leak Stack Values

```bash
python3 -c "print('%p.' * 20)" | ./target
```

### Step 3: Build Write Primitive

```bash
node scripts/agent.js exploit --binary ./target --offset 7
```

## Detection

```yaml
title: Format String Exploitation Detection
id: eed78498-bf8e-401d-98e6-e86ca92991ad
status: experimental
description: Detects suspicious activity related to performing format string exploitation techniques in binary exploitation context
logsource:
  category: process_creation
  product: windows
detection:
  selection:
    CommandLine: "*performing*format*"
  condition: selection
level: critical
tags:
  - attack.t1203
  - attack.execution
falsepositives:
  - Vulnerability scanner testing known exploit signatures
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Format String Exploitation Detection | windows/process_creation | Sigma rule (critical) |
| ATT&CK Coverage | MITRE ATT&CK | T1203 |

## Verification

- **Verify vulnerability**: `node scripts/agent.js analyze --binary ./target`
- **Confirm exploitation**: `node scripts/agent.js exploit --binary ./target --offset 7`

## References

- MITRE ATT&CK: T1203
- Frameworks: MITRE ATT&CK, CWE
- Tools: gdb, pwntools, ghidra
