Skip to content

Commit f24124b

Browse files
authored
Changes for Windows user account without profile #4891 (#4892)
1 parent 2ad42e3 commit f24124b

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

plaso/parsers/text_plugins/interface.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def _ParseString(self, string):
266266
raise errors.ParseError('No match found.')
267267

268268
if start > 0 and '\n' in string[:start + 1]:
269-
raise errors.ParseError('Found a line preceeding match.')
269+
raise errors.ParseError('Found a line preceding match.')
270270

271271
# Unwrap the line structure and retrieve its name (key).
272272
keys = list(structure.keys())

plaso/preprocessors/mediator.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ def AddUserAccount(self, user_account):
112112
Raises:
113113
KeyError: if the user account already exists.
114114
"""
115-
logger.debug(f'adding user account: {user_account.username:s}')
115+
if not user_account.username:
116+
logger.debug(f'adding user account: {user_account.identifier:s}')
117+
else:
118+
logger.debug(
119+
f'adding user account: {user_account.username:s} '
120+
f'({user_account.identifier:s})')
116121

117122
if self._storage_writer:
118123
self._storage_writer.AddAttributeContainer(user_account)

plaso/preprocessors/windows.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -903,21 +903,24 @@ def _ParseKey(self, mediator, registry_key, value_name):
903903
identifier=registry_key.name, path_separator='\\')
904904

905905
registry_value = registry_key.GetValueByName('ProfileImagePath')
906-
if not registry_value:
907-
username = 'N/A'
908-
else:
906+
if registry_value:
909907
profile_path = registry_value.GetDataAsObject()
908+
910909
username = self._GetUsernameFromProfilePath(profile_path)
910+
if profile_path and not username:
911+
mediator.ProducePreprocessingWarning(self.ARTIFACT_DEFINITION_NAME, (
912+
f'Unable to determine username from profile path: '
913+
f'"{profile_path!s}"'))
911914

912915
user_account.user_directory = profile_path or None
913916
user_account.username = username or None
914917

915918
try:
916919
mediator.AddUserAccount(user_account)
917920
except KeyError:
918-
mediator.ProducePreprocessingWarning(
919-
self.ARTIFACT_DEFINITION_NAME,
920-
f'Unable to add user account: "{username!s}" to knowledge base')
921+
mediator.ProducePreprocessingWarning(self.ARTIFACT_DEFINITION_NAME, (
922+
f'Unable to add user account: "{user_account.identifier:s}" to '
923+
f'knowledge base'))
921924

922925

923926
class WindowsWinDirEnvironmentVariablePlugin(

tests/preprocessors/windows.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,9 @@ def testParseKey(self):
713713
user_account = storage_writer.GetAttributeContainerByIndex(
714714
'user_account', 9)
715715

716-
expected_sid = 'S-1-5-21-2036804247-3058324640-2116585241-1114'
717-
self.assertEqual(user_account.identifier, expected_sid)
716+
self.assertEqual(
717+
user_account.identifier,
718+
'S-1-5-21-2036804247-3058324640-2116585241-1114')
718719
self.assertEqual(user_account.username, 'rsydow')
719720
self.assertEqual(user_account.user_directory, 'C:\\Users\\rsydow')
720721

0 commit comments

Comments
 (0)