Phase 04.02 · From CVE to Code

Finding & Running Exploits

Vulnerability analysis hands you a name — something like Apache 2.4.49 — CVE-2021-41773. A name is not access. To turn that finding into a foothold you need the actual exploit code, and you need to trust it before you run it. This lesson is about the three steps that close the gap: finding the exploit, vetting it, and detonating it safely against the right target.

00

From a validated finding to working code

You exit vulnerability analysis with a confirmed weakness pinned to a version and a CVE — for example, Apache 2.4.49 — CVE-2021-41773, a path-traversal flaw that can lead to remote code execution. That identifier is the handle everything else hangs on: it is how databases index the bug, how exploit authors title their code, and how you will search for the one thing you still lack — the working exploit that converts the vulnerability into a shell.

The temptation is to grab the first script that mentions your CVE and fire it at the target. Resist it. A public exploit is untrusted code written by a stranger, aimed at a system you were paid to protect. The professional workflow has three distinct steps, and skipping any one of them is how engagements go wrong: find a candidate exploit, vet it so you understand exactly what it does, and only then run it — in a lab first, against the client second.

The CVE is your search key. Carry the exact version and CVE forward from vulnerability analysis. The more precise your identifier, the faster you find an exploit that actually matches the target — and the less likely you are to run code built for a different version that simply crashes the service.
Lesson
04.02
Phase
Exploitation
Headline source
Exploit-DB
01

Where public exploits live

Public exploit code is scattered across the internet, but a handful of sources do the heavy lifting. The one you reach for first is the Exploit Database at exploit-db.com — OffSec's large, curated, CVE-tagged archive of public exploits and proof-of-concept code. It is searchable by product, version, or CVE, every entry links back to the original advisory, and its sheer breadth makes it the default starting point for almost any known-vulnerability lookup.

SourceWhat it isHow to search
Exploit-DBOffSec's large, curated, CVE-tagged archive of public exploits and proof-of-concept code — the headline source. Browse it at exploit-db.com.Search the site by product, version, or CVE. Offline, use its bundled Kali CLI searchsploit — e.g. searchsploit apache 2.4.49 — to query a local copy with no internet.
Metasploit modulesExploits packaged as ready-to-run modules inside the Metasploit Framework, often more reliable and configurable than a raw script.From the console, search cve:2021-41773 or search apache to find a matching module.
GitHub PoC reposIndependent researchers publish proof-of-concept code on GitHub, frequently within days of a CVE going public — sometimes the only place a fresh exploit exists.Search the CVE ID on GitHub; favor repos with stars, a clear README, and readable code over anonymous one-file drops.
Packet StormA long-running security archive of exploits, advisories, and tools that often mirrors or supplements Exploit-DB.Browse or search by product or CVE when a finding does not surface elsewhere.

Different sources suit different moments. Exploit-DB and searchsploit are where you start for an established CVE; Metasploit's module search is where you go when you want a polished, repeatable exploit; GitHub is where the newest proofs-of-concept appear before anything else has caught up. Whatever the source, treat every download as unverified until you have read it — the next sections cover running both kinds of exploit you will find.

02

Running a Metasploit module

When a matching Metasploit module exists, it is usually the cleanest path to access — the author has already handled the fiddly parts, and the framework gives you a consistent loop for every exploit. That loop is worth memorizing, because you will run it hundreds of times:

How do you know it worked? Two signals. The clearest is a session opening — Metasploit reports a new Meterpreter or command shell, and you now have interactive access to the target. The other is expected command output: the module runs and returns the file contents, the version banner, or the response that only a successful exploit could produce. If neither appears, the target may be patched, the wrong version, or behind a control you have not accounted for — go back to check and your option values before you assume the exploit is broken.

Use check first whenever you can. A module that supports check lets you confirm vulnerability with minimal noise and zero risk of crashing the service. Running it before exploit turns a blind gamble into a deliberate, evidence-backed action — exactly what a clean engagement looks like.
03

Running a standalone exploit

Plenty of vulnerabilities have no Metasploit module. Many Exploit-DB entries are standalone scripts — a Python, C, or Ruby file you download, read, adjust, and run yourself. The shape is always similar: open the file, find the variables at the top (the target IP and port, sometimes a memory offset or a payload string), set them to your environment, compile if it is C, and execute it against the target.

The friction is real and it is the point. A standalone exploit may need a specific interpreter version, may be written for a slightly different target build, or may expect you to understand what an offset is doing before it will work. Reading the code is not optional housekeeping — it is how you make the exploit fit your target at all.

Read it before you run it. Always. Public proof-of-concept code can be wrong (it crashes the service instead of exploiting it), intentionally sabotaged (some "exploits" are traps that attack the person who runs them — wiping files, phoning home, or opening a backdoor on your machine), or simply destructive by design. Open every script, understand exactly what each line does, and detonate it in a lab first. Never run unread code blind against a client's production system.

Treat the lab as a mandatory waypoint, not a nicety. You read the exploit, you run it against a disposable copy of the target, you confirm it behaves the way you expect — and only then do you point a known-good, fully understood exploit at the real engagement. The cost of that discipline is a few minutes; the cost of skipping it is a destroyed client system and a finished career.

04

Reliability, safety, and scope

Not all exploits are equally safe to run, and the framework tells you so. Metasploit modules carry a reliability ranking — from excellent down to low — that estimates how likely the exploit is to work without harming the target. A high-ranked module typically lands cleanly; a low-ranked one may corrupt memory, hang a process, or knock the service over entirely. When two modules hit the same vulnerability, prefer the more reliable one.

That matters because some exploits can crash the target service, and a crash is a denial of service. Denial of service is almost always out of scope unless the engagement explicitly authorizes it — taking a client's production system offline is a real outage with real consequences, not a successful test. The same discipline applies to standalone scripts, which carry no ranking at all and demand that you judge the risk yourself from the code.

Finding and running exploits is where reconnaissance and analysis finally pay off — but it is also where a careless action does the most damage. With the workflow in hand — find, vet, run, stay in scope — the next lesson puts it to work against the most common target of all: unpatched services running known-vulnerable software in the wild.