Scripts antivirus

root@shop:~# cat scan_update 
#! /bin/bash
date=`date +"%Y_%m_%d"`
DIR=/root/log/$date
mailbox=dmurrdj@gmail.com
num=0

if [ -d /root/log ]; then
        echo "Directory log existing"
else
        mkdir  -p -m 777 /root/log
fi
# Создание папки для логов
	mkdir -p -m 777 $DIR
# Обновление rkhunter
	rkhunter --update | tee $DIR/rkhunter_update.log
# Сканирование rkhunter мини 
	rkhunter -c --sk --rwo --summary | tee $DIR/rkhunter_scan_mini.log
# Сканирование rkhunter полное
	rkhunter -c --sk --summary | tee $DIR/rkhunter_scan_max.log
# Сканирование chrootkit
	chkrootkit | tee $DIR/chrootkit_scan.log
# Включение обновление clamav
	/etc/init.d/clamav-freshclam start | tee $DIR/clamav_update.log
# Обновление баз clamav
	freshclam | tee $DIR/clamav_update.log
# Выключение обновление clamav
	/etc/init.d/clamav-freshclam stop | tee $DIR/clamav_update.log
# Сканирование БЕЗ УДАЛЕНИЯ ФАЙЛОВ
	clamscan -ri --scan-html --scan-elf --scan-pdf --scan-archive --bytecode / | tee $DIR/clamav_scan_wo_del.log
# Включение avg
	/etc/init.d/avgd start | tee $DIR/avg_update.log
# Обновление avg
	avgupdate | tee $DIR/avg_update.log
# Сканирование avg
	avgscan --arc --pup2 --coo --media --ignerrors --report $DIR/avg_scan_wo_del.log  /
# Выключение avg
	/etc/init.d/avgd stop | tee $DIR/avg_update.log

ip_addr=$(ip -4 addr show | tail -n1 | tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 3 | cut -d '/' -f 1)  
touch $DIR/summary.txt
chmod 777 $DIR/summary.txt
echo $ip_addr >> $DIR/summary.txt
echo $(hostname) >> $DIR/summary.txt
echo "==============================================================================" >> $DIR/summary.txt
echo "Summary scan" >> $DIR/summary.txt
echo "Scan rkhunter" >> $DIR/summary.txt
tail -n15 $DIR/rkhunter_scan_mini.log | tee $DIR/summary.txt
rootkit_num=$(cat $DIR/rkhunter_scan_mini.log | grep "Possible rootkits:" | tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 4)
	if [ $rootkit_num -ne 0 ]; then
	num=$(($num + 1))
	fi
echo "==============================================================================" >> $DIR/summary.txt
# Summary scan Clamav
echo "Scan clamav" >> $DIR/summary.txt
cat $DIR/clamav_scan_wo_del.log >> $DIR/summary.txt
clamav_num=$(cat $DIR/clamav_scan_wo_del.log | grep "Infected files" | tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 3)
	if [ $clamav_num -ne 0 ]; then
        num=$(($num + 2))
        fi
echo "==============================================================================" >> $DIR/summary.txt
# Summary scan AVG
echo "Scan AVG" >> $DIR/summary.txt
cat $DIR/avg_scan_wo_del.log >> $DIR/summary.txt
avg_num=$(cat $DIR/avg_scan_wo_del.log | grep "Infections found" |  tr '\t' ' ' | tr -s ' ' | cut -d ' ' -f 4 | cut -d "(" -f 1)
        if [ $avg_num -ne 0 ]; then
        num=$(($num + 4))
        fi
echo "==============================================================================" >> $DIR/summary.txt

last -a >> $DIR/summary.txt

# Send Email
#num=$(($rootkit_num + $clamav_num + $avg_num))
case $num in
        "0" )
                cat $DIR/summary.txt | mail -s "NORMAL - $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
        "1" )
                cat $DIR/summary.txt | mail -s "WARNING - RKHUNTER $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
        "2" )
                cat $DIR/summary.txt | mail -s "WARNING - CLAMAV $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
        "3" )
                cat $DIR/summary.txt | mail -s "WARNING - RKHUNTER & CLAMAV $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
        "4" )
                cat $DIR/summary.txt | mail -s "WARNING - AVG $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
        "5" )
                cat $DIR/summary.txt | mail -s "WARNING - RKHUNTER & AVG $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
        "6" )
                cat $DIR/summary.txt | mail -s "WARNING - CLAMAV & AVG $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
        "7" )
                cat $DIR/summary.txt | mail -s "WARNING - RKHUNTER & CLAMAV & AVG $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
	* )
                cat $DIR/summary.txt | mail -s "WARNING - Anknown summary works  $ip_addr $(hostname) - Scan Antivir $ Rootkit" $mailbox
        ;;
esac

# Create log archive
tar cjvf $DIR.tar.bz2 $DIR
rm -r $DIR
Облицовочная плитка . Особенности гипсовой плитки
  1. Пока комментариев нет.

  1. Пока что обратных ссылок нет.