Skip to main content
Metasploit is the standard framework for finding, configuring, and launching exploits without writing one from scratch every time. It’s built around a few core pieces: a database to track what you’ve found, modules (exploits, auxiliary scanners, payloads) that do the actual work, and Meterpreter, the payload that gives you a full post-exploitation toolkit once a module lands.

msfconsole

The framework itself. Search for modules, configure options, launch exploits, and manage every session from one interface.

Meterpreter

What you get after a successful exploit. An in-memory agent for file operations, privilege escalation, and further post-exploitation, without dropping extra tools to disk.
Almost every module follows the same pattern: search, use, show options, set the required values, then run or exploit. Learn that loop once and most of msfconsole falls into place.

Getting Started

The database needs to be initialized once before first use, Metasploit falls back to working without it, but you lose the host/service tracking that makes the database worth using in the first place.
A few launch flags are worth knowing before you’re inside the console:
-x is handy for scripting a quick exploit launch from bash without sitting in the interactive console at all, e.g. msfconsole -q -x "use exploit/...; set RHOSTS TARGET; run; exit -y".

Workspace and Database

Metasploit’s database tracks hosts, services, and vulnerabilities across a whole engagement, which saves you from re-scanning or re-typing targets every session. Setting up a workspace per engagement keeps results from bleeding into each other.
Importing existing scan data is usually faster than scanning from inside msfconsole:
Or run nmap directly and have the results land in the database automatically:
Once you’ve got data in, these pull it back out:
If a database isn’t already connected, create and connect to one manually:

Finding and Configuring Modules

Everything in Metasploit, exploits, auxiliary scanners, and payloads, is a module you search for, load, and configure the same way.
Once a module is loaded, check what it needs before running it:
Set the values the module is asking for, then confirm it’s worth running:
setg sets a value globally across every module instead of just the current one, handy when you’re pivoting through several exploits against the same RHOSTS or LHOST.

Running Exploits

A few flags change how the exploit behaves once launched:
set autorunscript migrate -f automatically migrates the resulting session to a separate process as soon as the exploit lands, useful when the exploited process is likely to crash or get killed shortly after.

Session Management

Once a module succeeds, the session it opens needs to be managed, especially once you’ve got more than one shell running at a time.
Upgrading a plain shell to a full Meterpreter session unlocks everything covered below:

Meterpreter: File and System

Once you’ve got a Meterpreter session, these cover the basics: finding out where you landed and moving files in or out.

Meterpreter: Privilege Escalation and Tokens

Token impersonation and process migration are usually how you go from an initial low-privilege session to something with real reach on the host.
Token theft needs the incognito extension loaded first:

Meterpreter: Credentials and Surveillance

hashdump only pulls local SAM hashes. For anything beyond that, the kiwi extension (Mimikatz built into Meterpreter) gets plaintext credentials and tickets straight out of memory:
kerberos_ticket_list and kerberos_ticket_use TICKET let you list and then pass Kerberos tickets found in memory, useful once you’re past local hashes and into lateral movement.

Meterpreter: Persistence and Cleanup

Adding users, modifying the registry, and clearing event logs are all high-impact actions. Make sure they’re explicitly in scope before running any of these on a real engagement.

Pivoting and Web Scanning

WMAP runs a basic web vulnerability scan from inside msfconsole, convenient when you’re already in the console but not a replacement for a dedicated scanner.
WMAP documentation

Quick Reference Tools

metasploit-autopwn

Plugin that automatically matches detected open ports against known vulnerable modules.

PayloadsAllTheThings: Metasploit

Broader community-maintained reference for msfconsole usage.
getsystem, hashdump, and any persistence commands are heavy-handed actions. Confirm they’re within scope before running them against a real target.