LINUX.ORG.RU
решено ФорумAdmin

fail2ban MySQL не работае

 


0

2

Linux-Debian поставил правило из пакета

# Fail2Ban filter for unsuccesfull MySQL authentication attempts
#
#
# To log wrong MySQL access attempts add to /etc/my.cnf in [mysqld]:
# log-error=/var/log/mysqld.log
# log-warning = 2
#
# If using mysql syslog [mysql_safe] has syslog in /etc/my.cnf

[INCLUDES]

# Read common prefixes. If any customizations available -- read them from
# common.local
before = common.conf

[Definition]

_daemon = mysqld

failregex = ^%(__prefix_line)s(\d{6} \s?\d{1,2}:\d{2}:\d{2} )?\[Warning\] Access denied for user '\w+'@'<HOST>' (to database '[^']*'|\(using password: (YES|NO)\))*\s*$

ignoreregex = 

# DEV Notes:
#
# Technically __prefix_line can equate to an empty string hence it can support
# syslog and non-syslog at once.
# Example:
# 130322 11:26:54 [Warning] Access denied for user 'root'@'127.0.0.1' (using password: YES)
#
# Authors: Artur Penttinen
#          Yaroslav O. Halchenko
при проверке
fail2ban-regex /var/log/mysql/error.log /etc/fail2ban/filter.d/mysql.conf

Running tests
=============

Use regex file : /etc/fail2ban/filter.d/mysql.conf
Use log file   : /var/log/mysql/error.log

Found a match for '141201 15:58:01 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
' but no valid date/time found for '141201 15:58:01 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
'. Please contact the author in order to get support for this format
Found a match for '141201 15:58:02 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
' but no valid date/time found for '141201 15:58:02 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
'. Please contact the author in order to get support for this format
Found a match for '141201 15:58:03 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
' but no valid date/time found for '141201 15:58:03 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
'. Please contact the author in order to get support for this format
Results
=======

Failregex
|- Regular expressions:
|  [1] ^\s*(?:\S+ )?(?:kernel: \[\d+\.\d+\] )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?mysqld(?:\(\S+\))?[\]\)]?:?|[\[\(]?mysqld(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*(\d{6} \s?\d{1,2}:\d{2}:\d{2} )?\[Warning\] Access denied for user '\w+'@'<HOST>' (to database '[^']*'|\(using password: (YES|NO)\))*\s*$
|
`- Number of matches:
   [1] 0 match(es)

Ignoreregex
|- Regular expressions:
|
`- Number of matches:

Summary
=======

Sorry, no match

Look at the above section 'Running tests' which could contain important
information.
лог файл кусок
141201 15:58:01 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
141201 15:58:02 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
141201 15:58:03 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
141201 15:58:04 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
141201 15:58:05 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
141201 15:58:06 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
141201 15:58:07 [Warning] Access denied for user 'root'@'104.194.19.65' (using password: NO)
Что не так. Как я понял непонятка со временем и датой.
Спасибо.

★★

^%(__prefix_line)s(

Кажется, символ «s» там лишний. Остальное, вроде бы, выглядит правдоподобно.

AnDoR ★★★★★
()

hm. на ваших данных:

# fail2ban-regex /tmp/mysql.log filter.d/mysqld-auth.conf

Running tests
=============

Use   failregex file : filter.d/mysqld-auth.conf
Use         log file : /tmp/mysql.log
Use         encoding : ISO-8859-1


Results
=======

Failregex: 7 total
|-  #) [# of hits] regular expression
|   1) [7] ^\s*(<[^.]+\.[^.]+>)?\s*(?:\S+ )?(?:kernel: \[ *\d+\.\d+\] )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?mysqld(?:\(\S+\))?[\]\)]?:?|[\[\(]?mysqld(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:?)?\s(?:\[ID \d+ \S+\])?\s*(\d{6} \s?\d{1,2}:\d{2}:\d{2} )?\[Warning\] Access denied for user '\w+'@'<HOST>' (to database '[^']*'|\(using password: (YES|NO)\))*\s*$
`-

Ignoreregex: 0 total

Date template hits:
|- [# of hits] date format
|  [7] ^Year2MonthDay  ?24hour:Minute:Second
`-

Lines: 7 lines, 0 ignored, 7 matched, 0 missed
# fail2ban-client --version | head -1
Fail2Ban v0.9.0
#

у вас какая весия?

arto ★★
()
Ответ на: комментарий от pvvking

работа с mysql появилась в 0.8.9. почему у вас засунули данную конфигурацию в старый дистрибутив — непонятно. попробуйте обновиться, либо поставить из исходников.

arto ★★
()
Ответ на: комментарий от arto

Да вы правы обновил все работает.
Спасибо.

pvvking ★★
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.