diff --git a/fail2ban/filter.d/nginx-generic-badbots.conf b/fail2ban/filter.d/nginx-generic-badbots.conf new file mode 100644 index 0000000..78491e1 --- /dev/null +++ b/fail2ban/filter.d/nginx-generic-badbots.conf @@ -0,0 +1,13 @@ +# /etc/fail2ban/filter.d/nginx-generic-badbots.conf +# +# Filtro genérico para Bad Bots e scanners comuns que se aplica a todos os sites. +# Este filtro é referenciado pelas jails individuais de cada site. +# ******************************************************************* + +[Definition] +# Detecta tentativas de acesso a arquivos e diretórios sensíveis (path traversal, env, etc.) +failregex = ^ .* "(GET|POST|HEAD|OPTIONS) .*(\.env|\.git/|\.svn/|setup\.php|phpmyadmin/|vendor/|wp-config\.php|wlwmanifest\.xml|test\.php).* HTTP\/1\..*"$ +# Detecta ferramentas de scanner conhecidas (sqlmap, Nikto, wpscan, etc.) + ^ .* "(GET|POST|HEAD|OPTIONS) .*(sqlmap|Nikto|wpscan|Telescope|zgrab|masscan).* HTTP\/1\..*"$ + +ignoreregex = diff --git a/fail2ban/jail.d/nginx-template.conf b/fail2ban/jail.d/nginx-template.conf new file mode 100644 index 0000000..8c6f574 --- /dev/null +++ b/fail2ban/jail.d/nginx-template.conf @@ -0,0 +1,33 @@ +# /etc/fail2ban/jail.d/nginx-template.conf +# +# TEMPLATE: COPIE e RENOMEIE este arquivo para [SEU-SITE].conf +# ******************************************************************* +# Renomeie: nginx-template.conf -> site-meuprojeto.conf +# ******************************************************************* + +#[nginx-site-meuprojeto-badbots] +#enabled = true +## Ação: Usa a ação padrão definida no [DEFAULT] do jail.local +#action = %(action_mwl)s +## Porta a ser banida (HTTPS e HTTP) +#port = http,https +## Referencia o filtro genérico criado (1.1. Passo) +#filter = nginx-generic-badbots +## *** CRÍTICO: Mude este caminho para o log dedicado do NGINX *** +#logpath = /var/log/nginx/site-meuprojeto.bad-bot.log +# +## Configurações de Banimento Customizadas +#maxretry = 3 +#findtime = 10m +#bantime = 12h +# +# =================================================================== +# JAIL ADICIONAL (Exemplo de log de erro) +# =================================================================== +# +#[nginx-site-meuprojeto-errors] +#enabled = false # Desabilite ou Habilite conforme a necessidade de monitoramento +#filter = nginx-bad-request +#logpath = /var/log/nginx/site-meuprojeto.error.log +#maxretry = 5 +#bantime = 3h