無償アンチウィルスソフト(ClamAV)の導入
サーバをインターネットに公開するならば、セキュリティ対策の一つとしてアンチウィルスソフトの 導入は、検討すべきでしょう。RPMforgeリポジトリのインストール
インストールはやはりRPMパッケージが楽なので、ClamAVのRPMパッケージを提供しているRPMforgeリポジトリ をまずインストールします。 http://pkgs.repoforge.org/rpmforge-release/にアクセスし、導入するOSの最新版をインストールする。# wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm # rpm -ivh rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm # yum -y update rpmforge-release意図せず標準レポジトリのパッケージをRPMforgeリポジトリのパッケージで上書きされることを さけるため、無効化する。RPMforgeリポジトリのパッケージをインストールしたい場合は、「--enablerepo=rpmforge」 オプションを付けてyumコマンドを実行する。
enabled = 0※すべての「enabled」値を「0」とする。
ClamAVのインストール
「--enablerepo=rpmforge」オプションを付けて、ClamAVのRPMパッケージをインストールする。# yum -y --enablerepo=rpmforge install clamd
ClamAVの設定
オリジナルのClamAVの設定ファイルをバックアップする。# cp /etc/clamd.conf /etc/clamd.conf.orgClamAVををrootユーザで実行する。
# vi /etc/clamd.conf -------- #User clamv <----コメントアウト、rootユーザで起動する
Clam AntiVirusの自動起動設定
# chkconfig clamd on # /etc/rc.d/init.d/clamd start
ウィルス定義ファイルの最新化
・オリジナルのウィルス定義設定ファイルをバックアップする。# cp /etc/freshclam.conf /etc/freshclam.conf.org
# vi /etc/freshclam.conf ------------- #Example <---[Example]をコメントアウト
# freshclam
ウィルススキャン定期自動実行設定
ウィルススキャンスクリプトを作成する。・「/opt/scripts/bin/clamscan.exclude」にスキャン除外を定義する。
・ClamAVエンジンとウィルス定義ファイルの更新を行う。
・ウィルス検知した場合は、「infrasupport@cross-hoge.net」宛てに送信する。
vi /opt/scripts/bin/virusscan.sh
====================================
#!/bin/bash
PATH=/usr/bin:/bin
#ログ出力 開始
logger "[Info] ClamAV Scan Start"
# clamd update
yum -y --enablerepo=rpmforge update clamd > /dev/null 2>&1
freshclam > /dev/null 2>&1
# excludeopt setup
excludelist=/opt/scripts/bin/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
# 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`" infrasupport@cross-hoge.net
#ログ出力 ウィルス検知
grep FOUND$ $CLAMSCANTMP | logger
rm -f $CLAMSCANTMP
#ログ出力 終了
logger "[Info] ClamAV Scan Finish"
# chmod +x /opt/scripts/bin/virusscan.sh
# echo "/proc/" >> /opt/scripts/bin/clamscan.exclude # echo "/sys/" >> /opt/scripts/bin/clamscan.exclude
ClamAVの定期実行設定
50 3 * * * /opt/scripts/bin/virusscan.sh >/dev/null 2>&1
テストウィルス
無害のテストウィルスは下記から入手できます。# wget http://www.eicar.org/download/eicar.com.txt # wget http://www.eicar.org/download/eicar_com.zip # wget http://www.eicar.org/download/eicarcom2.zip
|
たった2日でわかるLinux―Cent OS 6.4対応 |
|