Skip to content

Commit

Permalink
IIS parser: Added additional characters for cs(Cookie) field
Browse files Browse the repository at this point in the history
  • Loading branch information
pyllyukko committed Oct 11, 2024
1 parent fdc687c commit d3a3260
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plaso/parsers/text_plugins/iis.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ class WinIISTextPlugin(interface.TextPlugin):
_UA = pyparsing.Word(
pyparsing.alphanums + _URI_SAFE_CHARACTERS + '[]') | _BLANK

_COOKIE = pyparsing.Word(pyparsing.alphanums + _URI_SAFE_CHARACTERS + '@{}"\\') | _BLANK

# Per https://blogs.iis.net/nazim/use-of-special-characters-like-in-an-iis-url
# IIS does not require that a query comply with RFC1738 restrictions on valid
# URI characters
Expand Down Expand Up @@ -204,7 +206,7 @@ class WinIISTextPlugin(interface.TextPlugin):
_LOG_LINE_STRUCTURES['time-taken'] = _INTEGER.set_results_name('time_taken')
_LOG_LINE_STRUCTURES['cs-version'] = _URI.set_results_name('protocol_version')
_LOG_LINE_STRUCTURES['cs-host'] = _URI.set_results_name('cs_host')
_LOG_LINE_STRUCTURES['cs(Cookie)'] = _URI.set_results_name('cs_cookie')
_LOG_LINE_STRUCTURES['cs(Cookie)'] = _COOKIE.set_results_name('cs_cookie')
_LOG_LINE_STRUCTURES['cs(Referrer)'] = _URI.set_results_name('cs_referrer')
_LOG_LINE_STRUCTURES['cs(Referer)'] = _URI.set_results_name('cs_referrer')

Expand Down
7 changes: 7 additions & 0 deletions test_data/iis10_cookies.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#Date: 2021-04-01 00:00:21
#Fields: date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) cs(Cookie) cs(Referer) sc-status sc-substatus sc-win32-status time-taken
#Software: Microsoft Internet Information Services 10.0
#Version: 1.0
2021-04-01 00:00:21 111.111.111.111 GET /foo/bar/baz.asp - 80 - 222.222.222.222 Mozilla/5.0+(Windows+NT+5.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/35.0.2309.372+Safari/537.36 OutlookSession="{AAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE}" http://111.111.111.111/ 200 0 0 65
2021-04-01 00:00:21 111.111.111.111 GET /foo/bar/baz.asp - 80 - 222.222.222.222 Mozilla/5.0+(Windows+NT+5.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/35.0.2309.372+Safari/537.36 username=realm\user http://111.111.111.111/ 200 0 0 65
2021-04-01 00:00:21 111.111.111.111 GET /foo/bar/baz.asp - 80 - 222.222.222.222 Mozilla/5.0+(Windows+NT+5.1)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/35.0.2309.372+Safari/537.36 username=realm@user http://111.111.111.111/ 200 0 0 65
17 changes: 17 additions & 0 deletions tests/parsers/text_plugins/iis.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,23 @@ def testProcessWithIIS10Log(self):
'recovery_warning')
self.assertEqual(number_of_warnings, 0)

"""Tests the Process function with an IIS 10 log file with cs(Cookie) field."""
plugin = iis.WinIISTextPlugin()
storage_writer = self._ParseTextFileWithPlugin(
['iis10_cookies.log'], plugin)

number_of_event_data = storage_writer.GetNumberOfAttributeContainers(
'event_data')
self.assertEqual(number_of_event_data, 3)

number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
'extraction_warning')
self.assertEqual(number_of_warnings, 0)

number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
'recovery_warning')
self.assertEqual(number_of_warnings, 0)


if __name__ == '__main__':
unittest.main()

0 comments on commit d3a3260

Please sign in to comment.