0

我不擅长正则表达式 - 因此我似乎无法匹配表示暴力 smtp 攻击的 plesk 邮件日志字符串 -

我的日志如下所示:

May 19 03:24:58 gohhllc smtp_auth[22702]: SMTP connect from mail.globaltrbilisim.com [213.144.99.201]
May 19 03:24:58 gohhllc smtp_auth[22702]: No such user 'chuong@drophit.net' in mail authorization database
May 19 03:24:58 gohhllc smtp_auth[22702]: FAILED: chuong@drophit.net - password incorrect from mail.globaltrbilisim.com [213.144.99.201]

在某些情况下,它也看起来像这样

May 19 03:25:22 gohhllc smtp_auth[23056]: SMTP connect from 89-97-124-22.fweds-spc.it [89.97.124.22]
May 19 03:25:22 gohhllc smtp_auth[23056]: FAILED: element - password incorrect from 89-97-124-22.fweds-spc.it [89.97.124.22]

我的正则表达式尝试匹配用户名失败和密码看起来像这样

failregex = No such user '.*' in mail authorization database
FAILED: .* - password incorrect from [<HOST>]

连同 20 多个其他无济于事的组合 - 大多数时候结果是这样的错误

Unable to compile regular expression 'FAILED:

谢谢

4

1 回答 1

0

我解决了这个问题并使用http://www.regexr.com/我能够编写一个相当简单的正则表达式(我想我会变得更好)来完成这项工作。

使用 Pleask 和 Qmail(至少在我的服务器上)时 smtp-auth 的结果语句是

failregex = FAILED: [-/\w]+ - password incorrect from <HOST>

至于“没有这样的用户”条目,我无法完成这项工作,因为该条目的日志文件中没有主机名,fail2ban 需要主机名:(

于 2015-05-20T15:51:49.700 回答