chkrootkitをインストールして、rootkit感染していないか自動チェックしたいと思います。
chkrootkitインストール
yumでchkrootkitインストール
[root@sl6 ~]# yum --enablerepo=epel -y install chkrootkit
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package chkrootkit.x86_64 0:0.49-2.el6 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
============================================================
Package Arch Version Repository Size
============================================================
Installing:
chkrootkit x86_64 0.49-2.el6 epel 303 k
Transaction Summary
============================================================
Install 1 Package(s)
Upgrade 0 Package(s)
Total download size: 303 k
Installed size: 789 k
Downloading Packages:
chkrootkit-0.49-2.el6.x86_64.rpm | 303 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : chkrootkit-0.49-2.el6.x86_64 1/1
Installed:
chkrootkit.x86_64 0:0.49-2.el6
Complete!
chkrootkit実行と自動実行設定
chkrootkit実行
chkrootkitを実行してrootkitに感染していないかチェックを行います。
[root@sl6 x86_64]# chkrootkit | grep INFECTED
Searching for Suckit rootkit... Warning: /sbin/init INFECTED
げげっ、rootkit感染を検知した!?
まだ外部公開もしていないサーバーだからrootkitされたとは考えにくいのだけれど。
「Searching for Suckit rootkit... Warning: /sbin/init INFECTED」でググってみると以下のような記事が。
Ubuntu日本語フォーラム / aptitude upgradeを実行後、chkrootkitでSuckitを検出
リブートしたら検知されなくなったって書き込みがあるので、試しにリブートしてみます。
[root@sl6 x86_64]# reboot
# リブート後、再度rootkitのチェックを行います
[root@sl6 ~]# chkrootkit | grep INFECTED
[root@sl6 ~]#
今度は出なくなりました。
ひとまずよしとします。
chkrootkit自動実行設定
chkrootkitの自動実行スクリプトを作成します。
下記サイトを参考にさせていただきました。
rootkit検知ツール導入(chkrootkit) - CentOSで自宅サーバー構築
[root@sl6 ~]# vi chkrootkit.sh
#!/bin/bash
PATH=/usr/bin:/bin
TMPLOG=`mktemp`
# chkrootkit実行
chkrootkit > $TMPLOG
# ログ出力
cat $TMPLOG | logger -t chkrootkit
# SMTPSのbindshell誤検知対応
if [ ! -z "$(grep 465 $TMPLOG)" ] && \
[ -z $(/usr/sbin/lsof -i:465|grep bindshell) ]; then
sed -i '/465/d' $TMPLOG
fi
# rootkit検知時のみroot宛メール送信
[ ! -z "$(grep INFECTED $TMPLOG)" ] && \
grep INFECTED $TMPLOG | mail -s "chkrootkit report in `hostname`" root
rm -f $TMPLOG
# 保存してviエディタを終了します([:]キー[w]キー[q]キー[Enter]キーの順に押下します)
# chkrootkit定期自動実行スクリプトに実行権限を付与します
[root@sl6 ~]# chmod 700 chkrootkit.sh
# chkrootkit定期自動実行スクリプトをスケジューラに登録
[root@sl6 ~]# crontab -e
0 3 * * * /root/tripwire.sh
0 2 * * * /root/chkrootkit.sh
# 保存してviエディタを終了します([:]キー[w]キー[q]キー[Enter]キーの順に押下します)
■関連記事
Scientific Linux 6で自宅サーバー構築 その1 サーバー機Express 5800 GT110bのオンボードRAIDでRAID1設定
Scientific Linux 6で自宅サーバー構築 その2 Scientific Linux 6をExpress5800/GT110bにインストール
Scientific Linux 6で自宅サーバー構築 その3 Scientific Linux 6インストール後の初期設定
Scientific Linux 6で自宅サーバー構築 番外編その1 Scientific Linux 6のcronについて
Scientific Linux 6で自宅サーバー構築 その4 Scientific Linux 6 にClamAVをインストールしてウィルス対策
Scientific Linux 6で自宅サーバー構築 その5 Scientific Linux 6 にTripwireをインストールしてファイル改ざんを検知する
Scientific Linux 6で自宅サーバー構築 その6 Scientific Linux 6 にchkrootkitをインストールしてrootkit感染を検知する
Scientific Linux 6で自宅サーバー構築 その7 NTPサーバーで自動時刻合わせ
Scientific Linux 6で自宅サーバー構築 その8 バッファオーバーフロー攻撃対策を行う
Scientific Linux 6で自宅サーバー構築 その9 logwatchでサーバー監視
Scientific Linux 6で自宅サーバー構築 その10 DNSサーバーを構築
Scientific Linux 6で自宅サーバー構築 番外編その2 Scientific Linuxを6.0から6.1にアップグレードする
Scientific Linux 6で自宅サーバー構築 その11 PostfixとDovecotとSMTP-AUTHでメールサーバーを構築する
Scientific Linux 6で自宅サーバー構築 その12 メールサーバーにSSLを導入する
Scientific Linux 6で自宅サーバー構築 その13 Apache PHP MySQLをインストール
Scientific Linux 6で自宅サーバー構築 その14 WebサーバーにSSLを導入する
Scientific Linux 6で自宅サーバー構築 その15 WordPressを導入する
Scientific Linux 6で自宅サーバー構築 その16 Piwikでアクセスログ集計
Scientific Linux 6で自宅サーバー構築 その17 Squidをインストール
Scientific Linux 6で自宅サーバー構築 その18 sshで鍵認証を導入
Scientific Linux 6で自宅サーバー構築 その19 WebDavの設定
Scientific Linux 6で自宅サーバー構築 その20 lm_sensorをインストール
