More correct exception handling

bug/bundler_fix
Jon Hart 2015-11-06 12:25:27 -08:00
parent 1473f2cfa7
commit f408bca3f0
No known key found for this signature in database
GPG Key ID: 2FA9F0A3AFA8E9D3
1 changed files with 8 additions and 3 deletions

View File

@ -11,6 +11,10 @@ class Metasploit3 < Msf::Auxiliary
include Msf::Auxiliary::Report
RSYNC_HEADER = '@RSYNCD:'
HANDLED_EXCEPTIONS = [
Rex::AddressInUse, Rex::HostUnreachable, Rex::ConnectionTimeout, Rex::ConnectionRefused,
::Errno::ETIMEDOUT, ::Timeout::Error, ::EOFError
]
def initialize
super(
@ -153,7 +157,7 @@ class Metasploit3 < Msf::Auxiliary
disconnect
return
end
rescue => e
rescue *HANDLED_EXCEPTIONS => e
vprint_error("#{peer} - error while connecting and negotiating: #{e}")
disconnect
return
@ -174,7 +178,7 @@ class Metasploit3 < Msf::Auxiliary
modules_metadata = {}
begin
modules_metadata = rsync_list
rescue => e
rescue *HANDLED_EXCEPTIONS => e
vprint_error("#{peer} -- error while listing modules: #{e}")
return
ensure
@ -195,8 +199,9 @@ class Metasploit3 < Msf::Auxiliary
connect
rsync_negotiate
module_metadata[:authentication] = get_rsync_auth_status(module_metadata[:name])
rescue => e
rescue *HANDLED_EXCEPTIONS => e
vprint_error("#{peer} - error while testing authentication on #{module_metadata[:name]}: #{e}")
break
ensure
disconnect
end