end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

OSSウイルス対策ソフト"ClamAV" を debian linux (raspberry)へインストール

japan.norton.com

srcからのinstall ( 参考 )

今回は、パッケージ(apt-get)でインストールしましたが、参考として記載しておきます。

configure error

raspbianにはデフォルトでopensslがインストールされていますが、デフォルトではconfigureでエラーになります。

$ wget http://www.clamav.net/downloads/production/clamav-0.98.7.tar.gz
$ tar -zxvf clamav-0.98.7.tar.gz
$ cd clamav-0.98.7/
$ ./configure
  :
configure: unable to compile/link with check
checking for libxml2 installation... not found
configure: ****** libxml2 support unavailable
checking for OpenSSL installation... /usr
configure: error: OpenSSL not found.

$ which openssl
/usr/bin/openssl
$ /usr/bin/openssl version
OpenSSL 1.0.1k 8 Jan 2015

このconfigure errorは "sudo apt-get install libssl-dev"で解消できます

$ sudo apt-get install libssl-dev
$ pwd
/home/endo/tmp/clamav-0.98.7
$ ./configure
$ make
$ make check
$ sudo make install

packageからのinstall

$ sudo apt-get install clamav

↑これだけ。で、apt-getにより...

4個のコマンドがインストールされます

"freshclam" は、ウイルスデータベースを更新し、 "clamscan" が、ウイルススキャンを行います。

 $ ls -l /usr/bin/*clam*                                                 
-rwxr-xr-x 1 root root  79872 Jun  7 01:40 /usr/bin/clambc
-rwxr-xr-x 1 root root 104352 Jun  7 01:40 /usr/bin/clamscan
-rwxr-xr-x 1 root root  79612 Jun  7 01:40 /usr/bin/clamsubmit
-rwxr-xr-x 1 root root 141408 Jun  7 01:40 /usr/bin/freshclam

ウイルスデータベースを更新する"clamscan"が、daemonで起動

"clamav"というユーザも追加されます

$ ps -ef | grep clam
clamav  1451  1  2 15:42 ? 00:00:02 /usr/bin/freshclam -d --foreground=true

freshclamの設定は /etc/clamav/freshclam.conf にあります

freshclam の自動起動が設定されます

$ sudo insserv -s | grep clam
K:01:0 1 6:clamav-freshclam
S:02:2 3 4 5:clamav-freshclam
$ find /etc/ -name "*clamav-freshclam*"
/etc/init.d/clamav-freshclam
/etc/rc0.d/K01clamav-freshclam
/etc/rc1.d/K01clamav-freshclam
/etc/rc2.d/S02clamav-freshclam
/etc/rc3.d/S02clamav-freshclam
/etc/rc4.d/S02clamav-freshclam
/etc/rc5.d/S02clamav-freshclam
/etc/rc6.d/K01clamav-freshclam
/etc/network/if-down.d/clamav-freshclam-ifupdown
/etc/network/if-up.d/clamav-freshclam-ifupdown
/etc/ppp/ip-up.d/clamav-freshclam-ifupdown
/etc/ppp/ip-down.d/clamav-freshclam-ifupdown

freshclamのログに対するlogrotate.dが設定されます

$ find /etc/ -name "*clamav-freshclam*"
   :
/etc/logrotate.d/clamav-freshclam

テスト実行

サンプルウイルスの入手

$ wget http://www.eicar.org/download/eicar.com
$ 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

テスト実行

$ /usr/bin/clamscan --infected --remove \
                    --recursive /home/endo/tmp/TEST_VIRUS
/home/endo/tmp/TEST_VIRUS/eicar_com.zip: Eicar-Test-Signature FOUND
/home/endo/tmp/TEST_VIRUS/eicar_com.zip: Removed.
/home/endo/tmp/TEST_VIRUS/eicar.com: Eicar-Test-Signature FOUND
/home/endo/tmp/TEST_VIRUS/eicar.com: Removed.
/home/endo/tmp/TEST_VIRUS/eicar.com.txt: Eicar-Test-Signature FOUND
/home/endo/tmp/TEST_VIRUS/eicar.com.txt: Removed.
/home/endo/tmp/TEST_VIRUS/eicarcom2.zip: Eicar-Test-Signature FOUND
/home/endo/tmp/TEST_VIRUS/eicarcom2.zip: Removed.

----------- SCAN SUMMARY -----------
Known viruses: 4113772
Engine version: 0.98.7
Scanned directories: 1
Scanned files: 4
Infected files: 4
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 173.278 sec (2 m 53 s)

が、raspberryでのclamscan 実行時間は、長い...

raspberry or clamav のどちらの原因であるかは分かりませんが、clamavを削除し、当面使用しないことにしました

$ sudo apt-get --purge remove clamav*