Hello Damian,
Thank you for the reply and I hope all is fine with you as well. I will try to answer all your questions...
I am running WAZUH 4.3.10, the decoder that I was referencing was the 0380-windows_decoders.xml located in "/var/ossec/ruleset/decoders/" and I did make a copy of the xml file (working on the original to make sure things work as I want them to before making final configurations).
I wondered if the decoders get overwritten when a new update / upgrade gets applied (I will make the final exclusions changes once I know things are working as I want them to).
The script that I'm trying to run is the default netsh.exe which is defined in my Manager ossec.conf as below:
<active-response>
<disabled>no</disabled>
<command>netsh</command>
<location>local</location>
<rules_id>60010</rules_id>
<timeout>1000</timeout>
</active-response>
And the command is defined as below:
<command>
<name>netsh</name>
<executable>netsh.exe</executable>
<timeout_allowed>yes</timeout_allowed>
</command>
rule_id>60010 is defined in my 0575-win-base_rules.xml as below (I changed the level to 5 so wazuh would show notifications in my dashboard, original was set to 0 and wazuh is configured to log anything abouve level 3):
<rule id="60010" level="5">
<if_sid>60000</if_sid>
<field name="win.system.eventID">^140$</field>
<field name="win.system.severityValue">^WARNING$</field>
<options>no_full_log</options>
<description>RdpCoreTS RemoteIP warning event.</description>
<group>gpg13_4.12,</group>
</rule>
So all these configurations are working until the part where wazuh should execute the command to block the offending IP address. Also, in my wazuh dashboard, agents, agent in question, security events, events - I do see the event with rule>id 60010 with all the information pulled from the event log (the table is below):
agent.id 011
data.win.eventdata.iPString x.x.x.x (I removed the IP info)
data.win.system.channel Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational
data.win.system.eventID 140
data.win.system.eventRecordID 50737427
data.win.system.keywords 0x4000000000000000
data.win.system.level 3
data.win.system.message "A connection from the client computer with an IP address of x.x.x.x (I removed the IP) failed because the user name or password is not correct."
data.win.system.opcode 14
data.win.system.processID 5276
data.win.system.providerGuid {1139C61B-B549-4251-8ED3-27250A1EDEC8}
data.win.system.providerName Microsoft-Windows-RemoteDesktopServices-RdpCoreTS
data.win.system.severityValue WARNING
data.win.system.systemTime 2022-12-13T15:16:26.398243900Z
data.win.system.task 4
data.win.system.threadID 5368
data.win.system.version 0
decoder.name windows_eventchannel
id 1670944586.314633764
input.type log
location EventChannel
manager.name name.domain.com (I removed the info)
rule.description RdpCoreTS RemoteIP warning event.
rule.firedtimes 1
rule.gpg13 4.12
rule.groups windows
rule.id 60010
rule.level 5
rule.mail false
timestamp Dec 13, 2022 @ 09:16:26.923
The reason I'm using this event channel is because if I use rule_id 60122 which monitors windows security event log for failed attempts with eventID 4625 (windows doesn't provide the Source Network Address as shown below and has to be retrieved from Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational - event logs).
Failure Information:
Failure Reason: Unknown user name or bad password.
Status: 0xC000006D
Sub Status: 0xC0000064
Process Information:
Caller Process ID: 0x0
Caller Process Name: -
Network Information:
Workstation Name: workstation
Source Network Address: - (this is where the problem is as windows doesn't record the IP address and that is why I want to extract / map the data.win.eventdata.iPString x.x.x.x to "srcip")
Source Port: -
In the agent log, I see the it tries to fire the script, however there is an error as below:
2022/12/13 09:36:37 active-response/bin/netsh.exe: Cannot read 'srcip' from data
When looking at the documentation of the netsh.exe command it references "srcip" as below:
// Get srcip
const char *srcip = get_srcip_from_json(input_json);
if (!srcip) {
write_debug_file(argv[0], "Cannot read 'srcip' from data");
cJSON_Delete(input_json);
return OS_INVALID;
So I'm thinking, if I can get the <regex>Source Network Address:\t*\s*(\S+.\S+.\S+.\S+)|Source Network Address:\t*\s*(\S*:\S*:\S*:\S*:\S*:\S*:\S*:\S*)|[CLIENT: (\S+\d)]</regex> changed to pull the IP info from win.eventdata.iPString x.x.x.x and map it to <order>srcip</order> then the script should execute and add the IP address into the Windows Firewall block list.
Also, my global agent.conf configuration has the following config:
<agent_config>
<!-- Shared agent configuration here -->
<localfile>
<location>Microsoft-Windows-RemoteDesktopServices-RdpCoreTS/Operational</location>
<log_format>eventchannel</log_format>
</localfile>
</agent_config>