Last Updated on 2013年4月17日 by かんりにん
MailScannerインストール †
RHEL4+postfix環境にて、MailScannerを試す。
これでウィルス/スパムを同時にスキャンできる。
【本家サイト】
http://www.fsl.com/mailscanner_basic_req.html
http://www.sng.ecs.soton.ac.uk/mailscanner/
ダウンロードとインストール †
サイトからダウンロード。
src.rpmやspamassassin同梱のアーカイブも別に用意されており、なかなか親切。
[root@example ~]# cd /usr/local/src/ [root@example src]# wget http://www.sng.ecs.soton.ac.uk/mailscanner/files/4/rpm/MailScanner-4.51.6-1.rpm.tar.gz [root@example src]# tar -zxvf MailScanner-4.51.6-1.rpm.tar.gz
展開すると以下のsrcやソースアーカイブが出来る。
インストール用のシェルスクリプトがあるので、試しに実行してみる。
src.rpmもオッケーかと思いきや…
[root@example src]# cd MailScanner-4.51.6-1 [root@example MailScanner-4.51.6-1]# ls -al 合計 5264 drwxr-xr-x 2 root root 4096 3月 12 02:26 . drwxr-xr-x 17 root root 4096 3月 27 15:15 .. -rwxr-xr-x 1 root root 684 3月 12 02:26 CheckModuleVersion -rw-r--r-- 1 root root 219796 3月 12 02:26 ExtUtils-MakeMaker-6.30.tar.gz -rw-r--r-- 1 root root 21709 3月 12 02:26 MailScanner-perl-MIME-Base64-3.05-5.src.rpm -rwxr-xr-x 1 root root 1720 3月 12 02:26 QuickInstall.txt -rwxr-xr-x 1 root root 1459 3月 12 02:26 README -rwxr-xr-x 1 root root 13144 3月 12 02:26 install.sh -rw-r--r-- 1 root root 2503519 3月 12 02:26 mailscanner-4.51.6-1.noarch.rpm -rw-r--r-- 1 root root 112791 3月 12 02:26 perl-Archive-Zip-1.14-1.src.rpm -rw-r--r-- 1 root root 147710 3月 12 02:26 perl-Compress-Zlib-1.34-1.src.rpm -rw-r--r-- 1 root root 86910 3月 12 02:26 perl-Convert-BinHex-1.119-2.src.rpm -rwxr-xr-x 1 root root 14788 3月 12 02:26 perl-Convert-TNEF-0.17-1.src.rpm -rw-r--r-- 1 root root 496504 3月 12 02:26 perl-DBD-SQLite-1.11-1.src.rpm -rw-r--r-- 1 root root 389138 3月 12 02:26 perl-DBI-1.50-2.src.rpm -rw-r--r-- 1 root root 222622 3月 12 02:26 perl-ExtUtils-MakeMaker-6.30-1.src.rpm -rwxr-xr-x 1 root root 19389 3月 12 02:26 perl-File-Spec-0.82-1.src.rpm -rw-r--r-- 1 root root 34278 3月 12 02:26 perl-File-Temp-0.16-1.src.rpm -rw-r--r-- 1 root root 39378 3月 12 02:26 perl-Getopt-Long-2.35-1.src.rpm -rw-r--r-- 1 root root 85320 3月 12 02:26 perl-HTML-Parser-3.48-1.src.rpm -rwxr-xr-x 1 root root 9222 3月 12 02:26 perl-HTML-Tagset-3.03-1.src.rpm -rwxr-xr-x 1 root root 70157 3月 12 02:26 perl-IO-stringy-2.108-1.src.rpm -rw-r--r-- 1 root root 390403 3月 12 02:26 perl-MIME-tools-5.419-1.src.rpm -rw-r--r-- 1 root root 50172 3月 12 02:26 perl-MailTools-1.71-1.src.rpm -rw-r--r-- 1 root root 11482 3月 12 02:26 perl-Net-CIDR-0.10-1.src.rpm -rw-r--r-- 1 root root 165733 3月 12 02:26 perl-Storable-2.15-1.src.rpm -rw-r--r-- 1 root root 71663 3月 12 02:26 perl-Time-HiRes-1.86-1.src.rpm -rw-r--r-- 1 root root 20227 3月 12 02:26 perl-TimeDate-1.1301-3.src.rpm -rw-r--r-- 1 root root 50018 3月 12 02:26 tnef-1.3.4-1.i386.rpm [root@example MailScanner-4.51.6-1]# ./install.sh
やはり
Good, you have /usr/src/redhat in place.
とメッセージが出るので、/usr/src/redhatへ移動する。
[root@example src]# mv MailScanner-4.51.6-1 /usr/src/redhat/ [root@example src]# cd /usr/src/redhat/ [root@example redhat]# cd MailScanner-4.51.6-1/ [root@example MailScanner-4.51.6-1]# ./install.sh
実行するとずらずらとメッセージが出てきてperlのバージョンなどを確認し
ビルド/コンパイルが始まる(いかにもperlっぽいインストールログが出力される)。
完了すると、MailScannerのほか以下のPerlモジュールが出来る。
debuginfoとExtUtils-MakeMaker、File-Temp、Getopt-Longを除いて
スクリプト実行時にインストールされる。
MailScanner-perl-MIME-Base64-3.05-5.i386.rpm MailScanner-perl-MIME-Base64-debuginfo-3.05-5.i386.rpm perl-Archive-Zip-1.14-1.noarch.rpm perl-Convert-BinHex-1.119-2.noarch.rpm perl-Convert-TNEF-0.17-1.noarch.rpm perl-DBD-SQLite-1.11-1.noarch.rpm perl-DBI-1.50-2.noarch.rpm perl-ExtUtils-MakeMaker-6.30-1.noarch.rpm perl-File-Temp-0.16-1.noarch.rpm perl-Getopt-Long-2.35-1.noarch.rpm perl-IO-stringy-2.108-1.noarch.rpm perl-MIME-tools-5.419-1.noarch.rpm perl-MailTools-1.71-1.noarch.rpm perl-Net-CIDR-0.10-1.noarch.rpm perl-Time-HiRes-1.86-1.noarch.rpm perl-TimeDate-1.1301-3.noarch.rpm perl-Compress-Zlib-1.34-1.i386.rpm perl-Compress-Zlib-debuginfo-1.34-1.i386.rpm perl-HTML-Parser-3.48-1.i386.rpm perl-HTML-Parser-debuginfo-3.48-1.i386.rpm
初期設定 †
postfix †
- /etc/postfix/main.cf
header_checksファイルをインクルードするため以下を追記。header_checks = regexp:/etc/postfix/header_checks
※デフォルトではコメントになっているので有効にする。
- /etc/postfix/header_checks
ファイルはデフォルトで用意されているがコメントのみの状態。
以下を追記する。/^Received:/ HOLD
これはHOLDキューにメッセージをすべて移動させる設定。
移動先は/var/spool/postifx/hold。
mailscanner †
- /etc/MailScanner/MailScanner.conf
# cp MailScanner.conf MailScanner.conf.org
設定箇所
%org-name% = example %org-long-name% = example.com %web-site% = www.your-organisation.com Run As User = postfix Run As Group = postfix Incoming Queue Dir = /var/spool/postfix/hold Outgoing Queue Dir = /var/spool/postfix/incoming MTA = postfix Monitors for ClamAV Updates = /var/lib/clamav/*.cvd SpamAssassin User State Dir = /var/spool/MailScanner/spamassassin
以下のディレクトリ/ファイルのパーミッションを変更
- postfixデーモンがメールファイルを移動できるよう
/var/spool/MailScanner以下のディレクトリのオーナーを変更。# chown postfix.postfix /var/spool/MailScanner/incoming # chown postfix.postfix /var/spool/MailScanner/incoming/SpamAssassin.cache.db # chown postfix.postfix /var/spool/MailScanner/quarantine
※上記のディレクトリはバージョンアップするとオーナーがrootに戻るので
都度オーナーをpostfixへ修正する必要がある(と説明書きにあった)。
起動 †
設定変更後、postfixを再起動し、続けてMailScannerを起動。
# /etc/init.d/postfix restart # /etc/init.d/MailScanner start
動作確認 †
ウィルスメールを転送した時のログ。
ウィルス・スパムのフィルタリングを行っている。
ウィルスについてはclamsmtpdに比べて処理速度が遅かった。
Mar 28 13:46:49 example postfix/smtpd[18638]: connect from unknown[10.0.0.11] Mar 28 13:46:49 example postfix/smtpd[18638]: 8F7A8FC1D7: client=unknown[10.0.0.11] Mar 28 13:46:49 example postfix/cleanup[18621]: 8F7A8FC1D7: hold: header Received: from foo.com (unknown [10.0.0.11])??by example.com (Postfix) with ESMTP id 8F7A8FC1D7??for <testuser2@example. com>; Tue, 28 Mar 2006 13:46:49 +0900 (JST) from unknown[10.0.0.11]; from=<testuser@foo.com> to=<testuser2@example.com> proto=ESMTP helo=<foo.com> Mar 28 13:46:49 example postfix/cleanup[18621]: 8F7A8FC1D7: hold: header Received: from [10.10.1.236] (gw.m21.hogehoge.com [***.***.***.***])??by foo.com (Postfix) with ESMTP id 946BABC55??for <testuser 2@example.com>; Tue, 28 Mar 2006 13:47:04 +0900 (JST) from unknown[10.0.0.11]; from=<testuser@foo.com> to=<testuser2@example.com> proto=ESMTP helo=<foo.com> Mar 28 13:46:49 example postfix/cleanup[18621]: 8F7A8FC1D7: message-id=<20060328134649.3B2F.testuser@foo.com> Mar 28 13:46:49 example postfix/smtpd[18638]: disconnect from unknown[10.0.0.11] Mar 28 13:46:52 example MailScanner[16468]: New Batch: Scanning 1 messages, 41497 bytes Mar 28 13:46:52 example MailScanner[16468]: Virus and Content Scanning: Starting Mar 28 13:46:54 example MailScanner[16468]: /var/spool/MailScanner/incoming/16468/./8F7A8FC1D7.38DE8 /information.do.pif: Worm.SomeFool.Q FOUND Mar 28 13:46:54 example MailScanner[16468]: Virus Scanning: ClamAV found 1 infections Mar 28 13:46:54 example MailScanner[16468]: Infected message 8F7A8FC1D7.38DE8 came from 10.0.0.11 Mar 28 13:46:54 example MailScanner[16468]: Virus Scanning: Found 1 viruses Mar 28 13:46:54 example MailScanner[16468]: Filename Checks: Possible MS-Dos program shortcut attack (8F7A8FC1D7.38DE8 information.doc.pif) Mar 28 13:46:54 example MailScanner[16468]: Filetype Checks: No executables (8F7A8FC1D7.38DE8 information.doc.pif) Mar 28 13:46:54 example MailScanner[16468]: Other Checks: Found 2 problems Mar 28 13:46:54 example postfix/pickup[18444]: 37437FC1DC: uid=102 from=<postmaster> orig_id=35D99FC1D7 Mar 28 13:46:54 example postfix/cleanup[18621]: 37437FC1DC: hold: header Received: by example.com (Postfix, from userid 102)??id 37437FC1DC; Tue, 28 Mar 2006 13:46:54 +0900 (JST) from local; from=<postmaster@example.com> Mar 28 13:46:54 example postfix/cleanup[18621]: 37437FC1DC: message-id=<20060328044654.37437FC1DC@example.com> Mar 28 13:46:54 example MailScanner[16468]: Notices: Warned about 1 messages Mar 28 13:46:54 example MailScanner[16468]: Batch (1 message) processed in 1.81 seconds Mar 28 13:46:54 example MailScanner[16468]: New Batch: Scanning 1 messages, 1882 bytes Mar 28 13:46:54 example MailScanner[16468]: Virus and Content Scanning: Starting Mar 28 13:46:55 example MailScanner[16468]: Requeue: 37437FC1DC.068A1 to DDEE3FC1D7 Mar 28 13:46:55 example postfix/qmgr[17528]: DDEE3FC1D7: from=<postmaster@example.com>, size=2068, nrcpt=1 (queue active) Mar 28 13:46:55 example postfix/trivial-rewrite[18264]: warning: do not list domain example.com in BOTH mydestination and virtual_mailbox_domains Mar 28 13:46:55 example MailScanner[16468]: Uninfected: Delivered 1 messages Mar 28 13:46:55 example MailScanner[16468]: Batch (1 message) processed in 1.70 seconds Mar 28 13:46:55 example postfix/virtual[18636]: DDEE3FC1D7: to=<testuser2@example.com>, orig_to=<postmaster>, relay=virtual, delay=1, status=sent (delivered to maildir) Mar 28 13:46:55 example postfix/qmgr[17528]: DDEE3FC1D7: removed
カスタマイズ †
基本的に/etc/MailScanner/MailScanner.confで設定する。
コンフィグを見ながらの設定なので、詳細な設定については随時追記。
スキャン時のメール送信設定 †
設定項目は以下のとおり。
(編集中)
運用 †
メール通知 †
- ウィルス削除通知メール
- spam通知メール
ログの出力 †
MailScanner自体の出力ログは無く、maillogにフィルタリングの経過が出力される。
ログレベルの変更は可能。
パターンファイルの更新 †
- clamAV
freshclamで更新。MailScanner側の設定は特に無い様子。 - spamassassin
スパムのデータベースの更新(?)
カスタマイズ †
基本的に/etc/MailScanner/MailScanner.confで設定する。
コンフィグを見ながらの設定なので、詳細な設定については随時追記。
スキャン時のメール送信設定 †
設定項目は以下のとおり。
(編集中)
フィッシングメールのスキャン設定 †
デフォルトでオンになっている様子だけど要確認。
[参考]clamav高速化モジュール †
デフォルトでのウィルススキャンは若干遅い(ていうか結構遅い)ので
高速化を行うperlモジュールPerl ClamAV Moduleの配布とインストール。
CPANで以下の3つのモジュールをインストール。
# perl -MCPAN -e shell cpan> install Parse::RecDescent cpan> install Inline cpan> install Mail::ClamAV
インストール後にウィルスメールを転送してみると、ログから
ClamAVModuleの読み込みが確認出来る。
が、処理速度は同程度だった…
Mar 28 17:47:29 example postfix/smtpd[23314]: initializing the server-side TLS engine Mar 28 17:47:29 example postfix/smtpd[23314]: connect from unknown[10.0.0.11] Mar 28 17:47:29 example postfix/trivial-rewrite[23318]: warning: do not list domain example.com in BOTH mydestination and virtual_mailbox_domains Mar 28 17:47:29 example postfix/smtpd[23314]: EDEEFFC1D7: client=unknown[10.0.0.11] Mar 28 17:47:29 example postfix/cleanup[23322]: EDEEFFC1D7: hold: header Received: from foo.com (unknown [10.0.0.11])??by example.com (Postfix) with ESMTP id EDEEFFC1D7??for <testuser2@example.com>; Tue, 28 Mar 2006 17:47:29 +0900 (JST) from unknown[10.0.0.11]; from=<testuser@foo.com> to=<testuser2@example.com> proto=ESMTP helo=<foo.com> Mar 28 17:47:29 example postfix/cleanup[23322]: EDEEFFC1D7: hold: header Received: from [10.10.1.236] (gate.hogehoge.com [***.***.***.***])??by foo.com (Postfix) with ESMTP id 7A401BC51??for <testuser2@example.com>; Tue, 28 Mar 2006 17:47:44 +0900 (JST) from unknown[10.0.0.11]; from=<testuser@foo.com> to=<testuser2@example.com> proto=ESMTP helo=<foo.com> Mar 28 17:47:29 example postfix/cleanup[23322]: EDEEFFC1D7: message-id=<20060328174731.3B40.testuser@foo.com> Mar 28 17:47:30 example postfix/smtpd[23314]: disconnect from unknown[10.0.0.11] Mar 28 17:47:30 example MailScanner[23140]: New Batch: Scanning 1 messages, 43513 bytes Mar 28 17:47:37 example MailScanner[23140]: Virus and Content Scanning: Starting Mar 28 17:47:37 example MailScanner[23325]: Unrar command /usr/bin/unrar does not exist or is not executable, please either install it or remove the setting from MailScanner.conf Mar 28 17:47:37 example MailScanner[23140]: ClamAVModule::INFECTED:: Worm.SomeFool.P:: ./EDEEFFC1D7.ABCB3/document_all02c_mailmag_admin.pif Mar 28 17:47:37 example MailScanner[23140]: Virus Scanning: ClamAV Module found 1 infections Mar 28 17:47:37 example MailScanner[23140]: Infected message EDEEFFC1D7.ABCB3 came from 10.0.0.11 Mar 28 17:47:37 example MailScanner[23140]: Virus Scanning: Found 1 viruses Mar 28 17:47:37 example MailScanner[23140]: Filename Checks: Possible MS-Dos program shortcut attack (EDEEFFC1D7.ABCB3 document_all02c_mailmag_admin.pif) Mar 28 17:47:37 example MailScanner[23140]: Filetype Checks: No executables (EDEEFFC1D7.ABCB3 document_all02c_mailmag_admin.pif) Mar 28 17:47:37 example MailScanner[23140]: Other Checks: Found 2 problems Mar 28 17:47:37 example postfix/pickup[23135]: DA59BFC1DC: uid=102 from=<postmaster> orig_id=D76D2FC1D7 Mar 28 17:47:37 example postfix/cleanup[23322]: DA59BFC1DC: hold: header Received: by example.com (Postfix, from userid 102)??id DA59BFC1DC; Tue, 28 Mar 2006 17:47:37 +0900 (JST) from local; from=<postmaster@example.com> Mar 28 17:47:37 example postfix/cleanup[23322]: DA59BFC1DC: message-id=<20060328084737.DA59BFC1DC@example.com> Mar 28 17:47:37 example MailScanner[23140]: Notices: Warned about 1 messages Mar 28 17:47:37 example MailScanner[23140]: Batch (1 message) processed in 7.04 seconds Mar 28 17:47:37 example MailScanner[23140]: New Batch: Scanning 1 messages, 1922 bytes Mar 28 17:47:38 example MailScanner[23140]: Virus and Content Scanning: Starting Mar 28 17:47:38 example MailScanner[23330]: Unrar command /usr/bin/unrar does not exist or is not executable, please either install it or remove the setting from MailScanner.conf Mar 28 17:47:38 example MailScanner[23140]: Requeue: DA59BFC1DC.073E5 to E9291FC1D7 Mar 28 17:47:38 example MailScanner[23140]: Uninfected: Delivered 1 messages Mar 28 17:47:38 example MailScanner[23140]: Batch (1 message) processed in 1.06 seconds Mar 28 17:47:38 example postfix/qmgr[23136]: E9291FC1D7: from=<postmaster@example.com>, size=2108, nrcpt=1 (queue active) Mar 28 17:47:38 example postfix/trivial-rewrite[23318]: warning: do not list domain example.com in BOTH mydestination and virtual_mailbox_domains Mar 28 17:47:38 example postfix/virtual[23333]: E9291FC1D7: to=<testuser2@example.com>, orig_to=<postmaster>, relay=virtual, delay=1, status=sent (delivered to maildir) Mar 28 17:47:38 example postfix/qmgr[23136]: E9291FC1D7: removed
所見 †
利点 †
- 設定が比較的簡単
- ウィルス・スパムを同時にスキャンできる→グッド
- スパム関連のリスト更新が自動(?)
- 英語以外(日本語、中国語など)のスパム検知率が高い(spamassassin用モジュールPyzorの効果?)
要検討箇所 †
- メール受信後のスキャン処理速度が遅い(10秒弱結構遅い)
メルマガ配信時のLAは3を超すため、実際の運用には不安が残る
(OEからのメール受信時、時たまタイムアウトが発生する)
→マシンスペックやパフォーマンスチューニングで高速化可能か?
ClamAVModuleはあまり効果が見られなかった。