Skip to content

Commit 9edb2b4

Browse files
committed
Fix rapid7#4378 - Do exception handling
Fix rapid7#4378
1 parent 4c714b3 commit 9edb2b4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

modules/auxiliary/scanner/rdp/ms12_020_check.rb

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,7 @@ def peer
128128
"#{rhost}:#{rport}"
129129
end
130130

131-
def run_host(ip)
132-
133-
connect
134-
131+
def check_rdp_vuln
135132
# check if rdp is open
136133
if not check_rdp
137134
vprint_status "#{peer} Could not connect to RDP."
@@ -168,8 +165,20 @@ def run_host(ip)
168165
else
169166
vprint_status("#{peer} Not Vulnerable")
170167
end
168+
end
171169

172-
disconnect()
170+
def run_host(ip)
171+
begin
172+
connect
173+
check_rdp_vuln
174+
rescue Rex::AddressInUse, ::Errno::ETIMEDOUT, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused, ::Timeout::Error, ::EOFError => e
175+
bt = e.backtrace.join("\n")
176+
print_error("Unexpected error: #{e.message}")
177+
vprint_line(bt)
178+
elog("#{e.message}\n#{bt}")
179+
ensure
180+
disconnect
181+
end
173182
end
174183

175184
end

0 commit comments

Comments
 (0)