Exploit Development Concepts
[!WARNING]
DISCLAIMER: EDUCATIONAL & DEFENSIVE PURPOSES ONLY
This skill covers memory corruption theory to teach defensive programming and compiler-level mitigations. It does not generate actionable exploit scripts.
1. Skill Context
Focus: Memory corruption theory, x86/x64 architecture, and modern binary mitigations.
Triggers: buffer overflow mechanics, rop chain theory, bypass aslr, format string vulnerability
2. Low-Level Memory Mechanics
The agent must possess deep knowledge of assembly, CPU registers, and OS memory management.
Stack-Based Buffer Overflow
- Mechanics: Writing more data to a stack-allocated buffer than it can hold, overwriting adjacent memory.
- Execution: The attacker overwrites the Instruction Pointer (
EIP/RIP) or the saved Return Address on the stack to point to their injected shellcode.
- Mitigation: Stack Canaries (Cookies) which place a random value before the return address; the program crashes if the canary is modified.
Return Oriented Programming (ROP)
- Why it exists: Introduced to bypass Data Execution Prevention (DEP / NX bit), which marks the stack and heap as non-executable.
- Mechanics: Instead of executing injected shellcode, the attacker hijacks the return address to execute existing snippets of executable code ending in a
ret instruction ("gadgets") already present in the binary or loaded libraries (like libc).
- Goal: Chain gadgets together to call functions like
system("/bin/sh") or VirtualProtect() to make the stack executable.
ASLR (Address Space Layout Randomization)
- Mechanics: Randomizes the base addresses of the executable, heap, stack, and libraries upon every execution.
- Bypass Theory: Attackers use memory leaks (e.g., Format String vulnerabilities reading off the stack) to find a single pointer, calculate the randomization offset, and dynamically adjust their ROP chain addresses.
3. Output Format
- Diagram the memory layout (Stack/Heap structures) using ASCII art or Markdown tables.
- Explain the assembly instructions involved (
call, ret, push, pop).
- Detail compiler-level mitigations (
-fstack-protector, PIE, RELRO).
1---2name: exploit-development-concepts3description: Exploit Development Concepts4---5# Exploit Development Concepts67> [!WARNING]8> **DISCLAIMER: EDUCATIONAL & DEFENSIVE PURPOSES ONLY**9> This skill covers memory corruption theory to teach defensive programming and compiler-level mitigations. It does not generate actionable exploit scripts.1011## 1. Skill Context12**Focus**: Memory corruption theory, x86/x64 architecture, and modern binary mitigations.13**Triggers**: buffer overflow mechanics, rop chain theory, bypass aslr, format string vulnerability1415## 2. Low-Level Memory Mechanics16The agent must possess deep knowledge of assembly, CPU registers, and OS memory management.1718### Stack-Based Buffer Overflow19- **Mechanics**: Writing more data to a stack-allocated buffer than it can hold, overwriting adjacent memory.20- **Execution**: The attacker overwrites the Instruction Pointer (`EIP`/`RIP`) or the saved Return Address on the stack to point to their injected shellcode.21- **Mitigation**: Stack Canaries (Cookies) which place a random value before the return address; the program crashes if the canary is modified.2223### Return Oriented Programming (ROP)24- **Why it exists**: Introduced to bypass Data Execution Prevention (DEP / NX bit), which marks the stack and heap as non-executable.25- **Mechanics**: Instead of executing injected shellcode, the attacker hijacks the return address to execute existing snippets of executable code ending in a `ret` instruction ("gadgets") already present in the binary or loaded libraries (like `libc`).26- **Goal**: Chain gadgets together to call functions like `system("/bin/sh")` or `VirtualProtect()` to make the stack executable.2728### ASLR (Address Space Layout Randomization)29- **Mechanics**: Randomizes the base addresses of the executable, heap, stack, and libraries upon every execution.30- **Bypass Theory**: Attackers use memory leaks (e.g., Format String vulnerabilities reading off the stack) to find a single pointer, calculate the randomization offset, and dynamically adjust their ROP chain addresses.3132## 3. Output Format33- Diagram the memory layout (Stack/Heap structures) using ASCII art or Markdown tables.34- Explain the assembly instructions involved (`call`, `ret`, `push`, `pop`).35- Detail compiler-level mitigations (`-fstack-protector`, `PIE`, `RELRO`).