Hi Micoots,
If you want to monitor an HTTP server like Apache, the best way is to deploy a Wazuh agent in the same host.
As you said, there are 2 pre-defined localfile blocks in the default Wazuh agent configuration, so there is no need to an extra configuration in the agent side.
Wazuh agent will monitor /var/log/httpd/error_log and /var/log/httpd/acces_log and send them to Wazuh manager.
By default in Wazuh manager, there are defined rules for apache in /var/ossec/ruleset/rules/0250-apache_rules.xml.
Take a look at that file because there are many ModSecurity rules defined.
The configuration you added on Wazuh manager is not needed unless you have an httpd server in the same host as your Wazuh manager.
I’ve tried to reproduce your environment with 2 CentOS 7 hosts. 1 Wazuh manager and 1 CentOS 7 with Apache. With the two localfile blocks in agent configuration /var/ossec/etc/ossec.conf
<localfile>
<log_format>apache</log_format>
<location>/var/log/httpd/error_log</location>
</localfile>
<localfile>
<log_format>apache</log_format>
<location>/var/log/httpd/access_log</location>
</localfile>
After setting up the Apache server I made some invalid requests to it like:
curl example.com/invadlireq
And in Wazuh manager I get the following alert:
** Alert 1612436633.3498915: - web,accesslog,attack,pci_dss_6.5,pci_dss_11.4,gdpr_IV_35.7.d,nist_800_53_SA.11,nist_800_53_SI.4,tsc_CC6.6,tsc_CC7.1,tsc_CC8.1,tsc_CC6.1,tsc_CC6.8,tsc_CC7.2,tsc_CC7.3,
2021 Feb 04 11:03:53 (apache) any->/var/log/httpd/access_log
Rule: 31101 (level 5) -> 'Web server 400 error code.'
Src IP: 127.0.0.1
127.0.0.1 - - [04/Feb/2021:11:03:53 +0000] "GET /invadlireq HTTP/1.1" 404 208 "-" "curl/7.29.0"
To troubleshoot your issue, first, we have to make sure that Wazuh manager is receiving events from your agent.
Activate the logall in ossec.conf and check for incoming events in /var/ossec/logs/archives/archives.log https://documentation.wazuh.com/4.0/user-manual/reference/ossec-conf/global.html#logall.
Once you see incoming events from your agent, you should turn logall off, to avoid disk flooding.
Check if Wazuh manager is generating alerts. Make some invalid request to your Apache server while monitoring Wazuh’s manager file /var/ossec/logs/alerts/alerts.log. It should log 404 alerts.
If Wazuh manager is generating alerts, then the events in your logs are not enough critical to generate alerts or there is no default rule for that event.
Please share with us the content of your Apache logs that you think should trigger an alert.
If there is no alert for that logs we could create a custom one. Please take a look at https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwi-kYGHi9DuAhWFWxUIHbaGBRYQFjABegQIBRAC&url=https%3A%2F%2Fwazuh.com%2Fblog%2Fcreating-decoders-and-rules-from-scratch%2F&usg=AOvVaw0RiHBT0ZTiPj_fC8Q8UdY5
If you couldn’t see any events coming from your agent, please check connectivity between your agent and your Wazuh manager. Check that there is no firewall blocking connections. You could make a fast test with ping or checking the Wazuh agent logs /var/ossec/logs/ossec.log to see if it is connected to the Manager. Make sure all required ports are open https://documentation.wazuh.com/4.0/getting-started/architecture.html
Hope it helps, Víctor.
vim wazuh-server-installation.sh
eval "mkdir /etc/filebeat/certs ${debug}"
eval "cp ~/certs.tar /etc/filebeat/certs/ ${debug}"
eval "cd /etc/filebeat/certs/ ${debug}"
eval "tar -xf certs.tar ${iname}.pem ${iname}.key root-ca.pem ${debug}"
if [ ${iname} != "filebeat" ]
then
eval "mv /etc/filebeat/certs/${iname}.pem /etc/filebeat/certs/filebeat.pem ${debug}"
eval "mv /etc/filebeat/certs/${iname}.key /etc/filebeat/certs/filebeat.key ${debug}"
fi
iname is defined in the top as what is given to the -n argument.
When extracted, the filenames are:
filebeat.pem
filebeat.key
So the first clause can’t extract anything, and the then clause then gets activated and can’t work because the names are actually as above, so nothing is done and the script fails.
Changed to:
eval "mkdir /etc/filebeat/certs ${debug}"
eval "cp ~/certs.tar /etc/filebeat/certs/ ${debug}"
eval "cd /etc/filebeat/certs/ ${debug}"
eval "tar -xf certs.tar filebeat.pem filebeat.key root-ca.pem ${debug}"
--
You received this message because you are subscribed to a topic in the Google Groups "Wazuh mailing list" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wazuh/8TH_cLbthVk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wazuh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/8ecf0087-8b50-4770-985b-6a21c5f44907n%40googlegroups.com.
Hi Michael,
Yes, you are right, your custom Apache logs won’t trigger the default Apache decoder built-in Wazuh.
For example, in my access_log Apache logs looks like:
127.0.0.1 - - [04/Feb/2021:15:44:04 +0000] "GET /invadlireq HTTP/1
.1" 404 208 "-" "curl/7.29.0"
And your logs:
192.168.54.4 somedomain.com - - 80 [04/Feb/2021:22:43:24 +1100] "
GET /invalidrequest HTTP/1.1" "" 404 212 "-" "curl/7.29.0" 373 419
1291
That’s the main reason for Wazuh not generating alerts. You should create your own decoders/rules.
Feel free to check our blog post: https://wazuh.com/blog/creating-decoders-and-rules-from-scratch/
If you need some help creating those rules/decoders, don’t hesitate to ask again!
Regards,
Víctor.