@@ -17,59 +17,58 @@ def initialize(info={})
17
17
'Name' => 'Windows Gather Enum User MUICache' ,
18
18
'Description' =>
19
19
%q{
20
- This module gathers information about the files and file paths that
21
- logged on users have executed on the system and it will also check
22
- if the file still exists on the system in the file path it has been
23
- previously executed. This information is gathered by using information
24
- stored under the MUICache registry key. If the user is logged in when the
25
- module is executed it will collect the MUICache entries by accessing
26
- the registry directly. If the user is not logged in the module will
27
- download users registry hive NTUSER.DAT/UsrClass.dat from the system
28
- and the MUICache contents are parsed from the downloaded hive.
29
- } ,
30
- 'License' => MSF_LICENSE ,
31
- 'Author' => [ 'TJ Glad <tjglad[at]cmail.nu>' ] ,
32
- 'Platform' => [ 'win' ] ,
33
- 'SessionType' => [ 'meterpreter' ]
34
- ) )
20
+ This module gathers information about the files and file paths that logged on users have
21
+ executed on the system. It also will check if the file exists on the system still. This
22
+ information is gathered by using information stored under the MUICache registry key. If
23
+ the user is logged in when the module is executed it will collect the MUICache entries
24
+ by accessing the registry directly. If the user is not logged in the module will download
25
+ users registry hive NTUSER.DAT/UsrClass.dat from the system and the MUICache contents are
26
+ parsed from the downloaded hive.
27
+ } ,
28
+ 'License' => MSF_LICENSE ,
29
+ 'Author' => [ 'TJ Glad <tjglad[at]cmail.nu>' ] ,
30
+ 'Platform' => [ 'win' ] ,
31
+ 'SessionType' => [ 'meterpreter' ]
32
+ ) )
35
33
end
36
34
37
- def find_usernames ( )
35
+ def find_user_names ( )
38
36
# This function scrapes usernames, sids and homepaths from the
39
37
# registry so that we'll know what user accounts are on the system
40
38
# and where we can find those users registry hives.
41
- usernames = Array . new
42
- user_homedir_paths = Array . new
43
- user_sids = Array . new
39
+ user_names = [ ]
40
+ user_homedir_paths = [ ]
41
+ user_sids = [ ]
44
42
45
43
username_reg_path = "HKLM\\ Software\\ Microsoft\\ Windows\ NT\\ CurrentVersion\\ ProfileList"
46
44
profile_subkeys = registry_enumkeys ( username_reg_path )
47
45
if profile_subkeys . blank?
48
46
print_error ( "Unable to access ProfileList registry key. Can't continue." )
49
47
return nil
50
- else
51
- profile_subkeys . each do |user_sid |
52
- if user_sid . length > 10
53
- user_home_path = registry_getvaldata ( "#{ username_reg_path } \\ #{ user_sid } " , "ProfileImagePath" )
54
- unless user_home_path . blank?
55
- full_path = user_home_path . strip
56
- usernames << full_path . split ( "\\ " ) . last
57
- user_homedir_paths << full_path
58
- user_sids << user_sid
59
- else
60
- print_error ( "Unable to read ProfileImagePath from the registry. Can't continue." )
61
- return nil
62
- end
63
- end
48
+ end
49
+
50
+ profile_subkeys . each do |user_sid |
51
+ unless user_sid . length > 10
52
+ next
64
53
end
54
+ user_home_path = registry_getvaldata ( "#{ username_reg_path } \\ #{ user_sid } " , "ProfileImagePath" )
55
+ if user_home_path . blank?
56
+ print_error ( "Unable to read ProfileImagePath from the registry. Can't continue." )
57
+ return nil
58
+ end
59
+ full_path = user_home_path . strip
60
+ user_names << full_path . split ( "\\ " ) . last
61
+ user_homedir_paths << full_path
62
+ user_sids << user_sid
65
63
end
66
- return usernames , user_homedir_paths , user_sids
64
+
65
+ return user_names , user_homedir_paths , user_sids
67
66
end
68
67
69
68
def enum_muicache_paths ( sys_sids , mui_path )
70
69
# This function builds full registry muicache paths so that we can
71
70
# later enumerate the muicahe registry key contents.
72
- user_mui_paths = Array . new
71
+ user_mui_paths = [ ]
73
72
hive = "HKU\\ "
74
73
sys_sids . each do |sid |
75
74
full_path = hive + sid + mui_path
@@ -114,13 +113,11 @@ def check_file_exists(key, user, table)
114
113
# if it detects the executable but it should be otherwise fairly
115
114
# reliable.
116
115
program_path = expand_path ( key )
117
- program_exists = file_exist? ( key )
118
- if program_exists == true
119
- exists = "File found"
116
+ if file_exist? ( key )
117
+ table << [ user , program_path , "File found" ]
120
118
else
121
- exists = "File not found"
119
+ table << [ user , program_path , "File not found" ]
122
120
end
123
- table << [ user , program_path , exists ]
124
121
end
125
122
126
123
def process_hive ( sys_path , user , local_hive_copy , table , muicache , hive_file )
@@ -211,10 +208,10 @@ def hive_parser(local_hive_copy, muicache, user, table)
211
208
return table
212
209
end
213
210
214
- def print_usernames ( sys_users )
211
+ def print_user_names ( sys_users )
215
212
# This prints usernames pulled from the paths found from the
216
213
# registry.
217
- user_list = Array . new
214
+ user_list = [ ]
218
215
sys_users . each do |user |
219
216
user_list << user
220
217
end
@@ -232,14 +229,14 @@ def run
232
229
# - http://www.irongeek.com/i.php?page=security/windows-forensics-registry-and-file-system-spots
233
230
234
231
print_status ( "Starting to enumerate MuiCache registry keys.." )
235
- sysnfo = sysinfo [ 'OS' ]
232
+ sys_info = sysinfo [ 'OS' ]
236
233
237
- if sysnfo =~/( Windows XP)/ and is_admin?
238
- print_good ( "Remote system supported: #{ sysnfo } " )
234
+ if sys_info =~/Windows XP/ && is_admin?
235
+ print_good ( "Remote system supported: #{ sys_info } " )
239
236
muicache = "\\ Software\\ Microsoft\\ Windows\\ ShellNoRoam\\ MUICache"
240
237
hive_file = "\\ NTUSER.DAT"
241
- elsif sysnfo =~/( Windows 7)/ and is_admin?
242
- print_good ( "Remote system supported: #{ sysnfo } " )
238
+ elsif sys_info =~/Windows 7/ && is_admin?
239
+ print_good ( "Remote system supported: #{ sys_info } " )
243
240
muicache = "_Classes\\ Local\ Settings\\ Software\\ Microsoft\\ Windows\\ Shell\\ MuiCache"
244
241
hive_file = "\\ AppData\\ Local\\ Microsoft\\ Windows\\ UsrClass.dat"
245
242
else
@@ -258,12 +255,13 @@ def run
258
255
] )
259
256
260
257
print_status ( "Phase 1: Searching usernames.." )
261
- sys_users , sys_paths , sys_sids = find_usernames ( )
262
- unless sys_users . blank?
263
- print_usernames ( sys_users )
264
- else
258
+ sys_users , sys_paths , sys_sids = find_user_names ( )
259
+
260
+ if sys_users . blank?
265
261
print_error ( "Was not able to find any user accounts. Unable to continue." )
266
262
return nil
263
+ else
264
+ print_user_names ( sys_users )
267
265
end
268
266
269
267
print_status ( "Phase 2: Searching registry hives.." )
0 commit comments