Skip to content

msfconsole

140 commands

The interactive console for Metasploit: search, configure and run modules, manage sessions and work with the database.

  • Metasploit
  • console
  • sessions

Install msfconsole

sudo apt install metasploit-framework

Console Startup3

msfconsole

Launches the Metasploit Framework interactive console

msfconsole -q

Starts the console in quiet mode without displaying the banner

msfconsole -r

Starts the console and executes a resource script containing automated commands

Link

Global Help and Documentation3

help

Displays the main help menu with available core commands

help <command>

Displays specific usage instructions for a particular command

Link
version

Shows the currently installed version of the Metasploit Framework

Global Navigation2

history

Displays the list of previously executed commands in the current session

connect

Connects to a remote host and port like netcat/telnet for verification

Link

Database Management5

db_status

Checks the connection status to the backend PostgreSQL database

workspace

Lists all available workspaces

Link
workspace -a

Creates and switches to a new isolated workspace

Link
workspace <name>

Switches the active context to an existing workspace

Link
db_nmap

Runs Nmap wrapper and automatically saves results to the database

Link

Importing External Scan Results1

db_import

Imports scan results from tools like Nmap, Nessus, or Qualys into the database

Link

Hosts and Services5

hosts

Lists all hosts discovered in the current workspace

Link
hosts -c

Lists hosts displaying only specific columns

Link
services

Lists all services discovered on stored hosts

Link
services -p

Filters and displays only services running on a specific port

Link
vulns

Displays all vulnerabilities recorded for the targets in the database

Link

Module Discovery4

search

Searches for modules related to a keyword

Link
search type

Filters search results by module type and target platform

Link
search cve

Searches for modules matching a specific CVE identifier

Link
search author

Searches for modules written by a specific author

Link

Module Selection2

use

Selects a specific module to configure and execute

Link
use <index>

Selects a module by its index number from the previous search results

Link

Module Information2

info

Displays detailed information about the currently selected module

Link
info -d

Displays the documentation and references for the module in markdown format

Link

Module Configuration8

show options

Lists the basic configurable options for the active module

Link
show advanced

Displays advanced options for fine-tuning the module behavior

Link
show targets

Lists the available target systems/versions for the exploit

Link
show evasion

Shows options specifically designed to evade IDS/IPS and antivirus

Link
set

Sets a value for a specific option in the current module context

Link
setg

Sets a global variable that persists across different module selections

Link
unset

Removes the value of a specific option

Link
unsetg

Removes a global variable

Link

Payload Selection2

show payloads

Lists compatible payloads for the currently selected exploit

Link
set payload

Selects the specific payload to deliver upon successful exploitation

Link

Payload Configuration3

set LHOST

Sets the listening address (attacker IP) for the reverse connection

Link
set LPORT

Sets the listening port on the attacker machine

Link
generate

Generates a standalone payload file based on current configurations

Link

Encoding and Evasion2

show encoders

Lists available encoders to obfuscate the payload

Link
set ENCODER

Applies a specific encoder to the payload

Link

Exploit Execution5

check

Validates if the target is vulnerable without actually exploiting it

Link
exploit

Executes the exploit module against the target

Link
run

Alias for exploit, often used with auxiliary and post modules

Link
exploit -j

Runs the exploit in the context of a background job

Link
exploit -z

Exploits the target but does not interact with the session immediately

Link

Background Jobs3

jobs

Lists all currently running background jobs

Link
jobs -k

Terminates a specific background job by its ID

Link
kill

Kills a running job (alias for jobs -k)

Link

Handler Management1

handler

Quickly starts a payload handler without using the multi/handler module

Link

Session Management4

sessions

Lists all active open sessions

Link
sessions -i

Interacts with a specific session ID, entering the shell or meterpreter

Link
sessions -u

Attempts to upgrade a basic shell session to a full Meterpreter session

Link
sessions -k

Kills a specific active session

Link

Meterpreter Core4

sysinfo

Displays information about the remote system, OS, and architecture

Link
getuid

Displays the user the server is running as

Link
getsystem

Attempts to elevate privileges to SYSTEM using various techniques

Link
background

Backgrounds the current meterpreter session returning to msfconsole

Link

Meterpreter File System8

pwd

Prints the current working directory on the remote machine

Link
ls

Lists files in the current remote directory

Link
cd

Changes the current directory on the remote machine

Link
cat

Displays the contents of a file on the remote system

Link
upload

Uploads a file from the attacker to the victim machine

Link
download

Downloads a file from the victim to the attacker machine

Link
edit

Opens a file on the remote system in the local editor (vim)

Link
search -f

Searches the file system for files matching a pattern

Link

Meterpreter Process Mgmt5

ps

Lists running processes on the remote system

Link
getpid

Gets the process ID of the current meterpreter injection

Link
migrate

Moves the meterpreter session into another running process ID

Link
execute

Executes a command on the remote system, optionally hidden

Link
kill

Terminates a process on the remote system by PID

Link

Meterpreter Network5

ipconfig

Displays network interfaces and IP addresses on the target

Link
ifconfig

Alias for ipconfig

Link
netstat

Displays network connections and listening ports on the target

Link
arp

Displays the ARP cache of the remote system

Link
route

Displays the routing table of the remote system

Link

Meterpreter Pivoting2

portfwd add

Forwards a local port to a remote service through the meterpreter session

Link
portfwd list

Lists active port forwarding rules

Link

Console Pivoting2

route add

Routes traffic for a subnet through a specific session ID

Link
route print

Displays the active routing table in msfconsole

Link

Meterpreter System4

shell

Drops into a standard system command shell (cmd or bash)

Link
idletime

Displays how long the user has been idle

Link
reboot

Reboots the remote system

Link
shutdown

Shuts down the remote system

Link

Credential Access2

hashdump

Dumps the contents of the SAM database (password hashes)

Link
creds_all

Dumps all retrieved credentials (plaintext and hashes) via kiwi extension

Link

Input Capture3

keyscan_start

Starts the keylogger on the remote system

Link
keyscan_dump

Dumps the captured keystrokes

Link
keyscan_stop

Stops the keylogger

Link

Surveillance5

screenshot

Takes a screenshot of the remote desktop

Link
screenshare

Watches the remote desktop in real-time via web browser

Link
webcam_list

Lists available webcams on the target

Link
webcam_snap

Takes a picture using the remote webcam

Link
record_mic

Records audio from the default microphone for X seconds

Link

Anti-Forensics2

timestomp

Manipulates file MACE attributes (timestamp)

Link
clearev

Clears the Application, System, and Security event logs on Windows

Link

Post Exploitation Selection1

use post

Selects a post-exploitation module

Link

Post Exploitation Configuration1

set SESSION

Target a specific active session for the post module

Link

Post Exploitation Execution1

run

Executes the post-exploitation module against the session

Link

Auxiliary Scanners2

use auxiliary

Selects an auxiliary scanning module

Link
run

Runs the scanner

Link

Local Exploit Suggester1

use post/multi/recon/local_exploit_suggester

Checks the session for missing patches and suggests local exploits

Link

Socks Proxy1

use auxiliary/server/socks_proxy

Sets up a SOCKS proxy to pivot external tools through MSF sessions

Link

Loot Management2

loot

Lists all collected loot (hashes, files, keys)

Link
loot -t

Lists loot filtered by type

Link

Credential Management2

creds

Lists all credentials stored in the database

Link
creds -a

Manually adds a credential to the database

Link

Automation3

makerc

Saves all commands executed in the current session to a resource file

Link
resource

Executes a resource script file containing msfconsole commands

Link
setg

Customizes the console prompt (e.g., adding timestamps)

Link

Logging2

spool

Starts logging all console output to a file

Link
spool off

Stops logging console output

Link

Module Editing1

edit

Opens the currently selected module code in the default editor

Link

Developer1

reload_all

Reloads all modules from disk (useful when developing custom modules)

Link

Payload Generation2

use payload

Selects a payload module directly for generation

Link
to_handler

Creates a handler for the currently selected payload module

Link

Cleanup1

unset all

Unsets all options for the current module

Link

Advanced Option6

set VERBOSE

Enables verbose output for more detailed execution logs

Link
set WfsDelay

Sets the wait-for-session delay in seconds for slow exploits

Link
set AutoRunScript

Automatically runs a script upon successful session creation

Link
set PrependMigrate

Automatically migrates the payload process immediately after exploitation

Link
set ExitOnSession

Keeps the listener open even after a session is created

Link
set StagerBlockSize

Adjusts the block size for staging payloads to evade some IPS signatures

Link

Module Type1

show nop

Lists NOP (No Operation) generators for buffer padding

Link

Red Team Workflow1

use evasion

Selects an evasion module designed to bypass AV/EDR

Link

Wait Command1

sleep

Pauses execution for a specified number of seconds (useful in scripts)

Link

Ruby Execution1

irb

Drops into an interactive Ruby shell within the console context

Link

Target Management1

db_rebuild_cache

Rebuilds the module search cache in the background

Link

Notes2

notes

Lists notes attached to hosts in the database

Link
notes -a

Adds a manual note to a specific host

Link

Configuration1

save

Saves the current global options and settings to the config file

Link

Console Interface1

color

Disables color output in the console

Link

Host Management1

hosts -d

Deletes a specific host from the database

Link

Service Management1

services -u

Lists only services that are currently up/running

Link

Meterpreter Extension3

load kiwi

Loads the Kiwi (Mimikatz) extension in Meterpreter

Link
load python

Loads the Python extension to run python code in memory

Link
load powershell

Loads the PowerShell extension to run PS scripts in memory

Link

Console Termination1

exit

Exits the Metasploit console

Link