Hi Maria!
You are welcome! thanks for use Wazuh, I hope you are doing well.
Sorry for the delay.
Just for test I did a change to your custom rule
<rule id="300003" level="12" timeframe="120">
<if_group>success_attack</if_group>
<if_matched_sid>300001</if_matched_sid> <---- I use the id to make it trigger and works too.
<description>Successful web-server attack after Suricata scan detected</description>
<group>intrusion</group>
</rule>
Same as your test, running twice
{"timestamp":"2022-05-13T17:18:12.271704+0200","flow_id":713546383238488,"in_iface":"enp0s3","event_type":"alert","src_ip":"192.168.8.55","src_port":36113,"dest_ip":"192.168.8.58","dest_port":3306,"proto":"TCP","alert":{"action":"allowed","gid":1,"signature_id":2010937,"rev":3,"signature":"ET SCAN Suspicious inbound to mySQL port 3306","category":"Potentially Bad Traffic","severity":2,"metadata":{"created_at":["2010_07_30"],"former_category":["HUNTING"],"updated_at":["2018_03_27"]}},"flow":{"pkts_toserver":1,"pkts_toclient":0,"bytes_toserver":60,"bytes_toclient":0,"start":"2022-05-13T17:18:12.271704+0200"}}
And running one
192.168.8.55 - - [13/May/2022:20:08:29 +0200] "GET /vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit HTTP/1.1" 200 4158
I got:
**Phase 3: Completed filtering (rules).
id: '300003'
level: '12'
description: 'Successful web-server attack after Suricata scan detected'
groups: '['local', 'syslog', 'sshd', 'intrusion']'
firedtimes: '1'
frequency: '2'
mail: 'True'
**Alert to be generated.
My question is, Is it correct use a full alert in log test? I always test it with full log section, in this example
{"timestamp":"2022-05-13T20:08:30.343+0200","rule":{"level":6,"description":"A web attack returned code 200 (success).","id":"31106","mitre":{"id":["T1190"],"tactic":["Initial Access"],"technique":["Exploit Public-Facing Application"]},"firedtimes":3,"mail":false,"groups":["web","accesslog","attack"],"pci_dss":["6.5","11.4"],"gdpr":["IV_35.7.d"],"nist_800_53":["SA.11","SI.4"],"tsc":["CC6.6","CC7.1","CC8.1","CC6.1","CC6.8","CC7.2","CC7.3"]},"agent":{"id":"002","name":"Ubuntu","ip":"192.168.8.61"},"manager":{"name":"siem"},"id":"1652465310.12452","full_log":"127.0.0.1 - - [13/May/2022:20:08:29 +0200] \"GET /vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit HTTP/1.1\" 200 4158","decoder":{"name":"web-accesslog"},"data":{"protocol":"GET","srcip":"127.0.0.1","id":"200","url":"/vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit"},"location":"/opt/lampp/logs/access_log"}
the full_log section is (it escape the double quotes before GET)
127.0.0.1 - - [13/May/2022:20:08:29 +0200] \"GET /vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit HTTP/1.1\" 200 4158
It will look like:
127.0.0.1 - - [13/May/2022:20:08:29 +0200] "GET /vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit HTTP/1.1" 200 4158
Same result as
192.168.8.55 - - [13/May/2022:20:08:29 +0200] "GET /vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit HTTP/1.1" 200 4158
**Phase 1: Completed pre-decoding.
full event: '127.0.0.1 - - [13/May/2022:20:08:29 +0200] "GET /vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit HTTP/1.1" 200 4158'
**Phase 2: Completed decoding.
name: 'web-accesslog'
id: '200'
protocol: 'GET'
srcip: '127.0.0.1'
url: '/vulnerabilities/sqli/?id=%3Fid%3Da%27+UNION+SELECT+%22text1%22%2C%22text2%22%3B--+-%26Submit%3DSubmit&Submit=Submit'
**Phase 3: Completed filtering (rules).
id: '300002'
level: '3'
description: 'Successful web-server attack'
groups: '['local', 'syslog', 'sshd', 'success_attack']'
firedtimes: '4'
mail: 'False'
**Alert to be generated.
Events before been processed should be in
/var/ossec/logs/archive/archives.json or
archives.log (archives.json to be sure)
If archives file doesn't exist, double check manager ossec.conf include log all options as following configuration, and restart the server.
<ossec_config>
<global>
<alerts_log>yes</alerts_log>
<logall>yes</logall>
<logall_json>no</logall_json>
</global>
Anyway, to match that alert log with a rule we can continues from rule
1002, because is the last rule that match it.
**Phase 3: Completed filtering (rules).
id: '1002'
level: '2'
description: 'Unknown problem somewhere in the system.'
groups: '['syslog', 'errors']'
firedtimes: '1'
gpg13: '['4.3']'
mail: 'False'
I did a custom rule:
<rule id="300000" level="5">
<if_sid>1002</if_sid>
<field name="full_log" type="pcre2">(?:\d{1,3}\.){3}\d{1,3}.*?GET\s+\S+\s+HTTP.*?200\s+\d+</field>
<description>test rule</description>
<options>no_full_log</options>
<group>intrusion,</group>
</rule>
The regex look for an valid IP at beginning
(?:\d{1,3}\.){3}\d{1,3}, then the
GET word, then
HTTP following by a
200.
(?:\d{1,3}\.){3}\d{1,3}.*?GET\s+\S+\s+HTTP.*?200\s+\d+And the result is:
**Phase 3: Completed filtering (rules).
id: '300000'
level: '7'
description: 'test rule'
groups: '['local', 'syslog', 'sshd', 'intrusion']'
firedtimes: '1'
mail: 'False'
At this point it's possible use this new custom rule to trigger rule 300002, or create a another rule (example 300005) that fires by
300002 or 300000, and change 300003 to fires with
300005. But rule
300000 doesn't include the
srcip field.
Could you check if it's mandatory use the full alert?, in that case we can try to make another decoder, to make it fit.
Let me know if this information is useful to you.
Regards!