Skip to content

Metasploit Framework

140 commands

The most widely used exploitation framework: thousands of exploits, payloads and post-exploitation modules plus a workspace database.

  • exploitation
  • framework
  • post-exploitation

Install Metasploit Framework

sudo apt install metasploit-framework

Core Console Usage6

msfconsole

Launches the Metasploit Framework interactive console.

msfconsole -q

Starts the console in quiet mode, suppressing the startup banner.

help

Displays the main help menu with a list of available commands.

version

Shows the current version of the Metasploit Framework.

history

Displays a list of previously executed commands in the current session.

connect

Uses the built-in Netcat-like utility to connect to a remote host and port.

Link

Database Management10

db_status

Checks the connection status to the backend database.

workspace

Lists all available workspaces in the database.

workspace -a

Creates and switches to a new workspace named Target_Alpha.

Link
workspace

Switches the current active workspace to Target_Alpha.

Link
db_nmap

Runs Nmap within Metasploit and automatically saves results to the database.

Link
hosts

Lists all hosts found and stored in the current workspace database.

Link
services

Lists all services and open ports discovered on stored hosts.

Link
services -p

Filters and displays only hosts with port 445 open.

Link
vulns

Displays vulnerabilities associated with hosts in the database.

Link
creds

Lists all credentials (usernames, passwords, hashes) gathered in the database.

Link

Module Discovery3

search

Searches for modules related to a specific 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

Module Selection3

use

Selects and loads a specific module for configuration.

Link
back

Unloads the current module and returns to the main prompt.

Link
info

Displays detailed information, options, and references for the active module.

Link

Module Configuration8

show options

Lists the required and optional parameters for the current module.

Link
show targets

Lists the operating systems or versions supported by the exploit.

Link
show payloads

Lists compatible payloads for the currently selected exploit.

Link
show advanced

Displays advanced configuration options for fine-tuning the module.

Link
set

Configures a specific option (e.g., target IP) for the module.

Link
setg

Sets a global variable that persists across different modules.

Link
unset

Removes the value of a specific option.

Link
set TARGET

Manually selects a specific target ID from the 'show targets' list.

Link

Payload Configuration3

set PAYLOAD

Assigns a specific payload to be delivered by the exploit.

Link
set LHOST

Sets the local IP address for the payload to connect back to.

Link
set LPORT

Sets the local listening port for the reverse connection.

Link

Auxiliary Modules2

use auxiliary

Selects an auxiliary module used for scanning or enumeration.

Link
run

Executes the currently selected auxiliary or post-exploitation module.

Link

Exploitation5

check

Attempts to verify if the target is vulnerable without exploiting it.

Link
exploit

Executes the exploit module against the target.

Link
exploit -j

Runs the exploit in the background as a job.

Link
exploit -z

Exploits the target but keeps the session in the background immediately.

Link
set ForceExploit

Forces the exploit to run even if the check determines the target is not vulnerable.

Link

Job Control2

jobs

Lists currently running background jobs.

Link
kill

Terminates a specific background job by its ID.

Link

Encoders & Evasion3

show encoders

Lists available encoders to obfuscate the payload.

Link
set ENCODER

Applies a specific encoder to the payload to attempt AV evasion.

Link
generate

Generates a payload file (executable) from the current configuration.

Link

Session Management5

sessions

Lists all active sessions connected to the framework.

Link
sessions -i

Interacts with specific session ID 1.

Link
sessions -k

Kills and terminates session ID 2.

Link
sessions -u

Attempts to upgrade a shell session (ID 1) to a Meterpreter session.

Link
background

Moves the current interactive session to the background.

Link

Meterpreter: Core6

sysinfo

Displays system information about the compromised host (OS, Arch, Domain).

Link
getuid

Displays the user identity that the Meterpreter session is running as.

Link
getpid

Shows the Process ID (PID) of the current Meterpreter session.

Link
getprivs

Lists the privileges available to the current user process.

Link
ps

Lists all running processes on the target system.

Link
migrate

Moves the Meterpreter session into another process ID to ensure persistence.

Link

Meterpreter: File System9

pwd

Prints the current working directory on the remote target.

Link
ls

Lists files and directories in the current remote folder.

Link
cd

Changes the directory on the remote target.

Link
cat

Reads and displays the contents of a file on the remote target.

Link
lpwd

Prints the local working directory (on the attacker's machine).

Link
lcd

Changes the local working directory on the attacker's machine.

Link
upload

Uploads a file from the attacker's machine to the target system.

Link
download

Downloads a file from the target system to the attacker's machine.

Link
search

Searches for files matching a pattern on the remote file system.

Link

Meterpreter: Networking8

ipconfig

Displays the network interfaces and IP addresses of the target.

Link
ifconfig

Alternative command to display network interfaces (Linux/Unix).

Link
netstat

Displays active network connections and listening ports on the target.

Link
arp

Displays the ARP cache of the target system.

Link
route

Displays the routing table of the target system.

Link
portfwd add

Forwards a local port to a remote service through the Meterpreter session.

Link
portfwd list

Lists active port forwarding rules in the current session.

Link
resolve

Resolves a hostname to an IP address on the target network.

Link

Meterpreter: System Interaction4

shell

Drops into a standard system shell (cmd.exe or /bin/bash) on the target.

Link
execute

Executes a command on the remote target, optionally hidden and interactive.

Link
shutdown

Shuts down the remote computer (Use with extreme caution).

Link
reboot

Reboots the remote computer (Use with extreme caution).

Link

Meterpreter: Credential Harvesting4

getsystem

Attempts multiple techniques to elevate privileges to SYSTEM/Root.

Link
hashdump

Dumps the SAM database contents (password hashes) from the target.

Link
load kiwi

Loads the Kiwi extension (Mimikatz integration) for advanced credential theft.

Link
creds_all

Retrieves all available credentials using the Kiwi extension.

Link

Meterpreter: User Monitoring6

screenshot

Takes a screenshot of the target's current desktop.

Link
screenshare

Streams the target's desktop to a browser on the attacker's machine.

Link
keyscan_start

Starts the keylogger to capture keystrokes on the target.

Link
keyscan_dump

Dumps the captured keystrokes from the memory buffer.

Link
keyscan_stop

Stops the keylogger capture process.

Link
idletime

Displays how long the remote user has been idle.

Link

Post Exploitation6

use post

Selects a post-exploitation module to gather info from a session.

Link
set SESSION

Links a post-exploitation module to an active session ID.

Link
run post/windows/gather/checkvm

Checks if the target system is a virtual machine.

Link
run post/windows/manage/migrate

Automatically migrates the session to a stable process.

Link
run post/linux/gather/hashdump

Dumps password hashes from a Linux target shadow file.

Link
run post/multi/recon/local_exploit_suggester

Suggests local exploits for privilege escalation based on system info.

Link

Pivoting & Routing4

route add

Routes traffic for the 10.10.10.0 network through session ID 1.

Link
route print

Displays the current routing table within Metasploit.

Link
run autoroute

Automatically adds a route to a subnet via the current Meterpreter session.

Link
use auxiliary/server/socks_proxy

Starts a SOCKS proxy to allow external tools to use the pivot.

Link

Listener Setup2

use exploit/multi/handler

Sets up a generic listener to catch incoming shell/meterpreter connections.

Link
set ExitOnSession

Keeps the listener active even after a session is received.

Link

Logging & Output2

spool

Saves all console output to a file for documentation.

Link
spool off

Stops saving console output to the file.

Link

Automation & Scripting3

makerc

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

Link
resource

Executes a list of commands stored in a resource script file.

Link
msfconsole -r

Launches Metasploit and immediately runs the specified resource script.

Link

Payload Generation1

msfvenom

Generates a standalone payload executable from the command line (outside console).

Link

Advanced5

load

Loads a plugin (e.g., PowerShell) into the Metasploit framework.

Link
unload

Unloads an active plugin or extension.

Link
advanced

Shows advanced options for the current module (alias for show advanced).

Link
edit

Opens the currently selected module code in the default text editor.

Link
reload_all

Reloads all modules from the disk, useful if you edited a module.

Link

Cleanup3

clearev

Clears the Application, System, and Security event logs on Windows (Meterpreter).

Link
timestomp

Manipulates file timestamps (MACE attributes) to hide file modification times.

Link
rm

Deletes a file on the remote system (Standard Meterpreter command).

Link

Web Exploitation4

load wmap

Loads the WMAP web application scanning plugin.

Link
wmap_sites -a

Adds a site to the WMAP target list.

Link
wmap_targets -t

Sets the target URL for WMAP scanning.

Link
wmap_run -e

Runs the WMAP modules against the configured targets.

Link

Defense Evasion2

set StageEncoder

Encodes the second stage of the payload sent over the network.

Link
set EnableStageEncoding

Enables encoding for the payload stage to evade network intrusion detection.

Link

Exploit Options2

set AutoRunScript

Specifies a script to run automatically as soon as a session is created.

Link
set PrependMigrate

Configures the payload to migrate to a new process immediately upon execution.

Link

Credentials1

db_import

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

Link

Transport3

transport list

Lists available transport mechanisms (e.g., HTTP, TCP) for the current session.

Link
transport add

Adds a secondary transport layer to a Meterpreter session for redundancy.

Link
transport next

Forces the Meterpreter session to switch to the next available transport.

Link

Extensions1

load python

Loads the Python extension to run Python scripts within Meterpreter.

Link

Debugging1

debug

Enables debugging output for troubleshooting module issues.

Link

Ruby Interaction1

irb

Drops into an interactive Ruby shell within the current session context.

Link

Payloads1

set HandlerSSLCert

Uses a custom SSL certificate for HTTPS listeners to mimic legitimate traffic.

Link

Pivoting2

portfwd delete

Removes a specific port forwarding rule.

Link
portfwd flush

Removes all active port forwarding rules.

Link

Enumeration3

run post/windows/gather/enum_patches

Enumerates installed patches on a Windows target to identify missing updates.

Link
run post/windows/gather/enum_shares

Lists network shares available on the target system.

Link
run post/multi/gather/env

Reads the environment variables from the target system.

Link

General2

notes

Displays any notes manually added to the database regarding hosts.

Link
loot

Lists all gathered loot (hashes, files) stored in the database.

Link

Meterpreter: Incognito3

load incognito

Loads the Incognito extension for token manipulation.

Link
list_tokens -u

Lists available delegation and impersonation tokens by user.

Link
impersonate_token

Impersonates the specified user token to escalate privileges.

Link

Termination1

exit

Exits the Metasploit console.

Link