
TOP >> centos >> 無料ウィルスソフトでウィルス対策
[root@centos ~]# wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm ← rpmforgeリポジトリダウンロード※CentOS5の場合 [root@centos ~]# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm ← rpmforgeリポジトリインストール※CentOS5の場合 [root@centos ~]# rm -f rpmforge-release-0.3.6-1.el5.rf.i386.rpm ← rpmforgeリポジトリ削除※CentOS5の場合 [root@centos ~]# rpm -Uvh http://ftp.belnet.be/packages/dries.ulyssis.org/redhat/el4/en/i386/RPMS.dries/rpmforge-release-0.2-2.2.el4.rf.i386.rpm ← rpmforgeリポジトリインストール※CentOS4の場合 [root@centos ~]# sed -i 's/enabled = 1/enabled = 0/g' /etc/yum.repos.d/rpmforge.repo ← 基本リポジトリとのパッケージ競合を避けるため、デフォルトは無効にしておく [root@centos ~]# yum -y --enablerepo=rpmforge install clamd ← Clam AntiVirusインストール
[root@centos ~]# vi /etc/clamd.conf ← clamd設定ファイル編集 User clamav ↓ #User clamav ← root権限で動作するようにする # Mark archives as viruses (e.g. RAR.ExceededFileSize, Zip.ExceededFilesLimit) # if ArchiveMaxFiles, ArchiveMaxFileSize, or ArchiveMaxRecursion limit is # reached. # Default: no ArchiveBlockMax no ↓ #ArchiveBlockMax no ← コメントアウト(大きな圧縮ファイル等をウィルス感染ファイルとみなさないようにする)
[root@centos ~]# /etc/rc.d/init.d/clamd star ← clamd起動
Starting Clam AntiVirus Daemon: [ OK ]
[root@centos ~]# chkconfig clamd on ← clamd自動起動設定
[root@centos ~]# chkconfig --list clamd ← clamd自動起動設定確認
clamd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@centos ~]# sed -i 's/Example/#Example/g' /etc/freshclam.conf ← ウィルス定義ファイル更新機能の有効化 [root@centos ~]# freshclam ← ウィルス定義ファイル最新化 Clamd successfully notified about the update.
※以後のウィルス定義ファイルのアップデートは、/etc/cron.daily/freshclamにより毎日自動で行われる
[root@centos ~]# clamscan --infected --remove --recursive ← ウィルススキャンテスト(ウィルスなしの場合) ----------- SCAN SUMMARY ----------- Infected files: 0 ← ウィルスは検知されなかった テストしたい方は [root@centos ~]# wget http://www.eicar.org/download/eicar.com ← テスト用ウィルスをダウンロード [root@centos ~]# wget http://www.eicar.org/download/eicar.com.txt ← [root@centos ~]# wget http://www.eicar.org/download/eicar_com.zip ← [root@centos ~]# wget http://www.eicar.org/download/eicarcom2.zip ← [root@centos ~]# clamscan --infected --remove --recursive ← ウィルススキャンテスト(ウィルスありの場合) /root/eicarcom2.zip: Eicar-Test-Signature FOUND ← ウィルス検知 /root/eicarcom2.zip: Removed ← ウィルス削除 /root/eicar.com.txt: Eicar-Test-Signature FOUND ← ウィルス検知 /root/eicar.com.txt: Removed ← ウィルス削除 /root/eicar_com.zip: Eicar-Test-Signature FOUND ← ウィルス検知 /root/eicar_com.zip: Removed ← ウィルス削除 /root/eicar.com: Eicar-Test-Signature FOUND ← ウィルス検知 /root/eicar.com: Removed ← ウィルス削除
----------- SCAN SUMMARY ----------- Known viruses: 116966 Engine version: 0.90.2 Scanned directories: 5 Scanned files: 39 Infected files: 4 ← 4つのウィルスを検知した Data scanned: 0.24 MB Time: 29.437 sec (0 m 29 s)
[root@centos ~]# vi clamscan ← ウィルススキャン実行スクリプト作成 #!/bin/bash PATH=/usr/bin:/bin # excludelist excludelist=/root/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 CLAMSCANTMP=`mktemp` freshclam > /dev/null clamscan --recursive --remove ${excludeopt} / > $CLAMSCANTMP 2>&1 [ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \ grep FOUND$ $CLAMSCANTMP | mail -s "Virus Found in `hostname`" root rm -f $CLAMSCANTMP [root@centos ~]# chmod +x clamscan ← ウィルススキャン実行スクリプトへ実行権限付加 [root@centos ~]# echo "/backup/backup.tar.bz2" >> clamscan.exclude ← 例として/backup/backup.tar.bz2をスキャン対象外にする [root@centos ~]# echo "/proc/" >> clamscan.exclude ← 例として/procディレクトリをスキャン対象外にする [root@centos ~]# echo "/sys/" >> clamscan.exclude ← 例として/sysディレクトリをスキャン対象外にする ※ディレクトリを除外する場合は末尾に「/」を付加すること
これで、毎日定期的に全ファイルのウィルススキャンが行われ、ウィルスを検知した場合のみroot宛にメールが送られてくるようになる。
※Clam AntiVirusインストールディレクトリにテスト用ウィルスがあるので、インストール後最初の全体スキャンでは必ずウィルス検知メールがくる
サーバー関連のウィルスソフトって有料というイメージがありますが、無料のウィルスソフトがあるのです。その名は「clamav」!!