Bloquer les attaques de type w00tw00t.at.ISC.SANS sur Apache2
Administration des Réseaux, Adminstration Server Linux Add comments
Si vous avez un serveur Apache, vous avez très certainement dans les logs des attaques de type w00tw00t.at.ISC.SANS. Elles sont le fruit de kiddies utilisant un logiciel de scanning nommé DFind
Si votre serveur est à jour et correctement configuré, vous ne devriez pas en avoir peur. Mais on va quand même s’occuper de ces petits mariols du net tout juste bon à utiliser un script.
On va installer Fail2Ban est dés que l’on trouvera la signature du scanner dans les logs, on bannira l’IP de l’attaquant via iptables, simple et radicale.
On commence par mettre à jour les dépôts et installer fail2ban
apt-get update && apt-get install fail2ban
On créer maintenant le fichier qui ajoutera une règle iptables
vi /etc/fail2ban/action.d/iptables-allports.conf
On copie les lignes suivantes dedans
# Fail2Ban configuration file # # Author: Cyril Jaquier # Modified: Yaroslav O. Halchenko <debian@onerussian.com> # made active on all ports from original iptables.conf # # $Revision: 658 $ # [Definition] # Option: actionstart # Notes.: command executed once at the start of Fail2Ban. # Values: CMD # actionstart = iptables -N fail2ban-<name> iptables -A fail2ban-<name> -j RETURN iptables -I INPUT -p <protocol> -j fail2ban-<name> # Option: actionstop # Notes.: command executed once at the end of Fail2Ban # Values: CMD # actionstop = iptables -D INPUT -p <protocol> -j fail2ban-<name> iptables -F fail2ban-<name> iptables -X fail2ban-<name> # Option: actioncheck # Notes.: command executed once before each actionban command # Values: CMD # actioncheck = iptables -n -L INPUT | grep -q fail2ban-<name> # Option: actionban # Notes.: command executed when banning an IP. Take care that the # command is executed with Fail2Ban user rights. # Tags: <ip> IP address # <failures> number of failures # <time> unix timestamp of the ban time # Values: CMD # actionban = iptables -I fail2ban-<name> 1 -s <ip> -j DROP # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the # command is executed with Fail2Ban user rights. # Tags: <ip> IP address # <failures> number of failures # <time> unix timestamp of the ban time # Values: CMD # actionunban = iptables -D fail2ban-<name> -s <ip> -j DROP [Init] # Defaut name of the chain # name = default # Option: protocol # Notes.: internally used by config reader for interpolations. # Values: [ tcp | udp | icmp | all ] Default: tcp # protocol = all
On créé maintenant le fichier qui contenant le regex de détection de la signature de Dfind
vi /etc/fail2ban/filter.d/apache-w00tw00t.conf
On le rempli avec ce qui suit
# w00tw00t.at.ISC.SANS.DFind [Definition] # Option: failregex # Notes.: regex to match the w00tw00t scan messages in the logfile. The # host must be matched by a group named "host". The tag "<HOST>" can # be used for standard IP/hostname matching. # Values: TEXT failregex = [[]client <HOST>[]] (client sent HTTP/1.1 request without hostname|Invalid method in request|request failed: URI too long|erroneous characters after protocol string) # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT ignoreregex =
Pour finir on édit le fichier jail.conf
vi /etc/fail2ban/jail.conf
Et on y ajoute les lignes suivantes, elles on pour effet de bannir complètement pendant 24h l’IP des attaquant.
[apache-w00tw00t] enabled = true filter = apache-w00tw00t action = iptables-allports[name=w00tw00t] logpath = /var/log/apache2/error.log maxretry = 1 bantime = 86400
On redémarre Fail2ban
/etc/init.d/fail2ban restart
On peut à présent attendre tranquillement les prochaines attaques
tail /var/log/fail2ban.log 2009-04-30 20:24:29,858 fail2ban.actions: WARNING [apache-w00tw00t] Ban 85.114.141.205 2009-04-30 20:24:29,906 fail2ban.actions: WARNING [apache-w00tw00t] Ban 62.75.220.143 2009-04-30 20:24:29,954 fail2ban.actions: WARNING [apache-w00tw00t] Ban 212.180.3.123 2009-04-30 20:24:30,001 fail2ban.actions: WARNING [apache-w00tw00t] Ban 91.121.210.244 2009-04-30 20:26:03,142 fail2ban.actions: WARNING [apache-w00tw00t] Ban 89.19.1.18


mars 8th, 2011 at 11 h 46 min
Bonjour,
j’ai suivi ton tuto et j’ai cela qui s’affiche :
2011-03-08 11:41:29,307 fail2ban.jail : INFO Jail ‘apache-w00tw00t’ started
2011-03-08 11:41:29,308 fail2ban.jail : INFO Jail ‘ssh’ started
2011-03-08 11:41:29,312 fail2ban.actions.action: ERROR iptables -N fail2ban-w00tw00t
iptables -A fail2ban-w00tw00t -j RETURN
iptables -I INPUT -p all -j fail2ban-w00tw00t returned 400
Tu as une idée ?
Merci
mars 8th, 2011 at 18 h 34 min
slt,
essaye de renommer ta jail apache-w00tw00t en apachew00tw00t
il aime pas les –
++
juillet 30th, 2011 at 23 h 53 min
[...] Source : http://www.majorxtrem.be/2009/04/30/bloquer-les-attaques-de-type-w00tw00tatiscsans-sur-apache2/ [...]
septembre 13th, 2011 at 17 h 22 min
Yop,
J’ai cette erreur aussi (iptables -I INPUT -p all -j fail2ban-w00tw00t returned 400).
Dans jail.conf
remplacez :
action = iptables-allports[name=w00tw00t]
par :
action = iptables-allports[name=apache-w00tw00t]
Et là, plus d’erreur.
J’attends mon premier pigeon maintenant