-
Notifications
You must be signed in to change notification settings - Fork 13.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve network interface support for LHOST (OptAddressLocal) #10094
Conversation
Rex::Socket#getifaddrs doesn't exist.
It's occasionally useful, and we already warn when setting it.
def interfaces | ||
NetworkInterface.interfaces || [] | ||
end | ||
|
||
def normalize(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def normalize(value)
return unless value.kind_of?(String)
return value unless interfaces.include?(value)
ip_address = NetworkInterface.addresses(value).values.flatten.map{|x| x['addr']}.select do |addr|
begin
IPAddr.new(addr).ipv4?
rescue IPAddr::InvalidAddressError
nil
end
end
return if ip_address.blank?
ip_address.first
end
So pretty 👍
|
LGTM
|
6160ddd
to
c724eff
Compare
Option validation relied on the value being false, not nil, even though normalizing a string to a Boolean doesn't make sense. Normalizing to an empty string seems to work fine.
I do believe the list is already sorted IPv4 first.
This looks the hotness |
LGTM too, thanks @wvu-r7 |
@@ -40,7 +40,7 @@ def self.Proxies(default=nil, required=false, desc="A proxy chain of format type | |||
Msf::OptString.new(__method__.to_s, [ required, desc, default ]) | |||
end | |||
|
|||
# @return [OptAddress] | |||
# @return [OptAddressRange] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
conflict, I fixed this too :)
Release NotesThis implements support for tab-completing network interface names for the LHOST parameter, as well as fixes an issue with tab completion of IP addresses. |
WIPTest me!Do we really want to exclude loopback? It's occasionally useful, and there's already a warning when setting it.No longer excluded.#8336, #10086