Skip to content

Commit 868aa0f

Browse files
authored
Changed IIS parser to support cs(Cookie) field (#4911)
1 parent 8b43a72 commit 868aa0f

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

plaso/parsers/text_plugins/iis.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class WinIISTextPlugin(interface.TextPlugin):
114114
_UA = pyparsing.Word(
115115
pyparsing.alphanums + _URI_SAFE_CHARACTERS + '[]') | _BLANK
116116

117+
_COOKIE = pyparsing.Word(
118+
pyparsing.alphanums + _URI_SAFE_CHARACTERS + '@{}"\\') | _BLANK
119+
117120
# Per https://blogs.iis.net/nazim/use-of-special-characters-like-in-an-iis-url
118121
# IIS does not require that a query comply with RFC1738 restrictions on valid
119122
# URI characters
@@ -204,7 +207,7 @@ class WinIISTextPlugin(interface.TextPlugin):
204207
_LOG_LINE_STRUCTURES['time-taken'] = _INTEGER.set_results_name('time_taken')
205208
_LOG_LINE_STRUCTURES['cs-version'] = _URI.set_results_name('protocol_version')
206209
_LOG_LINE_STRUCTURES['cs-host'] = _URI.set_results_name('cs_host')
207-
_LOG_LINE_STRUCTURES['cs(Cookie)'] = _URI.set_results_name('cs_cookie')
210+
_LOG_LINE_STRUCTURES['cs(Cookie)'] = _COOKIE.set_results_name('cs_cookie')
208211
_LOG_LINE_STRUCTURES['cs(Referrer)'] = _URI.set_results_name('cs_referrer')
209212
_LOG_LINE_STRUCTURES['cs(Referer)'] = _URI.set_results_name('cs_referrer')
210213

test_data/iis10_cookies.log

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Date: 2021-04-01 00:00:21
2+
#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
3+
#Software: Microsoft Internet Information Services 10.0
4+
#Version: 1.0
5+
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
6+
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
7+
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

tests/parsers/text_plugins/iis.py

+18
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ def testProcessWithIIS10Log(self):
186186
'recovery_warning')
187187
self.assertEqual(number_of_warnings, 0)
188188

189+
def testProcessWithIIS10LogAndCookieField(self):
190+
"""Tests the Process function with an IIS 10 log file and cs(Cookie)."""
191+
plugin = iis.WinIISTextPlugin()
192+
storage_writer = self._ParseTextFileWithPlugin(
193+
['iis10_cookies.log'], plugin)
194+
195+
number_of_event_data = storage_writer.GetNumberOfAttributeContainers(
196+
'event_data')
197+
self.assertEqual(number_of_event_data, 3)
198+
199+
number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
200+
'extraction_warning')
201+
self.assertEqual(number_of_warnings, 0)
202+
203+
number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
204+
'recovery_warning')
205+
self.assertEqual(number_of_warnings, 0)
206+
189207

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

0 commit comments

Comments
 (0)