Phase 04.01 · The Exploitation Engine

The Metasploit Framework

Reconnaissance found the doors; now we open them. Metasploit is the platform almost everyone learns exploitation on — a structured library of attack code paired with the plumbing to configure, deliver, and manage it from a single console. This lesson covers what Metasploit is, how its modules are organized, the workflow that turns a vulnerability into a session, and the one limitation that explains why professionals don't stop here.

00

What Metasploit is

The Metasploit Framework is the most widely used exploitation framework in the world. It is open-source, maintained by Rapid7, and it ships by default on every offensive-security distribution — which makes it the de facto standard platform people learn exploitation on. When someone says they are "firing up Metasploit," they almost always mean the main interface, msfconsole: an interactive command-line shell that drives the entire framework.

The cleanest way to picture Metasploit is as a structured library of attack code plus the plumbing to configure and deliver it. On its own, a public exploit is a fragile script with hard-coded addresses and assumptions. Metasploit takes thousands of those scripts, wraps each in a common interface, and hands you a consistent set of controls: pick the attack you want, fill in a handful of parameters, choose what should happen on success, and pull the trigger. The framework handles the messy middle — encoding, networking, session management — so you can focus on which attack and against what.

One console, many tools. msfconsole is not just an exploit launcher. It is a unified front end for scanning, fuzzing, exploiting, and post-exploitation alike — everything in this lesson happens from that one prompt.
Lesson
04.01
Phase
Exploitation
Maintained by
Rapid7
01

The module taxonomy

Everything in Metasploit is a module — a self-contained unit of code with a defined job. Understanding the six module types is the single most useful mental model you can build, because every action you take is really just selecting a module and feeding it options. The two you will reach for most are exploits (the code that breaks in) and payloads (the code that runs once you are in). The rest support, automate, or disguise those two.

Module typeWhat it doesExample
ExploitCode that triggers a specific vulnerability to gain a foothold — the actual "break-in." Selecting one is the start of most engagements.exploit/windows/smb/ms17_010_eternalblue
PayloadWhat runs after the exploit succeeds. Defines the access you get back — a shell, a callback, or a full Meterpreter session.windows/x64/meterpreter/reverse_tcp
AuxiliaryScanners, fuzzers, and probes that do work without delivering a payload. Used for discovery, enumeration, and brute-forcing.auxiliary/scanner/smb/smb_version
PostPost-exploitation modules that run on an already-compromised host — harvesting credentials, gathering data, escalating, or pivoting.post/windows/gather/hashdump
EncoderRewrites a payload into an equivalent form to dodge bad characters or naive signature matching, without changing what it does.x86/shikata_ga_nai
NOPGenerates "no-operation" instruction sleds that pad a payload and keep its length and alignment stable — classic for memory-corruption exploits.x86/single_byte

Hold onto the pairing at the top of that table: an exploit gets you in, a payload decides what you get. Auxiliary modules do reconnaissance-style work with no payload at all, post modules pick up after a host has fallen, and encoders and NOPs are low-level helpers that shape a payload before it goes out the door. Once the taxonomy clicks, the entire workflow below reads as nothing more than choosing modules in order.

02

The core workflow

Almost every exploitation session in Metasploit follows the same handful of steps. Learn this rhythm once and it transfers to nearly every module in the framework:

Read the difference between R and L. The R options (RHOSTS, RPORT) describe the remote target you are attacking; the L options (LHOST, LPORT) describe your listener that a reverse payload calls back to. Mixing these two up is the most common reason a "working" exploit never returns a session.
03

Sessions and Meterpreter

When an exploit succeeds, the result is a session — a live, interactive channel back to the compromised host. Metasploit tracks every session by number, lets you background one and resume it later, and lets you juggle several at once across multiple targets. A session is your foothold; what you can do through it depends entirely on the payload you chose.

The payload that makes Metasploit so powerful is Meterpreter. Unlike a plain command shell, Meterpreter is an advanced, in-memory payload — it loads into the target's memory and, by default, never touches disk, which keeps it stealthier than dropping an executable. It exposes a rich, consistent post-exploitation command set: browsing and pulling files, dumping credentials, capturing screenshots, logging keystrokes, migrating between processes, and pivoting — using the compromised machine as a launch point to reach networks you could not touch directly.

A shell is access; Meterpreter is a toolkit. Both come back as a session, but a raw shell gives you only the target's command line, while Meterpreter brings an entire post-exploitation suite with it — which is exactly why defenders watch for it so closely.
04

Strengths and the big limitation

For two jobs, Metasploit is essentially unbeatable. The first is learning: nothing else lets you go from "I read about a vulnerability" to "I have a session on a host" as quickly, with as gentle a ramp, while teaching the universal exploit-payload-session model along the way. The second is known exploits: when a vulnerability is public and a module exists, Metasploit weaponizes it reliably and consistently. For lab work, for CTFs, and for the broad class of unpatched, known-CVE targets, it is the right tool and often the fastest one.

But there is a catch that defines the rest of the offensive toolkit. Metasploit is loud, and its default payloads are heavily signatured. Stock Meterpreter is one of the most-studied pieces of code in security history — every modern antivirus and EDR product is tuned to spot it on sight. Fire a default payload at a defended host and it is flagged, killed, and alerted on almost immediately. Encoders help with crude signature matching, but they do not meaningfully fool behavior-based EDR; the underlying payload is simply too well known.

This limitation is the whole reason the next chapter exists. Metasploit's noise and its signatured payloads are exactly why professionals reach for dedicated command-and-control frameworks — tooling built from the ground up for stealth, evasion, and long-haul operations against defended networks. Metasploit teaches you the model; C2 frameworks are how you operate once the defenders are paying attention.

Use Metasploit for what it is best at, and recognize when you have outgrown it. When the target has real defenses and getting caught means failing the engagement, the next step is the Command & Control Frameworks lesson. And as always: everything here is for authorized targets only — explicit written permission and a target in scope are the line between a penetration test and a crime.