Fail2ban

用於 ical 正則表達式的 fail2ban 過濾器

  • July 24, 2019

我正在嘗試為我的主機上的 ical 服務獲取一個正則表達式,但沒有成功。這是日誌文件的一部分:

Tue Jul 23 13:55:23 2019: ical|T720] [info   ] Accepted connection from [::ffff:2.3.4.5]:56450
Tue Jul 23 13:55:23 2019: [net/[::ffff:5.6|T5234] [error  ] HrLogon server "http://localhost:123/" user "Admin": logon failed   
Tue Jul 23 13:55:23 2019: [net/[::ffff:5.6|T5234] [warning] Login failed (0x80040111 logon failed), resending authentication request   
Tue Jul 23 13:55:23 2019: [net/[::ffff:5.6|T5234] [notice ] [::ffff:5.61.48.194]:56450 - Admin [23/Jul/2019:13:55:23 +0200] "GET / HTTP/1.1" 401 0 "-" "Mozilla/5.0 (Windows NT 5.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"   
Tue Jul 23 13:55:23 2019: [net/[::ffff:5.6|T5234] [info   ] Connection closed

這是日誌文件的一部分,我已經嘗試了不同的方法來將其放入過濾器。重要部分是“登錄失敗”,下一行是 IP 部分。但我怎樣才能讓這個工作?任何幫助都會很棒!!!

提前致謝

冰冷

實際配置如下:ical.conf:

[INCLUDES]
before = common.conf

[Definition]

failregex = ^*Login failed\n^.*\[notice \] \[::ffff:<HOST>\]$

ignoreregex =
[Init]
maxlines = 2

和監獄會議:

[ical]

enabled = false
port = 8443
filter = kopano-ical
logpath = /var/log/ical.log
maxtetry = 3
bantime = 3600

我相信你的正則表達式不正確。您在 之後^.*之前\n和之後的開頭缺少點 (.),因為您使用$了並且需要放在.*之前$的結尾]不是最後一個字元。

failregex = ^.*Login failed.*\n^.*\[notice \] \[::ffff:<HOST>\].*$

引用自:https://serverfault.com/questions/976472