ossecの覚書
2008/5/26
本家
概要
ルートキットの検索, システムファイルの変更の通知
インストール
解凍して, できたディレクトリに行き, ./install.shを実行 すればよい。
gccが必要。
$ su # yum install gcc # wget http://www.ossec.net/files/ossec-hids-1.5.tar.gz # zcat ossec-hids-1.5.tar.gz | tar -xvf - # cd ossec-hids-1.5 # ./install.sh (以下, 質問が続く。最初の質問でjpと答えると日本語でできる。) # /var/ossec/bin/ossec-control start
DNSキャッシュポイズニング攻撃?への対応
現象
下記のようなログ(/var/log/messages)が1分に10行前後残される。
Feb 1 14:07:10 dns named[20747]: client 65.23.129.220#24071: view external: query (cache) './NS/IN' denied Feb 1 14:07:15 dns named[20747]: client 71.6.131.81#24437: view external: query (cache) './NS/IN' denied
今回の環境
Fedora core 10, bind9(DNSキャッシュポイズニング対応済みバージョン)
ossecの作業ディレクトリは/var/ossec。
対応
まず, 下記内容の/var/ossec/rules/local-named-rules.xmlを作成
<group name="named,syslog,"> <rule id="101201" level="5"> <decoded_as>named</decoded_as> <match>view external: query . IN NS </match> <description>recursive root query; possible forged attacher</description> </rule> <rule id="101202" level="10"> <if_matched_sid>101201</if_matched_sid> <same_source_ip /> <description>Multiple recursive root queries</description> </rule> <rule id="101203" level="5"> <decoded_as>named</decoded_as> <match>view external: query (cache) './NS/IN' denied</match> <description>recursive root query(cache); possible forged attacher</description> </rule> <rule id="101204" level="10"> <if_matched_sid>101203</if_matched_sid> <same_source_ip /> <description>Multiple recursive root queries(cache)</description> </rule> </group>
id=101201と101202は不要かも知れない。
次に/var/ossec/etc/ossec.confを編集する。まず, syslog_rules.xmlの前にlocal-named-rules.xmlをincludeする。 前後の行は次の通り
<rules> <include>rules_config.xml</include> ... <include>telnetd_rules.xml</include> <include>local_named_rules.xml</include> <include>syslog_rules.xml</include> ...
syslog_rulesでdeniedを含むログに反応するため, 念のため syslog_rulesより前に書いたが, 前に書くことが必要かどうかは 定かではない。
次に, 事態が発生した場合の設定を/var/ossec/etc/ossec.confに 書く。ここでは, 87000秒アクセスを拒否することにする。
<active-response> <!-- This response is going to execute the host-deny - command for every event that fires a rule with - level (severity) >= 10. - The IP is going to be blocked for 600 seconds. --> <command>host-deny</command> <location>local</location> <level>10</level> <timeout>87000</timeout> </active-response> <active-response> <!-- Firewall Drop response. Block the IP for - 87000 seconds on the firewall (iptables, - ipfilter, etc). --> <command>firewall-drop</command> <location>local</location> <level>10</level> <timeout>87000</timeout> </active-response>
念のため, 規定のlevel6の場合より前に書いた。
再起動して, 現象で述べたログが発生し, かつ同じIPアドレスから 何度もくれば, 1日強接続を拒否してくれるはずである。
注意
タイトルに?がついているのは, このログが本当に DNSキャッシュポイズニング攻撃のものかどうか わからないため。