Hello team,
I'm encountered some problems with custom decoders and rules for syslog traffic.
1. Logs received by Fluentd for parsing and normalizing
2. Fluentd sends logs to the Wazuh Manager
3. There are custom rules and decoders implemented
The problem is that alerts do not generated in /alerts.json file.
Wazuh version:
/var/ossec/bin/wazuh-control -j info
{"error":0,"data":[{"WAZUH_VERSION":"v4.4.0"},{"WAZUH_REVISION":"40405"},{"WAZUH_TYPE":"server"}]}
### Log sample'aN..T).....<13>May
24 01:00:09 wfluentd01 checkpoint:
{"timestamp":"2023-05-24T01:00:08+03:00","host":"10.196.8.12","syslogtag":"CP-GW","filed1":"-","log.type":"Log","
log.id":"1.3.6.1.4.1.2620","log.delay":"1684879208","source.ip":"10.197.1.220","destination.ip":"10.196.1.120","destination.proto":"6","device.up_match.input.start":"TABLE_START","device.row.start":"0","device.match_id":"18","device.layer_uuid":"8a994dd3-993e-4c0c-92a1-a8630b153f4c","device.layer_name":"Network","device.rule_uid":"d0cc4a57-21e7-4294-b489-ec2ab7994016","device.rule_name":"TEMP","device.row.end":"0","device.up_match_table.end":"TABLE_END","
device.product.name":"VPN-1 & FireWall-1","destination.port":"993","source.port":"40108","device.product.family":"Network"}'
### Custom decoder<decoder name="checkpoint_json_extractor">
<prematch>checkpoint: </prematch>
<plugin_decoder offset="after_prematch">JSON_Decoder</plugin_decoder>
</decoder>
### Custom rule<group name="fluentd parser rules">
<rule id="100001" level="5">
<decoded_as>checkpoint_json_extractor</decoded_as>
<match>checkpoint</match>
<description>checkpoint_traffic_logs.</description>
</rule>
</group>
### Logtest via /var/ossec/bin/wazuh-logtestStarting wazuh-logtest v4.4.0
Type one log per line
**Phase 1: Completed pre-decoding.
full
event: 'aN..T).....<13>May 24 01:00:09 wfluentd01 checkpoint:
{"timestamp":"2023-05-24T01:00:08+03:00","host":"10.196.8.12","syslogtag":"CP-GW","filed1":"-","log.type":"Log","
log.id":"1.3.6.1.4.1.2620","log.delay":"1684879208","source.ip":"10.97.10.22","destination.ip":"10.196.1.120","destination.proto":"6","device.up_match.input.start":"TABLE_START","device.row.start":"0","device.match_id":"18","device.layer_uuid":"8a994dd3-993e-4c0c-92a1-a8630b153f4c","device.layer_name":"Network","device.rule_uid":"d0cc4a57-21e7-4294-b489-ec2ab7994016","device.rule_name":"TEMP","device.row.end":"0","device.up_match_table.end":"TABLE_END","
device.product.name":"VPN-1 & FireWall-1","destination.port":"993","source.port":"40108","device.product.family":"Network"}'
**Phase 2: Completed decoding.
name: 'checkpoint_json_extractor'
destination.ip: '10.196.1.120'
destination.port: '993'
destination.proto: '6'
device.layer_name: 'Network'
device.layer_uuid: '8a994dd3-993e-4c0c-92a1-a8630b153f4c'
device.match_id: '18'
device.product.family: 'Network'
device.product.name: 'VPN-1 & FireWall-1'
device.row.end: '0'
device.row.start: '0'
device.rule_name: 'TEMP'
device.rule_uid: 'd0cc4a57-21e7-4294-b489-ec2ab7994016'
device.up_match.input.start: 'TABLE_START'
device.up_match_table.end: 'TABLE_END'
filed1: '-'
host: '10.196.8.12'
log.delay: '1684879208'
log.id: '1.3.6.1.4.1.2620'
log.type: 'Log'
source.ip: '10.197.1.220'
source.port: '40108'
syslogtag: 'CP-GW'
timestamp: '2023-05-24T01:00:08+03:00'
**Phase 3: Completed filtering (rules).
id: '100001'
level: '5'
description: 'checkpoint_traffic_logs.'
groups: '['fluentd parser rules']'
firedtimes: '1'
mail: 'False'
**Alert to be generated.
### Events in archives.json after logall_json sudo tail -n 20 /var/ossec/logs/archives/archives.json | grep checkpoint
{"timestamp":"2023-05-24T21:51:24.481+0300","agent":{"id":"000","name":"wazuhserver01"},"manager":{"name":"wazuhserver01"},"id":"1684954284.498855","cluster":{"name":"wazuh","node":"wazuhserver01"},"full_log":"May
24 21:51:24 wfluentd01 checkpoint:
{\"timestamp\":\"2023-05-24T21:51:24+03:00\",\"host\":\"10.196.8.12\",\"syslogtag\":\"CP-GW\",\"filed1\":\"-\",\"log.type\":\"Log\",\"
log.id\":\"1.3.6.1.4.1.2620\",\"log.delay\":\"1684954284\",\"destination.service\":\"http\",\"source.ip\":\"10.197.1.220\",\"destination.ip\":\"10.196.12.22\",\"destination.proto\":\"6\",\"device.up_match.input.start\":\"TABLE_START\",\"device.row.start\":\"0\",\"device.match_id\":\"18\",\"device.layer_uuid\":\"8a994dd3-993e-4c0c-92a1-a8630b153f4c\",\"device.layer_name\":\"Network\",\"device.rule_uid\":\"d0cc4a57-21e7-4294-b489-ec2ab7994016\",\"device.rule_name\":\"TEMP\",\"device.row.end\":\"0\",\"device.up_match_table.end\":\"TABLE_END\",\"
device.product.name\":\"VPN-1
&
FireWall-1\",\"destination.port\":\"80\",\"source.port\":\"59212\",\"device.product.family\":\"Network\"}","predecoder":{"program_name":"checkpoint","timestamp":"May
24
21:51:24","hostname":"wfluentd01"},"decoder":{},"location":"10.197.8.12"}
{"timestamp":"2023-05-24T21:51:24.481+0300","agent":{"id":"000","name":"wazuhserver01"},"manager":{"name":"wazuhserver01"},"id":"1684954284.498855","cluster":{"name":"wazuh","node":"wazuhserver01"},"full_log":"May
24 21:51:24 wfluentd01 checkpoint:
{\"timestamp\":\"2023-05-24T21:51:24+03:00\",\"host\":\"10.196.8.12\",\"syslogtag\":\"CP-GW\",\"filed1\":\"-\",\"log.type\":\"Log\",\"
log.id\":\"1.3.6.1.4.1.2620\",\"log.delay\":\"1684954284\",\"destination.service\":\"Modbus\",\"source.ip\":\"10.96.44.111\",\"destination.ip\":\"10.199.8.13\",\"destination.proto\":\"6\",\"device.up_match.input.start\":\"TABLE_START\",\"device.row.start\":\"0\",\"device.match_id\":\"18\",\"device.layer_uuid\":\"8a994dd3-993e-4c0c-92a1-a8630b153f4c\",\"device.layer_name\":\"Network\",\"device.rule_uid\":\"d0cc4a57-21e7-4294-b489-ec2ab7994016\",\"device.rule_name\":\"TEMP\",\"device.row.end\":\"0\",\"device.up_match_table.end\":\"TABLE_END\",\"
device.product.name\":\"VPN-1
&
FireWall-1\",\"destination.port\":\"502\",\"source.port\":\"51490\",\"device.product.family\":\"Network\"}","predecoder":{"program_name":"checkpoint","timestamp":"May
24
21:51:24","hostname":"wfluentd01"},"decoder":{},"location":"10.197.8.12"}
It contains some additional symbols "\" as a separator.
I tried to set up a rsyslog server with debug mode on wazuh manager to see how my normalized log looks like:
Rsyslog debug output:
Debug line with all properties:
FROMHOST: '10.197.7.180', fromhost-ip: '10.197.7.180', HOSTNAME: 'wfluentd01', PRI: 13,
syslogtag 'checkpoint:', programname: 'checkpoint', APP-NAME: 'checkpoint', PROCID: '-', MSGID: '-',
TIMESTAMP: 'May 27 12:30:40', STRUCTURED-DATA: '-',
msg: ' {"timestamp":"2023-05-27T12:30:39+03:00","host":"10.196.5.120","syslogtag":"CP-GW","filed1":"-","log.type":"Log","
log.id":"1.3.6.1.4.1.2620","log.delay":"1685179839","destination.service":"https","source.ip":"10.197.1.210","destination.ip":"10.196.1.110","destination.proto":"6","device.up_match.input.start":"TABLE_START","device.row.start":"0","device.match_id":"18","device.layer_uuid":"8a994dd3-993e-4c0c-92a1-a8630b153f4c","device.layer_name":"Network","device.rule_uid":"d0cc4a57-21e7-4294-b489-ec2ab7994016","device.rule_name":"TEMP","device.row.end":"0","device.up_match_table.end":"TABLE_END","
device.product.name":"VPN-1 & FireWall-1","destination.port":"443","source.port":"51796","device.product.family":"Network"}'
escaped
msg: '
{"timestamp":"2023-05-27T12:30:39+03:00","host":"10.196.5.120","syslogtag":"CP-GW","filed1":"-","log.type":"Log","
log.id":"1.3.6.1.4.1.2620","log.delay":"1685179839","destination.service":"https","source.ip":"10.197.1.210","destination.ip":"10.196.1.110","destination.proto":"6","device.up_match.input.start":"TABLE_START","device.row.start":"0","device.match_id":"18","device.layer_uuid":"8a994dd3-993e-4c0c-92a1-a8630b153f4c","device.layer_name":"Network","device.rule_uid":"d0cc4a57-21e7-4294-b489-ec2ab7994016","device.rule_name":"TEMP","device.row.end":"0","device.up_match_table.end":"TABLE_END","
device.product.name":"VPN-1 & FireWall-1","destination.port":"443","source.port":"51796","device.product.family":"Network"}'
inputname:
imudp rawmsg: '<13>May 27 12:30:40 wfluentd01 checkpoint:
{"timestamp":"2023-05-27T12:30:39+03:00","host":"10.196.5.120","syslogtag":"CP-GW","filed1":"-","log.type":"Log","
log.id":"1.3.6.1.4.1.2620","log.delay":"1685179839","destination.service":"https","source.ip":"10.197.1.210","destination.ip":"10.196.1.110","destination.proto":"6","device.up_match.input.start":"TABLE_START","device.row.start":"0","device.match_id":"18","device.layer_uuid":"8a994dd3-993e-4c0c-92a1-a8630b153f4c","device.layer_name":"Network","device.rule_uid":"d0cc4a57-21e7-4294-b489-ec2ab7994016","device.rule_name":"TEMP","device.row.end":"0","device.up_match_table.end":"TABLE_END","
device.product.name":"VPN-1 & FireWall-1","destination.port":"443","source.port":"51796","device.product.family":"Network"}'
It looks ok.wserver01
Also I see that syslog is ok in the tcpdump.
### TCPDUMP OUTPUT
~$ sudo tcpdump port 10514 -AA
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on ens160, link-type EN10MB (Ethernet), snapshot length 262144 bytes
12:43:53.387534 IP 10.197.7.180.39090 > wserver01.10514: UDP, length 776
.PV..s.PV.....E..$D.@.@.B.
aN.
aN...)....c<13>May
27 12:43:53 wfluentd01 checkpoint:
{"timestamp":"2023-05-27T12:43:48+03:00","host":"10.196.5.120","syslogtag":"CP-GW","filed1":"-","log.type":"Log","
log.id":"1.3.6.1.4.1.2620","log.delay":"1685180628","destination.service":"https","source.ip":"10.97.10.22","destination.ip":"10.96.10.12","destination.proto":"6","device.up_match.input.start":"TABLE_START","device.row.start":"0","device.match_id":"18","device.layer_uuid":"8a994dd3-993e-4c0c-92a1-a8630b153f4c","device.layer_name":"Network","device.rule_uid":"d0cc4a57-21e7-4294-b489-ec2ab7994016","device.rule_name":"TEMP","device.row.end":"0","device.up_match_table.end":"TABLE_END","
device.product.name":"VPN-1 & FireWall-1","destination.port":"443","source.port":"55958","device.product.family":"Network"}
12:43:53.387564 IP 10.197.7.180.39090 > wserver01.10514: UDP, length 776
.PV..s.PV.....E..$D.@.@.B.
aN.
Looking forward to your reply.
Best regards,
Kirill