Security

fail2ban 不匹配 xmlrpc

  • December 19, 2016

我為 fail2ban 添加了一個 xmlrpc 監獄,以防止持續攻擊。apache access.log 如下…

191.96.249.80 - - [16/Dec/2016:14:54:21 +0000] "POST /xmlrpc.php HTTP/1.0" 403 469 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
191.96.249.80 - - [16/Dec/2016:14:54:21 +0000] "POST /xmlrpc.php HTTP/1.0" 403 469 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
191.96.249.80 - - [16/Dec/2016:14:54:21 +0000] "POST /xmlrpc.php HTTP/1.0" 403 469 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"
191.96.249.80 - - [16/Dec/2016:14:54:22 +0000] "POST /xmlrpc.php HTTP/1.0" 403 469 "-" "Mozilla/4.0 (compatible: MSIE 7.0; Windows NT 6.0)"

我未能禁止def如下…

[Definition]
failregex = ^<HOST> .*POST .*xmlrpc\.php.*
ignoreregex =

這似乎不匹配,因為 xmlrpc 沒有任何內容出現在 fail2ban 日誌中,但 fail2ban 確實報告該監獄處於活動狀態。

我的監獄在我的 jail.conf 文件中是這樣設置的

[xmlrpc]
enabled = true
filter = xmlrpc
action = iptables[name=xmlrpc, port=http, protocol=tcp]
logpath = /var/log/apache2/access.log
bantime = 43600
maxretry = 0

有人知道為什麼它可能不匹配嗎?

我最終想通了。事實證明,我錯過了 xmlrpc 監獄設置中的埠定義。

[xmlrpc]
enabled = true
filter = xmlrpc
port = http,https
action = iptables[name=xmlrpc, port=http, protocol=tcp]
logpath = /var/log/apache2/access.log
bantime = 43600
maxretry = 0

現在完美執行

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