![]() |
| ◆ | Clam AntiVirus のインストール(ウィルスソフト) |
| このサイトの『 yum 用リポジトリ追加 』を先に実行しておく事 | |
|
[root@centos]# yum -y install clamd <--- 入力 |
|
| ◆ | Clam AntiVirus の設定 |
|
[root@centos]# vi /etc/clamd.conf <--- 入力 ## ## Example config file for the Clam AV daemon ## Please read the clamd.conf(5) manual before editing this file. ## 途中略 # Run as another user (clamd must be started by root for this option to work) # Default: don't drop privileges User clamav <--- コメントアウト ↓ #User clamav 以下略 |
|
| ◆ | ウィルス定義ファイルの最新化 |
|
[root@centos]# sed -i 's/Example/#Example/g' /etc/freshclam.conf <--- 入力 |
|
|
[root@centos]# freshclam <--- 入力 |
|
| ◆ | ウィルススキャンの 実行 |
|
[root@centos]# clamscan --infected --remove --recursive <--- 入力 ----------- SCAN SUMMARY ----------- Known viruses: 3511445 Engine version: 0.98.4 Scanned directories: 344 Scanned files: 2026 Infected files: 0 <--- ここが 0 だとウィルスは無し Data scanned: 354.95 MB Data read: 576.57 MB (ratio 0.62:1) Time: 135.535 sec (2 m 15 s) |
|
| ◆ | テスト用ウィルスのダウンロード |
|
[root@centos]# wget http://www.eicar.org/download/eicar.com.txt <--- 入力 |
|
| ◆ | 再度ウィルススキャンを実行 |
|
[root@centos]# clamscan --infected --remove --recursive <--- 入力 /root/eicar.com.txt: Eicar-Test-Signature FOUND <--- ウィルスファイルを検出 /root/eicar.com.txt: Removed. <--- ウィルスファイルを駆除 ----------- SCAN SUMMARY ----------- Known viruses: 3511445 Engine version: 0.98.4 Scanned directories: 344 Scanned files: 2026 Infected files: 1 <--- 1個のウィルスを検出して駆除 Data scanned: 354.95 MB Data read: 576.57 MB (ratio 0.62:1) Time: 135.535 sec (2 m 15 s) |
|
| ◆ | Clamの起動 |
|
[root@centos]# /etc/rc.d/init.d/clamd start <--- 入力 |
|
| ◆ | Clamの自動起動設定 |
|
[root@centos]# chkconfig clamd on <--- 入力 |
|
| ◆ | 自動起動設定確認 |
|
[root@centos]# chkconfig --list clamd <--- 入力 motion 0:off 1:off 2:on 3:on 4:on 5:on 6:off <--- 2・3・4・5 が on になっていればOK |
|
| ◆ | ウィルス定義ファイルの自動更新の確認 |
|
[root@centos]# vi /etc/cron.daily/freshclam <--- 入力 /usr/bin/freshclam --quiet <--- 記載がある事を確認 |
|
| 毎日自動的にウィルス 定義ファイルが更新される | |
| ◆ | ウィルススキャンの自動化 |
|
[root@centos]# vi /etc/cron.daily/clamscan <--- 入力 以下新規記述 #!/bin/bash PATH=/usr/bin:/bin # --- update --- <--- clam のアップデート yum --enablerepo=epel -y update clamd > /dev/null 2>&1 # --- fresh --- <--- ウィルス定義ファイルの更新 /usr/bin/freshclam > /dev/null 2>&1 # --- scan --- <--- ウィルススキャンの実行 CLAMSCANTMP=`mktemp` /usr/bin/clamscan --infected --remove --recursive / > $CLAMSCANTMP 2>&1 [ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \ # --- mail --- <--- ウィルススキャンの実行結果のメール送信 grep FOUND$ $CLAMSCANTMP | mail -s "Virus Found in `hostname`" root rm -f $CLAMSCANTMP |
|
| ※ウィルス 定義ファイルは /etc/cron.daily/freshclam で毎日自動更新されているが、必ずウィルス 定義ファイルの更新直後にウィルススキャンが実行されるとは限らないのでここでもウィルス定義ファイルが更新を行う | |
| 実行権限の付与 | |
|
[root@centos]# chmod 755 /etc/cron.daily/clamscan <--- 入力 |
|
| ◆ | SpamAssassinのインストール(スパムソフト) |
|
[root@centos]# yum -y install spamassassin <--- 入力 |
|
| ◆ | スパム定義ファイルの最新化 |
|
[root@centos]# sa-update <--- 入力 |
|
|
|
|
| ◆ | スパム定義ファイルの更新回数の設定 |
| デフォルトの状態では毎日4時10分に更新を実行するように設定されているが自由に変更できる | |
|
[root@centos]# vi /etc/cron.d/sa-update <--- 入力 10 4 * * * root /usr/share/spamassassin/sa-update.cron 2>&1 | tee -a /var/log/sa-update.log |
|
| ◆ | SpamAssassin の起動 |
|
[root@centos]# /etc/rc.d/init.d/spamassassin start <--- 入力 |
|
|
|
|
| SpamAssassin の自動起動設定 | |
|
[root@centos]# chkconfig spamassassin on <--- 入力 |
|
|
|
|
| 自動起動設定の確認 | |
|
[root@centos]# chkconfig --list spamassassin <--- 入力 spamassassin 0:off 1:off 2:on 3:on 4:on 5:on 6:off <--- 2・3・4・5 が on になっていればOK |
|
|
|
|
| ◆ | AMaViSd のインストール(SpamAssassin ・ Clam AntiVirus の連動ソフト) |
|
[root@centos]# yum -y install amavisd-new <--- 入力 |
|
|
|
|
| ◆ | AMaViSd の設定 |
|
[root@centos]# vi /usr/share/doc/amavisd-new-2.6.6/amavisd.conf <--- 入力 途中略 $max_servers = 2; # num of pre-forked children (2..15 is common), -m $daemon_user = 'amavis'; # (no default; customary: vscan or amavis), -u $daemon_group = 'amavis'; # (no default; customary: vscan or amavis), -g $mydomain = 'example.com'; # a convenient default for other settings ↓ $mydomain = '******.com'; <--- ドメイン名の指定 以下略 |
|
|
|
|
| ◆ | AMaViSd の起動 |
|
[root@centos]# /etc/rc.d/init.d/amavisd start <--- 入力 |
|
|
|
|
| 再起動に SpamAssassin を自動起動 | |
|
[root@centos]# chkconfig amavisd on <--- 入力 |
|
|
|
|
| 自動起動設定の確認 | |
|
[root@centos]# chkconfig --list amavisd <--- 入力 amavisd 0:off 1:off :on 3:on 4:on 5:on 6:off <--- 2・3・4・5 が on になっていればOK |
|
|
|
|
| ◆ | Postfix の設定 |
|
[root@centos]# vi /etc/postfix/main.cf <--- 入力 途中略 content_filter = smtp-amavis:[127.0.0.1]:10024 <--- 最終行に追記 |
|
|
|
|
| ◆ | master.cf の設定 |
|
[root@centos]# vi /etc/postfix/master.cf <--- 入力 途中略 smtp-amavis unix - - n - 2 smtp <--- 最終行に以下追記 -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes 127.0.0.1:10025 inet n - n - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_client_restrictions= -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o mynetworks=127.0.0.0/8 -o strict_rfc821_envelopes=yes -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 |
|
|
|
|
| ◆ | Postfix の再起動 |
|
[root@centos]# /etc/rc.d/init.d/postfix restart <--- 入力 |
|
|
|
|
| ◆ | サーバー受信時の駆除テスト |
|
下記の文字列をメールの本文に書いてメールを自分宛に送ってみる |
|
|
[root@centos]# vi /var/log/maillog <--- 入力 Jan 17 12:36:14 mail-server amavis[9101]: (09101-03) Blocked INFECTED (Eicar-Test-Signature), [202.238.83.191] [121.3.165.5] <abc@****.ne.jp> -> <xyz@****.com>, Message-ID: <BD653DFEFF9241DAA94148F3CB599923@ZIC2266SB>, mail_id: ZpcNA7ZcVB3s, Hits: -, size: 1768, 29103 ms ↑ ウィルスメールを受信 Jan 17 12:36:14 mail-server postfix/smtp[9206]: 071B92189F: to=<xyz@****.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=29, delays=0.09/0/0.03/29, dsn=2.7.0, status=sent (250 2.7.0 Ok, discarded, id=09101-03 - INFECTED: Eicar-Test-Signature)Jan 17 12:36:14 mail-server postfix/qmgr[9200]: 071B92189F: removed ↑ ウィルスメールを駆除 |
|
| ◆ |
スパムメールの振り分け受信(サーバー側) |
| 上記の設定ではサーバーにメールが届いた時点でウィルスメールとスパムメールを駆除する設定になっているが、ウィルスメールはこのままの設定で問題はないがスパムメールについてはスパムメールと判断されてしまった普通のメールがある可能性がある のでスパムメールと判断されたメールもとりあえず駆除しないでクライアントに送り、クライアント側で振り分ける設定を行う | |
|
[root@centos]# vi /etc/amavisd/amavisd.conf <--- 入力 途中略 $final_virus_destiny = D_DISCARD; $final_banned_destiny = D_BOUNCE; $final_spam_destiny = D_DISCARD; <--- 書き換え(スパムメールと判断したメールも駆除しない) ↓ $final_spam_destiny = D_PASS; $final_bad_header_destiny = D_BOUNCE; 以下略 |
|
| ◆ | AMaViSd の再起動 |
|
[root@centos]# /etc/rc.d/init.d/amavisd restart <--- 入力 |
|
| ◆ | スパムメールの振り分け受信(クライアント側) |
|
Windowsがクライアントとしての設定 Windows XP までは Outlook Express で Windows Vista 以降では Windowsメール になっていますが設定は同じ |
|
| Outlook Express 及び Windowsメール を起動 | |
| “ローカル フォルダ”にマウスを持って行き右クリックして“フォルダの作成”をクリックして開き“フォルダ名”に“スパムメール”と入力して「OK」 をクリック | |
|
|
|
| タスクバーの“ツール”⇒“メッセージルール”⇒“メール”をクリックし、『メッセージルール』のダイアログが開いたら“新規作成をクリック | |
|
|
|
| ”新規のメールルール”ダイアログが開くので“1.ルールの条件を選択してください(C)”の中にある“件名に指定した言葉が含まれる場合”と“2.ルールのアクションを選択してください(A)”の中にある“指定したフォルダーに移動する”にチャックを入れる | |
|
“3.ルールの説明(下線をクリックすると編集できます)(D)”の中にある“指定した言葉が含まれる”をクリック 『単語の入力』のダイアログが開 くので“単語または文字列を入力してから、「追加」をクリックしてください(T)”に“***SPAM***”を入力して“追加(A)”ボタンをクリックし“OK”ボタンをクリック |
|
|
|
|
|
”新規のメールルール”ダイアログに戻るので“3.ルールの説明(下線をクリックすると編集できます)(D)”の中にある“指定したフォルダ”をクリック 『移動』のダイアログが開くので先ほど作った“スパムメール”をクリックして再度“OK”ボタンをクリック |
|
|
|
|
| 後は“OK”ボタンを押し続けて終了 | |
| これでスパムメールと判断されたメールは『スパムメール』フォルダーに保存されることになる | |
| ◆ | スパムメールの振り分け受信(クライアント側)確認 |
|
下記のスパムサンプルを本文に書き自分宛にメールを送ってみる XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X その後、メールを受信して件名に『***SPAM***』が追加されスパムメールフォルダーに保存されていればOK |
|