Hi Pradeep,
I've created a very simple rule to for illustration purposes. Bear in mind that for more involved custom developments, we have a
Professional Hours option available as well.
Now on to our topic, let's take a look at our new sample rule:
<group name="json,sysmon,">
<rule id="100300" level="3">
<decoded_as>json</decoded_as>
<field name="misp.source.description">^Sysmon\.*PING.EXE</field>
<description>$(misp.source.description)</description>
</rule>
</group>
The <group> tag is mandatory, so I just assigned it to the json and sysmon groups, though you could use any criteria as dictated by your policies.
Within the <rule> field, we need an id and a level attribute as well. Level 3 will ensure that this is visible on the Dashboard (this is the default threshold for visibility on the Dashboard) and the id above 100000 marks this as a custom rule.
Now, the field tag is where we are setting our criteria on what needs to be matched. We are using simple OSREGEX here to match things within the misp.source.description field on your jSON log that start with the word "Sysmon" and contain the string "PING.EXE" somewhere after.
The description field is mandatory, and in this case, we are just using the contents of the original log's misp.source.description field as the value to be shown in the interface.
I dumped this rule to an xml file within /var/ossec/etc/rules and then restarted the wazuh-manager service.
With that done, you can check whether your log is being decoded/alerted upon successfully by running:
This produces the following output in my environment:
root@manager:~# echo '{"misp": {"source": {"description": "Sysmon - Event 22: DNS Request by C:\\\\Windows\\\\System32\\\\PING.EXE"}, "event_id": "5", "category": "External analysis", "value": "https://docs.google.com/spreadsheets/d/1TLJXtAfcFVFOxbndK0W5VmE/", "type": "link"}}' | /var/ossec/bin/wazuh-logtest
Starting wazuh-logtest v4.3.10
Type one log per line
**Phase 1: Completed pre-decoding.
full event: '{"misp": {"source": {"description": "Sysmon - Event 22: DNS Request by C:\\\\Windows\\\\System32\\\\PING.EXE"}, "event_id": "5", "category": "External analysis", "value": "https://docs.google.com/spreadsheets/d/1TLJXtAfcFVFOxbndK0W5VmE/", "type": "link"}}'
**Phase 2: Completed decoding.
name: 'json'
misp.category: 'External analysis'
misp.event_id: '5'
misp.source.description: 'Sysmon - Event 22: DNS Request by C:\\Windows\\System32\\PING.EXE'
misp.type: 'link'
misp.value: 'https://docs.google.com/spreadsheets/d/1TLJXtAfcFVFOxbndK0W5VmE/'
**Phase 3: Completed filtering (rules).
id: '100300'
level: '3'
description: 'Sysmon - Event 22: DNS Request by C:\\Windows\\System32\\PING.EXE'
groups: '['json', 'sysmon']'
firedtimes: '1'
mail: 'False'
**Alert to be generated.
So, we can see the alert is actually going to be generated, with the proper description as set up in the rule file.
Check out our documentation for reference on all the mentioned topics:
I advise going through that page orderly, since it's an all-encompassing resource which will teach you all that's needed to create your own decoders and rules.
We also have a simpler tutorial available on our blog:
I hope this was of help, let me know how it goes.
Regards,
Federico Galland