Linux
Réseaux
Fail2ban
Bannir l'IP des pirates qui font des attaques par brute-force
Pour : Linux
Fail2ban est une protection supplémentaire pour votre serveur contre les pirates.
Le logiciel permet de se protéger des attaques par force brute ou par dictionnaire, comment?
En bannissant l'adresse IP des gens qui essayent de se connecter plusieurs fois de suite sans réussir.
Installation
On fait une installation depuis les dépôts:
apt-get install fail2ban
nano /etc/fail2ban/jail.conf
# Les adresse IP a ignorer par Fail2ban ignoreip = 127.0.0.1 # Temps de bannissement en secondes bantime = 600 # Nombre de tentative autorisés avant d'être banni maxretry = 3 # Adresse e-mail destinataire pour recevoir les notifications destmail XXXXXXX@test.com # Action à éffectuer en cas de détection positive (voir dans /etc/fail2ban/action.d/) action
[ssh] enabled = true port = ssh filter = sshd logpath = /var/log/auth.log maxretry = 6
/etc/init.d/fail2ban restart
fail2ban-client [argument]
man fail2ban-client
[apache-404] enabled = true port = http filter = apache-404 logpath = /var/log/apache*/error*.log maxretry = 8
# Fail2Ban configuration file # # Author: Cédric OLIVIER # # [Definition] # Option: failregex # Notes.: regex to match the 404 failure messages in the logfile. The # host must be matched by a group named "host". The tag "
" can # be used for standard IP/hostname matching and is only an alias for # (?:::f{4,6}:)?(?P [\w\-.^_]+) # Values: TEXT # failregex = [[]client []] (File does not exist|script not found or unable to stat): .* # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT # ignoreregex =
[apache-phpmyadmin] enabled = true port = http,https filter = apache-phpmyadmin logpath = /var/log/apache*/*error.log maxretry = 3
# Fail2Ban configuration file # # Bans bots scanning for non-existing phpMyAdmin installations on your webhost. # # Author: Gina Haeussge # [Definition] docroot = /var/www badadmin = PMA|phpmyadmin|myadmin|mysql|mysqladmin|sqladmin|mypma|admin|xampp|mysqldb|mydb|db|pmadb|phpmyadmin1|phpmyadmin2 # Option: failregex # Notes.: Regexp to match often probed and not available phpmyadmin paths. # Values: TEXT # failregex = [[]client
[]] File does not exist: %(docroot)s/(?:%(badadmin)s) # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT # ignoreregex =
[apache-admin] enabled = true port = http filter = apache-admin logpath = /var/log/apache*/error*.log maxretry = 6
# Fail2Ban configuration file # # Author: Cyril Jaquier # # $Revision: 471 $ # [Definition] # Option: failregex # Notes.: regex to match the password failure messages in the logfile. The # host must be matched by a group named "host". The tag "" can # be used for standard IP/hostname matching. # Values: TEXT # [client x.x.x.x] File does not exist: /home/www/admin/admin, failregex = [[]client []] File does not exist: .*admin|PMA|mysql # # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT # ignoreregex =