Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Catch exception from net/ssh/connection/session.rb:381 #16309

Merged
merged 3 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/metasploit/framework/login_scanner/ssh.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ def attempt_login(credential)

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)
Expand Down
11 changes: 10 additions & 1 deletion modules/auxiliary/scanner/ssh/ssh_login.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,16 @@ def run_host(ip)
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"
Expand Down