Hi, I'm trying to get a custom decoder working for a Draytek Router, but I can’t seem to get the phase 2 decoder to work.
Logs sent directly to Wazuh Manager - Syslog "remote" configured and working. The Logs are being successful received and show in archives.json. The example log matches the “full log” field.
The decoder is successfully trigging a basic "show all" custom rule alert that I've created, and Security events are listed in the console but I'm struggling to decode the fields within the message itself.
Can anyone point me in the right direction on how to get the fields out of the message body. I’ve tested the regex out in regex101 and both pre-match and main body work OK.
Example log ("X" substituted here in example for the actual IP address )
Mar 23 21:10:36 vigor.router DrayTek: Local User (MAC=00-04-4D-83-0A-65): XXX.XXX.XXX.XXX:36301 -> XXX.XXX.XXX.XXX:443 (UDP)
The following decoder is entered in the local_decoder.xml
<decoder name="draytek_usr">
<prematch>^\w+ \d+ \d+:\d+:\d+ \w+.\w+ \w+: \w+ \w+\s</prematch>
<regex offset="after_prematch">\SMAC\S(\w+-\w+-\w+-\w+-\w+-\w+)\S: (\d+.\d+.\d+.\d+):(\d+) \S+ (\d+.\d+.\d+.\d+):(\d+) \S(\w+)\S</regex>
<order>rule_type, mac, srcip, srcport, dstip, dstport, protcol</order>
</decoder>
Custom Rule Created – draytek.xml
<group name="draytek">
<rule id="100021" level="5">
<decoded_as>DrayTek</decoded_as>
<description>Draytek Events</description>
</rule>
</group>
The Log Decoder Test Returns the following.
**Phase 1: Completed pre-decoding.
full event: 'Mar 23 21:10:36 vigor.router DrayTek: Local User (MAC=00-04-4D-83-0A-65): XXX.XXX.XXX.XXX:36301 -> XXX.XXX.XXX.XXX:443 (UDP)'
timestamp: 'Mar 23 21:10:36'
hostname: 'vigor.router'
program_name: 'DrayTek'
**Phase 2: Completed decoding.
name: 'DrayTek'
**Phase 3: Completed filtering (rules).
id: '100021'
level: '5'
description: 'Draytek Events'
groups: '["draytek"]'
firedtimes: '1'
mail: 'false'
**Alert to be generated.