forked from log2timeline/plaso
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved EventLog message string formatting to helper log2timeline#4169
- Loading branch information
1 parent
134e4ee
commit 2bd81ce
Showing
26 changed files
with
216 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Windows EventLog custom event formatter helpers.""" | ||
|
||
from plaso.formatters import interface | ||
from plaso.formatters import logger | ||
from plaso.formatters import manager | ||
|
||
|
||
class WindowsEventLogMessageFormatterHelper( | ||
interface.CustomEventFormatterHelper): | ||
"""Windows EventLog message formatter helper.""" | ||
|
||
IDENTIFIER = 'windows_eventlog_message' | ||
|
||
def __init__(self): | ||
"""Initialized a indows EventLog message formatter helper.""" | ||
super(WindowsEventLogMessageFormatterHelper, self).__init__() | ||
self._winevt_resources_helper = None | ||
|
||
def FormatEventValues(self, output_mediator, event_values): | ||
"""Formats event values using the helper. | ||
Args: | ||
output_mediator (OutputMediator): output mediator. | ||
event_values (dict[str, object]): event values. | ||
""" | ||
if not self._winevt_resources_helper: | ||
self._winevt_resources_helper = output_mediator.GetWinevtResourcesHelper() | ||
|
||
message_string = None | ||
provider_identifier = event_values.get('provider_identifier', None) | ||
source_name = event_values.get('source_name', None) | ||
message_identifier = event_values.get('message_identifier', None) | ||
event_version = event_values.get('event_version', None) | ||
if (provider_identifier or source_name) and message_identifier: | ||
message_string_template = self._winevt_resources_helper.GetMessageString( | ||
provider_identifier, source_name, message_identifier, event_version) | ||
if message_string_template: | ||
string_values = [ | ||
string or '' for string in event_values.get('strings', [])] | ||
|
||
try: | ||
message_string = message_string_template.format(*string_values) | ||
except (IndexError, TypeError) as exception: | ||
logger.error(( | ||
'Unable to format message: 0x{0:08x} of provider: {1:s} ' | ||
'template: "{2:s}" and strings: "{3:s}" with error: ' | ||
'{4!s}').format( | ||
message_identifier, provider_identifier or '', | ||
message_string_template, ', '.join(string_values), exception)) | ||
# Unable to create the message string. | ||
# TODO: consider returning the unformatted message string. | ||
|
||
event_values['message_string'] = message_string | ||
|
||
|
||
manager.FormattersManager.RegisterEventFormatterHelper( | ||
WindowsEventLogMessageFormatterHelper) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.