diff --git a/monitoring/docker-compose.yml b/monitoring/docker-compose.yml index 8639c5b5..e113d3d6 100644 --- a/monitoring/docker-compose.yml +++ b/monitoring/docker-compose.yml @@ -59,7 +59,9 @@ services: - SSL_KEY=/etc/ssl/filebeat.key - API_USERNAME=wazuh-wui - API_PASSWORD=${WAZUH_API_PASSWORD} + entrypoint: ["/bin/bash", "/wazuh-custom/init.sh"] volumes: + - ./wazuh/config/wazuh_manager/:/wazuh-custom/:ro - wazuh_api_configuration:/var/ossec/api/configuration - wazuh_etc:/var/ossec/etc - wazuh_logs:/var/ossec/logs diff --git a/monitoring/wazuh/config/wazuh_manager/decoders/modsecurity_decoder.xml b/monitoring/wazuh/config/wazuh_manager/decoders/modsecurity_decoder.xml new file mode 100644 index 00000000..8685a477 --- /dev/null +++ b/monitoring/wazuh/config/wazuh_manager/decoders/modsecurity_decoder.xml @@ -0,0 +1,29 @@ + + + + + ModSecurity: + + + + + modsecurity + ModSecurity: Access denied + \[client (\d+\.\d+\.\d+\.\d+):\p+\] ModSecurity: Access denied with code (\d+) \(phase \d+\)\.\s*(\S[^[]*?)\s*\[id "(\d+)"\][^\[]*\[msg "([^"]+)"\][^\[]*\[uri "([^"]+)"\] + srcip,status,extra_data,id,extra_data2,url + + + + + modsecurity + ModSecurity: Warning + \[client (\d+\.\d+\.\d+\.\d+):\p+\] ModSecurity: Warning\.[^\[]*\[id "(\d+)"\][^\[]*\[msg "([^"]+)"\][^\[]*\[uri "([^"]+)"\] + srcip,id,extra_data,url + diff --git a/monitoring/wazuh/config/wazuh_manager/init.sh b/monitoring/wazuh/config/wazuh_manager/init.sh new file mode 100644 index 00000000..25ecb054 --- /dev/null +++ b/monitoring/wazuh/config/wazuh_manager/init.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -e + +# ─── Copie de la config custom (montée hors du volume wazuh_etc) ────────────── +CUSTOM=/wazuh-custom + +cp "$CUSTOM/ossec.conf" /var/ossec/etc/ossec.conf + +mkdir -p /var/ossec/etc/decoders /var/ossec/etc/rules +cp "$CUSTOM/decoders/"*.xml /var/ossec/etc/decoders/ 2>/dev/null || true +cp "$CUSTOM/rules/"*.xml /var/ossec/etc/rules/ 2>/dev/null || true + +# ─── Démarrage Wazuh Manager (entrypoint original) ──────────────────────────── +exec /init diff --git a/monitoring/wazuh/config/wazuh_manager/ossec.conf b/monitoring/wazuh/config/wazuh_manager/ossec.conf new file mode 100644 index 00000000..cf206535 --- /dev/null +++ b/monitoring/wazuh/config/wazuh_manager/ossec.conf @@ -0,0 +1,579 @@ + + + + + yes + yes + no + no + no + 10m + 0 + + + + + 3 + + + + + plain + + + + + secure + 1514 + tcp + 131072 + + + + + no + yes + yes + yes + yes + yes + yes + yes + 43200 + etc/rootcheck/rootkit_files.txt + etc/rootcheck/rootkit_trojans.txt + yes + + + + yes + 1800 + 1d + yes + wodles/java + wodles/ciscat + + + + yes + yes + /var/log/osquery/osqueryd.results.log + /etc/osquery/osquery.conf + yes + + + + + no + 1h + yes + yes + yes + yes + yes + yes + yes + + 10 + + + + + + yes + yes + 12h + yes + + + + + yes + yes + 60m + + + + + yes + + https://wazuh.indexer:9200 + + + + /etc/ssl/root-ca.pem + + /etc/ssl/filebeat.pem + /etc/ssl/filebeat.key + + + + + + no + 43200 + yes + yes + no + /etc,/usr/bin,/usr/sbin + /bin,/sbin,/boot + /etc/mtab + /etc/hosts.deny + /etc/mail/statistics + /etc/random-seed + /etc/random.seed + /etc/adjtime + /etc/httpd/logs + /etc/utmpx + /etc/wtmpx + /etc/cups/certs + /etc/dumpdates + /etc/svc/volatile + .log$|.swp$ + /etc/ssl/private.key + yes + yes + yes + yes + 10 + 100 + + yes + 5m + 1h + 10 + + + + + + 127.0.0.1 + ^localhost.localdomain$ + 90.50.148.138 + + + + + disable-account + disable-account + yes + + + + restart-wazuh + restart-wazuh + + + + firewall-drop + firewall-drop + yes + + + + host-deny + host-deny + yes + + + + route-null + route-null + yes + + + + win_route-null + route-null.exe + yes + + + + netsh + netsh.exe + yes + + + + + + + firewall-drop + local + 5710,5711,5712,5716,5720,5760,5763 + 0 + + + + + firewall-drop + local + authentication_failures + 0 + + + + + firewall-drop + local + authentication_failed + 0 + + + + + host-deny + local + 5710,5711,5712,5716,5720,5760,5763 + 0 + + + + + firewall-drop + local + 7 + web,attack + 300 + + + + + firewall-drop + local + 1002,2502,2503,2504 + 3600 + + + + + host-deny + local + authentication_failures,authentication_failed + 0 + + + + + firewall-drop + local + 100202,100203,100205 + 21600 + + + + + firewall-drop + local + 100204,100206 + 86400 + + + + + firewall-drop + local + 100210 + 86400 + + + + no + host-deny + all + 100210 + 86400 + + + + firewall-drop + all + 100204,100206 + 86400 + + + + firewall-drop + all + 5710,5711,5712,5716,5720,5760,5763 + 0 + + + + + firewall-drop + all + authentication_failures + 0 + + + + + firewall-drop + all + authentication_failed + 0 + + + + + host-deny + all + 5710,5711,5712,5716,5720,5760,5763 + 0 + + + + + firewall-drop + all + 7 + web,attack + 300 + + + + + firewall-drop + all + 1002,2502,2503,2504 + 3600 + + + + + host-deny + all + authentication_failures,authentication_failed + 0 + + + + + firewall-drop + all + 100202,100203,100205 + 21600 + + + + + command + df -P + 360 + + + + full_command + netstat -tulpn | sed 's/\([[:alnum:]]\+\)\ \+[[:digit:]]\+\ \+[[:digit:]]\+\ \+\(.*\):\([[:digit:]]*\)\ \+\([0-9\.\:\*]\+\).\+\ \([[:digit:]]*\/[[:alnum:]\-]*\).*/\1 \2 == \3 == \4 \5/' | sort -k 4 -g | sed 's/ == \(.*\) ==/:\1/' | sed 1,2d + netstat listening ports + 360 + + + + full_command + last -n 20 + 360 + + + + + + ruleset/decoders + ruleset/rules + + 0025-sendmail_rules.xml + 0030-postfix_rules.xml + 0035-spamd_rules.xml + 0040-imapd_rules.xml + 0045-mailscanner_rules.xml + 0050-ms-exchange_rules.xml + 0055-courier_rules.xml + 0065-pix_rules.xml + 0070-netscreenfw_rules.xml + 0075-cisco-ios_rules.xml + 0080-sonicwall_rules.xml + 0090-telnetd_rules.xml + 0100-solaris_bsm_rules.xml + 0105-asterisk_rules.xml + 0110-ms_dhcp_rules.xml + 0115-arpwatch_rules.xml + 0130-trend-osce_rules.xml + 0135-hordeimp_rules.xml + 0155-dovecot_rules.xml + 0160-vmpop3d_rules.xml + 0165-vpopmail_rules.xml + 0170-ftpd_rules.xml + 0175-proftpd_rules.xml + 0185-vsftpd_rules.xml + 0190-ms_ftpd_rules.xml + 0195-named_rules.xml + 0215-policy_rules.xml + 0750-github_rules.xml + 0250-apache_rules.xml + 0255-zeus_rules.xml + 0265-php_rules.xml + 0275-squid_rules.xml + 0295-mysql_rules.xml + 0305-dropbear_rules.xml + 0315-apparmor_rules.xml + 0320-clam_av_rules.xml + 0350-amazon_rules.xml + 0360-serv-u_rules.xml + 0385-oscap_rules.xml + 0390-fortiddos_rules.xml + 0391-fortigate_rules.xml + 0392-fortimail_rules.xml + 0393-fortiauth_rules.xml + 0120-symantec-av_rules.xml + 0125-symantec-ws_rules.xml + 0395-hp_rules.xml + 0405-rsa-auth-manager_rules.xml + 0410-imperva_rules.xml + 0415-sophos_rules.xml + 0990-amazon-security-lake_rules.xml + 0435-ms_logs_rules.xml + 0445-identity_guard_rules.xml + 0450-mongodb_rules.xml + 0460-jenkins_rules.xml + 0470-vshell_rules.xml + 0475-suricata_rules.xml + 0480-qualysguard_rules.xml + 0485-cylance_rules.xml + 0700-paloalto_rules.xml + 0500-owncloud_rules.xml + 0505-vuls_rules.xml + 0525-openvas_rules.xml + 0530-mysql_audit_rules.xml + 0535-mariadb_rules.xml + 0540-pfsense_rules.xml + 0545-osquery_rules.xml + 0550-kaspersky_rules.xml + 0555-azure_rules.xml + 0565-ms_ipsec_rules.xml + 0575-win-base_rules.xml + 0580-win-security_rules.xml + 0585-win-application_rules.xml + 0590-win-system_rules.xml + 0601-win-vipre_rules.xml + 0602-win-wfirewall_rules.xml + 0610-win-ms_logs_rules.xml + 0630-nextcloud_rules.xml + 0675-panda-paps_rules.xml + 0680-checkpoint-smart1_rules.xml + 0770-gitlab_rules.xml + 0775-arbor_rules.xml + 0780-fireeye_rules.xml + 0785-huawei-usg_rules.xml + 0800-sysmon_id_1.xml + 0810-sysmon_id_3.xml + 0820-sysmon_id_7.xml + 0830-sysmon_id_11.xml + 0840-win_event_channel.xml + 0860-sysmon_id_13.xml + 0870-sysmon_id_8.xml + 0905-cisco-ftd_rules.xml + 0690-gcp_rules.xml + 0910-ms-exchange-proxylogon_rules.xml + 0920-oracledb_rules.xml + 0925-eset-remote_rules.xml + 0955-WEF-baseline_rules.xml + 0960-macos_rules.xml + 0995-microsoft-graph_rules.xml + 0755-office365_rules.xml + 0140-roundcube_rules.xml + 0998-aws-security-hub-rules.xml + 0400-openvpn_rules.xml + etc/lists/audit-keys + etc/lists/amazon/aws-eventnames + etc/lists/security-eventchannel + etc/lists/malicious-ioc/malicious-ip + etc/lists/malicious-ioc/malicious-domains + etc/lists/malicious-ioc/malware-hashes + + etc/decoders + etc/rules + + + + + yes + 1 + 64 + 15m + + + + + no + 1515 + no + yes + no + HIGH:!ADH:!EXP:!MD5:!RC4:!3DES:!CAMELLIA:@STRENGTH + no + etc/sslmanager.cert + etc/sslmanager.key + no + + + + + wazuh + node01 + master + aa093264ef885029653eea20dfcf51ae + 1516 + 0.0.0.0 + + wazuh.manager + + no + yes + + + + + + + syslog + /var/ossec/logs/active-responses.log + + diff --git a/monitoring/wazuh/config/wazuh_manager/rules/modsecurity_rules.xml b/monitoring/wazuh/config/wazuh_manager/rules/modsecurity_rules.xml new file mode 100644 index 00000000..058d1f52 --- /dev/null +++ b/monitoring/wazuh/config/wazuh_manager/rules/modsecurity_rules.xml @@ -0,0 +1,94 @@ + + + + + + + modsecurity-block + ModSecurity: requête bloquée ($(extra_data)) sur $(url) + modsecurity_block, + + + + + modsecurity-warning + ModSecurity: alerte $(extra_data) sur $(url) + modsecurity_warning, + + + + + + + 100200 + SQL Injection + ModSecurity: SQL Injection détecté depuis $(srcip) sur $(url) + modsecurity_sqli,sql_injection, + + + + + 100200 + XSS + ModSecurity: XSS détecté depuis $(srcip) sur $(url) + modsecurity_xss,xss, + + + + + 100200 + RCE + ModSecurity: tentative RCE depuis $(srcip) sur $(url) + modsecurity_rce,rce, + + + + + 100200 + LFI + ModSecurity: LFI détecté depuis $(srcip) sur $(url) + modsecurity_lfi,lfi, + + + + + 100200 + Critical anomaly score\|anomaly score + ModSecurity: score d'anomalie critique depuis $(srcip) + modsecurity_anomaly, + + + + + 100200 + IP is banned\|ip.banned + ModSecurity: IP bannie $(srcip) tente un accès + modsecurity_banned, + + + + + modsecurity-block + 429 + ModSecurity: rate-limit déclenché depuis $(srcip) + modsecurity_ratelimit, + + + + + + 100200 + + ModSecurity: $(srcip) bloqué 5 fois en 2 min — attaque soutenue + modsecurity_repeated, + + +