Skip to content
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

Merged
merged 10 commits into from
May 30, 2018

Conversation

wvu
Copy link
Contributor

@wvu wvu commented May 24, 2018

WIP Test me!

Do we really want to exclude loopback? It's occasionally useful, and there's already a warning when setting it. No longer excluded.

  • Test tab completion of IPv4 and IPv6 by address
  • Note that the full list of addresses is displayed now (fixed regression)
  • Test tab completion of IPv4 and IPv6 by interface
  • Test setting of IPv4 and IPv6 by address
  • Test setting of IPv4 and IPv6 by interface

#8336, #10086

@wvu wvu added library blocked Blocked by one or more additional tasks feature msfconsole labels May 24, 2018
It's occasionally useful, and we already warn when setting it.
def interfaces
NetworkInterface.interfaces || []
end

def normalize(value)
Copy link
Contributor

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

@jmartin-tech
Copy link
Contributor

So pretty 👍

msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload linux/x64/meterpreter_reverse_tcp
payload => linux/x64/meterpreter_reverse_tcp
msf5 exploit(multi/handler) > set LHOST
set LHOST 127.0.0.1                        set LHOST bridge0                          set LHOST gif0
set LHOST X.X.X.X                          set LHOST en0                              set LHOST lo0
set LHOST X.X.X.X                          set LHOST en1                              set LHOST p2p0
set LHOST X.X.X.X                          set LHOST en2                              set LHOST stf0
set LHOST X.X.X.X                          set LHOST xxxx::x%lo0                      set LHOST utun0
set LHOST ::1                              set LHOST xxxx::xxxx:xxxx:xxxx:xxxx%en0    set LHOST utun1
set LHOST XHC20                            set LHOST xxxx::xxxx:xxxx:xxxx:xxxx%utun0  set LHOST vmnet1
set LHOST awdl0                            set LHOST xxxx::xxxx:xxxx:xxxx:xxxx%awdl0  set LHOST vmnet8
msf5 exploit(multi/handler) > set LHOST

@bcoles
Copy link
Contributor

bcoles commented May 24, 2018

LGTM

msf5 exploit(multi/handler) > set lhost 
set lhost 127.0.0.1                      set lhost eth0
set lhost 172.16.X.X                     set lhost XXXX::XXX:XXXX:XXXX:XXXX%eth0
set lhost ::1                            set lhost lo

@wvu wvu force-pushed the feature/interface branch 3 times, most recently from 6160ddd to c724eff Compare May 24, 2018 23:13
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.
@wvu wvu added bug and removed blocked Blocked by one or more additional tasks labels May 24, 2018
@wvu wvu changed the title Add tab completion for network interfaces Improve network interface support for LHOST (OptAddressLocal) May 24, 2018
@h00die
Copy link
Contributor

h00die commented May 25, 2018

This looks the hotness

@busterb busterb self-assigned this May 30, 2018
@busterb
Copy link
Member

busterb commented May 30, 2018

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]
Copy link
Member

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 :)

@busterb busterb merged commit ebf2020 into rapid7:master May 30, 2018
@wvu wvu deleted the feature/interface branch May 30, 2018 04:18
@busterb
Copy link
Member

busterb commented Jun 1, 2018

Release Notes

This implements support for tab-completing network interface names for the LHOST parameter, as well as fixes an issue with tab completion of IP addresses.

@tdoan-r7 tdoan-r7 added rn-fix release notes fix rn-enhancement release notes enhancement and removed rn-fix release notes fix labels Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants