Skip to content

Metasploit

The Metasploit Framework (msfconsole) is the primary exploit-delivery tool. It provides an interactive console for searching, configuring and launching CVE exploits against target servers.

Type metasploit in the terminal to open the interactive console. Your prompt changes to msf6 >, indicating you are inside Metasploit.

# 1. Search for exploits matching a service
msf6 > search apache
# 2. Select a module by index or CVE ID
msf6 > use 0
msf6 > use CVE-2021-41773
# 3. Set the target IP and port
msf6 exploit(...) > set RHOSTS 10.0.1.5
msf6 exploit(...) > set RPORT xxx
# 4. Review options and run
msf6 exploit(...) > show options
msf6 exploit(...) > exploit
# 5. Open the session and drop a shell
msf6 exploit(...) > session -i X
msf6 exploit(...) > shell
Command What it does
search <query> Search exploits by service, CVE or type
use <module> Select a module (by index, CVE ID or path)
sessions List active exploit sessions
show exploits List all available exploit modules
banner Display the MSF banner
version Show the framework version
exit Exit msfconsole and return to the terminal

Available after selecting a module with use:

Command What it does
set <opt> <val> Set a module option (RHOSTS, RPORT, LHOST, LPORT)
show options View current module options and their values
info Detailed module information (CVE, rank, description)
check Check whether the target is vulnerable before exploiting
exploit / run Launch the exploit against RHOSTS
back Deselect the module and return to the main console
Option Meaning
RHOSTS (required) Target IP address
RPORT (required) Target port
LHOST Your IP (listener address, auto-set)
LPORT Listener port (default: 4444)
PAYLOAD Auto-selected based on target platform

Available after a successful exploit, via sessions -i <id>:

Command What it does
sysinfo Show target system information
getuid Display the current user / access level
hashdump Dump password hashes from the target
shell Drop into the target’s system shell (connect)
upload <file> Upload a file to the target
download <file> Download a file from the target
background Background the session and return to the console
exit Close the Meterpreter session
Rank Reliability
excellent Reliable, no crash risk (Backdoor, RCE, Auth Bypass)
great High success rate (Buffer Overflow, Priv Escalation)
good Moderate reliability (Path Traversal, SSRF)
normal May require specific conditions (Info Disclosure, DoS)
  • You must nmap a target before you can exploit it.
  • Use searchsploit <service> to find matching CVEs for a target’s services.
  • The check command verifies vulnerability without triggering the IDS.
  • Tier 5+ servers with an IDS may detect exploits; route through proxychains first.
  • Higher-tier servers take longer to exploit.
  • After exploitation, use shell from a Meterpreter session to connect directly.