Can someone explain to me why the following does not work
I have a function in a pipeline at stage 0 with two other functions with different matching criteria
Here is the function
rule "detect powershell-excel"
when
// detects powershell executing from Excel
has_field("sysmon_event_id") AND
has_field("sysmon_data_process") AND
has_field("sysmon_cmd_parent_file") AND
contains("1",to_string($message.sysmon_event_id)) AND
contains("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", to_string($message.sysmon_data_process)) AND
contains("EXCEL.EXE", to_string($message.sysmon_cmd_parent_file))
then
set_field("MitreRef", "T1086");
end
If you donât see the debug messages in the logs of the Graylog node, then the condition in the when block wasnât true. Youâre checking more than just for the existence of these message fields in the when block of that rule.
when
// detects powershell executing from Excel
has_field(âsysmon_event_idâ) AND
has_field(âsysmon_data_processâ) AND
has_field(âsysmon_cmd_parent_fileâ) AND
contains(â1â,to_string($message.sysmon_event_id)) AND
contains(âC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exeâ, to_string($message.sysmon_data_process)) AND
contains(âEXCEL.EXEâ, to_string($message.sysmon_cmd_parent_file))
then
set_field(âRefâ, âT1090â);
end
Now I know that the fields are present because if i do something like
when
has_field(âCustomerIDâ) AND contains(to_string($message.Channel), âMicrosoft-Windows-Sysmonâ)
then
let debug_message = concat("Field present ", to_string($message.sysmon_cmd_parent_file));
debug(debug_message);
let debug_message2 = concat("Field present ", to_string($message.sysmon_data_process));
debug(debug_message2);
let debug_message3 = concat("Field present ", to_string($message.sysmon_event_id));
debug(debug_message3);
end
So why doesnât the above trigger? The pipeline stage is set to at least one rule must be matched and there are three rules in total. One of them is the very specific one that you help me create the other day.
has_field(âfield-xâ) AND
has_field(âfield-yâ) AND
has_field(âfield-zâ) AND
contains(âmatch for xâ,to_string($message.field-x)) AND
contains(âmatch for yâ, to_string($message.field-y)) AND
contains(âmatch for z", to_string($message.field-z))
or is it meant to be
has_field(âfield-xâ) AND
has_field(âfield-yâ) AND
has_field(âfield-zâ) AND
contains(âmatch for xâ,to_string($message.field-z)) AND
contains(âmatch for yâ, to_string($message.field-y)) AND
contains(âmatch for z", to_string($message.field-x))