How To Integrate ClamAV (Through mod_clamav) Into ProFTPd For Virus Scanning On Ubuntu 10.04
How To Integrate ClamAV (Through mod_clamav) Into ProFTPd For Virus Scanning On Ubuntu 10.04Version 1.0 This tutorial explains how you can integrate ClamAV into ProFTPd for virus scanning on an Ubuntu 10.04 system. This is achieved through mod_clamav. In the end, whenever a file gets uploaded through ProFTPd, ClamAV will check the file and delete it if it is malware. I do not issue any guarantee that this will work for you!
1 Preliminary NoteYou should have a working ProFTPd setup on your Ubuntu 10.04 server. Because we will run all the steps from this tutorial with root privileges, we can either prepend all commands in this tutorial with the string sudo, or we become root right now by typing sudo su
2 Installing ClamAVClamAV can be installed as follows: aptitude install clamav clamav-daemon libclamav-dev Now we must reconfigure ClamAV so that Clamd uses TCP connections instead of a local Unix socket. It is highly recommended that Unix socket connections are avoided when using the Chroot feature of ProFTPd (DefaultRoot ~). The reason is that if mod_clamav needs to connect to Clamd, the Unix socket is not available in the chroot environment. Run dpkg-reconfigure clamav-base ... and answer these questions as follows (accept the default values for all other questions): Socket type: <-- TCP Then restart Clamd and freshclam: /etc/init.d/clamav-daemon restart Now run netstat -tap | grep clamd ... and you should see that Clamd is listening on localhost through TCP: root@server1:~# netstat -tap | grep clamd
3 Rebuilding ProFTPdUnfortunately mod_clamav isn't part of ProFTPd by default, and there's no Ubuntu package for mod_clamav, so we have to rebuild ProFTPd with mod_clamav. I will use the Ubuntu source package of ProFTPd and build new ProFTPd .deb packages with mod_clamav support. First we install all packages that are needed to rebuild ProFTPd: aptitude build-dep proftpd-dfsg We also need the following packages: aptitude install libpam-dev dpkg-dev libmysqlclient-dev debhelper libpq-dev libldap2-dev libwrap0-dev libcap2-dev autotools-dev libncurses5-dev dpatch libacl1-dev libattr1-dev unixodbc-dev libsqlite3-dev Now we download the ProFTPd source package to /usr/src: cd /usr/src Next we download mod_clamav to /usr/src and unpack it: wget --no-check-certificate https://secure.thrallingpenguin.com/redmine/attachments/download/1/mod_clamav-0.11rc.tar.gz Then we copy the mod_clamav-0.11rc/mod_clamav.* files to the proftpd-dfsg-1.3.2c/contrib directory... cp mod_clamav-0.11rc/mod_clamav.* proftpd-dfsg-1.3.2c/contrib ... and patch the ProFTPd sources: cd proftpd-dfsg-1.3.2c Next we must edit debian/rules: vi debian/rules Search the CONF_ARGS section and add --with-modules=mod_clamav to it:
Now we can rebuild ProFTPd: dpkg-buildpackage Now we go one directory up, that's where the new .deb packages have been created: cd .. The command ls -l shows you the available packages: root@server1:/usr/src# ls -l We can install the new ProFTPd .deb packages as follows: dpkg -i proftpd*.deb
4 Configuring ProFTPdNow we must configure ProFTPd to use mod_clamav whenever a file is uploaded. Open /etc/proftpd/proftpd.conf... vi /etc/proftpd/proftpd.conf ... and add the stanza <IfModule mod_clamav.c> somewhere, e.g. below the <IfModule mod_ctrls_admin.c> section:
Restart ProFTPd: /etc/init.d/proftpd restart Now check if mod_clamav is loaded by running: proftpd -vv mod_clamav should be listed in the output: root@server1:~# proftpd -vv That's it! Now whenever someone tries to upload malware to your server through ProFTPd, the "bad" file(s) will be deleted. You can test that by downloading the Eicar test virus from http://www.eicar.org/anti_virus_test_file.htm; try to upload it to your ProFTPd server, and if all goes well, it should be deleted:
5 Links
|





Recent comments
23 hours 53 min ago
1 day 4 hours ago
1 day 9 hours ago
1 day 11 hours ago
2 days 1 hour ago
2 days 1 hour ago
2 days 6 hours ago
2 days 13 hours ago
2 days 13 hours ago
2 days 15 hours ago