Sunday, January 7, 2018

how to install ClamAV antivirus in linux

  • yum install -y epel-release
  • yum install -y clamav clamd
  • /etc/init.d/clamd start
  • chkconfig clamd on
  • chkconfig --list | grep clam
  • /usr/bin/freshclam
  • vim /etc/cron.daily/manual_clamscan
#!/bin/bash  
SCAN_DIR="/"
DATE=`date +%Y-%m-%d`
LOG_FILE="/var/log/clamav/manual_clamscan$DATE.log"
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE
  • chmod +x /etc/cron.daily/manual_clamscan
  • sh /etc/cron.daily/manual_clamscan
  • less /var/log/clamav/manual_clamscan (Current date).log (For Testing Purpose, May ignore)
  • vim /etc/freshclam.conf
line 118 - Checks 4 (Sometimes line no may vary)
  • /etc/init.d/clamd restart
  • rpm -qa |grep mail
  • yum install mail
  • less /var/log/maillog (For Testing Purpose, May ignore)
  • /etc/init.d/postfix status
  • yum install postfix (Skip if already installed)
  • /etc/init.d/postfix start
  • chkconfig postfix on
  • vim /etc/postfix/main.cf
line 119 - inet_protocols = ipv4 (Sometimes line no may vary)
  • /etc/init.d/postfix restart
  • vim clam_scan_result_notify.sh
#!/bin/bash  
DATE=`date +%Y-%m-%d`
LOGFILE=/var/log/clamav/manual_clamscan$DATE.log
if [ ! -f "$LOGFILE" ]
then
echo "No logfile exists"
exit 3
else
#ERRORS=$( grep -c "Infected files" /var/log/clamav/manual_clamscan$DATE.log )
ERRORS=$( tail "$LOGFILE"|grep Infected|cut -d" " -f3 )
if [ $ERRORS -eq 0 ]
then
#echo "OK: $ERRORS Infected files found"
exit 0
elif [ $ERRORS -gt 0 ]
then
#echo "WARNING: $ERRORS Infected files found"
echo "WARNING: $ERRORS Infected files $(hostname) @ $(date)" | mail -s 'ClamScan Infected Files Found!!!' alerts@e2enetworks,client email id
exit 1
fi
fi
  • chmod +x clam_scan_result_notify.sh
  • crontab -e
0 3 * * * sudo sh /root/clam_scan_result_notify.sh

No comments:

Post a Comment

Installation FreeRADIUS and Daloradius on CentOS 7 and RHEL 7

SELINUX Setting:- Before installations, I recommend turning off SELinux or setting it in permissive mode:- [root@radius ~]# setenforce ...

Popular Posts