OracleLinux9.3 clamav ( アンチウィルスソフト )のインストール
環境
OracleLinux9.3
1.Clam AntiVirusをインストールする
# dnf -y install clamav clamd clamav-update
2.Clam AntiVirus設定ファイルを修正する
# vi /etc/clamd.d/scan.conf
#14行目
# Default: disabled
LogFile /var/log/clamd.scan ← コメント解除
#77行目
# Default: disabled
PidFile /run/clamd.scan/clamd.pid ← コメント解除
#96行目
# Path to a local socket file the daemon will listen on.
# Default: disabled (must be specified by a user)
LocalSocket /run/clamd.scan/clamd.sock ← コメント解除
#227行目
# Run as another user (clamd must be started by root for this option to work)
# Default: don't drop privileges
#User clamscan ← 行頭に#を追加してコメントアウト
3.ウイルス定義ファイル更新設定
# vi /etc/freshclam.conf
#75行目
「DatabaseMirror database.clamav.net」の行頭に「#」を挿入し、
「DatabaseMirror db.jp.clamav.net」を追加
#DatabaseMirror database.clamav.net
DatabaseMirror db.jp.clamav.net
#151 行目あたり
「NotifyClamd /etc/clamd.d/scan.conf」を追加
#NotifyClamd /path/to/clamd.conf
NotifyClamd /etc/clamd.d/scan.conf
#14行目
# Default: disabled
LogFile /var/log/clamd.scan ← コメント解除
#77行目
# Default: disabled
PidFile /run/clamd.scan/clamd.pid ← コメント解除
#96行目
# Path to a local socket file the daemon will listen on.
# Default: disabled (must be specified by a user)
LocalSocket /run/clamd.scan/clamd.sock ← コメント解除
#227行目
# Run as another user (clamd must be started by root for this option to work)
# Default: don't drop privileges
#User clamscan ← 行頭に#を追加してコメントアウト
3.ウイルス定義ファイル更新設定
# vi /etc/freshclam.conf
#75行目
「DatabaseMirror database.clamav.net」の行頭に「#」を挿入し、
「DatabaseMirror db.jp.clamav.net」を追加
#DatabaseMirror database.clamav.net
DatabaseMirror db.jp.clamav.net
#151 行目あたり
「NotifyClamd /etc/clamd.d/scan.conf」を追加
#NotifyClamd /path/to/clamd.conf
NotifyClamd /etc/clamd.d/scan.conf
#14行目 # Default: disabled LogFile /var/log/clamd.scan ← コメント解除 #77行目 # Default: disabled PidFile /run/clamd.scan/clamd.pid ← コメント解除 #96行目 # Path to a local socket file the daemon will listen on. # Default: disabled (must be specified by a user) LocalSocket /run/clamd.scan/clamd.sock ← コメント解除 #227行目 # Run as another user (clamd must be started by root for this option to work) # Default: don't drop privileges #User clamscan ← 行頭に#を追加してコメントアウト 3.ウイルス定義ファイル更新設定 # vi /etc/freshclam.conf #75行目 「DatabaseMirror database.clamav.net」の行頭に「#」を挿入し、 「DatabaseMirror db.jp.clamav.net」を追加 #DatabaseMirror database.clamav.net DatabaseMirror db.jp.clamav.net #151 行目あたり 「NotifyClamd /etc/clamd.d/scan.conf」を追加 #NotifyClamd /path/to/clamd.conf NotifyClamd /etc/clamd.d/scan.conf
4.ウイルス定義ファイル最新化
# freshclam
5.Clam AntiVirus起動
# systemctl start clamd@scan
clamd自動起動設定
# systemctl enable clamd@scan
動作確認
# systemctl status clamd@scan
6.テスト用ウィルスをダウンロードして、ウィスルスキャンを実施
# cd /
# wget https://secure.eicar.org/eicar.com.txt
# clamscan --infected --remove --recursive /
# cd /
# wget https://secure.eicar.org/eicar.com.txt
# clamscan --infected --remove --recursive /
# cd / # wget https://secure.eicar.org/eicar.com.txt # clamscan --infected --remove --recursive /
7.スクリプト格納ディレクトリー作成
# mkdir -p /var/www/system
# vi /var/www/system/clamscan.sh
以下の内容を記載する
#!/bin/bash
PATH=/usr/bin:/bin
# excludeopt setup
excludelist=/var/www/system/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
# virus scan
clamscan --recursive --remove ${excludeopt} /
#!/bin/bash
PATH=/usr/bin:/bin
# excludeopt setup
excludelist=/var/www/system/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
# virus scan
clamscan --recursive --remove ${excludeopt} /
#!/bin/bash PATH=/usr/bin:/bin # excludeopt setup excludelist=/var/www/system/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 # virus scan clamscan --recursive --remove ${excludeopt} /
# chmod 700 clamscan.sh
8.ウイルススキャン除外ディレクトリー設定する
# echo "/sys/" >> /var/www/system/clamscan.exclude
# echo "/proc/" >> /var/www/system/clamscan.exclude
# echo "/sys/" >> /var/www/system/clamscan.exclude
# echo "/proc/" >> /var/www/system/clamscan.exclude
# echo "/sys/" >> /var/www/system/clamscan.exclude # echo "/proc/" >> /var/www/system/clamscan.exclude
9.ウィルススキャンの定期実行
# crontab -e
0 1 * * * /var/www/system/clamscan.sh > /dev/null 2>&1
# crontab -e
0 1 * * * /var/www/system/clamscan.sh > /dev/null 2>&1
# crontab -e 0 1 * * * /var/www/system/clamscan.sh > /dev/null 2>&1
10.クリプトを実行し、フルスキャンする
# /var/www/system/clamscan.sh