Skip to content

Commit 03e14ec

Browse files
committed
Land rapid7#7232, Net::SSH Regression Fixes
Fixes rapid7#7160 Fixes rapid7#7175 Fixes rapid7#7229
2 parents 95b8221 + 20947cd commit 03e14ec

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

lib/msf/core/exploit/ssh.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Msf
22
module Exploit::Remote::SSH
3+
require 'rex/socket/ssh_factory'
34
def ssh_socket_factory
45
Rex::Socket::SSHFactory.new(framework, self, datastore['Proxies'])
56
end

modules/auxiliary/scanner/ssh/ssh_login_pubkey.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
require 'net/ssh'
88
require 'metasploit/framework/login_scanner/ssh'
99
require 'metasploit/framework/credential_collection'
10+
require 'sshkey'
11+
require 'net/ssh/command_stream'
1012

1113
class MetasploitModule < Msf::Auxiliary
1214

@@ -140,7 +142,7 @@ def pull_cleartext_keys(keys)
140142
return cleartext_keys
141143
end
142144

143-
def session_setup(result, ssh_socket)
145+
def session_setup(result, ssh_socket, fingerprint)
144146
return unless ssh_socket
145147

146148
# Create a new session from the socket
@@ -157,7 +159,7 @@ def session_setup(result, ssh_socket)
157159
'KEY_PATH' => nil
158160
}
159161

160-
info = "SSH #{result.credential.public}:#{ssh_socket.auth_info[:pubkey_id]} (#{ip}:#{rport})"
162+
info = "SSH #{result.credential.public}:#{fingerprint} (#{ip}:#{rport})"
161163
s = start_session(self, info, merge_me, false, conn.lsock)
162164
self.sockets.delete(ssh_socket.transport.socket)
163165

@@ -229,7 +231,9 @@ def run_host(ip)
229231
credential_core = create_credential(credential_data)
230232
credential_data[:core] = credential_core
231233
create_credential_login(credential_data)
232-
session_setup(result, scanner.ssh_socket)
234+
tmp_key = result.credential.private
235+
ssh_key = SSHKey.new tmp_key
236+
session_setup(result, scanner.ssh_socket, ssh_key.fingerprint)
233237
:next_user
234238
when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
235239
if datastore['VERBOSE']

0 commit comments

Comments
 (0)