/dev/null | cut -f1); cpuuse=$(top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}') if [ "$cpuuse" > 0.8 ];then echo "CPU FREE < 40% " echo "Starting a daily scan of "$S" directory. echo " Scan Started " Amount of data to be scanned is "$DIRSIZE"."; clamscan -r /home/ "$LOGFILE" "$S" > "/home/ec2-user/error.log"; MALWARE=$(tail "$LOGFILE"|grep Infected|cut -d" " -f3); if [ "$MALWARE" -ne "0" ];then echo "VIRUS-INFECTED EMAIL-SEND TO [email protected] $MALWARE" echo "Test Email" | mail -a "$LOGFILE" -v -s "Send an email via mailx" [email protected]; else echo "no found virus-infected files - Email is not triggering" fi else echo "CPU USAGE > 40% command failed" fi done"> /dev/null | cut -f1); cpuuse=$(top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}') if [ "$cpuuse" > 0.8 ];then echo "CPU FREE < 40% " echo "Starting a daily scan of "$S" directory. echo " Scan Started " Amount of data to be scanned is "$DIRSIZE"."; clamscan -r /home/ "$LOGFILE" "$S" > "/home/ec2-user/error.log"; MALWARE=$(tail "$LOGFILE"|grep Infected|cut -d" " -f3); if [ "$MALWARE" -ne "0" ];then echo "VIRUS-INFECTED EMAIL-SEND TO [email protected] $MALWARE" echo "Test Email" | mail -a "$LOGFILE" -v -s "Send an email via mailx" [email protected]; else echo "no found virus-infected files - Email is not triggering" fi else echo "CPU USAGE > 40% command failed" fi done"> /dev/null | cut -f1); cpuuse=$(top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}') if [ "$cpuuse" > 0.8 ];then echo "CPU FREE < 40% " echo "Starting a daily scan of "$S" directory. echo " Scan Started " Amount of data to be scanned is "$DIRSIZE"."; clamscan -r /home/ "$LOGFILE" "$S" > "/home/ec2-user/error.log"; MALWARE=$(tail "$LOGFILE"|grep Infected|cut -d" " -f3); if [ "$MALWARE" -ne "0" ];then echo "VIRUS-INFECTED EMAIL-SEND TO [email protected] $MALWARE" echo "Test Email" | mail -a "$LOGFILE" -v -s "Send an email via mailx" [email protected]; else echo "no found virus-infected files - Email is not triggering" fi else echo "CPU USAGE > 40% command failed" fi done">
#!/bin/sh
#This file is used to scan any directory that it is called from and report any infected files if any.
# it will trigger a mail if any infected files are found
LOGFILE="/home/ec2-user/error.log";
for S in ${LOGFILE}; do
DIRSIZE=$(du -sh "$S" 2>/dev/null | cut -f1);
cpuuse=$(top -b -n1 | grep "Cpu(s)" | awk '{print $2 + $4}')
if [ "$cpuuse" > 0.8 ];then
echo "CPU FREE < 40% "
echo "Starting a daily scan of "$S" directory.
echo " Scan Started "
Amount of data to be scanned is "$DIRSIZE".";
clamscan -r /home/ "$LOGFILE" "$S" > "/home/ec2-user/error.log";
MALWARE=$(tail "$LOGFILE"|grep Infected|cut -d" " -f3);
if [ "$MALWARE" -ne "0" ];then
echo "VIRUS-INFECTED EMAIL-SEND TO [email protected] $MALWARE"
echo "Test Email" | mail -a "$LOGFILE" -v -s "Send an email via mailx" [email protected];
else
echo "no found virus-infected files - Email is not triggering"
fi
else
echo "CPU USAGE > 40% command failed"
fi
done
echo "set smtp=smtps://smtp.gmail.com:465" >> mail.rc
echo "set smtp-auth=login" >> mail.rc
echo "set [email protected]" >> mail.rc
echo "set smtp-auth-password=somepassword" >> mail.rc
echo "set ssl-verify=ignore" >> mail.rc
echo "set nss-config-dir=/etc/pki/nssdb/" >> mail.rc