Break Out!? - blog ver.

こっちー(kojiaki)がメモとか物欲の記録とかラーメン食べ歩きとかを書きなぐる blog みたいなものです。

今更ながらshellshock狙いのapacheへのアタックをfail2banで対応する

忘れた頃に403が増えてて、なんだろなとログを見てたらそれっぽい形跡があったので
filter書いて対応したメモ
bashの脆弱性対応はもちろんの事、fail2banはインストール及び稼働しているものとする

■フィルター準備
以下の内容のフィルタを /etc/fail2ban/filter.d/apache-shellshock.conf として保存する
docrootは環境に合わせ適宜修正すること

# Fail2Ban filter to block shellshock requests
#
#
[Definition]
docroot = /var/www/html
failregex = <HOST>.*\(\s*\)\s*\{[^"]*\}\s*\;[^"]+
ignoreregex =

■テスト

fail2ban-regex /var/log/httpd/access_log /etc/fail2ban/filter.d/apache-shellshock.conf

として想定通りmatchするか確認

■適用
以下の内容の設定を /etc/fail2ban/jail.local へ追記
maxretry, bantimeは環境に合わせ適宜修正すること

[apache-shellshock]
enabled  = true
port     = http,https
filter   = apache-shellshock
action   = iptables[name=shellshock, port=http, protocol=tcp]
           sendmail-whois[name=shellshock, dest=root@localhost]
logpath  = /var/log/httpd/access_log
           /var/log/httpd/error_log
maxretry = 10
findtime = 1200
bantime  = 1200

以上

トラックバック(0)

コメントする