About

pyClamAV is a python binding to libclamav written in C. By using pyClamAV, you can add virus detection capabilities to your python software in an efficient and easy way.

Warning you must upgrade to libclamav version 0.90 (at least).
Due to removal of cl_scanbuff in libclamav, pyclamav.scanthis() has to be removed. You are now strongly encouraged to use pyClamd !
pyclamav-0.4.1.tar.gz - 2008-04-16
  • pyclamav-0.4.1/CHANGELOG
  • pyclamav-0.4.1/README.txt
  • pyclamav-0.4.1/Makefile
  • pyclamav-0.4.1/setup.py
  • pyclamav-0.4.1/pyclamav.c
  • pyclamav-0.4.1/example.py
  • pyclamav-0.4.1/gpl.txt
md5sum is 9e1f29ea118bac87223ff4df3c077556

Has been tested to works with libclamav up to version 0.93.0 (and may be later versions)

CHANGELOG.

Older releases

Work with libclamav version up to 0.92
Work with libclamav version up to 0.88.7
Work only with libclamav version 0.80
Work with libclamav version 0.71-0.80
top

Installation

These are generic installation instructions.

You need to have clamav and libclamav installed with clamav.h header file. You also need to have python installed.

The simplest way to compile this package is:

  1. Run 'python setup.py build'
  2. As root run 'python setup.py install'
  3. It should be done.
top

Install on Debian

On debian stable (Woody)
No official package yet. You have to install it manually.
On debian testing/unstable (Etch / Sid)
Thanks to Cédric Delfosse (Debian maintainer), you just have to issue :
apt-get install python-clamav

Debian Package maintained by Cédric Delfosse

top

Install on *BSD

FAQ
to be written
top

Usage

From python :
Python 2.3.3 (#1, Mar 21 2004, 00:29:15) 
[GCC 2.95.4 20011002 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyclamav
>>> ret=pyclamav.scanfile('/tmp/virus')
>>> print ret
(1, 'Worm.Sober.G')
>>> ret=pyclamav.scanthis("Buffer to test blalblabla...")
>>> print ret
(0, '')
>>> print pyclamav.get_numsig()
34861
>>> print pyclamav.get_version()
('0.86.1', 898, 1117257063)
>>> print pyclamav.version()
0.3.0
>>> print pyclamav.scanfile('/tmp')   # /tmp is a directory
Traceback (most recent call last):
  File "", line 1, in ?
ValueError: Argument is not a filename
More usage example :
example.py
top

Functions

pyclamav.scanfile(filename)
Return value is a tupple (integer, string) where integer
  • = 1 : if a virus was found, string then contains the name of the virus
  • = 0 : no virus found, string is empty
May raise :
  • a ValueError exception if an error occurs
  • a TypeError exception if wrong arguments are passed
  • an exception "pyclamav.error" if an error occurs in libclamav
>>> pyclamav.scanfile('/tmp/virus.txt')
(1, 'Eicar-Test-Signature')
>>> pyclamav.scanfile('/tmp/novirus.txt')
(0, '')
pyclamav.scanthis(buffer)
Return value is a tupple (integer, string) where integer
  • = 1 : if a virus was found, string then contains the name of the virus
  • = 0 : no virus found, string is empty
May raise :
  • a ValueError exception if an error occurs
  • a TypeError exception if wrong arguments are passed
  • an exception "pyclamav.error" if an error occurs in libclamav
>>> pyclamav.scanthis(virus_string)
(1, 'Eicar-Test-Signature')
>>> pyclamav.scanthis(no_virus_string)
(0, '')

Beware using scanthis for scanning a buffer is less secure than scanning a file. For example, Trojan.SubSeven.20 is not detected using buffer scanning. This is due to a bug/functionnality no yet implemented in libclamav 0.86 and earlier. - Thanks to Michael Lang for pointing this out.

pyclamav.version()
Return clamav version number
>>> pyclamav.version()
'0.3.1'
pyclamav.get_version()
Return a tupple indicating libclamav version number
>>> pyclamav.get_version()
('0.84', 1304, 1140954448)
pyclamav.get_numsig()
Return libclamav signature version
>>> pyclamav.get_numsig()
45686
top

FAQ

top

Contributors

top

License

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.