Skip to content

Commit c2f603d

Browse files
author
=
committed
Issue rapid7#7188 resolved along with checking for all loopback addresses
1 parent 4005e4f commit c2f603d

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

lib/msf/core/handler/reverse.rb

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,18 @@ def bind_addresses
4848

4949
addrs
5050
end
51+
#Function to check for loopback addresses
52+
def loopback_addr(addr)
53+
begin
54+
a=IPAddr.new(addr.to_s)
55+
return true if
56+
IPAddr.new('127.0.0.1/8') === a
57+
return true if IPAddr.new('::1') ==a
58+
rescue
59+
end
60+
false
61+
end
62+
5163

5264
# @return [Integer]
5365
def bind_port
@@ -82,10 +94,11 @@ def setup_handler
8294
'MsfPayload' => self,
8395
'MsfExploit' => assoc_exploit
8496
})
85-
86-
if (ip=='127.0.0.1' || ip=='127.0.0.2' || ip=='127.0.0.3' || ip=='127.0.0.4'|| ip=='127.0.0.5'||ip=='127.0.0.6' || ip=='127.0.0.7' || ip=='127.0.0.8')
87-
print_error("Please note that errors might be experienced with this choice of address for LHOST.")
88-
end
97+
#Checking whether LHOST is a loopback address
98+
if loopback_addr(ip) ==true
99+
print_warning ("You are attempting to listen on a loopback address by setting LHOST to #{ip}, did you mean to set ReverseListenerBindAddress instead?\n")
100+
end
101+
89102
rescue
90103
ex = $!
91104
print_error("Handler failed to bind to #{ip}:#{local_port}:- #{comm} -")

0 commit comments

Comments
 (0)