WebHostGear.com - the hosting resource for professionalshosting tutorials 
hosting howto webhost guide server managementJuly 25, 2008
server management, apache tutorials, hosting tutorials, cpanel, server security
Home / Hosting Tutorials / cPanel Tutorials / Use Exiscan to Scan For Viruses

Use Exiscan to Scan For Viruses



Printer Friendly Printer Friendly Send to a friend Send to a friend
By : Rack911 Rating : Average Rating : 6.55 From 11 Voter(s)

Most responsible system administrators have implemented some form of virus scanning of incoming email to protect their users from getting viruses and to help stem the flow of these resource stealing entities. If you are a cPanel administrator, then about your only option has been Mailscanner. There are a number of HOWTOs out there that have shown people how to install Mailscanner, but just recently we've been given a much more integrated and less resource intensive solution.

Enter Exiscan.

Exiscan is a patch against exim version 4, providing support for content scanning in email messages received by exim. It works after the sending client has completed the SMTP data phase and waits for an answer from the server. Messages containing unwanted content can be rejected at that stage, so the job of generating a bounce message is the job of the sending host. Four different scanning facilities are supported: antivirus, antispam, regular expressions, and file extensions.

The beauty of this is that, as noted above, the email is rejected during the receiving process, so the unwanted message never actually enters your server, and notifies the sending server that this message is not being accepted.  This takes much of the burden of processing off your server and puts it back on the server that is trying to send this to you.


Article provided by WebHostGear.com
This system even allows for filetype rejection!  .exe, .scr, .pif, whatever you want to exclude and be excluded.



Article provided by WebHostGear.com

cPanel included this patch in a recent update for Exim, and you probably already have it installed, but it has not been 'plugged in' to your server.

The exiscan-acl patch adds content scanning to the exim4 ACL
system. It supports the following scanning features:


These features are hooked into exim by extending exim's ACL
system. The patch adds expansion variables and ACL conditions.
These conditions are designed to be used in the acl_smtp_data
ACL. It is run when the sending host has completed the DATA
phase and is waiting for our final response to his end-of-data
marker. This allows us to reject messages containing
unwanted content at that stage.

 

Configuring ClamAV for Exim / Exiscan:

cd /usr/src
wget -c http://www.rack911.com/files/clamav-0.72-1.i386.rpm
rpm -Uvh clamav-0.72-1.i386.rpm
/usr/bin/freshclam
ln -s /usr/bin/freshclam /etc/cron.daily/updateclamav
perl -pi -e "s/^Example/#Example/g" /etc/clamav.conf
perl -pi -e "s/^#MaxThreads 10/MaxThreads 5/g" /etc/clamav.conf
perl -pi -e "s/^#ScanMail/ScanMail/g" /etc/clamav.conf
perl -pi -e "s/^LocalSocket /tmp/clamd/LocalSocket /var/run/clamav/clamd/g" /etc/clamav.conf

Configuring Exim for use with exiscan:

( you should always backup your configuration file before any changes)

find the lines:

######################################################################
# MAIN CONFIGURATION SETTINGS #
######################################################################

Add the following under it:

av_scanner = clamd:/var/run/clamav/clamd

it should now look like

######################################################################
# MAIN CONFIGURATION SETTINGS #
######################################################################
av_scanner = clamd:/var/run/clamav/clamd

next find the following

check_message:
require verify = header_sender
accept

modify it so it looks like the following (notice the bold part):

check_message:
require verify = header_sender
######## EXISCAN ACL #########
deny message = This message contains malformed MIME ($demime_reason)
demime = *
condition = ${if >{$demime_errorlevel}{2}{1}{0}}
deny message = This message contains a virus or other harmful content ($malware_name)
demime = *
malware = *
deny message = This message contains an attachment of a type which we
do not accept (.$found_extension)
demime = bat:com:pif:prf:scr:vbs
warn message = X-Antivirus-Scanner: Clean mail though you should still use an Antivirus
######## EXISCAN ACL #########

accept

Save the file.

Restart exim

/sbin/service exim restart

It should result with the following:

root@w00t [~]# /sbin/service exim restart
Shutting down clamd: [FAILED]
Shutting down exim: [ OK ]
Shutting down antirelayd: [ OK ]
Shutting down spamd: [ OK ]
Starting clamd: [ OK ]
Starting exim: [ OK ]
Starting exim-smtps: [ OK ]
Starting antirelayd: [ OK ]
Starting spamd: [ OK ]
root@w00t [~]#

 

If something dont work correctly, restore from your backup exim.conf or run /scripts/exim4 and try agian. If you still cannot get it to work contact steve @ rack911

Thanks to: Jon of Got-Management.com and to Steve of Rack911.com

New! - Need server help? Hire an Expert

Get professional help with your configuration, script installation or server issue.
Learn how we can help you with any server problem and make your server run like new. Professional staff will contact you, after submitting a quote request, by phone or email.

Rate this Article :

1

2

3

4

5

6

7

8

9

10
Poor Excellent
Sources
http://duncanthrax.net/exiscan-acl

Related Articles


» Official Cpanel Newbie Guide
» Setting up Private Nameservers in Cpanel
» Guide to Chkrootkit - checking for intruders
» Common SSH Commands - Linux Shell Commands
» How to install APF (Advanced Policy Firewall)
» Installing DrWEB server antivirus for Linux CPanel
» Exim Extended Logging


Discuss this article with others in our new hosting forums

Comments / Feedback

Chris
Got a bit messy for me around the last perl -pi line, has anyone else managed to get this working?
[/usr/src]# perl -pi -e "s/^LocalSocket /tmp/clamd/LocalSocket /var/run/clamav/clamd/g" /etc/clamav.conf
Bareword found where operator expected at -e line 1, near "s/^LocalSocket /tmp/clamd"
syntax error at -e line 1, near "s/^LocalSocket /tmp/clamd"
Execution of -e aborted due to compilation errors.
jane doe
this tutorial isn't accurate enough for new admin,
where's the path of exim conf?
how to uninstalled the mailscanner first?
steve
same problem for me, rack911 please help
John Doe
locate exim.conf
pixel
wow, this is like trying to explain war and peace in four words or less. There is SO much more to this method! Especially if your host has played with the ACLs at all.
Aditya
@ Chris:

perl -pi -e "s/^LocalSocket /tmp/clamd/LocalSocket //var/run/clamav/clamd/g" /etc/clamav.conf

HTH
makan
01-01-2006
for ClamAV 0.87.1
you just need to perform these steps:
1. rpm -Uvh clam*
2. /usr/bin/freshclam
3. ln -s /usr/bin/freshclam /etc/cron.daily/updateclamav
4. perl -pi -e "s/^#MaxThreads 20/MaxThreads 5/g" /etc/clamd.conf
5. Add the following under "MAIN CONFIGURATION SETTINGS" of your exim.conf:
av_scanner = clamd:127.0.0.1 3310
6. add "EXISCAN ACL" as mention on this article
7. save exim.conf
8. restart exim

it works for me

 Add Comment
Name
Email
Image Code
Refresh Image

Comments / Feedback



Web Hosting News RSS ?


WebHostGear Hire an Expert - NEW!
Let us improve your servers performance, find that spammer and take care of that kernel upgrade. Hire us to help with any tutorials listed on the site or any other services needed. Get your free, NO obligation quote now

Our site offers free hosting tutorials, cpanel tutorial, web hosting news, shell commands, running a web hosting business, dedicated guides, linux tutorial, apache install, home web server, web server guide, ssh commands, dedicated servers, DNS nameservers, chkrootkit, apf firewall, exim configuration, server compromised, cron backup solution, ftp backup script

Server Tutorials


WebHostGear Reviewed by Ping Zine - Click here

Special Offer:


Links:
cPanel server administration

MidPhase Coupons

Reseller Hosting

Reseller Hosting FAQ

Icon

Web Hosting

Datacenter Discussion Forum

Lunarpages Coupon

Hosting Coupon



WebhostGear Sponsors
Going Up Advertise Hosting Free Uptime Check Web Hosting Chat Icons Banners Mall