概要
特定のディレクトリ配下をウイルススキャンしたい場合にclamavを使った方法です。
clamavのインストール手順
clamvをインストール
$ brew install clamav
設定ファイルのサンプルのPATHを確認
$ find /usr/local -name "freshclam*"
/usr/local/bin/freshclam
/usr/local/Cellar/clamav/0.103.0/bin/freshclam
/usr/local/Cellar/clamav/0.103.0/.bottle/etc/clamav/freshclam.conf.sample
/usr/local/Cellar/clamav/0.103.0/share/man/man5/freshclam.conf.5
/usr/local/Cellar/clamav/0.103.0/share/man/man1/freshclam.1
/usr/local/share/man/man5/freshclam.conf.5
/usr/local/share/man/man1/freshclam.1
ディレクトリ作成
$ mkdir /usr/local/etc/clamav/
サンプルのコピー
$ cp /usr/local/Cellar/clamav/0.103.0/.bottle/etc/clamav/freshclam.conf.sample /usr/local/etc/clamav/freshclam.conf
/usr/local/Cellar/clamav/0.103.0/.bottle/etc/clamav/freshclam.conf.sample -> /usr/local/etc/clamav/freshclam.conf
元ファイルのバックアップ
$ cp /usr/local/etc/clamav/freshclam.conf{,.bak}
/usr/local/etc/clamav/freshclam.conf -> /usr/local/etc/clamav/freshclam.conf.bak
設定ファイルの Example
という文字列をコメントアウト
$ diff -u /usr/local/etc/clamav/freshclam.conf{.bak,}
--- /usr/local/etc/clamav/freshclam.conf.bak 2020-10-26 19:37:45.000000000 +0900
+++ /usr/local/etc/clamav/freshclam.conf 2020-10-26 19:38:29.000000000 +0900
@@ -5,7 +5,7 @@
# Comment or remove the line below.
-Example
+#Example
# Path to the database directory.
# WARNING: It must match clamd.conf's directive!
データベースの更新
$ freshclam -v
スキャン方法
clamscanを使って対象ディレクトリをスキャンする
$ clamscan public_html -r -i
-r 再帰的に実行
-i 対象ファイルのみを表示