ModSecurity はオープンソースの WAF (Web Application Framework) で、導入までの手間は結構かかりますが無償で利用できるのは大きなメリットです。ですが、アンインストールができないと気楽に試すことができません。
以下の IPA の WAF の資料によると「ソースコードから」ビルドしてインストールした ModSecurity にはアンインストールの方法がマニュアルに記載がないとのこと。
代替案として、ModSecurity を無効にする方法が提示されています。ModSecurity を無効にする方法は以下の記事を参考にしてください。
ソースコードからビルドしてインストールしたのではなく、以下の記事のように EPEL リポジトリから yum コマンドを使用してインストールした場合は簡単にアンインストールすることができます。
yum コマンドで、ModSecurity と CRS (Core Rule Set) をアンインストールするには以下のコマンドを実行します。
# yum --enablerepo=epel remove mod_security mod_security_crs
Web サーバーを再起動します。
#service httpd restart
すると、以下のようなエラーメッセージが表示されてしまいます。
Syntax error on line 552 of /etc/httpd/conf/httpd.conf: Invalid command 'SecRuleRemoveById', perhaps misspelled or defined by a module not included in the server
どうも、httpd.conf にエラーがあるようです。httpd.conf を開いて 552 行目を確認します。
# vi /etc/httpd/conf/httpd.conf
すると、以下のように ModSecurity の設定が残っているので削除して保存します。
<LocationMatch "(/wp-login.php)"> SecRuleRemoveById 960024 </LocationMatch> <LocationMatch "(/wp-admin/|/xmlrpc.php|/wp-comments-post.php)"> SecRuleRemoveById 950001 SecRuleRemoveById 950007 SecRuleRemoveById 950901 SecRuleRemoveById 958030 SecRuleRemoveById 959073 SecRuleRemoveById 960024 SecRuleRemoveById 973300 SecRuleRemoveById 973302 SecRuleRemoveById 973304 SecRuleRemoveById 973305 SecRuleRemoveById 973306 SecRuleRemoveById 973316 SecRuleRemoveById 973332 SecRuleRemoveById 973333 SecRuleRemoveById 973335 SecRuleRemoveById 981173 SecRuleRemoveById 981231 SecRuleRemoveById 981240 SecRuleRemoveById 981242 SecRuleRemoveById 981243 SecRuleRemoveById 981245 SecRuleRemoveById 981246 SecRuleRemoveById 981248 SecRuleRemoveById 981249 SecRuleRemoveById 981255 SecRuleRemoveById 981257 SecRuleRemoveById 981260 SecRuleRemoveById 981276 SecRuleRemoveById 981317 SecRuleRemoveById 981318 SecRuleRemoveById 981319 SecRuleRemoveById 981320 </LocationMatch>
Web サーバーを起動します。
# service httpd start
問題なく起動できたので、以下のアドレスにアクセスしてみます。
http://hostname/?union+select
以下のように、リクエストがブロックされることなく画面が表示できたので、問題なくアンインストールできたことが分かります。
WAF設定まとめ
WAFの設定については以下のページにまとめていますので、こちらもどうぞ。
コメント