Hi Musakkarul,
At a first sight, the parenthesis are not needed. So, it would be like this:
<url type="pcre2">^\w*.telemetry.mozilla.org</url>
Is the asterisk literal or are you trying to capture anything with that asterisk?
Could you also please share with us the alert that you have mentioned?
Best Regards,
Mariano Koremblum
Hi Musakkarul,
I wouldn’t recommend modifying the default ruleset, as if you someday upgrade your manager, all the changes will be lost.
The best way is to create/modify the rules on the local_rules file which is located in /var/ossec/etc/rules/local_rules.xml. I tested the following and it is working:
<group name="squid,">
<rule id="135000" level="0">
<if_sid>35004, 35005, 35006, 35009</if_sid>
<url type="pcre2">trendmicro\.com|</url>
<url type="pcre2">telemetry\.mozilla\.org</url>
<description>Squid: Ignored files on a 40x error.</description>
</rule>
</group>
And this is the output I get when using the wazuh-logtest tool:
# /var/ossec/bin/wazuh-logtest
Starting wazuh-logtest v4.3.5
Type one log per line
0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.trendmicro.com:443 - HIER_NONE/- test/html
**Phase 1: Completed pre-decoding.
full event: '0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.trendmicro.com:443 - HIER_NONE/- test/html'
**Phase 2: Completed decoding.
name: 'squid-accesslog'
action: 'TCP_DENIED'
id: '403'
srcip: '192.168.10.10'
url: 'incoming.trendmicro.com:443'
**Phase 3: Completed filtering (rules).
id: '135000'
level: '0'
description: 'Squid: Ignored files on a 40x error.'
groups: '['test']'
firedtimes: '1'
mail: 'False'
0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- test/html
**Phase 1: Completed pre-decoding.
full event: '0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- test/html'
**Phase 2: Completed decoding.
name: 'squid-accesslog'
action: 'TCP_DENIED'
id: '403'
srcip: '192.168.10.10'
url: 'incoming.telemetry.mozilla.org:443'
**Phase 3: Completed filtering (rules).
id: '135000'
level: '0'
description: 'Squid: Ignored files on a 40x error.'
groups: '['test']'
firedtimes: '2'
mail: 'False'
I would strongly recommend you to read the following links to have a better understanding of the rules/decoders creation:
Please, give it a try and let us know if it is useful for you. PS: remember to reset your manager after applying the changes.
Best Regards,
Mariano Koremblum
Hi Musakkarul,
Could you please share with us the full_log field of one of such events? Remember to obfuscate the sensitive information it may contain.
I will be waiting for your reply,
Mariano Koremblum
Hi again Musakkarul,
When I test the log with our wazuh-logtest tool, I get the following:
# /var/ossec/bin/wazuh-logtest
Starting wazuh-logtest v4.3.6
Type one log per line
0 172.16.2.56 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- text/html
**Phase 1: Completed pre-decoding.
full event: '0 172.16.2.56 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- text/html'
**Phase 2: Completed decoding.
name: 'squid-accesslog'
action: 'TCP_DENIED'
id: '403'
srcip: '172.16.2.56'
url: 'incoming.telemetry.mozilla.org:443'
**Phase 3: Completed filtering (rules).
id: '135000'
level: '0'
description: 'Squid: Ignored files on a 40x error.'
groups: '['test']'
firedtimes: '1'
mail: 'False'
Which means that it is working as expected.
Just in case, did you restart your manager after applying the changes?
Best Regards,
Mariano Koremblum
Additionally, please check in the event if the field url is being correctly extracted. If not, when passing through our custom rule, the URL labels won’t have any effect.
Regards
Hi Musakarul,
If I test your configuration using wazuh-logtest I get the following:
# /var/ossec/bin/wazuh-logtest 130 ↵
Starting wazuh-logtest v4.3.6
Type one log per line
0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- test/html
**Phase 1: Completed pre-decoding.
full event: '0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- test/html'
**Phase 2: Completed decoding.
name: 'squid-accesslog'
action: 'TCP_DENIED'
id: '403'
srcip: '192.168.10.10'
url: 'incoming.telemetry.mozilla.org:443'
**Phase 3: Completed filtering (rules).
id: '135000'
level: '0'
description: 'Squid: Ignored files on a 40x error.'
groups: '['squid']'
firedtimes: '1'
mail: 'False'
0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.trendmicro.com:443 - HIER_NONE/- test/html
**Phase 1: Completed pre-decoding.
full event: '0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.trendmicro.com:443 - HIER_NONE/- test/html'
**Phase 2: Completed decoding.
name: 'squid-accesslog'
action: 'TCP_DENIED'
id: '403'
srcip: '192.168.10.10'
url: 'incoming.trendmicro.com:443'
**Phase 3: Completed filtering (rules).
id: '35005'
level: '5'
description: 'Squid: Forbidden: Attempt to access forbidden file or directory.'
groups: '['squid']'
firedtimes: '1'
gdpr: '['IV_35.7.d']'
hipaa: '['164.312.b']'
mail: 'False'
nist_800_53: '['AU.14', 'AC.7']'
pci_dss: '['10.2.4']'
tsc: '['CC6.1', 'CC6.8', 'CC7.2', 'CC7.3']'
**Alert to be generated.
It is not handling correctly the trendmicro URLs. But, if you change the rule to:
<group name="squid,">
<rule id="135000" level="0">
<if_sid>35004, 35005, 35006, 35009</if_sid>
<url type="pcre2">trendmicro\.com|</url>
<url type="pcre2">mozilla.org</url>
<description>Squid: Ignored files on a 40x error.</description>
</rule>
</group>
Then I get the expected output:
# /var/ossec/bin/wazuh-logtest
Starting wazuh-logtest v4.3.6
Type one log per line
0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- test/html
**Phase 1: Completed pre-decoding.
full event: '0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.telemetry.mozilla.org:443 - HIER_NONE/- test/html'
**Phase 2: Completed decoding.
name: 'squid-accesslog'
action: 'TCP_DENIED'
id: '403'
srcip: '192.168.10.10'
url: 'incoming.telemetry.mozilla.org:443'
**Phase 3: Completed filtering (rules).
id: '135000'
level: '0'
description: 'Squid: Ignored files on a 40x error.'
groups: '['squid']'
firedtimes: '1'
mail: 'False'
0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.trendmicro.com:443 - HIER_NONE/- test/html
**Phase 1: Completed pre-decoding.
full event: '0 192.168.10.10 TCP_DENIED/403 4140 CONNECT incoming.trendmicro.com:443 - HIER_NONE/- test/html'
**Phase 2: Completed decoding.
name: 'squid-accesslog'
action: 'TCP_DENIED'
id: '403'
srcip: '192.168.10.10'
url: 'incoming.trendmicro.com:443'
**Phase 3: Completed filtering (rules).
id: '135000'
level: '0'
description: 'Squid: Ignored files on a 40x error.'
groups: '['squid']'
firedtimes: '2'
mail: 'False'
We do not recommend mixing different regexes types.
Coming back to your question, yes, it will omit every URL that contains the string mozilla.org.
Best Regards,
Mariano Koremblum