Fail2ban: differenze tra le versioni

m
Tag non chiuso
m (Tag non chiuso)
 
(11 versioni intermedie di 2 utenti non mostrate)
Riga 46: Riga 46:
</pre>
</pre>


== Attivazione di nuovi filtri ==
== Attivazione di nuovi filtri (Da Debian Stretch) ==
Fail2ban utilizza una directory apposita per l'attivazione e la gestione di filtri personalizzati. Tutti i file inseriti in questa directory e aventi estensione <tt>.conf</tt> vengono letti e processati all'avvio del demone.
<br/>
Per attivare dei filtri su demoni diversi da SSH è sufficiente quindi creare un nuovo file di configurazione, inserendolo nella directory <tt>/etc/fail2ban/jail.d</tt>:
<pre>
# nano /etc/fail2ban/jail.d/custom.conf
</pre>
Un contenuto per il file, che ci garantisca un buon numero di filtri attivi può essere il seguente:
<pre>
[DEFAULT]
bantime = 14400
ignoreip = 127.0.0.1/8
maxretry = 5
 
[sshd]
enabled = true
port    = 2293
logpath = %(sshd_log)s
backend = %(sshd_backend)s
 
[dropbear]
enabled = true
port    = 2293
logpath  = %(dropbear_log)s
backend  = %(dropbear_backend)s
 
[apache-auth]
enabled = true
port    = http,https
logpath  = %(apache_error_log)s
 
[apache-badbots]
enabled = true
port    = http,https
logpath  = %(apache_access_log)s
bantime  = 172800
maxretry = 1
 
[apache-noscript]
enabled = true
port    = http,https
logpath  = %(apache_error_log)s
 
[apache-overflows]
enabled = true
port    = http,https
logpath  = %(apache_error_log)s
maxretry = 2
 
[apache-nohome]
enabled = true
port    = http,https
logpath  = %(apache_error_log)s
maxretry = 2
 
[apache-botsearch]
enabled = true
port    = http,https
logpath  = %(apache_error_log)s
maxretry = 2
 
[apache-fakegooglebot]
port    = http,https
logpath  = %(apache_access_log)s
maxretry = 1
ignorecommand = %(ignorecommands_dir)s/apache-fakegooglebot <ip>
 
[apache-modsecurity]
enabled = true
port    = http,https
logpath  = %(apache_error_log)s
maxretry = 2
 
[apache-shellshock]
enabled = true
port    = http,https
logpath = %(apache_error_log)s
maxretry = 1
 
[php-url-fopen]
enabled = true
port    = http,https
logpath = %(apache_access_log)s
 
[suhosin]
enabled = true
port    = http,https
logpath = %(suhosin_log)s
 
[roundcube-auth]
[roundcube-auth]
#enabled = true
port    = http,https
logpath  = %(roundcube_errors_log)s
 
[drupal-auth]
enabled = true
port    = http,https
logpath  = %(syslog_daemon)s
backend  = %(syslog_backend)s
 
[monit]
#enabled = true
port = 2812
logpath  = /var/log/monit
 
[webmin-auth]
enabled = true
port    = 10000
logpath = %(syslog_authpriv)s
backend = %(syslog_backend)s
 
[froxlor-auth]
enabled = true
port    = http,https
logpath  = %(syslog_authpriv)s
backend  = %(syslog_backend)s
 
[vsftpd]
enabled = true
port    = ftp,ftp-data,ftps,ftps-data
logpath  = %(vsftpd_log)s
 
[postfix]
#enabled = true
port    = smtp,465,submission
logpath  = %(postfix_log)s
backend  = %(postfix_backend)s
 
[postfix-rbl]
#enabled = true
port    = smtp,465,submission
logpath  = %(postfix_log)s
backend  = %(postfix_backend)s
maxretry = 1
 
[postfix-sasl]
#enabled = true
port    = smtp,465,submission,imap3,imaps,pop3,pop3s
logpath  = %(postfix_log)s
backend  = %(postfix_backend)s
 
[squirrelmail]
#enabled = true
port = smtp,465,submission,imap2,imap3,imaps,pop3,pop3s,http,https,socks
logpath = /var/lib/squirrelmail/prefs/squirrelmail_access_log
 
[recidive]
enabled = true
logpath  = /var/log/fail2ban.log
banaction = %(banaction_allports)s
bantime  = 604800  ; 1 week
findtime = 86400  ; 1 day
 
[pam-generic]
enabled = true
banaction = %(banaction_allports)s
logpath  = %(syslog_authpriv)s
backend  = %(syslog_backend)s
 
[xinetd-fail]
enabled = true
banaction = iptables-multiport-log
logpath  = %(syslog_daemon)s
backend  = %(syslog_backend)s
maxretry  = 2
</pre>
 
== Attivazione di nuovi filtri (Fino a Debian Jessie) ==
=== Server di posta Dovecot ===
=== Server di posta Dovecot ===
Creare il file di filtro <code>/etc/fail2ban/filter.d/dovecot-pop3imap.conf</code>:
Creare il file di filtro <code>/etc/fail2ban/filter.d/dovecot-pop3imap.conf</code>:
Riga 100: Riga 268:


=== Apache ===
=== Apache ===
Aggiungere in <code>/etc/fail2ban/jail.d/jail.local i seguenti filtri:
Aggiungere in <code>/etc/fail2ban/jail.d/jail.local</code> i seguenti filtri:
<pre>
<pre>
##To block failed login attempts use the below jail.
##To block failed login attempts use the below jail.
Riga 167: Riga 335:
Salviamo e riavviamo:
Salviamo e riavviamo:
<pre>
<pre>
# systemctl restart fal2ban
# systemctl restart fail2ban
</pre>
</pre>


=== Server FTP===
=== Server FTP===
All'interno del file <code>/etc/fail2ban/jail.conf</code> è presente una sezione FTP in cui basta abilitare quello che si desidera.
All'interno del file /etc/fail2ban/jail.conf è presente una sezione FTP in cui basta abilitare quello che si desidera.
<pre>
<pre>
# FTP servers
# FTP servers
Riga 235: Riga 403:
</pre>
</pre>
"ssh" va sostituito con la porta effettivamente usata dall'utente. Nel caso si lasci "ssh", il ban avverrà sulla porta di default di SSH (porta 22).
"ssh" va sostituito con la porta effettivamente usata dall'utente. Nel caso si lasci "ssh", il ban avverrà sulla porta di default di SSH (porta 22).
=== Altri filtri consigliati ===
Alcuni filtri utili da inserire in <code>jail.local</code>:
<pre>
[pam-generic]
enabled  = true
banaction = iptables-allports
[apache-nohome]
enabled  = true
port      = http,https
filter    = apache-nohome
banaction = iptables-multiport
action    = %(action_mwl)s
logpath  = /var/log/apache*/*access.log
maxretry  = 1
[php-url-fopen]
enabled  = true
port      = http,https
filter    = php-url-fopen
logpath  = /var/log/apache*/*access.log
maxretry  = 1
</pre>


=== Attivazione dei nuovi filtri ===
=== Attivazione dei nuovi filtri ===
Riga 543: Riga 735:
:[[Utente:porkyhttp|porkyhttp]] 17:04, 06 mag 2012 (CEST)
:[[Utente:porkyhttp|porkyhttp]] 17:04, 06 mag 2012 (CEST)
: lula  12 gen 2017 (CET)
: lula  12 gen 2017 (CET)
|Numero_revisori=2
|Estesa_da =  
|Estesa_da =  
: [[Utente : mm-barabba|mm-barabba]] 06-04-2013
: [[Utente : mm-barabba|mm-barabba]] 06-04-2013