我无法获得fail2ban的正则expression式。 我想匹配以下内容:
[Tue Jun 24 10:22:14.528987 2014] [fcgid:warn] [pid 22526:tid 139757615011584] [client IP:PORT] mod_fcgid: stderr: user admin joomla authentication failure, referer: http://www.mydomain.com/administrator/index.php?option=com_login
我试过了:
^\[.*\s*.*]* \[client <HOST>\] mod_fcgid: stderr: user .* joomla authentication failure, referer: .*
任何帮助将非常感激。
只有2个笔记:
IP:PORT
,即使它是假的。 <HOST>:[0-9]+
。 我假设这个端口是强制的。 testing(最后一行是正则expression式):
fail2ban-regex \ '[Tue Jun 24 10:22:14.528987 2014] [fcgid:warn] [pid 22526:tid 139757615011584] [client 1.2.3.4:1234] mod_fcgid: stderr: user admin joomla authentication failure, referer: http://www.mydomain.com/administrator/index.php?option=com_login' \ '^\[.*]* \[client <HOST>:[0-9]+\] mod_fcgid: stderr: user .* joomla authentication failure, referer: .*'
这个对我有用。
你不需要有一个复杂的正则expression式来跳过领先的时间字段。 我怀疑这是什么导致你的问题。 对于这个工作提供的日志条目,我把你的IP:PORT
转换成一个数字的ip:port值。
'^.*[[]client <HOST>.*user .*joomla authentication failure,'
以上将禁止任何用户身份validation失败太多。
我不知道你是否使用它,但fail2ban-regex是一个很好的工具