Fail2ban: 忽略正则表达式不起作用

创建于 2012-12-21  ·  3评论  ·  资料来源: fail2ban/fail2ban

配置文件中的 ignoreregex 选项不起作用 (v0.8.4)。
使用 fail2ban-regex 进行测试时,甚至不会抛出“无法编译正则表达式”错误。

fail2ban-regex error.log /etc/fail2ban/filter.d/suhosin.conf

根本没有匹配项:

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

例子:
配置文件

[Definition]
failregex = suhosin\[\d*\].*\(attacker\s'<HOST>'.*
ignoreregex = suhosin\[\d*\].*(memory_limit).*\(attacker\s'<HOST>'.*

错误日志

Dec 17 15:51:13 server suhosin[27622]: ALERT - ASCII-NUL chars not allowed within request variables - dropped variable      'action' (attacker '67.210.100.166', file '/bla.php')
Dec 17 15:51:13 server suhosin[27624]: ALERT - ASCII-NUL chars not allowed within request variables - dropped variable 'board' (attacker '67.210.100.166', file '/bla.php')
Dec 17 15:51:13 server suhosin[27624]: ALERT - ASCII-NUL chars not allowed within request variables - dropped variable 'topic' (attacker '67.210.100.166', file '/bla.php')
Dec 20 18:58:21 server suhosin[4088]: ALERT - script tried to increase memory_limit to 120000000 bytes which is above the allowed value (attacker '123.123.123.123', file '/bla.php', line 10)
Dec 20 18:58:32 server suhosin[4051]: ALERT - script tried to increase memory_limit to 120000000 bytes which is above the allowed value (attacker '123.123.123.123', file '/bla.php', line 10)

我试图匹配所有 suhosin 攻击并减去所有试图增加 memory_limit 的攻击。

最有用的评论

:+1:
啊,你说得对。 感谢您指出正确的第三个参数。
我应该在发布之前阅读手册页。
无论如何这有效:

fail2ban-regex error.log /etc/fail2ban/filter.d/suhosin.conf /etc/fail2ban/filter.d/suhosin.conf

我正在关闭问题。 圣诞节快乐。 再见。

所有3条评论

描述性:您是否指定了 ignoreregex ?

$> /usr/bin/fail2ban-regex | head
Usage: /usr/bin/fail2ban-regex [OPTIONS] <LOG> <REGEX> [IGNOREREGEX]

所以如果我确实将 ignoregex 添加到例如 sshd.conf (虽然需要避免
锚定在前面,因为忽略正则表达式的匹配应用于完整
行,没有剥离时间/日期)——一切都很好

$> ./fail2ban-regex testcases/files/logs/sshd config/filter.d/sshd.conf config/filter.d/sshd.conf  2>/dev/null | grep -A2 Ignoreregex 
Ignoreregex: 2 total
|- #) [# of hits] regular expression
|  1) [2] \s*(?:\S+ )?(?:kernel: \[\d+\.\d+\] )?(?:@vserver_\S+ )?(?:(?:\[\d+\])?:\s+[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?|[\[\(]?sshd(?:\(\S+\))?[\]\)]?:?(?:\[\d+\])?:)?\s*(?:error: PAM: )?Authentication failure for .* from <HOST>\s*$

$> grep ignoreregex config/filter.d/sshd.conf
# Option:  ignoreregex
ignoreregex = %(__prefix_line)s(?:error: PAM: )?Authentication failure for .* from <HOST>\s*$

2012 年 12 月 21 日星期五,Jens-André Koch 写道:

配置文件中的 ignoreregex 选项不起作用 (v0.8.4)。
使用 fail2ban-regex 进行测试时,甚至没有“无法编译常规
表达式”错误被抛出。
根本没有匹配项:

忽略正则表达式
|- 正则表达式:

`- 匹配数:

我错过了一个通用配置选项还是这是一个错误?

雅罗斯拉夫·O·哈尔琴科
心理与脑科学系博士后研究员
达特茅斯学院, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
电话:+1 (603) 646-9834 传真:+1 (603) 646-1419
万维网: http :

:+1:
啊,你说得对。 感谢您指出正确的第三个参数。
我应该在发布之前阅读手册页。
无论如何这有效:

fail2ban-regex error.log /etc/fail2ban/filter.d/suhosin.conf /etc/fail2ban/filter.d/suhosin.conf

我正在关闭问题。 圣诞节快乐。 再见。

圣诞节快乐! ;)

2012 年 12 月 21 日星期五,Jens-André Koch 写道:

[1]:+1:
啊,你说得对。 感谢您指出正确的第三个参数。
我应该在发布之前阅读手册页。
无论如何这有效:
fail2ban-regex error.log /etc/fail2ban/filter.d/suhosin.conf
/etc/fail2ban/filter.d/suhosin.conf

我正在关闭问题。 圣诞节快乐。 再见。


直接回复此邮件或 [2] 在 GitHub 上查看。

参考

可见链接

  1. https://github.com/fail2ban/fail2ban/issues/100#issuecomment -11623202

雅罗斯拉夫·O·哈尔琴科
心理与脑科学系博士后研究员
达特茅斯学院, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
电话:+1 (603) 646-9834 传真:+1 (603) 646-1419
万维网: http :

此页面是否有帮助?
0 / 5 - 0 等级