|
[ CentOS/セキュリティ ] Clam AntiVirus インストール・設定 †chkrootkit インストールには、rpmforgeリポジトリが必要です。 最新バージョン確認
Clam AntiVirus インストール †[user@linux ~]$ wget ftp://ftp.riken.jp/Linux/dag/redhat/el5/en/i386/RPMS.dag/clamav-0.93-2.el5.rf.i386.rpm ←■ rpmforgeリポジトリダウンロード [user@linux ~]$ wget ftp://ftp.riken.jp/Linux/dag/redhat/el5/en/i386/dag/RPMS/clamav-db-0.93-2.el5.rf.i386.rpm ←■ rpmforgeリポジトリダウンロード [root@linux ~]# rpm -Uvh clamav-0.93-2.el5.rf.i386.rpm clamav-db-0.93-2.el5.rf.i386.rpm ←■ インストール 準備中... ########################################### [100%] 1:clamav-db ########################################### [ 50%] 2:clamav ########################################### [100%] [root@linux ~]# [root@linux ~]# sed -i 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo ←■ 基本リポジトリとのパッケージ競合を避けるため、デフォルトは無効にしておく [root@linux ~]# [root@linux ~]# yum -y --enablerepo=rpmforge install clamd ←■ Clam AntiVirusインストール Clam AntiVirus 設定 †[root@linux ~]# cp -a /etc/clamd.conf /etc/clamd.conf.org ←■ 設定ファイルをバックアップ [root@linux ~]# vi /etc/clamd.conf ←■ clamd 設定ファイル編集 User clamav ↓■ root権限で動作するように変更する #User clamav [root@linux ~]# [root@linux ~]# cp -a /etc/freshclam.conf /etc/freshclam.conf.org ←■ 設定ファイルをバックアップ [root@linux ~]# [root@linux ~]# vi /etc/freshclam.conf ←■ ウィルスデータベース更新設定ファイル編集 # Uncomment the following line and replace XY with your country # code. See http://www.iana.org/cctld/cctld-whois.htm for the full list. #DatabaseMirror db.XY.clamav.net DatabaseMirror db.jp.clamav.net ←■ ウィルスデータベース取得元を日本に変更 [root@linux ~]# Clam AntiVirus 起動 †[root@linux ~]# /etc/rc.d/init.d/clamd start ←■ clamd 起動 Starting Clam AntiVirus Daemon: [ OK ] [root@linux ~]# chkconfig --list clamd ←■ clamd 自動起動設定確認 clamd 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@linux ~]# chkconfig clamd on ←■ clamd 自動起動になっていない場合は ON にする [root@linux ~]# Clam AntiVirus のウィルス定義ファイル最新化 †[root@linux ~]# sed -i 's/Example/#Example/g' /etc/freshclam.conf ←■ ウィルス定義ファイル更新機能の有効化 [root@linux ~]# freshclam ←■ ウィルス定義ファイル最新化 ClamAV update process started at Mon May 12 11:28:49 2008 main.cvd is up to date (version: 46, sigs: 231834, f-level: 26, builder: sven) WARNING: getfile: daily-6689.cdiff not found on remote server (IP: 61.206.123.121) WARNING: getpatch: Can't download daily-6689.cdiff from db.jp.clamav.net WARNING: getfile: daily-6689.cdiff not found on remote server (IP: 219.117.246.122) WARNING: getpatch: Can't download daily-6689.cdiff from db.jp.clamav.net WARNING: getfile: daily-6689.cdiff not found on remote server (IP: 219.106.242.51) WARNING: getpatch: Can't download daily-6689.cdiff from db.jp.clamav.net WARNING: Incremental update failed, trying to download daily.cvd Downloading daily.cvd [100%] daily.cvd updated (version: 7093, sigs: 52514, f-level: 26, builder: ccordes) Database updated (284348 signatures) from db.jp.clamav.net (IP: 218.44.253.75) [root@linux ~]# ※ ウィルス定義ファイル最新化(freshclam)実行以後、ウィルス定義ファイルのアップデートは、/etc/cron.daily/freshclamにより毎日自動で行われる ウィルスチェック †ウィルス検出無し †[root@linux ~]# clamscan --infected --remove --recursive ----------- SCAN SUMMARY ----------- Known viruses: 283581 Engine version: 0.93 Scanned directories: 307 Scanned files: 1131 Infected files: 0 ←■ Infected filesが0ならば、ウィルスは検出されなかった事を表す Data scanned: 57.61 MB Time: 40.507 sec (0 m 40 s) [root@linux ~]# ウィルス検出有り †[root@linux ~]# wget -P /home/user/virus/ http://www.eicar.org/download/eicar.com ←■ 無害なテスト用ウィルスを /home/user/vitur/ディレクトリにダウンロード [root@linux ~]# wget -P /home/user/ http://www.eicar.org/download/eicar.com.txt ←■ 〃 [root@linux ~]# wget -P /home/user/ http://www.eicar.org/download/eicar_com.zip ←■ 〃 [root@linux ~]# wget -P /home/user/ http://www.eicar.org/download/eicarcom2.zip ←■ 〃 [root@linux ~]# clamscan --infected --remove --recursive /home/user/ ←■ /home/user/パス以下をチェックする /home/user/virus/eicar_com.zip: Eicar-Test-Signature FOUND ←■ ウィルス検出 /home/user/virus/eicar_com.zip: Removed ←■ ウィルス削除 /home/user/virus/eicarcom2.zip: Eicar-Test-Signature FOUND ←■ ウィルス検出 /home/user/virus/eicarcom2.zip: Removed ←■ ウィルス削除 /home/user/virus/eicar.com: Eicar-Test-Signature FOUND ←■ ウィルス検出 /home/user/virus/eicar.com: Removed ←■ ウィルス削除 /home/user/virus/eicar.com.txt: Eicar-Test-Signature FOUND ←■ ウィルス検出 /home/user/virus/eicar.com.txt: Removed ←■ ウィルス削除 ----------- SCAN SUMMARY ----------- Known viruses: 283581 Engine version: 0.93 Scanned directories: 20 Scanned files: 1619 Infected files: 4 ←■ Infected filesが4ならば、4個のウィルスが検出された事を表す Data scanned: 45.09 MB Time: 48.287 sec (0 m 48 s) [root@linux ~]# ls /home/hassy/virus/ -l ウィルススキャン 定期自動実行 †ウィルススキャン実行スクリプト作成 †[root@linux ~]# mkdir -m 750 clamd ←■ ディレクトリ作成
[root@linux ~]#
[root@linux ~]# vi /root/clamd/clamscan
#!/bin/bash
PATH=/usr/bin:/bin
# clamd update
yum -y --enablerepo=rpmforge update clamd > /dev/null 2>&1
# excludeopt setup
excludelist=/root/clamd/clamscan.exclude
if [ -s $excludelist ]; then
for i in `cat $excludelist`
do
if [ $(echo "$i"|grep \/$) ]; then
i=`echo $i|sed -e 's/^\([^ ]*\)\/$/\1/p' -e d`
excludeopt="${excludeopt} --exclude-dir=$i"
else
excludeopt="${excludeopt} --exclude=$i"
fi
done
fi
# signature update
freshclam > /dev/null
# virus scan
CLAMSCANTMP=`mktemp`
clamscan --recursive --remove ${excludeopt} / > $CLAMSCANTMP 2>&1
[ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \
# report mail send
grep FOUND$ $CLAMSCANTMP | mail -s "Virus Found in `hostname`" root
rm -f $CLAMSCANTMP
:wq ←■ 保存して閉じる
[root@linux ~]#
[root@linux ~]# chmod +x /root/clamd/clamscan ←■ ウィルススキャン実行スクリプトへ実行権限付加
ウィルススキャン対象外ディレクトリ設定 †[root@linux ~]# vi /root/clamd/clamscan.exclude /proc/ ←■ /proc を対象外にする場合の例 /sys/ ←■ /sys を対象外にする場合の例 :wq ←■ 保存して閉じる [root@linux ~]# ※ ディレクトリを指定する場合は、必ず末尾に / を付けること 定期的に実行するcrondの設定 †[root@linux ~]# crontab -e 10 5 * * 1 /root/clamd/clamscan ←■ 毎週月曜日の5時10分に実行する :wq ←■ 保存して閉じる [root@linux ~]# |