Van egy virtualboxban futó Debian Lenny (csak alaprendszer), amin fut egy vsftp és egy Apache2+SSL pár virtualhosttal tesztelésre. Felraktam csomagból a fail2ban-t, a vsftp-re probléma nélkül sikerült belőni, míg az Apache2-nél nagyon nem akarja az igazat, azaz nem csinál semmit.
Infók:
uname -a
Linux vmdeb 2.6.26-2-686 #1 SMP Wed Nov 4 20:45:37 UTC 2009 i686 GNU/Linux
/ect/fail2ban/jail.local tartalma (csak a módosított részek - alapból csak az apache-noscript-et szerettem volna bekapcsolni, csak miután nem csinált semmit, kínomban bekapcsoltam a többit is)
[apache]
enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 3
# default action is now multiport, so apache-multiport jail was left
# for compatibility with previous (0.7.6-2) releases
[apache-multiport]
enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 3
[apache-noscript]
enabled = true
port = http,https
filter = apache-noscript
logpath = /var/log/apache*/*error.log
maxretry = 3
.
.
.
[vsftpd]
enabled = true
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log
# or overwrite it in jails.local to be
# logpath = /var/log/auth.log
# if you want to rely on PAM failed login attempts
# vsftpd's failregex should match both of those formats
maxretry = 3
/etc/fail2ban/filters/apache-noscript.conf (hátha ebben van valami bibi)
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
#
# $Revision: 658 $
#
[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 and is only an alias for
# (?:::f{4,6}:)?(?P\S+)
# Values: TEXT
#
failregex = [[]client ŐHOSTŐ[]] (File does not exist|script not found or unable to stat): /\S*(\.php|\.asp|\.exe|\.pl)
[[]client ŐHOSTŐ[]] script '/\S*(\.php|\.asp|\.exe|\.pl)\S*' not found or unable to stat *$
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
Az Ő a "rigójancsicsőrőket jelenti, mert a code tag nem szerette.
Mivel a vsftp beállítás minden egyéb trükk nélkül tökéletesen megy, ezért nem értem, hogy az apache miért nem. Talán rossz a regexp - de az még nekem eléggé kínai :). Ha a hostról "betámadom" a virtuális gépet, az apache logokban ott van szépen a nyoma, de semmi más nem történik. Az iptables -L szépen mutatja, hogy létrejöttek a megfelelő chainek, a fail2ban logban látszik, hogy elindítja a jaileket, de más semmi.
fail2ban.log
2009-12-10 15:39:22,886 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.3
2009-12-10 15:39:22,890 fail2ban.jail : INFO Creating new jail 'apache-noscript'
2009-12-10 15:39:22,890 fail2ban.jail : INFO Jail 'apache-noscript' uses poller
2009-12-10 15:39:22,934 fail2ban.filter : INFO Added logfile = /var/log/apache2/error.log
2009-12-10 15:39:22,937 fail2ban.filter : INFO Set maxRetry = 3
2009-12-10 15:39:22,943 fail2ban.filter : INFO Set findtime = 600
2009-12-10 15:39:22,946 fail2ban.actions: INFO Set banTime = 600
2009-12-10 15:39:22,986 fail2ban.jail : INFO Creating new jail 'vsftpd'
2009-12-10 15:39:22,987 fail2ban.jail : INFO Jail 'vsftpd' uses poller
2009-12-10 15:39:22,991 fail2ban.filter : INFO Added logfile = /var/log/vsftpd.log
2009-12-10 15:39:22,994 fail2ban.filter : INFO Set maxRetry = 3
2009-12-10 15:39:23,000 fail2ban.filter : INFO Set findtime = 600
2009-12-10 15:39:23,003 fail2ban.actions: INFO Set banTime = 600
2009-12-10 15:39:23,041 fail2ban.jail : INFO Creating new jail 'apache-multiport'
2009-12-10 15:39:23,041 fail2ban.jail : INFO Jail 'apache-multiport' uses poller
2009-12-10 15:39:23,045 fail2ban.filter : INFO Added logfile = /var/log/apache2/error.log
2009-12-10 15:39:23,049 fail2ban.filter : INFO Set maxRetry = 3
2009-12-10 15:39:23,054 fail2ban.filter : INFO Set findtime = 600
2009-12-10 15:39:23,057 fail2ban.actions: INFO Set banTime = 600
2009-12-10 15:39:23,099 fail2ban.jail : INFO Creating new jail 'apache'
2009-12-10 15:39:23,099 fail2ban.jail : INFO Jail 'apache' uses poller
2009-12-10 15:39:23,103 fail2ban.filter : INFO Added logfile = /var/log/apache2/error.log
2009-12-10 15:39:23,107 fail2ban.filter : INFO Set maxRetry = 3
2009-12-10 15:39:23,113 fail2ban.filter : INFO Set findtime = 600
2009-12-10 15:39:23,115 fail2ban.actions: INFO Set banTime = 600
2009-12-10 15:39:23,173 fail2ban.jail : INFO Jail 'apache-noscript' started
2009-12-10 15:39:23,213 fail2ban.jail : INFO Jail 'vsftpd' started
2009-12-10 15:39:23,288 fail2ban.jail : INFO Jail 'apache-multiport' started
2009-12-10 15:39:23,392 fail2ban.jail : INFO Jail 'apache' started
és utána "síri csend", hacsak nem az ftp-t "támadom be". Akkor megjelenik szépen a Ban üzenet, meg nem is értem el.
/var/log/apache2/error.log (részlet)
.
[Thu Dec 10 15:40:22 2009] [error] [client 192.168.0.4] File does not exist: /var/www/site2/hulla
[Thu Dec 10 15:40:22 2009] [error] [client 192.168.0.4] File does not exist: /var/www/site2/hulla
[Thu Dec 10 15:40:22 2009] [error] [client 192.168.0.4] File does not exist: /var/www/site2/hulla
[Thu Dec 10 15:40:22 2009] [error] [client 192.168.0.4] File does not exist: /var/www/site2/hulla
[Thu Dec 10 15:40:22 2009] [error] [client 192.168.0.4] File does not exist: /var/www/site2/hulla
[Thu Dec 10 15:40:22 2009] [error] [client 192.168.0.4] File does not exist: /var/www/site2/hulla
[Thu Dec 10 15:40:23 2009] [error] [client 192.168.0.4] File does not exist: /var/www/site2/hulla
.
.
Kínomban már 777-re pakoltam a var/log/apache2-t meg tartalmát, de mivel a vsftpd.log is "alap" jogokkal működött, így nem vártam tőle csodát.
Szóval mit nézzek, mit rontok el?
Upd: a hozzászolásban is elbarmolhatom valahol a code tag-eket, mert nem úgy néz ki, ahogyan szeretném :) )