#! /bin/bash # # check_virus_in_web_contents # # Version: 1.00 # # Check virus in web content files on your webserver local. # Copyright(C) 2010 HOLLY&Co.,Ltd. # # This program is free software; you can redistribute # it and/or modify it under the terms of # the GNU General Public License as published # by the Free Software Foundation; either version 3 of the License, # or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # See the GNU General Public License for more details. # # You should have received a copy of # the GNU General Public License along with this program. # If not, see . # To address alert mail MT="horimoto@holly-linux.com" # From address alert mail MF="virus-alert@www.hinase.ne.jp" # Reply-to address alert mail MR="horimoto@holly-linux.com" # Temp. files LGF=/tmp/check_virus_log.txt MLF=/tmp/check_virus_mail.txt # Scan target Directories for A in /var/www/html a; do if [ $A != /var/www/html ]; then A=/home/$A fi clamscan --quiet -r $A -i --log $LGF RC=$? if [ $RC -ne 0 ]; then echo "To: "$MT > $MLF echo "From: "$MF >> $MLF echo "Reply-To: "$MR >> $MLF case $RC in 1) echo "Subject: (1)ALERT VIRUS FOUNDED." >> $MLF echo "" >> $MLF cat $LGF >> $MLF sendmail $MT < $MLF ;; 40) echo "Subject: (40)Unknown option passed." >> $MLF sendmail $MT < $MLF ;; 50) echo "Subject: (50)DATABASE initialization error." >> $MLF sendmail $MT < $MLF ;; 52) echo "Subject: (52)Not supported file type." >> $MLF sendmail $MT < $MLF ;; 53) echo "Subject: (53)Can’t open directory." >> $MLF sendmail $MT < $MLF ;; 54) echo "Subject: (54)Can’t open file. (ofm)" >> $MLF sendmail $MT < $MLF ;; 55) echo "Subject: (55)Error reading file. (ofm)" >> $MLF sendmail $MT < $MLF ;; 56) echo "Subject: (56)Can’t stat input file / directory." >> $MLF sendmail $MT < $MLF ;; 57) echo "Subject: (57)Can’t get absolute path name of current working directory." >> $MLF sendmail $MT < $MLF ;; 58) echo "Subject: (58)I/O error, please check your file system." >> $MLF sendmail $MT < $MLF ;; 62) echo "Subject: (62)Can’t initialize logger." >> $MLF sendmail $MT < $MLF ;; 63) echo "Subject: (63)Can’t create temporary files/directories (check permissions)." >> $MLF sendmail $MT < $MLF ;; 64) echo "Subject: (64)Can’t write to temporary directory (please specify another one)." >> $MLF sendmail $MT < $MLF ;; 70) echo "Subject: (70)an’t allocate memory (calloc)." >> $MLF sendmail $MT < $MLF ;; 71) echo "Subject: (71)an’t allocate memory (malloc)." >> $MLF sendmail $MT < $MLF ;; esac fi /bin/rm $MLF /bin/rm $LGF done