fail2ban.actions
- April 30th April 2008
- Kommentar schreiben
Webserver hacken ist ja ein beliebtes Hobby. Ein Blick in die Logfiles reicht aus um dieses zu erkennen.
Um diesem Treiben ein Ende zu bereiten oder es zumindest einzugrenzen ist es ratsam entsprechende Vorkehrungen zu treffen.
fail2ban zum Beispiel erfüllt diesen Zweck gut und bannt die entsprechende IP-Adresse nach X Fehlversuchen.
Unter debian istalliert man fail2ban mittels:
aptitude install fail2ban
Angabe der Konfiguration:
[DEFAULT] # “ignoreip” can be an IP address, a CIDR mask or a DNS hostignoreip = 127.0.0.1 bantime = 600maxretry = 3 # “backend” specifies the backend used to get files modification. Available# options are “gamin”, “polling” and “auto”.# yoh: For some reason Debian shipped python-gamin didn’t work as expected# This issue left ToDo, so polling is default backend for nowbackend = polling ## Destination email address used solely for the interpolations in# jail.{conf,local} configuration files.destemail = root@localhost # Default action to take: ban onlyaction = iptables[name=%(__name__)s, port=%(port)s] [ssh] enabled = trueport = sshfilter = sshdlogpath = /var/log/auth.logmaxretry = 5 [postfix] enabled = falseport = smtpfilter = postfixlogpath = /var/log/mail.logmaxretry = 5 [courierpop3] enabled = trueport = pop3filter = courierloginfailregex = courierpop3login: LOGIN FAILED.*ip=\[.*:<HOST>\]logpath = /var/log/mail.logmaxretry = 5 [courierimap] enabled = trueport = imap2filter = courierloginfailregex = imapd: LOGIN FAILED.*ip=\[.*:<HOST>\]logpath = /var/log/mail.logmaxretry = 5 [sasl] enabled = trueport = smtpfilter = saslfailregex = warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failedlogpath = /var/log/mail.logmaxretry = 5Starten des Dienstes:
/etc/init.d/fail2ban restart
In dem Logfile von fail2ban unter /var/log/fail2ban.log kann man die Aktionen nachlesen. Dort wird jeweils ein entsprechender Eintrag vorgenommen. Hier als Beispiel eine Ein- und Austragung für den Mailserver:
2008-04-30 06:28:47,070 fail2ban.actions: WARNING [courierpop3] Ban <ip-adresse>
2008-04-30 06:38:47,985 fail2ban.actions: WARNING [courierpop3] Unban <ip-adresse>
Entsprechend kontrollieren kann man dieses in den IPTABLES ebenfalls mittels:
iptables -L -n
