Hi!
I did some test and I found that yours custom rules and decoders works on
local_decoder.xml and
local_rules.xml files.
As first test I Included the deceoder and rule files in each respective paths, then I restarted wazuh and found this WARNING message.
Category was not found. Invalid 'category'. Rule '100100' will be ignored.Warning message# /var/ossec/bin/wazuh-control start
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7611): Category was not found. Invalid 'category'. Rule '100100' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100100' was not found and will be ignored in the 'if_sid' option of rule '100101'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100101' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100100' was not found and will be ignored in the 'if_sid' option of rule '100102'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100102' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100100' was not found and will be ignored in the 'if_sid' option of rule '100103'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100103' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100100' was not found and will be ignored in the 'if_sid' option of rule '100104'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100104' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100100' was not found and will be ignored in the 'if_sid' option of rule '100105'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100105' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100105' was not found and will be ignored in the 'if_sid' option of rule '100106'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100106' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100105' was not found and will be ignored in the 'if_sid' option of rule '100107'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100107' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100105' was not found and will be ignored in the 'if_sid' option of rule '100108'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100108' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100105' was not found and will be ignored in the 'if_sid' option of rule '100109'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100109' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7620): Signature ID '100109' was not found. Invalid 'if_matched_sid'.Rule '100110' will be ignored.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7617): Signature ID '100105' was not found and will be ignored in the 'if_sid' option of rule '100111'.
2022/12/26 14:22:29 wazuh-analysisd: WARNING: (7619): Empty 'if_sid' value. Rule '100111' will be ignored.
I have not yet analyzed it in depth, but the file looks good, so I decided to include the decoders and rules in the local_decoder.xml and local_rules.xml files respectively. After that I tested on
wazuh-logtest and works.
Running on wazuh-logtest tool# /var/ossec/bin/wazuh-logtest
Type one log per line
Apr 30 23:30:00 192.168.1.1 mongosyslog: 2022-08-30T23:30:00.946+0700 I ACCESS [conn3099] SASL SCRAM-SHA-1 authentication failed for user on admin from client
192.168.1.11:40128 ; UserNotFound: Could not find user user@admin
**Phase 1: Completed pre-decoding.
full event: 'Apr 30 23:30:00 192.168.1.1 mongosyslog: 2022-08-30T23:30:00.946+0700 I ACCESS [conn3099] SASL SCRAM-SHA-1 authentication failed for user on admin from client
192.168.1.11:40128 ; UserNotFound: Could not find user user@admin'
timestamp: 'Apr 30 23:30:00'
hostname: '192.168.1.1'
program_name: 'mongosyslog'
**Phase 2: Completed decoding.
name: 'mongosyslog'
component: 'ACCESS'
msg: '[conn3099] SASL SCRAM-SHA-1 authentication failed for user on admin from client
192.168.1.11:40128 ; UserNotFound: Could not find user user@admin'
severity: 'I'
srcip: '192.168.1.11'
**Phase 3: Completed filtering (rules).
id: '100109'
level: '4'
description: 'MongoDB: Failed authentication'
groups: '['local', 'syslog', 'sshd', 'authentication_failed']'
firedtimes: '1'
gdpr: '['IV_35.7.d', 'IV_32.2']'
gpg13: '['7.1']'
hipaa: '['164.312.b']'
mail: 'False'
nist_800_53: '['AU.14', 'AC.7']'
pci_dss: '['10.2.4', '10.2.5']'
tsc: '['CC6.1', 'CC6.8', 'CC7.2', 'CC7.3']'
**Alert to be generated.
Finally I decide to include the log in a sample file in an Agent, to simulate the data collection, and alerts were generated as expected.
Agent configuration|
<localfile>
<location>C:\Users\test.txt</location>
<log_format>syslog</log_format>
</localfile>
I pasted the example log in the
test.txt file, including an enter space.
And look for the alert in
alert.json file in manager side.
/var/ossec/logs/alerts/alerts.json{"timestamp":"2022-12-26T14:09:35.772-0300",
"rule":{"level":4,"description":"MongoDB: Failed authentication","
id":"100109","firedtimes":2,"mail":false,"groups":["local","syslog","sshd","authentication_failed"],"pci_dss":["10.2.4","10.2.5"],"gpg13":["7.1"],"gdpr":["IV_35.7.d","IV_32.2"],"hipaa":["164.312.b"],"nist_800_53":["AU.14","AC.7"],"tsc":["CC6.1","CC6.8","CC7.2","CC7.3"]},"agent":{"id":"001","name":"DESKTOP-U8OHD3A","ip":"2803:9800:9882:B7A5:5E87:5DE6:650F:1A7F"},"manager":{"name":"VBox"},"id":"167575.46967",
"full_log":"Apr 30 23:30:00 192.168.1.1 mongosyslog: 2022-08-30T23:30:00.946+0700 I ACCESS [conn3099] SASL SCRAM-SHA-1 authentication failed for user on admin from client 192.168.1.11:40128 ; UserNotFound: Could not find user user@admin","predecoder":{"program_name":"mongosyslog","timestamp":"Apr 30 23:30:00","hostname":"192.168.1.1"},"decoder":{"name":"mongosyslog"},"data":{"srcip":"192.168.1.11","severity":"I","component":"ACCESS","msg":"[conn3099] SASL SCRAM-SHA-1 authentication failed for user on admin from client
192.168.1.11:40128 ; UserNotFound: Could not find user user@admin"},"location":"C:\\Users\\test.txt"}
Let me know if that works for you.
Regards.