UnixServerAdmin

Server Administration & Management

clamav_scan.sh

###########################################################
## clamav_scan.sh ##
###########################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Following in msg.txt file ##
###########################################################
## Hi, ##
## The ClamAV Scan process of “/home” partition of the server has been completed. ##
## For ClamAV Scan Report, please check the attached clamav Report. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
###########################################################
#! /bin/bash

/bin/echo “==========================================================” > /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “THE ClamAV Scan is started at $(date)” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “==========================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)

/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “ClamAV Update Logs:”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/usr/bin/freshclam >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/clamav.log_$(date +%d%m%y)

/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “ClamAV Logs are as follows:”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/usr/bin/clamdscan –remove /home/ >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/clamav.log_$(date +%d%m%y)

/bin/echo “==================================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “THE ClamAV Scan has been completed at $(date)” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “==================================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)

mutt -s “ClamAV Scan REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/clamav.log_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “ClamAV Scan REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/clamav.log_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

Advertisements

May 6, 2011 Posted by | Security, Shell Script | , , | 2 Comments

How to Install ClamAV in cPanel

ClamAV is an popular open source anti-virus toolkit for *nix, and while many people don’t find much value in using antivirus software on Unix, it is very useful for email scanning.  cPanel’s implementation allows end users to run scans on their home folders, public FTP folders, mail, and public_html.

It’s really hard to install ClamAV on cPanel – if you’re too lazy to click a couple buttons.  Simply go to WHM –> Manage Plugins and enable the ClamAV Connector, and you’re good to go.

After this is done, you can go to WHM –> Configure ClamAV Scanner and set scanning options for the entire server or specific users:

You should now see a Virus Scanner option in cPanel. If you don’t, you may need to enable it in Feature Manager.

From here, cPanel users can run scans on any permitted items.

For administrators, here are a few quick commands that may be useful:

Update antivirus database:

#freshclam

Scan a directory and print out infected files:

#clamav -ri /home

Scan a directly and remove infected files and emails:

#clamav -ri –remove /home

January 7, 2011 Posted by | cPanel, Unix/Linux | , , , | Leave a comment