Fail2Ban SASL 过滤器未命中失败的登录

AJ.*_*AJ. 3 regex sasl fail2ban

我在我的邮件服务器上使用fail2ban。我今天早上发现通过 SMTP 有大约 5000 次失败的登录尝试(在 1 小时内)没有被我的 sasl 过滤器检测到。这是 /var/log/mail.log 中条目的示例

Jan 25 04:39:56 ***** postfix/smtpd[23828]: warning: 114-32-231-17.HINET-IP.hinet.net[114.32.231.17]: SASL LOGIN authentication failed: authentication failure
Run Code Online (Sandbox Code Playgroud)

这是我的(未修改的)fail2ban 的 sasl 过滤器定义:

# Fail2Ban configuration file
#
# Author: Yaroslav Halchenko
#
# $Revision: 728 $
#

[Definition]

# Option: failregex
# Notes.: regex to match the password failures 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 and is only an alias for
#          (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
# Values: TEXT
#
failregex = (?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [A-Za-z0-9+/]*={0,2})?$

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
Run Code Online (Sandbox Code Playgroud)

任何人都可以推荐对正则表达式的改进也可以捕获此记录吗?

Sac*_*acx 6

定义另一个失败正则表达式

(?i): warning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(:.*)$
Run Code Online (Sandbox Code Playgroud)

我用 fail2ban-regex 测试了这个正则表达式并且正在工作。