Skip to content

Commit f408bca

Browse files
committed
More correct exception handling
1 parent 1473f2c commit f408bca

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modules/auxiliary/scanner/rsync/modules_list.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ class Metasploit3 < Msf::Auxiliary
1111
include Msf::Auxiliary::Report
1212

1313
RSYNC_HEADER = '@RSYNCD:'
14+
HANDLED_EXCEPTIONS = [
15+
Rex::AddressInUse, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused,
16+
::Errno::ETIMEDOUT, ::Timeout::Error, ::EOFError
17+
]
1418

1519
def initialize
1620
super(
@@ -153,7 +157,7 @@ def run_host(ip)
153157
disconnect
154158
return
155159
end
156-
rescue => e
160+
rescue *HANDLED_EXCEPTIONS => e
157161
vprint_error("#{peer} - error while connecting and negotiating: #{e}")
158162
disconnect
159163
return
@@ -174,7 +178,7 @@ def run_host(ip)
174178
modules_metadata = {}
175179
begin
176180
modules_metadata = rsync_list
177-
rescue => e
181+
rescue *HANDLED_EXCEPTIONS => e
178182
vprint_error("#{peer} -- error while listing modules: #{e}")
179183
return
180184
ensure
@@ -195,8 +199,9 @@ def run_host(ip)
195199
connect
196200
rsync_negotiate
197201
module_metadata[:authentication] = get_rsync_auth_status(module_metadata[:name])
198-
rescue => e
202+
rescue *HANDLED_EXCEPTIONS => e
199203
vprint_error("#{peer} - error while testing authentication on #{module_metadata[:name]}: #{e}")
204+
break
200205
ensure
201206
disconnect
202207
end

0 commit comments

Comments
 (0)