ctf-pwn
A toolkit for identifying and exploiting memory corruption vulnerabilities in CTF capture-the-flag challenges.
Install
mkdir -p .claude/skills/ctf-pwn && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4145" && unzip -o skill.zip -d .claude/skills/ctf-pwn && rm skill.zipInstalls to .claude/skills/ctf-pwn
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Solve CTF binary exploitation challenges by discovering and exploiting memory corruption vulnerabilities to read flags. Use for buffer overflows, format strings, heap exploits, ROP challenges, or any pwn/exploitation task.Key capabilities
- →Identify memory corruption vulnerabilities
- →Analyze stack and heap layouts
- →Develop buffer overflow exploits
- →Map binary memory sections
- →Plan ROP chains and shellcode injection
How it works
The framework guides systematic vulnerability discovery and exploitation planning by analyzing data flow and memory safety.
Inputs & outputs
When to use ctf-pwn
- →Analyzing memory corruption vulnerabilities
- →Developing buffer overflow exploits
- →Leaking addresses or canaries
- →Redirecting program control flow
About this skill
CTF Binary Exploitation (Pwn)
Purpose
You are a CTF binary exploitation specialist. Your goal is to discover memory corruption vulnerabilities and exploit them to read flags through systematic vulnerability analysis and creative exploitation thinking.
This is a generic exploitation framework - adapt these concepts to any vulnerability type you encounter. Focus on understanding why memory corruption happens and how to manipulate it, not just recognizing specific bug classes.
Conceptual Framework
The Exploitation Mindset
Think in three layers:
-
Data Flow Layer: Where does attacker-controlled data go?
- Input sources: stdin, network, files, environment, arguments
- Data destinations: stack buffers, heap allocations, global variables
- Transformations: parsing, copying, formatting, decoding
-
Memory Safety Layer: What assumptions does the program make?
- Buffer boundaries: Fixed-size arrays, allocation sizes
- Type safety: Integer types, pointer validity, structure layouts
- Control flow integrity: Return addresses, function pointers, vtables
-
Exploitation Layer: How can we violate trust boundaries?
- Memory writes: Overwrite critical data (return addresses, function pointers, flags)
- Memory reads: Leak information (addresses, canaries, pointer values)
- Control flow hijacking: Redirect execution to attacker-controlled locations
- Logic manipulation: Change program state to skip checks or trigger unintended paths
Core Question Sequence
For every CTF pwn challenge, ask these questions in order:
-
What data do I control?
- Function parameters, user input, file contents, environment variables
- How much data? What format? Any restrictions (printable chars, null bytes)?
-
Where does my data go in memory?
- Stack buffers? Heap allocations? Global variables?
- What's the size of the destination? Is it checked?
-
What interesting data is nearby in memory?
- Return addresses (stack)
- Function pointers (heap, GOT/PLT, vtables)
- Security flags or permission variables
- Other buffers (to leak or corrupt)
-
What happens if I send more data than expected?
- Buffer overflow: Overwrite adjacent memory
- Identify what gets overwritten (use pattern generation)
- Determine offset to critical data
-
What can I overwrite to change program behavior?
- Return address → redirect execution on function return
- Function pointer → redirect execution on indirect call
- GOT/PLT entry → redirect library function calls
- Variable value → bypass checks, unlock features
-
Where can I redirect execution?
- Existing code: system(), exec(), one_gadget
- Leaked addresses: libc functions
- Injected code: shellcode (if DEP/NX disabled)
- ROP chains: reuse existing code fragments
-
How do I read the flag?
- Direct: Call system("/bin/cat flag.txt") or open()/read()/write()
- Shell: Call system("/bin/sh") and interact
- Leak: Read flag into buffer, leak buffer contents
Core Methodologies
Vulnerability Discovery
Unsafe API Pattern Recognition:
Identify dangerous functions that don't enforce bounds:
- Unbounded copies: strcpy, strcat, sprintf, gets
- Underspecified bounds: read(), recv(), scanf("%s"), strncpy (no null termination)
- Format string bugs: printf(user_input), fprintf(fp, user_input)
- Integer overflows: malloc(user_size), buffer[user_index], length calculations
Investigation strategy:
get-symbolsincludeExternal=true → Find unsafe API importsfind-cross-referencesto unsafe functions → Locate usage pointsget-decompilationwith includeContext=true → Analyze calling context- Trace data flow from input to unsafe operation
Stack Layout Analysis:
Understand memory organization:
High addresses
├── Function arguments
├── Return address ← Critical target for overflow
├── Saved frame pointer
├── Local variables ← Vulnerable buffers here
├── Compiler canaries ← Stack protection (if enabled)
└── Padding/alignment
Low addresses
Investigation strategy:
get-decompilationof vulnerable function → See local variable layout- Estimate offsets: buffer → saved registers → return address
set-bookmarktype="Analysis" category="Vulnerability" at overflow siteset-decompilation-commentdocumenting buffer size and adjacent targets
Heap Exploitation Patterns:
Heap vulnerabilities differ from stack:
- Use-after-free: Access freed memory (dangling pointers)
- Double-free: Free same memory twice (corrupt allocator metadata)
- Heap overflow: Overflow into adjacent heap chunk (overwrite metadata/data)
- Type confusion: Use object as wrong type after reallocation
Investigation strategy:
search-decompilationpattern="(malloc|free|realloc)" → Find heap operations- Trace pointer lifecycle: allocation → use → free
- Look for dangling pointer usage after free
- Identify adjacent allocations (overflow targets)
Memory Layout Understanding
Address Space Discovery:
Map the binary's memory:
get-memory-blocks→ See sections (.text, .data, .bss, heap, stack)- Note executable sections (shellcode candidates if NX disabled)
- Note writable sections (data corruption targets)
- Identify ASLR status (addresses randomized each run?)
Offsets and Distances:
Calculate critical distances:
- Buffer to return address: For stack overflow payload sizing
- GOT to PLT: For GOT overwrite attacks
- Heap chunk to chunk: For heap overflow targeting
- libc base to useful functions: For address calculation after leak
Investigation strategy:
get-dataorread-memoryat known addresses → Sample memory layoutfind-cross-referencesdirection="both" → Map relationships- Calculate offsets manually from decompilation
set-commentat key offsets documenting distances
Exploitation Planning
Constraint Analysis:
Identify exploitation constraints:
- Bad bytes: Null bytes (\x00) terminate C strings → avoid in address/payload
- Input size limits: Truncation, buffering, network MTU
- Character restrictions: Printable-only, alphanumeric, no special chars
- Protection mechanisms: Detect via
search-decompilationpattern="(canary|__stack_chk)"
Bypass Strategies:
Common protections and bypass techniques:
- Stack canaries: Leak canary value, brute-force (fork servers), overwrite without corrupting
- ASLR: Leak addresses (format strings, uninitialized data), partial overwrite (last byte randomization)
- NX/DEP: ROP (Return-Oriented Programming), ret2libc, JOP (Jump-Oriented Programming)
- PIE: Leak code addresses, relative offsets within binary, partial overwrites
Exploitation Primitives:
Build these fundamental capabilities:
- Arbitrary write: Write controlled data to chosen address (format string, heap overflow)
- Arbitrary read: Read from chosen address (format string, uninitialized data, overflow into pointer)
- Control flow hijack: Redirect execution (overwrite return address, function pointer, GOT entry)
- Information leak: Obtain addresses, canaries, pointers (uninitialized variables, format strings)
Chain multiple primitives when needed:
- Leak → Calculate addresses → Overwrite function pointer → Exploit
- Partial overwrite → Leak full address → Calculate libc base → ret2libc
- Heap overflow → Overwrite function pointer → Arbitrary write → GOT overwrite → Shell
Flexible Workflow
This is a thinking framework, not a rigid checklist. Adapt to the challenge:
Phase 1: Binary Reconnaissance (5-10 tool calls)
Understand the challenge:
get-current-programorlist-project-files→ Identify target binaryget-memory-blocks→ Map sections, identify protectionsget-functionsfilterDefaultNames=false → Count functions (stripped vs. symbolic)get-stringsregexPattern="flag" → Find flag-related stringsget-symbolsincludeExternal=true → List imported functions
Identify entry points and input vectors:
get-decompilationfunctionNameOrAddress="main" limit=50 → See program flow- Look for input functions: read(), recv(), gets(), scanf(), fgets()
find-cross-referencesto input functions → Map input flowset-bookmarktype="TODO" category="Input Vector" at each input point
Flag suspicious patterns:
- Unsafe functions (strcpy, sprintf, gets)
- Large stack buffers with small read operations
- Format string vulnerabilities (user-controlled format)
- Unbounded loops or recursion
Phase 2: Vulnerability Analysis (10-15 tool calls)
Trace data flow from input to vulnerability:
get-decompilationof input-handling function with includeReferenceContext=true- Identify buffer sizes: char buf[64], malloc(size), etc.
- Identify write operations: strcpy(dest, src), read(fd, buf, 1024)
- Calculate vulnerability: Write size > buffer size?
Analyze vulnerable function context:
rename-variables→ Clarify data flow (user_input, buffer, size, etc.)change-variable-datatypes→ Fix types for clarityset-decompilation-comment→ Document vulnerability location and type
Map memory layout around vulnerability:
- Identify local variables and their stack positions
- Calculate offset from buffer start to return address
read-memoryat nearby addresses → Sample stack layout (if debugging available)set-bookmarktype="Warning" category="Overflow" → Mark vulnerability
Cross-reference analysis:
find-cross-referencesto vulnerable function → How is it called?- Check for exploitation helpers: system(), exec(), "/bin/sh" string
get-stringsregexPattern="/bin/(sh|bash)" → Find shell stringssearch-decompilationpattern="system|exec" → Find execution functions
Phase 3: Exploitation Strategy (5-10 tool calls)
**Determine exploitation approach:
Content truncated.
When not to use it
- →Non-binary exploitation tasks
Prerequisites
Limitations
- →Requires manual verification of assumptions
- →Exploit execution occurs outside the analysis tool
How it compares
It focuses on a conceptual exploitation mindset and structured analysis rather than automated exploit generation.
Compared to similar skills
ctf-pwn side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| ctf-pwn (this skill) | 7 | 5mo | Review | Advanced |
| reverse-engineering-tools | 73 | 4mo | No flags | Advanced |
| game-hacking-techniques | 42 | 2mo | No flags | Advanced |
| solidity-security | 15 | 2mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by cyberkaida
View all by cyberkaida →You might also like
reverse-engineering-tools
gmh5225
Guide for reverse engineering tools and techniques used in game security research. Use this skill when working with debuggers, disassemblers, memory analysis tools, binary analysis, or decompilers for game security research.
game-hacking-techniques
gmh5225
Guide for game hacking techniques and cheat development. Use this skill when researching memory manipulation, code injection, ESP/aimbot development, overlay rendering, or game exploitation methodologies.
solidity-security
wshobson
Master smart contract security best practices to prevent common vulnerabilities and implement secure Solidity patterns. Use when writing smart contracts, auditing existing contracts, or implementing security measures for blockchain applications.
1password
openclaw
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
senior-security
davila7
Comprehensive security engineering skill for application security, penetration testing, security architecture, and compliance auditing. Includes security assessment tools, threat modeling, crypto implementation, and security automation. Use when designing security architecture, conducting penetration tests, implementing cryptography, or performing security audits.
ghidra
mitsuhiko
Reverse engineer binaries using Ghidra's headless analyzer. Decompile executables, extract functions, strings, symbols, and analyze call graphs without GUI.