Home
Cybersecurity & AI Security / Part 26 — Exploitation and Metasploit

Exploitation and Metasploit

CAP, ACID vs BASE, latency numbers, back-of-envelope estimation, single points of failure — the vocabulary every system designer thinks in.


Core Philosophy: An exploit is the bridge between “this system has a weakness” and “I now have access.” Page 2.10 established that vulnerabilities are often publicly documented; this page is about what it means to actually use one. Understanding exploitation is essential for offense — and just as essential for defense, because you cannot grasp why patching matters until you’ve seen a known vulnerability turn into a shell.

Part 1: The Problem

You’ve found weak services (3.2) and you know that services can have known vulnerabilities (2.10, 3.1). But there’s a gap between knowing a vulnerability exists and gaining access through it. Closing that gap is exploitation.

This page demystifies it. Exploitation has an aura — it sounds like the “real hacking.” In reality, for the vast majority of practical work, it is a understood, structured process, often using existing tools. The mystique is unhelpful; the understanding is essential. And critically: understanding exploitation is what makes a defender take patching seriously — abstract “vulnerability” becomes concrete “this is how they get in.”

Part 2: The Concept — What an Exploit Actually Is

Precise definitions, building on 1.1:

text
   EXPLOIT  =  the method that breaks through a specific weakness
   PAYLOAD  =  the code that runs on the target after it breaks through

   Analogy:
   exploit  = the technique that gets the door open
   payload  = what you do once you're through the door

A very common payload goal is a shell — command-line access to the target machine, letting the attacker run commands on it. A widely used, more capable payload type provides a richer interactive session for working with the compromised machine.

Two terms you’ll hear: a 0-day (zero-day) is a vulnerability not yet publicly known and not yet patched — rare, valuable, and not what everyday practical work uses. Far more common is exploiting known/N-day vulnerabilities — publicly documented ones (CVEs, 2.10) where the issue is simply that the target hasn’t patched. Most real-world compromise, by attackers and testers alike, uses known vulnerabilities against unpatched systems. That fact is the entire argument for patching.

Part 3: The Concept — Where Exploits Come From

When a vulnerability is publicly disclosed (the CVE process from 2.10), exploit code is often developed and published too — for legitimate reasons: defenders need it to test their systems, and security professionals need it for authorized assessments.

This means a practitioner usually does not write exploits from scratch. They:

Writing original exploits — and the deep, low-level skills behind it (memory corruption, and so on) — is a genuine specialization (it sits in Phase 5’s advanced and research-oriented directions). It is not a prerequisite for being a competent, employable security practitioner. Most pentesters and bug bounty hunters are highly effective using existing exploits skillfully and understanding them deeply.

⚠️ Public exploit code is dangerous in two directions. It can damage the target — exploits can crash services, corrupt data, destabilize systems (some are unreliable; some are meant to crash things). And it can be malicious to you — recall 0.6: some published “exploits” actually attack whoever runs them. So: read exploit code before running it (0.6), run it only against authorized targets, and understand that exploitation carries real risk of disruption — which is why engagement rules often restrict it.

Part 4: The Concept — The Metasploit Framework

Metasploit is the best-known exploitation framework: a single tool that brings together a large library of exploits, payloads, and supporting modules under one consistent interface. It’s pre-installed in Kali and is a standard part of the field — add it to your Tools & Reference Cheatsheet.

What a framework like Metasploit gives you, conceptually:

The conceptual workflow:

text
   1. SEARCH   — find an exploit module for the target's
                 known vulnerability (matched by service + version)
   2. SELECT   — choose that exploit module
   3. CONFIGURE— set options: target address, port, etc.
   4. PAYLOAD  — choose what to deliver (e.g. a shell)
   5. RUN      — launch the exploit
   6. RESULT   — on success, you get a session on the target

A crucial caveat — a framework is a convenience, not a replacement for understanding. Metasploit makes running an exploit straightforward; it does not teach you what the exploit does, why it works, or why it sometimes fails. Treat it as a power tool wielded by someone who understands the underlying work — never as a substitute for that understanding. A person who only knows “run Metasploit” is lost the moment it doesn’t just work.

Part 5: The Exploitation Workflow in Context

Exploitation doesn’t stand alone — it slots into the Phase 3 chain. Pulling the pieces together:

text
   3.1  SCAN          → service X, exact version identified
            │
            ▼
   2.10 RESEARCH      → that version has a known CVE
            │
            ▼
   3.3  FIND EXPLOIT  → existing exploit code / a Metasploit module
            │            exists for that CVE
            ▼
   3.3  EXPLOIT       → run it (authorized target) → a session/shell
            │
            ▼
        FOOTHOLD      → access on the machine — usually LOW-privileged
            │
            ▼
   3.4  PRIVILEGE ESCALATION → low-privileged → admin/root
            │
            ▼
   3.5  go from one machine → the whole network

This is the same picture as 3.2’s foothold diagram, with exploitation as the alternative route in: 3.2 got a foothold via misconfiguration (weak/default/anonymous access); 3.3 gets a foothold via a vulnerability in the service itself. Real engagements use whichever works — often both.

After a successful exploit comes post-exploitation: understanding what you have access to, what the machine is, what’s reachable from it. Two important sub-ideas you’ll develop in 3.4–3.5:

Part 6: The Defense — A Preview of Phase 4

The offense/defense mirror, and arguably the most important “why” of this page. Defending against exploitation is built across Phase 4 — hardening (4.4), monitoring and detection (4.6), incident response (4.7), and vulnerability management (4.8). The shape:

🔑 The deep lesson — and the reason exploitation is on the curriculum even for someone who wants to be defensive: once you have seen a known, patched-years-ago vulnerability turn into a shell on a machine in seconds, “keep your systems patched” stops being a platitude and becomes an obvious, urgent priority. Understanding the attack is what makes the defense feel real.

📓 Key Terms

Term Plain meaning
ExploitCode or a technique that takes advantage of a specific vulnerability.
PayloadThe code an exploit delivers and runs on the target.
ShellCommand-line access to a compromised machine.
0-day (zero-day)A vulnerability not yet publicly known or patched.
Known / N-day vulnerabilityA publicly documented vulnerability; exploitable on unpatched systems.
Exploitation frameworkA tool packaging many exploits and payloads (e.g. Metasploit).
MetasploitThe best-known exploitation framework.
Post-exploitationActivity after a successful compromise.
PivotingUsing a compromised machine to reach others deeper in the network.
PersistenceEstablishing a way to retain access to a compromised system.

🧪 Hands-On Lab

Exploitation runs only against your own lab VMs (Phase 0.5) or authorized practice platforms. Exploits can crash and damage systems — never run them against anything you don’t own or aren’t explicitly authorized (and scoped) to exploit. Read any exploit code before running it (0.6).

Task 1 — Pick a known-vulnerable target. Use a deliberately vulnerable VM in your lab (e.g. Metasploitable, set up in 0.5) — these intentionally run services with well-known vulnerabilities, expressly for this practice.

Task 2 — Identify a vulnerability. From your 3.1 infrastructure map, take a service and version on the target. Research it: find a known CVE for that version in a public vulnerability database (the 2.10 skill).

Task 3 — Explore Metasploit. Launch Metasploit in Kali. Search for an exploit module matching the CVE / service from Task 2. Read the module’s description and options. Understand what it targets before running anything.

Task 4 — Run an exploit (your lab only). Follow the framework workflow from Part 4: select the exploit module, configure its options for your victim VM, choose a payload (a shell), and run it. On success, you have a session on the machine.

Task 5 — Read an exploit’s code. Find the standalone exploit code for one CVE in a public exploit database. Read it (don’t necessarily run it) — apply the 0.6 skill. What vulnerability does it target? What does it send? What would the payload do?

Task 6 — Explore post-exploitation. With your session from Task 4, look around the compromised machine: who are you (which user?), what is this machine, what’s on it. Note your privilege level — this is the starting point for 3.4.

Task 7 — Reflect as a defender. Write a short note: that exploit used a known, long-patched vulnerability. How quickly did known-vuln + unpatched-service become a shell? What single defensive action (Part 6) would have stopped it? This reflection is the bridge to Phase 4.

⚠️ Common Mistakes

✅ Recap & What’s Next

Next (3.4): Your exploit or service attack gave you a foothold — but as a low-privileged user. Page 3.4 covers privilege escalation: the art of climbing from limited access to full administrative control of a machine.

⁂ Back to all modules