Skip to content

Commit fdc687c

Browse files
authored
Changed IIS parser to support User-Agent with square brackets (#4910)
1 parent fc65934 commit fdc687c

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

plaso/parsers/text_plugins/iis.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ class WinIISTextPlugin(interface.TextPlugin):
111111
_URI_STEM = (pyparsing.Word(
112112
pyparsing.alphanums + _URI_SAFE_CHARACTERS + '$') | _BLANK)
113113

114+
_UA = pyparsing.Word(
115+
pyparsing.alphanums + _URI_SAFE_CHARACTERS + '[]') | _BLANK
116+
114117
# Per https://blogs.iis.net/nazim/use-of-special-characters-like-in-an-iis-url
115118
# IIS does not require that a query comply with RFC1738 restrictions on valid
116119
# URI characters
@@ -157,7 +160,7 @@ class WinIISTextPlugin(interface.TextPlugin):
157160
PORT.set_results_name('dest_port') +
158161
_USERNAME.set_results_name('cs_username') +
159162
_IP_ADDRESS.set_results_name('source_ip') +
160-
_URI.set_results_name('user_agent') +
163+
_UA.set_results_name('user_agent') +
161164
_INTEGER.set_results_name('sc_status') +
162165
_INTEGER.set_results_name('sc_substatus') +
163166
_INTEGER.set_results_name('sc_win32_status') +
@@ -185,7 +188,7 @@ class WinIISTextPlugin(interface.TextPlugin):
185188
_LOG_LINE_STRUCTURES['cs-username'] = _USERNAME.set_results_name(
186189
'cs_username')
187190
_LOG_LINE_STRUCTURES['c-ip'] = _IP_ADDRESS.set_results_name('source_ip')
188-
_LOG_LINE_STRUCTURES['cs(User-Agent)'] = _URI.set_results_name('user_agent')
191+
_LOG_LINE_STRUCTURES['cs(User-Agent)'] = _UA.set_results_name('user_agent')
189192
_LOG_LINE_STRUCTURES['sc-status'] = _INTEGER.set_results_name('http_status')
190193
_LOG_LINE_STRUCTURES['sc-substatus'] = _INTEGER.set_results_name(
191194
'sc_substatus')

test_data/iis10_edge_cases.log

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
2022-01-01 18:42:55 ::1 GET /rancertloc/logoff.aspx ActID=werwer-3e02-56456-ererere545-sdf8798798dfh 444 RaDomain\RandomMailbox3242354 ::1 Mozilla/4.0+(compatible;+MSIE+12.0;+Trident/7.0;+rv:12.0;+Windows+NT+6.1;+MSEXCHMON;+ACTIVEMONITORING;+BACKLOOK) - 302 0 0 5
1717
2022-01-01 00:01:24 ::1 POST /powershell clientApplication=ActiveMonitor;PSVersion=5.1.14393.4467 444 random/ranuser1 ::1 Microsoft+WinRM+Client - 200 0 0 15
1818
2022-01-01 00:01:24 ::1 POST /powershell clientApplication=ActiveMonitor;PSVersion=5.1.14393.4467 444 ranuser1@random ::1 Microsoft+WinRM+Client - 200 0 0 15
19+
2022-01-01 00:01:24 ::1 POST /powershell clientApplication=ActiveMonitor;PSVersion=5.1.14393.4467 444 random\ranuser1 ::1 Mozilla/5.0+(Linux;+Android+5.0;+SM-G900P+Build/LRX21T;+wv)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Version/4.0+Chrome/43.0.2357.121+Mobile+Safari/537.36+[FB_IAB/FB4A;FBAV/35.0.0.48.273;] - 200 0 0 15

tests/parsers/text_plugins/iis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def testProcessWithIIS10Log(self):
176176

177177
number_of_event_data = storage_writer.GetNumberOfAttributeContainers(
178178
'event_data')
179-
self.assertEqual(number_of_event_data, 14)
179+
self.assertEqual(number_of_event_data, 15)
180180

181181
number_of_warnings = storage_writer.GetNumberOfAttributeContainers(
182182
'extraction_warning')

0 commit comments

Comments
 (0)