【问题标题】:Create fail2ban custom rule for Apache2为 Apache2 创建 fail2ban 自定义规则
【发布时间】:2016-03-04 01:47:48
【问题描述】:

我正在尝试创建一个自定义规则来禁止用户尝试登录太多次。触发器是apache日志文件中的单词“CheckLogin”。

日志提取:

[03/Mar/2016:19:38:24 -0600] 186.77.136.133 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "POST /CheckLogin HTTP/1.1" -
[03/Mar/2016:19:38:24 -0600] 186.77.136.133 TLSv1.2 ECDHE-RSA-AES128-GCM-SHA256 "GET /Login?nok=badpassword HTTP/1.1" 10570
[03/Mar/2016:19:38:27 -0600] 186.77.136.133 TLSv1.2 ECDHE-RSA-AES128-

当前过滤器:/etc/fail2ban/filter.d/test.conf:

[INCLUDES]
[Definition]
failregex = ^<HOST> -.*"(GET|POST|HEAD).*CheckLogin".*$
ignoreregex =

当前jail.local

# detect password authentication failures
[test-auth-ssl]
enabled  = true
port     = https
filter   = test
logpath  = /var/log/apache2/ssl_request_log
maxretry = 3
bantime  = 36000  ; 10 hrs
findtime = 360   ; 


[test-auth]
enabled  = true
port     = http
filter   = test
logpath  = /var/log/apache2/access_log
maxretry = 3
bantime  = 36000  ; 10 hrs
findtime = 360   ; 

必须是过滤器失败正则表达式中的一个棘手细节,但我尝试了各种选项,但都没有奏效。我可以重启fail2ban而不会出错,但是用于测试的外部IP永远不会被禁止(触发deos不起作用)。

Status for the jail: test-auth-ssl
|- Filter
|  |- Currently failed: 0
|  |- Total failed:     0
|  `- Journal matches:
`- Actions
   |- Currently banned: 0
   |- Total banned:     0
   `- Banned IP list:

【问题讨论】:

    标签: regex apache fail2ban


    【解决方案1】:

    知道了!

    玩弄fail2ban-regex终于找到了解决办法。

    /etc/fail2ban/filter.d/test.conf 
    [INCLUDES]
    [Definition]
    failregex =  <HOST> .*CheckLogin.*$
    ignoreregex = 
    

    jail.local 中我也必须添加backend=auto,因为它默认使用systemd

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-16
      • 2011-05-17
      • 2015-04-22
      • 2012-01-01
      • 2017-01-07
      相关资源
      最近更新 更多