fail2ban para o apache2 não parece estar funcionando

2

Tenho muitas das seguintes mensagens de erro no meu log de erros do apache:

[Thu Dec 16 15:13:24 2010] [error] [client 168.144.92.191] File does not exist: /var/www/mydomain/fud
[Thu Dec 16 15:13:24 2010] [error] [client 168.144.92.191] File does not exist: /var/www/mydomain/flag, referer: http://lexington.craigslist.org/fud/2076870022.html
[Thu Dec 16 15:14:28 2010] [error] [client 168.144.92.191] File does not exist: /var/www/mydomain/flag, referer: http://lexington.craigslist.org/fud/2115799176.html
[Thu Dec 16 15:17:51 2010] [error] [client 168.144.92.191] File does not exist: /var/www/mydomain/fud

No meu /etc/fail2ban/jail.local tenho:

# Fail2Ban configuration file.
#
# This file was composed for Debian systems from the original one
#  provided now under /usr/share/doc/fail2ban/examples/jail.conf
#  for additional examples.
#
# To avoid merges during upgrades DO NOT MODIFY THIS FILE
# and rather provide your changes in /etc/fail2ban/jail.local
#
# Author: Yaroslav O. Halchenko <[email protected]>
#
# $Revision: 281 $
#

# The DEFAULT allows a global definition of the options. They can be override
# in each jail afterwards.

[DEFAULT]

# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = myip
bantime  = -1
maxretry = 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 now
backend = polling

#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost

#
# ACTIONS
#

# Default banning action (e.g. iptables, iptables-new,
# iptables-multiport, shorewall, etc) It is used to define 
# action_* variables. Can be overriden globally or per 
# section within jail.local file
banaction = iptables-allports

# email action. Since 0.8.1 upstream fail2ban uses sendmail
# MTA for the mailing. Change mta configuration parameter to mail
# if you want to revert to conventional 'mail'.
mta = sendmail

# Default protocol
protocol = tcp

#
# Action shortcuts. To be used to define action parameter

# The simplest action to take: ban only
action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s]

# ban & send an e-mail with whois report to the destemail.
action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s]
              %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s]

# ban & send an e-mail with whois report and relevant log lines
# to the destemail.
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s]
               %(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s]

# Choose default action.  To change, just override value of 'action' with the
# interpolation to the chosen action shortcut (e.g.  action_mw, action_mwl, etc) in jail.local
# globally (section [DEFAULT]) or per specific section 
action = %(action_mw)s

#
# JAILS
#

#
# HTTP servers
#

[apache]

enabled = true
port  = http,https
filter  = apache-auth
logpath = /var/log/apache2/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   = false
port    = http,https
filter    = apache-auth
logpath   = /var/log/apache*/*error.log
maxretry  = 6

[apache-noscript]

enabled = true
port    = http,https
filter  = apache-noscript
logpath = /var/log/apache2/error.log
maxretry = 3

[apache-overflows]

enabled = false
port    = http,https
filter  = apache-overflows
logpath = /var/log/apache*/*error.log
maxretry = 2

No meu /etc/fail2ban/filter.d/apache-noscript.conf eu tenho:

failregex = [[]client <HOST>[]] (File does not exist|script not found or unable to stat): .*
failregex = [[]client <HOST>[]] script '.*' not found or unable to stat

Meu /var/log/fail2ban.log só tem entradas de quando foi iniciado. Nada mencionando IPs banidos como o meu denyhosts.log faz.

Uma verificação de "iptables -L -v -n" mostra:

Chain INPUT (policy ACCEPT 834K packets, 145M bytes)
 pkts bytes target     prot opt in     out     source               destination         
  403 71010 fail2ban-apache  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           
  403 71010 fail2ban-apache-noscript  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 574K packets, 976M bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain fail2ban-apache (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  403 71010 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain fail2ban-apache-noscript (1 references)
 pkts bytes target     prot opt in     out     source               destination         
  403 71010 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0           

O que estou perdendo ou o que fiz de errado?

**** Poste atualizado para mostrar os arquivos jail.local completos em vez de apenas a seção da jaula do Apache e os resultados de "iptables -L -v -n". **

    
por Daemon of Chaos 16.12.2010 / 22:59

2 respostas

2

Eu acho que a segunda linha do apache-noscript.conf é o primeiro do nuking.

Tente isto:

failregex = [[]client <HOST>[]] (File does not exist|script not found or unable to stat): .*
            [[]client <HOST>[]] script '.*' not found or unable to stat
    
por 17.12.2010 / 00:18
0

A menos que haja um padrão action em falta, você não tem linha action . Aqui está o meu (que funciona):

[apache-noscript]

enabled  = true
filter   = apache-noscript
action   = iptables-multiport[name=NoScript, port="http,https"]
logpath  = /usr/local/www/sites/*/logs/*_error_log
bantime  = 172800
maxretry = 5

Eu simplifiquei o match regex para 1 linha:

failregex = [[]client <HOST>[]] (File does not exist|script not found or unable to stat)

Será que iptables -L -v -n mostra que as cadeias estão configuradas corretamente?

    
por 17.12.2010 / 01:11