diff --git a/lib/metasploit/framework/login_scanner/ssh.rb b/lib/metasploit/framework/login_scanner/ssh.rb index bdaa46c881..34984229b6 100644 --- a/lib/metasploit/framework/login_scanner/ssh.rb +++ b/lib/metasploit/framework/login_scanner/ssh.rb @@ -94,7 +94,12 @@ module Metasploit unless result_options.has_key? :status if ssh_socket - proof = gather_proof unless skip_gather_proof + begin + proof = gather_proof unless skip_gather_proof + rescue StandardError => e + elog('Failed to gather SSH proof', error: e) + proof = nil + end result_options.merge!(status: Metasploit::Model::Login::Status::SUCCESSFUL, proof: proof) else result_options.merge!(status: Metasploit::Model::Login::Status::INCORRECT, proof: nil) diff --git a/modules/auxiliary/scanner/ssh/ssh_login.rb b/modules/auxiliary/scanner/ssh/ssh_login.rb index 22293c2715..50dc278a09 100644 --- a/modules/auxiliary/scanner/ssh/ssh_login.rb +++ b/modules/auxiliary/scanner/ssh/ssh_login.rb @@ -126,7 +126,16 @@ class MetasploitModule < Msf::Auxiliary credential_core = create_credential(credential_data) credential_data[:core] = credential_core create_credential_login(credential_data) - session_setup(result, scanner) if datastore['CreateSession'] + + if datastore['CreateSession'] + begin + session_setup(result, scanner) + rescue StandardError => e + elog('Failed to setup the session', error: e) + print_brute :level => :error, :ip => ip, :msg => "Failed to setup the session - #{e.class} #{e.message}" + end + end + if datastore['GatherProof'] && scanner.get_platform(result.proof) == 'unknown' msg = "While a session may have opened, it may be bugged. If you experience issues with it, re-run this module with" msg << " 'set gatherproof false'. Also consider submitting an issue at github.com/rapid7/metasploit-framework with"