Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed winreg parser to better handle corrupt keys #3572

Merged
merged 1 commit into from
Apr 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions plaso/parsers/winreg_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,29 @@ def _ParseKey(self, parser_mediator, registry_key):
if matching_plugin:
self._ParseKeyWithPlugin(parser_mediator, registry_key, matching_plugin)

def _ParseRecurseKeys(self, parser_mediator, root_key):
def _ParseRecurseKeys(self, parser_mediator, registry_key):
"""Parses the Registry keys recursively.

Args:
parser_mediator (ParserMediator): parser mediator.
root_key (dfwinreg.WinRegistryKey): root Windows Registry key.
registry_key (dfwinreg.WinRegistryKey): Windows Registry key.
"""
for registry_key in root_key.RecurseKeys():
# Note that we do not use dfWinReg generators here to be able to catch
# exceptions raised by corrupt files.

self._ParseKey(parser_mediator, registry_key)

for subkey_index in range(registry_key.number_of_subkeys):
if parser_mediator.abort:
break

self._ParseKey(parser_mediator, registry_key)
try:
subkey = registry_key.GetSubkeyByIndex(subkey_index)
except IOError as exception:
parser_mediator.ProduceExtractionWarning(
'in key: {0:s} error: {1!s}'.format(registry_key.path, exception))

self._ParseRecurseKeys(parser_mediator, subkey)

def _ParseKeysFromFindSpecs(self, parser_mediator, win_registry, find_specs):
"""Parses the Registry keys from FindSpecs.
Expand Down