Hi Seb!
In order to help you I need to verify two things:
<rule id="100030" level="5">
<if_sid>60122</if_sid>
<field name="win.eventdata.logonProcessName">NtLmSsp</field>XY
<description>RDP Logon Failure - Unknown user or bad password</description>
</rule>
Because of the “XY”, that shouldn’t be there, it might cause trouble.
I wil be waiting for your reply! :)
Regards,
Koremblum Nicolás Mariano
9-02-21 10:40:11,97
"active-response/bin/test1.cmd" add "-" "-"
"1613727616.906986 100035 (PS-LAB) any->EventChannel -
-"
with
<command>
<name>RDPBlock</name>
<executable>test1.cmd</executable>
<expect>win.eventdata.ipAddress</expect>
<timeout_allowed>yes</timeout_allowed>
</command>
i put the json from the alert 100035
Thank you
Hi Seb!
I’ve been doing further research about this topic and there is no easy way of getting the IP with EventChannel. Despite this, there have been some workarounds that probed to work.
So, as there is no way to get srcip from data.win.eventdata.ipAddress given an EventChannel event, in order to be able to acquire the IP, it is required to convert the event type, from EventChannel to EventLog (you can get more info about these on this Wazuh’s documentation page: How to collect Windows logs)
Before proceeding with this, could you please share with us your manager and agent's ossec.conf files?
Regards,
Koremblum Nicolás Mariano
2021 Feb 23 11:02:41 WinEvtLog: Security: AUDIT_FAILURE(4625): Microsoft-Windows-Security-Auditing: (no user): no domain: domain.com An account failed to log on. Subject: Security ID: S-1-0-0 Account Name: - Account Domain: - Logon ID: 0x0 Logon Type: 3 Account For Which Logon Failed: Security ID: S-1-0-0 Account Name: Administrator Account Domain: NAME Failure Information: Failure Reason: %%2313 Status: 0xc000006d Sub Status: 0xc000006a Process Information: Caller Process ID: 0x0 Caller Process Name: - Network Information: Workstation Name: B39RD63 Source Network Address: 192.168.0.254 Source Port: 0 Detailed Authentication Information: Logon Process: NtLmSsp Authentication Package: NTLM Transited Services: - Package Name (NTLM only): - Key Length: 0 This event is generated when a logon request fails. It is generated on the computer where access was attempted.
Hi Seb,
So, given the Wazuh’s limitation, we need to acquire win.eventdata.ipAddress as srcip, since the <command> supports only this last parameter, user and/or filename on the <expect> option. The proven way of doing so consist on using a “child decoder” of <eventchannel>‘s decoder, in order to obtain the specific field of interest and map it back to srcip, but, at the moment, Wazuh does not support the use of XML decoders for Eventchannel, as it is stated in the issue: “Windows Eventchannel decoder is not compatible with other XML decoders“
So, in order to implement the workaround, you should follow the next steps:
1- On the ossec.conf file, of the Windows Agent, you should change:
<localfile>
<location>Security</location>
<log_format>eventchannel</log_format>
<query>Event/System[EventID != 5145 and EventID != 5156 and EventID != 5447 and
EventID != 4656 and EventID != 4658 and EventID != 4663 and EventID != 4660 and
EventID != 4670 and EventID != 4690 and EventID != 4703 and EventID != 4907 and
EventID != 5152 and EventID != 5157]</query>
</localfile>
To:
<localfile>
<location>Security</location>
<log_format>eventlog</log_format>
<query>Event/System[EventID != 5145 and EventID != 5156 and EventID != 5447 and
EventID != 4656 and EventID != 4658 and EventID != 4663 and EventID != 4660 and
EventID != 4670 and EventID != 4690 and EventID != 4703 and EventID != 4907 and
EventID != 5152 and EventID != 5157]</query>
</localfile>
In this step we changed log_format from eventchannel to eventlog.
2- Restart the agent.
3- On the manager, you should add a new custom decoder with the following information:
<decoder name="eventlog_child">
<parent>windows</parent>
<regex>Source Network Address: (\.*) </regex>
<order>srcip</order>
</decoder>
Now, this child decoder will get the network data of the event and store it on srcip field. You can check whether this field is being set by looking the alerts in Kibana.
4- Restart the Manager and then, the Active Response should execute as expected.
The Wazuh team has already improved the way parameters are sent to the Active Response and this update will be included on Wazuh v4.2.0. You can have more info about this in the following links:
Active Response/Command support additional EXPECT fields #2084
Remove the limitation of fields used by active responses #6954
PR: Remove the limitation of fields used by active responses #7317
Wazuh active response concatenating args #7521
I hope this helps you!
Regards,
Koremblum Nicolás Mariano