Skip to content

Commit bed40a8

Browse files
author
Brent Cook
committed
fix rapid7#4337: gracefully handle resolve_sid failure when enumerating user profiles
Rather than throwing a backtrace with an unresolvable SID, try to get as much profile data as possible if resolve_sid fails. ``` [*] Determining session platform and type... [-] Unexpected windows error 1332 [*] Checking for Firefox directory in: C:\Users\Administrator\AppData\Roaming\Mozilla\ [-] Firefox not found [*] Post module execution completed ```
1 parent b90639f commit bed40a8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/msf/core/post/windows/user_profiles.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ def parse_profiles(hives)
4949
#
5050
def parse_profile(hive)
5151
profile={}
52-
sidinf = resolve_sid(hive['SID'].to_s)
53-
profile['UserName'] = sidinf[:name]
54-
profile['Domain'] = sidinf[:domain]
5552
profile['SID'] = hive['SID']
5653
profile['ProfileDir'] = hive['PROF']
5754
profile['AppData'] = registry_getvaldata("#{hive['HKU']}\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", 'AppData')
@@ -65,6 +62,12 @@ def parse_profile(hive)
6562
profile['Temp'] = registry_getvaldata("#{hive['HKU']}\\Environment", 'TEMP').to_s.sub('%USERPROFILE%',profile['ProfileDir'])
6663
profile['Path'] = registry_getvaldata("#{hive['HKU']}\\Environment", 'PATH')
6764

65+
sidinf = resolve_sid(hive['SID'].to_s)
66+
if sidinf
67+
profile['UserName'] = sidinf[:name]
68+
profile['Domain'] = sidinf[:domain]
69+
end
70+
6871
return profile
6972
end
7073

0 commit comments

Comments
 (0)