rapid7/metasploit-framework — pull request #3633 by iquaba (2014-08-08 20:08:33+00:00)
Title: Adds ability to set lhost IP by specifying an interface name

This pull allows a user to set their lhost by specifying a local interface. It uses an added gem to attempt to automatically determine the interface's IP address. It only applies when "set lhost" or "setg lhost" is used. If the attempt to retrieve the IP address fails (eg. an actual IP address or an invalid interface), it proceeds as before.

Verification tests:
msf > set lhost eth0
[*] Setting lhost to address of interface eth0
lhost => 192.168.0.101
msf > set lhost 8.8.8.8
lhost => 8.8.8.8
msf > set lhost eth0:1
[*] Setting lhost to address of interface eth0:1
lhost => 192.168.10.4
msf > set lhost eth1
[*] Setting lhost to address of interface eth1
lhost => 192.168.8.3
msf > set lhost gibberish
lhost => gibberish
msf > set lhost eth0 junk
lhost => eth0 junk
msf > setg lhost eth0
[*] Setting lhost to address of interface eth0
lhost => 192.168.0.101