Missed an LHOST option

making OptAddressLocal inherit from OptAddress
bug/bundler_fix
darkbushido 2017-05-02 12:37:59 -05:00
parent 81bcf2ca70
commit fee0fb5e90
2 changed files with 8 additions and 26 deletions

View File

@ -28,7 +28,7 @@ module Msf
# @return [OptAddress]
def self.LHOST(default=nil, required=true, desc="The listen address")
Msf::OptAddress.new(__method__.to_s, [ required, desc, default ])
Msf::OptAddressLocal.new(__method__.to_s, [ required, desc, default ])
end
# @return [OptPort]

View File

@ -1,4 +1,5 @@
# -*- coding: binary -*-
require 'network_interface'
module Msf
@ -7,19 +8,12 @@ module Msf
# Network address option.
#
###
class OptAddressLocal < OptBase
def type
return 'address'
end
class OptAddressLocal < OptAddress
def normalize(value)
return nil unless value.kind_of?(String)
if (value =~ /^iface:(.*)/)
iface = $1
return false if not NetworkInterface.interfaces.include?(iface)
ip_address = NetworkInterface.addresses(iface).values.flatten.collect{|x| x['addr']}.select do |addr|
if NetworkInterface.interfaces.include?(value)
ip_address = NetworkInterface.addresses(value).values.flatten.collect{|x| x['addr']}.select do |addr|
begin
IPAddr.new(addr).ipv4?
rescue IPAddr::InvalidAddressError => e
@ -28,7 +22,7 @@ class OptAddressLocal < OptBase
end
return false if ip_address.blank?
return ip_address
return ip_address.first
end
return value
@ -38,19 +32,7 @@ class OptAddressLocal < OptBase
return false if check_empty && empty_required_value?(value)
return false unless value.kind_of?(String) or value.kind_of?(NilClass)
if (value != nil and not value.empty?)
begin
getaddr_result = ::Rex::Socket.getaddress(value, true)
# Covers a wierdcase where an incomplete ipv4 address will have it's
# missing octets filled in with 0's. (e.g 192.168 become 192.0.0.168)
# which does not feel like a legit behaviour
if value =~ /^\d{1,3}(\.\d{1,3}){1,3}$/
return false unless value =~ Rex::Socket::MATCH_IPV4
end
rescue
return false
end
end
return true if NetworkInterface.interfaces.include?(value)
return super
end