Accept IPv6 addresses in getaddress() responses
parent
49ff9f594a
commit
1cc68d1ed5
|
@ -121,7 +121,7 @@ module Socket
|
|||
def self.is_ipv4?(addr)
|
||||
return false if addr =~ MATCH_IPV6
|
||||
return true if addr =~ MATCH_IPV4
|
||||
res = Rex::Socket.getaddress(addr)
|
||||
res = Rex::Socket.getaddress(addr, true)
|
||||
res.match(/:/) ? false : true
|
||||
end
|
||||
|
||||
|
@ -131,7 +131,7 @@ module Socket
|
|||
def self.is_ipv6?(addr)
|
||||
return true if addr =~ MATCH_IPV6
|
||||
return false if addr =~ MATCH_IPV4
|
||||
res = Rex::Socket.getaddress(addr)
|
||||
res = Rex::Socket.getaddress(addr, true)
|
||||
res.match(/:/) ? true : false
|
||||
end
|
||||
|
||||
|
@ -278,7 +278,7 @@ module Socket
|
|||
# Resolves a host to raw network-byte order.
|
||||
#
|
||||
def self.resolv_nbo(host)
|
||||
self.gethostbyname(Rex::Socket.getaddress(host))[3]
|
||||
self.gethostbyname(Rex::Socket.getaddress(host, true))[3]
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -154,7 +154,7 @@ class Rex::Socket::Comm::Local
|
|||
elsif (local == "\x7f\x00\x00\x01")
|
||||
param.localhost = '::1'
|
||||
else
|
||||
param.localhost = '::ffff:' + Rex::Socket.getaddress(param.localhost)
|
||||
param.localhost = '::ffff:' + Rex::Socket.getaddress(param.localhost, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -164,7 +164,7 @@ class Rex::Socket::Comm::Local
|
|||
elsif (peer == "\x7f\x00\x00\x01")
|
||||
param.peerhost = '::1'
|
||||
else
|
||||
param.peerhost = '::ffff:' + Rex::Socket.getaddress(param.peerhost)
|
||||
param.peerhost = '::ffff:' + Rex::Socket.getaddress(param.peerhost, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ module Rex::Socket::Udp
|
|||
# Catch unconnected IPv6 sockets talking to IPv4 addresses
|
||||
peer = Rex::Socket.resolv_nbo(peerhost)
|
||||
if (peer.length == 4 and self.ipv == 6)
|
||||
peerhost = Rex::Socket.getaddress(peerhost)
|
||||
peerhost = Rex::Socket.getaddress(peerhost, true)
|
||||
if peerhost[0,7].downcase != '::ffff:'
|
||||
peerhost = '::ffff:' + peerhost
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue