Land #9694, move ssh platforms to lib
commit
65ae1e33e1
|
@ -146,6 +146,33 @@ module Metasploit
|
||||||
self.verbosity = :fatal if self.verbosity.nil?
|
self.verbosity = :fatal if self.verbosity.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
public
|
||||||
|
|
||||||
|
def get_platform(proof)
|
||||||
|
case proof
|
||||||
|
when /Linux/
|
||||||
|
'linux'
|
||||||
|
when /Darwin/
|
||||||
|
'osx'
|
||||||
|
when /SunOS/
|
||||||
|
'solaris'
|
||||||
|
when /BSD/
|
||||||
|
'bsd'
|
||||||
|
when /HP-UX/
|
||||||
|
'hpux'
|
||||||
|
when /AIX/
|
||||||
|
'aix'
|
||||||
|
when /Win32|Windows/
|
||||||
|
'windows'
|
||||||
|
when /Unknown command or computer name/
|
||||||
|
'cisco-ios'
|
||||||
|
when /unknown keyword/ # ScreenOS
|
||||||
|
'juniper'
|
||||||
|
when /JUNOS Base OS/ #JunOS
|
||||||
|
'juniper'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,11 +53,11 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
datastore['RPORT']
|
datastore['RPORT']
|
||||||
end
|
end
|
||||||
|
|
||||||
def session_setup(result, ssh_socket)
|
def session_setup(result, scanner)
|
||||||
return unless ssh_socket
|
return unless scanner.ssh_socket
|
||||||
|
|
||||||
# Create a new session
|
# Create a new session
|
||||||
conn = Net::SSH::CommandStream.new(ssh_socket)
|
conn = Net::SSH::CommandStream.new(scanner.ssh_socket)
|
||||||
|
|
||||||
merge_me = {
|
merge_me = {
|
||||||
'USERPASS_FILE' => nil,
|
'USERPASS_FILE' => nil,
|
||||||
|
@ -68,31 +68,10 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
}
|
}
|
||||||
info = "#{proto_from_fullname} #{result.credential} (#{@ip}:#{rport})"
|
info = "#{proto_from_fullname} #{result.credential} (#{@ip}:#{rport})"
|
||||||
s = start_session(self, info, merge_me, false, conn.lsock)
|
s = start_session(self, info, merge_me, false, conn.lsock)
|
||||||
self.sockets.delete(ssh_socket.transport.socket)
|
self.sockets.delete(scanner.ssh_socket.transport.socket)
|
||||||
|
|
||||||
# Set the session platform
|
# Set the session platform
|
||||||
case result.proof
|
s.platform = scanner.get_platform(result.proof)
|
||||||
when /Linux/
|
|
||||||
s.platform = "linux"
|
|
||||||
when /Darwin/
|
|
||||||
s.platform = "osx"
|
|
||||||
when /SunOS/
|
|
||||||
s.platform = "solaris"
|
|
||||||
when /BSD/
|
|
||||||
s.platform = "bsd"
|
|
||||||
when /HP-UX/
|
|
||||||
s.platform = "hpux"
|
|
||||||
when /AIX/
|
|
||||||
s.platform = "aix"
|
|
||||||
when /Win32|Windows/
|
|
||||||
s.platform = "windows"
|
|
||||||
when /Unknown command or computer name/
|
|
||||||
s.platform = "cisco-ios"
|
|
||||||
when /unknown keyword/ # ScreenOS
|
|
||||||
s.platform = "juniper"
|
|
||||||
when /JUNOS Base OS/ #JunOS
|
|
||||||
s.platform = "juniper"
|
|
||||||
end
|
|
||||||
|
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
@ -140,7 +119,7 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
credential_core = create_credential(credential_data)
|
credential_core = create_credential(credential_data)
|
||||||
credential_data[:core] = credential_core
|
credential_data[:core] = credential_core
|
||||||
create_credential_login(credential_data)
|
create_credential_login(credential_data)
|
||||||
session_setup(result, scanner.ssh_socket)
|
session_setup(result, scanner)
|
||||||
:next_user
|
:next_user
|
||||||
when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
|
when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
|
||||||
vprint_brute :level => :verror, :ip => ip, :msg => "Could not connect: #{result.proof}"
|
vprint_brute :level => :verror, :ip => ip, :msg => "Could not connect: #{result.proof}"
|
||||||
|
|
|
@ -68,11 +68,11 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
datastore['RHOST']
|
datastore['RHOST']
|
||||||
end
|
end
|
||||||
|
|
||||||
def session_setup(result, ssh_socket, fingerprint)
|
def session_setup(result, scanner, fingerprint)
|
||||||
return unless ssh_socket
|
return unless scanner.ssh_socket
|
||||||
|
|
||||||
# Create a new session from the socket
|
# Create a new session from the socket
|
||||||
conn = Net::SSH::CommandStream.new(ssh_socket)
|
conn = Net::SSH::CommandStream.new(scanner.ssh_socket)
|
||||||
|
|
||||||
# Clean up the stored data - need to stash the keyfile into
|
# Clean up the stored data - need to stash the keyfile into
|
||||||
# a datastore for later reuse.
|
# a datastore for later reuse.
|
||||||
|
@ -87,31 +87,10 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
|
|
||||||
info = "SSH #{result.credential.public}:#{fingerprint} (#{ip}:#{rport})"
|
info = "SSH #{result.credential.public}:#{fingerprint} (#{ip}:#{rport})"
|
||||||
s = start_session(self, info, merge_me, false, conn.lsock)
|
s = start_session(self, info, merge_me, false, conn.lsock)
|
||||||
self.sockets.delete(ssh_socket.transport.socket)
|
self.sockets.delete(scanner.ssh_socket.transport.socket)
|
||||||
|
|
||||||
# Set the session platform
|
# Set the session platform
|
||||||
case result.proof
|
s.platform = scanner.get_platform(result.proof)
|
||||||
when /Linux/
|
|
||||||
s.platform = "linux"
|
|
||||||
when /Darwin/
|
|
||||||
s.platform = "osx"
|
|
||||||
when /SunOS/
|
|
||||||
s.platform = "solaris"
|
|
||||||
when /BSD/
|
|
||||||
s.platform = "bsd"
|
|
||||||
when /HP-UX/
|
|
||||||
s.platform = "hpux"
|
|
||||||
when /AIX/
|
|
||||||
s.platform = "aix"
|
|
||||||
when /Win32|Windows/
|
|
||||||
s.platform = "windows"
|
|
||||||
when /Unknown command or computer name/
|
|
||||||
s.platform = "cisco-ios"
|
|
||||||
when /unknown keyword/ # ScreenOS
|
|
||||||
s.platform = "juniper"
|
|
||||||
when /JUNOS Base OS/ #JunOS
|
|
||||||
s.platform = "juniper"
|
|
||||||
end
|
|
||||||
|
|
||||||
s
|
s
|
||||||
end
|
end
|
||||||
|
@ -164,7 +143,7 @@ class MetasploitModule < Msf::Auxiliary
|
||||||
create_credential_login(credential_data)
|
create_credential_login(credential_data)
|
||||||
tmp_key = result.credential.private
|
tmp_key = result.credential.private
|
||||||
ssh_key = SSHKey.new tmp_key
|
ssh_key = SSHKey.new tmp_key
|
||||||
session_setup(result, scanner.ssh_socket, ssh_key.fingerprint)
|
session_setup(result, scanner, ssh_key.fingerprint)
|
||||||
:next_user
|
:next_user
|
||||||
when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
|
when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT
|
||||||
if datastore['VERBOSE']
|
if datastore['VERBOSE']
|
||||||
|
|
Loading…
Reference in New Issue