Hello riiky,
Maybe something like this will do the job:
<decoder name="trend_micro">
<program_name>CEF</program_name>
</decoder>
<decoder name="trend_micro_add">
<parent>trend_micro</parent>
<prematch>Attack Discovery</prematch>
<regex>cn1Label=(\S+) cn1=(\S+)</regex>
<order>add_cn1Label, add_cn1 </order>
</decoder>
<decoder name="trend_micro_bm">
<parent>trend_micro</parent>
<prematch>Behavior Monitoring</prematch>
<regex>cn2Label=(\S+) cn2=(\S+)</regex>
<order>bm_cn2Label, bm_cn2 </order>
</decoder>
trend_micro: Generic decoder for all Trend Micro events
trend_micro_add: Decoder for Attack Discovery Detections (add)
For this kind of event, we are going to expect add_cn1Label and add_cn1 ( include the add header to differentiate fields for different kinds of TrendMicro events )
trend_micro_bm: Decoder for Behavior Monitoring (bm).
Similarly, we expect bm_cn2Label, bm_cn2.
Using this hierarchy we can decode different fields for each type of event.
This is only a PoC, the trend_micro generic decoder should be improved in order to include the rest of the desired fields.
Using logtest we get the following:
timestamp: 'Feb 18 18:55:22'
hostname: 'amlfmp.manage.trendmicro.com'
program_name: 'CEF'
**Phase 2: Completed decoding.
name: 'trend_micro'
parent: 'trend_micro'
add_cn1: '0'
add_cn1Label: 'SLF_RiskLevel'
timestamp: 'Feb 18 18:55:22'
hostname: 'amlfmp.manage.trendmicro.com'
program_name: 'CEF'
**Phase 2: Completed decoding.
name: 'trend_micro'
parent: 'trend_micro'
bm_cn2: '4'
bm_cn2Label: 'Event_Type'
If you have any doubt, please share your current decoders and I will help you with them.
You can not duplicate decoder prematch.
The best approach is to create a consistent decoder/rule hierarchy that matches your use case. In this case, there are a few options:
1.- Desired fields always appear in Attack Discovery event type.
If those values are always generated in the Attack Discovery Detections event type, you can use something like the following
<decoder name="trend_micro_add">
<parent>trend_micro</parent>
<prematch>Attack Discovery</prematch>
<regex>dhost=(\S+) dst=(\S+) \.* cn1Label=(\S+) cn1=(\S+)</regex>
<order>dhost,dst,add_cn1Label, add_cn1 </order>
</decoder>
wazuh-logtest
**Phase 2: Completed decoding.
name: 'trend_micro'
parent: 'trend_micro'
add_cn1: '0'
add_cn1Label: 'SLF_RiskLevel'
dhost: 'VCAC-Window-331'
dst: '10.201.86.150'
2.- Only a few events include desired fields
In this use case, this hierarchy is more practical:
<decoder name="trend_micro_add">
<program_name>CEF</program_name>
<prematch>Attack Discovery</prematch>
</decoder>
<decoder name="trend_micro_add_complete">
<parent>trend_micro_add</parent>
<regex>dhost=(\S+) dst=(\S+) \.* cn1Label=(\S+) cn1=(\S+)</regex>
<order>dhost,dst,add_cn1Label, add_cn1 </order>
</decoder>
<decoder name="trend_micro_add_basic">
<parent>trend_micro_add</parent>
<regex>dhost=cn1Label=(\S+) cn1=(\S+)</regex>
<order>add_cn1Label, add_cn1 </order>
</decoder>
This can be customized for your use case.
If you have any doubt do not hesitate to ask.
The best approach is to use \. regex and a delimiter string.
In your use case, the cs2Label label.
This decoder should do the job:
<decoder name="trend_micro_add_complete">
<parent>trend_micro_attd</parent>
<regex>dhost=(\S+) dst=(\S+) \.* cn1Label=(\S+) cn1=(\S+) cn2Label=(\S+) cn2=(\S+) cs1Label=(\S+) cs1=(\.+) cat=(\.+) cs2Label=(\S+)</regex>
<order>dhost,dst,add_cn1Label, add_cn1, add_cn2Label, add_cn2, add_cs1Label, add_cs1, cat, add_c2Label </order>
</decoder>
**Phase 2: Completed decoding.
name: 'trend_micro_attd'
add_c2Label: 'SLF_ADEObjectGroup_Info_1'
add_cn1: '0'
add_cn1Label: 'SLF_RiskLevel'
add_cn2: '30.1012.00'
add_cn2Label: 'SLF_PatternNumber'
add_cs1: 'powershell invoke expression'
add_cs1Label: 'SLF_RuleID'
cat: 'point of entry'
dhost: 'VCAC-Window-331'
dst: '10.201.86.150'