I have a number of search strings from a siem to highlight certain security events from windows logs. The problem is these search strings contain nested boolean operators and I need to flatten them to show every possible option in a separate line.
So far I've tried to split the relevant sections out (Source, event_ids, additional parameters) The issue is due to the nesting and the various ORs and ANDs I'm struggling to accomplish this.
((`sysmon` event_id=1) OR (`windows-security` event_id=4688)) (process_command_line="*control* \/name*" OR process_command_line="rundll32* shell32.dll Control_RunDLL") \
`sysmon` (event_id=12 OR event_id=13 OR event_id=14) (registry_key_path="*\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ControlPanel\\NameSpace*" OR registry_key_path="*\\Software\\Microsoft\\Windows\\CurrentVersion\\Controls Folder\\*\\Shellex\\PropertySheetHandlers\\*" OR registry_key_path="*\\Software\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\*") \
((`sysmon` event_id=1) OR (`windows-security` event_id=4688)) (process_name="net.exe" AND process_command_line="*net* config*") OR (process_name="ipconfig.exe" OR process_name="netsh.exe" OR process_name="arp.exe" OR process_name="nbtstat.exe") \
I'd expect to be able to flatten each one out with the result being it produces multiple flat match strings that only include ANDs e.g.
Original:
((`sysmon` event_id=1) OR (`windows-security` event_id=4688)) (process_command_line="*control* \/name*" OR process_command_line="rundll32* shell32.dll Control_RunDLL") \
Expected Output:
sysmon, event_id=1, process_command_line="*control* \/name*"
sysmon, event_id=1, process_command_line="rundll32* shell32.dll Control_RunDLL"
windows-security, event_id=4688, process_command_line="*control* \/name*"
windows-security, event_id=4688, process_command_line="rundll32* shell32.dll Control_RunDLL"