Clément BONNAL
Here's an XPATH query I wrote the other day to safelist some PowerShellCore events. Recommend testing with the Event Filter (eventvwr.msc) first to ensure you get your desired results. I had to break this query into two separate Ids ("0" and "1") as I think there is a character limit for each Query Id. I am using the latest WinCollect 10 (10.1.4.44). Hopefully this will help you and others in the future.
<QueryList>
<Query Id="0" Path="PowerShellCore/Operational">
<Select Path="PowerShellCore/Operational"> *[System[(EventID=4104)]]
</Select>
<Suppress Path="PowerShellCore/Operational"> *[System[(EventID=4104)]] and
( *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\CimCmdlets\CimCmdlets.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Archive\en-US\ArchiveResources.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Diagnostics\Microsoft.PowerShell.Diagnostics.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Host\Microsoft.PowerShell.Host.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Management\Microsoft.PowerShell.Management.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Security\Microsoft.PowerShell.Security.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\Microsoft.WSMan.Management\Microsoft.WSMan.Management.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PackageManagement\DSCResources\MSFT_PackageManagement\MSFT_PackageManagement.strings.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PackageManagement\DSCResources\MSFT_PackageManagementSource\MSFT_PackageManagementSource.strings.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PackageManagement\DSCResources\PackageManagementDscUtilities.strings.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PackageManagement\PackageManagement.Resources.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PowerShellGet\DSCResources\MSFT_PSModule\en-US\MSFT_PSModule.strings.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PowerShellGet\DSCResources\MSFT_PSRepository\en-US\MSFT_PSRepository.strings.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PowerShellGet\en-US\PSGet.Resource.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PowerShellGet\Modules\PowerShellGet.ResourceHelper\en-US\PowerShellGet.ResourceHelper.strings.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PowerShellGet\PowerShellGet.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PowerShellGet\PSGet.Resource.psd1']]
)
</Suppress>
</Query>
<Query Id="1" Path="PowerShellCore/Operational">
<Select Path="PowerShellCore/Operational"> *[System[(EventID=4104)]]
</Select>
<Suppress Path="PowerShellCore/Operational"> *[System[(EventID=4104)]] and
( *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PSReadLine\PSReadLine.psd1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\PSReadLine\PSReadLine.psm1']] or *[EventData[Data[@Name='Path'] = 'C:\program files\powershell\7\Modules\ThreadJob\ThreadJob.psd1']]
)
</Suppress>
</Query>
</QueryList>
------------------------------
Tom L
------------------------------
Original Message:
Sent: Thu May 11, 2023 04:20 PM
From: Clément BONNAL
Subject: Wincollect complex eventID filter
Hi Jonathan,
Finally I used XPath to collect my Security logs, and applies <Suppress> filters in the Query!
Thank you
------------------------------
Clément BONNAL
Original Message:
Sent: Thu May 11, 2023 03:17 PM
From: Jonathan Pechta
Subject: Wincollect complex eventID filter
Can you confirm your WinCollect version? There was an issue logged against WinCollect 10.0.2, which was fixed in WinCollect 10.1.3 to resolve issues related to filtering for OR conditions as APAR IJ44662.
That being said,the filtering in WinCollect 10.1.4 and earlier are limited at the moment. I had a quick discussion with the dev team on your question and do not support combined filtering using parentheses like in your example.
You can use parentheses to filter for:
- Event IDs to filter ranges or specific values. The docs refers to these as Implicit filtering, such as
-(7000,7022-7026,7031-7034,7045)
. - Event ID and source or message values. The docs refer to these as Explicit filtering, such as
EventIDCode <= 7045 AND Message ~ bankingapp.exe
- More complex filtering for source and IDs for Forwarded event logs. The docs refers to this type as Forwarded Events filtering. This is closer to what you want, but at this time only works on Forwarded events, such as
Application(200-256,4097,34);Security(1)
which is equivalent to (channel=Application AND (200-256, 4097, 34)) OR (channel=Security AND 1)
and much closer to what you want per your example. However, this is only available with Forwarded events. Be aware, in this example of the translated filter, the AND
condition is evaluated first, followed by OR
conditions.
At this time, you cannot combine implicit and explicit filter types together like your example and nested parentheses are not supported at this time. And unless you are using Forwarded events, you cannot use the filter you are looking to create. There are discussions going on as to how to improve filtering for examples like you listed, but at this time it is not possible. We usually have users look at creating an XPath query as it can do some of the more complex filtering.
If you have suggestions as to the type of filtering you want to see going forward, it might not be a bad idea to open an IBM Idea to contribute to some specific filtering needs you might want in the future.
------------------------------
Jonathan Pechta
QRadar Support Content Lead
Support forums: ibm.biz/qradarforums
jonathan.pechta1@ibm.com
Original Message:
Sent: Wed May 10, 2023 09:04 AM
From: Clément BONNAL
Subject: Wincollect complex eventID filter
Hello,
I read this documentation Event filtering but I didn't find the answer how to combine multiple conditions in a filter.
For example, we want to exclude some event ids :
-(7000,7022-7026,7031-7034,7045)
And we want also exclude a pair of an event id associated with a specific message :
-(EventIDCode == 4702 AND Message =~
'test')
But how to combine them in a single line ?
When I do that I have errors in the wincollect logs as it is invalid. The expected filter would look like :
-(eventid1 or eventid2 or eventid3 or (eventid4 and messageX))
Thank you so much for your help.
------------------------------
Clément BONNAL
------------------------------