centos:clamav_centos_host

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen Revision Vorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
centos:clamav_centos_host [11.06.2012 10:07. ] – [erster Programmstart] djangocentos:clamav_centos_host [22.07.2019 14:48. ] (aktuell) – [Links] django
Zeile 1: Zeile 1:
 +====== ClamAV unter CentOS 5 bzw. Centos 6 ======
 +{{:centos:clamav.png?100 |ClamAV Logo}}ClamAV((Clam AntiVirus)) ist ein unter der GNU GPL((GNU General Public License)) stehender Virenscanner. [[http://www.clamav.net|ClamAV]] beinhaltet eine Bibliothek, zur Einbindung in eigene Programme und Abläufe, dem ClamAV-Daemon und sowie eine Kommandozeilenapplikation.
 +
 +Hauptsächlich wird **//ClamAV//** im Zusammenhang mit [[centos:mailserver:start|Postfix]] und [[centos:mailserver:grundinstallation_von_amavis|AMaViS]] genutzt - nachfolgend zeigt die Installation auf einen LINUX-Desktop - so könnte man dann erhaltene Dateien von einem Fremdsystem auf unerwünschte //"Mitbringsel"// (Schadcode) hin überprüfen. Die installation von ClamAV im Mailserverumfeld ist [[centos:mailserver:installation_von_clamav|hier]] beschrieben.
 +===== Installation =====
 +Als erstes installieren wir uns die benötigten Server-Komponenten via **YUM**. Da die benötigten Pakete aus dem rpmforge-Repository kommen, wird die korrekte Einbindung dieses 3rd-party Repositories vorausgesetzt. Wie das geht, steht [[http://dokuwiki.nausch.org/doku.php/centos:rpmforge_einbinden|hier]].
 +   # yum install clamd clamav clamav-db clamtk -y
 +Was uns die einzelnen Pakete mitliefern, offentbart uns jeweils ein **rpm -iql**.
 +==== Paket clamd====
 +<code># rpm -iql clamd
 +Name        : clamd                        Relocations: (not relocatable)
 +Version     : 0.99.1                            Vendor: Dag Apt Repository, http://dag.wieers.com/apt/
 +...
 +
 +...
 +Size        : 514863                           License: GPL
 +Signature   : DSA/SHA1, Mo 04 Mai 2009 22:13:20 CEST, Key ID a20e52146b8d79e6
 +Packager    : Dag Wieers <dag@wieers.com>
 +URL         : http://www.clamav.net/
 +Summary     : The Clam AntiVirus Daemon
 +Description :
 +The Clam AntiVirus Daemon
 +/etc/clamd.conf
 +/etc/logrotate.d/clamav
 +/etc/rc.d/init.d/clamd
 +/usr/bin/clamconf
 +/usr/bin/clamdscan
 +/usr/bin/clamdtop
 +/usr/sbin/clamd
 +/usr/share/doc/clamd-0.95.1
 +/usr/share/doc/clamd-0.95.1/clamd.conf
 +/usr/share/doc/clamd-0.95.1/clamdwatch
 +/usr/share/doc/clamd-0.95.1/clamdwatch/clamdwatch.tar.gz
 +/usr/share/man/man1/clamconf.1.gz
 +/usr/share/man/man1/clamdscan.1.gz
 +/usr/share/man/man1/clamdtop.1.gz
 +/usr/share/man/man5/clamd.conf.5.gz
 +/usr/share/man/man8/clamd.8.gz
 +/var/clamav
 +/var/log/clamav
 +/var/log/clamav/clamd.log
 +/var/run/clamav
 +</code>
 +==== Paket clamav-db====
 +<code># rpm -iql clamav-db
 +Name        : clamav-db                    Relocations: (not relocatable)
 +Version     : 0.99.1                            Vendor: Dag Apt Repository, http://dag.wieers.com/apt/
 +...
 +
 +...
 +Size        : 21126396                         License: GPL
 +Signature   : DSA/SHA1, Mo 04 Mai 2009 22:13:19 CEST, Key ID a20e52146b8d79e6
 +Packager    : Dag Wieers <dag@wieers.com>
 +URL         : http://www.clamav.net/
 +Summary     : Virus database for clamav
 +Description :
 +The actual virus database for clamav
 +/etc/cron.daily/freshclam
 +/etc/logrotate.d/freshclam
 +/var/clamav
 +/var/clamav/daily.cvd
 +/var/clamav/main.cvd
 +/var/log/clamav
 +/var/log/clamav/freshclam.log</code>
 +==== Paket clamav====
 +<code># rpm -iql clamav
 +Name        : clamav                       Relocations: (not relocatable)
 +Version     : 0.99.1                            Vendor: Dag Apt Repository, http://dag.wieers.com/apt/
 +...
 +
 +...
 +Size        : 5077647                          License: GPL
 +Signature   : DSA/SHA1, Mo 04 Mai 2009 22:13:20 CEST, Key ID a20e52146b8d79e6
 +Packager    : Dag Wieers <dag@wieers.com>
 +URL         : http://www.clamav.net/
 +Summary     : Anti-virus software
 +Description :
 +Clam AntiVirus is a GPL anti-virus toolkit for UNIX. The main purpose of
 +this software is the integration with mail servers (attachment scanning).
 +The package provides a flexible and scalable multi-threaded daemon, a
 +command line scanner, and a tool for automatic updating via Internet.
 +
 +The programs are based on a shared library distributed with the Clam
 +AntiVirus package, which you can use with your own software. Most
 +importantly, the virus database is kept up to date
 +/etc/freshclam.conf
 +/usr/bin/clamscan
 +/usr/bin/freshclam
 +/usr/bin/sigtool
 +/usr/lib/libclamav.so
 +/usr/lib/libclamav.so.6
 +/usr/lib/libclamav.so.6.0.3
 +/usr/lib/libclamunrar.so
 +/usr/lib/libclamunrar.so.6
 +/usr/lib/libclamunrar.so.6.0.3
 +/usr/lib/libclamunrar_iface.so
 +/usr/lib/libclamunrar_iface.so.6
 +/usr/lib/libclamunrar_iface.so.6.0.3
 +/usr/share/doc/clamav-0.95.1
 +/usr/share/doc/clamav-0.95.1/AUTHORS
 +/usr/share/doc/clamav-0.95.1/BUGS
 +/usr/share/doc/clamav-0.95.1/COPYING
 +/usr/share/doc/clamav-0.95.1/ChangeLog
 +/usr/share/doc/clamav-0.95.1/FAQ
 +/usr/share/doc/clamav-0.95.1/INSTALL
 +/usr/share/doc/clamav-0.95.1/NEWS
 +/usr/share/doc/clamav-0.95.1/README
 +/usr/share/doc/clamav-0.95.1/clamav-mirror-howto.pdf
 +/usr/share/doc/clamav-0.95.1/clamdoc.pdf
 +/usr/share/doc/clamav-0.95.1/freshclam.conf
 +/usr/share/doc/clamav-0.95.1/phishsigs_howto.pdf
 +/usr/share/doc/clamav-0.95.1/signatures.pdf
 +/usr/share/doc/clamav-0.95.1/test
 +/usr/share/doc/clamav-0.95.1/test/.split
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-aspack.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-aspack.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-fsg.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-fsg.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-mew.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-mew.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-nsis.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-nsis.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-pespin.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-pespin.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-petite.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-petite.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-upack.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-upack.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-upx.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-upx.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-v2.raraa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-v2.rarab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-v3.raraa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-v3.rarab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-wwpack.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam-wwpack.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.arjaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.arjab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.bz2.zipaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.bz2.zipab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.cabaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.cabab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.chmaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.chmab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.d64.zipaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.d64.zipab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.ea05.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.ea05.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.ea06.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.ea06.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.binhexaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.binhexab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.bz2aa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.bz2ab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.htmlaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.htmlab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.mbox.base64aa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.mbox.base64ab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.mbox.uuaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.mbox.uuab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.rtfaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.rtfab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.szddaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exe.szddab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exeaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.exeab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.impl.zipaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.impl.zipab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.mailaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.mailab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.ole.docaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.ole.docab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.pdfaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.pdfab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.pptaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.pptab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.sisaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.sisab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.tar.gzaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.tar.gzab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.tnefaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.tnefab
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.zipaa
 +/usr/share/doc/clamav-0.95.1/test/.split/split.clam.zipab
 +/usr/share/doc/clamav-0.95.1/test/Makefile
 +/usr/share/doc/clamav-0.95.1/test/Makefile.am
 +/usr/share/doc/clamav-0.95.1/test/Makefile.in
 +/usr/share/doc/clamav-0.95.1/test/README
 +/usr/share/doc/clamav-0.95.1/test/clam-aspack.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-fsg.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-mew.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-nsis.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-pespin.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-petite.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-upack.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-upx.exe
 +/usr/share/doc/clamav-0.95.1/test/clam-v2.rar
 +/usr/share/doc/clamav-0.95.1/test/clam-v3.rar
 +/usr/share/doc/clamav-0.95.1/test/clam-wwpack.exe
 +/usr/share/doc/clamav-0.95.1/test/clam.arj
 +/usr/share/doc/clamav-0.95.1/test/clam.bz2.zip
 +/usr/share/doc/clamav-0.95.1/test/clam.cab
 +/usr/share/doc/clamav-0.95.1/test/clam.chm
 +/usr/share/doc/clamav-0.95.1/test/clam.d64.zip
 +/usr/share/doc/clamav-0.95.1/test/clam.ea05.exe
 +/usr/share/doc/clamav-0.95.1/test/clam.ea06.exe
 +/usr/share/doc/clamav-0.95.1/test/clam.exe
 +/usr/share/doc/clamav-0.95.1/test/clam.exe.binhex
 +/usr/share/doc/clamav-0.95.1/test/clam.exe.bz2
 +/usr/share/doc/clamav-0.95.1/test/clam.exe.html
 +/usr/share/doc/clamav-0.95.1/test/clam.exe.mbox.base64
 +/usr/share/doc/clamav-0.95.1/test/clam.exe.mbox.uu
 +/usr/share/doc/clamav-0.95.1/test/clam.exe.rtf
 +/usr/share/doc/clamav-0.95.1/test/clam.exe.szdd
 +/usr/share/doc/clamav-0.95.1/test/clam.impl.zip
 +/usr/share/doc/clamav-0.95.1/test/clam.mail
 +/usr/share/doc/clamav-0.95.1/test/clam.ole.doc
 +/usr/share/doc/clamav-0.95.1/test/clam.pdf
 +/usr/share/doc/clamav-0.95.1/test/clam.ppt
 +/usr/share/doc/clamav-0.95.1/test/clam.sis
 +/usr/share/doc/clamav-0.95.1/test/clam.tar.gz
 +/usr/share/doc/clamav-0.95.1/test/clam.tnef
 +/usr/share/doc/clamav-0.95.1/test/clam.zip
 +/usr/share/man/man1/clamscan.1.gz
 +/usr/share/man/man1/freshclam.1.gz
 +/usr/share/man/man1/sigtool.1.gz
 +/usr/share/man/man5/freshclam.conf.5.gz</code>
 +==== Paket clamtk====
 +<code># rpm -iql clamtk
 +Name        : clamtk                       Relocations: (not relocatable)
 +Version     : 3.67                              Vendor: Dag Apt Repository, http://dag.wieers.com/apt/
 +...
 +
 +...
 +Size        : 110094                           License: Perl
 +Signature   : DSA/SHA1, Di 27 Mai 2008 02:00:39 CEST, Key ID a20e52146b8d79e6
 +Packager    : Dag Wieers <dag@wieers.com>
 +URL         : http://clamtk.sourceforge.net/
 +Summary     : Easy to use front-end for ClamAV
 +Description :
 +ClamTk is a front-end, point and click gui for ClamAV on Linux systems.
 +It supports easy signature-updates.
 +/usr/bin/clamtk
 +/usr/share/applications/rpmforge-clamtk.desktop
 +/usr/share/doc/clamtk-3.09
 +/usr/share/doc/clamtk-3.09/CHANGES
 +/usr/share/doc/clamtk-3.09/DISCLAIMER
 +/usr/share/doc/clamtk-3.09/LICENSE
 +/usr/share/doc/clamtk-3.09/README
 +/usr/share/man/man1/clamtk.1.gz
 +/usr/share/pixmaps/clamtk.png
 +/usr/share/pixmaps/clamtk.xpm</code>
 +===== clamav Konfiguration =====
 +==== erster Programmstart ====
 +Nun ist es an der Zeit unseren **ClamAV**-Daemon das erste mal zu starten. 
 +   # service clamd start
 +<code>Starting Clam AntiVirus Daemon: LibClamAV Warning: **************************************************
 +LibClamAV Warning: ***  The virus database is older than 7 days!  ***
 +LibClamAV Warning: ***   Please update it as soon as possible.    ***
 +LibClamAV Warning: **************************************************
 +                                                            OK  ]</code>
 +Wir müssen also unser Virendatenbank erst einmal updaten - Hierzu nutzen wir das Programm **freshclam** aus dem Paket **//clamav//**. Wir stoppen nun erst einmal unseren Daemon uns fahren mit der Installation und Konfiguration der weiteren Schritte fort.
 +   # service clamd stop
 +
 +   Stopping Clam AntiVirus Daemon:                            [  OK  ]
 +
 +==== automatisches Starten des Daemon beim Systemstart ====
 +Damit nun unser ClamAV-Daemon beim Booten automatisch gestartet wird, nehmen wir noch folgende Konfigurationsschritte vor.
 +   # chkconfig clamd on
 +Anschließend überprüfen wir noch unsere Änderung: 
 +   # chkconfig --list | grep clamd
 +   clamd           0:Aus   1:Aus   2:Ein   3:Ein   4:Ein   5:Ein   6:Aus
 +
 +===== freshlam Konfiguration =====
 +Damit [[http://www.clamav.net|ClamAV]] stets mit den aktuellen Vireninformationen versorgen wird, steht und das Programm **freshclam** aus dem Paket **clamav** zu Diensten.
 +
 +In der Standardkonfiguration sorgt **freshclam** dafür, dass **1x am Tag** ein Update der Virenpattern-Datenbank vorgenommen wird. Bei Bedarf können wir den Updatezyklus unseren Erfordernissen anpassen und so z.B. alle Stunde überprüfen lassen ob neue Patternfiles vorhanden sind und diese dann auf unseren Rechner herunterzuladen und in die lokale Datenbak einfließen zu lassen. Hierbei stehen uns prinzipiell zwei Mechanismen zur Verfügung, die **crontab** und der **Daemon-Modus**. Beide Varianten könnten im System parallel genutzt werden - nachfolgend werden bei Möglichkeiten kurz beschrieben. 
 +
 +==== Nutzung crontab ====
 +Die erste und einfache Variante besteht darin das Update-Script, welches sich mit dem Namen **freshclam** aktuell und standardmäßig unter //**/etc/cron.daily**// befindet, nach //**/etc/cron.hourly/**// zu verschieben. 
 +Das Updatescript beinhaltet folgende Parameter und Aufrufe:
 +<file freshclam>#!/bin/sh
 +
 +### A simple update script for the clamav virus database.
 +### This could as well be replaced by a SysV script.
 +
 +### fix log file if needed
 +LOG_FILE="/var/log/clamav/freshclam.log"
 +if [ ! -f "$LOG_FILE" ]; then
 +    touch "$LOG_FILE"
 +    chmod 644 "$LOG_FILE"
 +    chown clamav.clamav "$LOG_FILE"
 +fi
 +
 +/usr/bin/freshclam \
 +    --quiet \
 +    --datadir="/var/clamav" \
 +    --log="$LOG_FILE" \
 +    --daemon-notify="/etc/clamd.conf"
 +</file>
 +Wir verschieben also das Script bei Bedarf nach //**/etc/cron.hourly/**//.
 +   # mv /etc/cron.daily/freshclam /etc/cron.hourly/
 +==== Nutzung Daemon-Modus ====
 +Die zuvor erwähnte zweite Möglichkeit zum Updaten der Virenpattern-Datenbank ist die Nutzung des **freshclam-Daemons**, der im Hintergrund läuft und regelmäßig zu den Pattenservern eine Abfrage startet. 
 +=== Startscript ===
 +Da bei unserer Installation kein passendes Init-V-Script mitgeliefert wurde legen wir uns ein eigenes Startscript an.
 +  # vim /etc/init.d/freshclamd
 +<file bash freshclamd>
 +#!/bin/sh
 +#
 +# freshclamd    Init Script to start/stop the freshclamd.
 +#
 +# chkconfig: - 62 38
 +# description: freshclam is an update daemon for Clam AV database.
 +#
 +# processname: freshclamd
 +# config: /etc/freshclam.conf
 +# pidfile: /var/run/clamav/freshclam.pid
 +
 +# Source function library
 +. /etc/init.d/functions
 +
 +# Get network config
 +. /etc/sysconfig/network
 +
 +test -f /etc/freshclam.conf || exit 0
 +
 +RETVAL=0
 +DATA_DIR="/var/clamav"
 +CLAMD_CONF_FILE="/etc/clamd.conf"
 +LOG_FILE="/var/log/clamav/freshclam.log"
 +
 +if [ ! -f "$LOG_FILE" ]; then
 +    touch "$LOG_FILE"
 +    chmod 644 "$LOG_FILE"
 +    chown clamav.clamav "$LOG_FILE"
 +fi
 +
 +start() {
 +        echo -n $"Starting freshclam: "
 +        # Start me up!
 +        #       --log="$LOG_FILE" \
 +        #       --log-verbose \
 +        daemon /usr/bin/freshclam -d -p /var/run/clamav/freshclam.pid \
 +                -c 48 \
 +                --quiet \
 +                --datadir="$DATA_DIR" \
 +                --daemon-notify="$CLAMD_CONF_FILE"
 +        RETVAL=$?
 +        echo
 +        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/freshclam
 +        return $RETVAL
 +}
 +
 +stop() {
 +        echo -n $"Stopping freshclam: "
 +        killproc freshclam
 +        RETVAL=$?
 +        echo
 +        [ $RETVAL -eq 0 ] && rm -f /var/run/clamav/freshclam.pid /var/lock/subsys/freshclam
 +        return $RETVAL
 +}
 +
 +restart() {
 +        stop
 +        start
 +}
 +
 +reload() {
 +        echo -n $"Reloading DB: "
 +        killproc freshclam -ALRM
 +        RETVAL=$?
 +        echo
 +        return $RETVAL
 +}
 +
 +
 +case "$1" in
 +  start)
 +        start
 +        ;;
 +  stop)
 +        stop
 +        ;;
 +  status)
 +        status freshclam
 +        ;;
 +  restart)
 +        restart
 +        ;;
 +  condrestart)
 +        [ -f /var/lock/subsys/freshclam ] && restart || :
 +        ;;
 +  reload)
 +        reload
 +        ;;
 +  *)
 +        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
 +        exit 1
 +esac
 +
 +exit $?
 +</file>
 +Anschließend passen wir noch die Dateirechte an:
 +   # chmod +x /etc/init.d/freshclamd
 +
 +=== Konfiguration ===
 +Wir passen nun in der Konfigurationsdatei **///etc/freshclam.conf//** das Updateintervall unseren Vorstellungen entsprechend an.
 +<code># vim /etc/freshclam.conf
 +
 +...
 +# Number of database checks per day.
 +# Default: 12 (every two hours)
 +# Django 17.05.2009 für halbstündlichen Virenpatterndatenbankcheck
 +Checks 48
 +...
 +</code>
 +=== erster Programmstart ===
 +Unseren Updatemechanismus **freshclam-daemon** starten wir wie gewohnt mit:
 +   # service freshclamd start
 +   Starting freshclam:                                        [  OK  ]
 +Im Logfile //**/var/log/clamav/freshclam.log**// wird der Programmaufruf entsprechend dokumentiert:
 +<code># tail -f /var/log/clamav/freshclam.log 
 +--------------------------------------
 +freshclam daemon 0.95.1 (OS: linux-gnu, ARCH: i386, CPU: i386)
 +ClamAV update process started at Sun May 17 22:15:13 2009
 +Downloading main-51.cdiff [100%]
 +main.cld updated (version: 51, sigs: 545035, f-level: 42, builder: sven)
 +WARNING: getfile: daily-9214.cdiff not found on remote server (IP: 193.27.50.222)
 +WARNING: getpatch: Can't download daily-9214.cdiff from db.de.clamav.net
 +Trying host db.de.clamav.net (213.174.32.130)...
 +WARNING: getfile: daily-9214.cdiff not found on remote server (IP: 213.174.32.130)
 +WARNING: getpatch: Can't download daily-9214.cdiff from db.de.clamav.net
 +Trying host db.de.clamav.net (212.1.60.18)...
 +WARNING: getfile: daily-9214.cdiff not found on remote server (IP: 212.1.60.18)
 +WARNING: getpatch: Can't download daily-9214.cdiff from db.de.clamav.net
 +WARNING: Incremental update failed, trying to download daily.cvd
 +Trying host db.de.clamav.net (130.133.110.67)...
 +Downloading daily.cvd [100%]
 +daily.cvd updated (version: 9365, sigs: 5249, f-level: 42, builder: mcichosz)
 +Database updated (550284 signatures) from db.de.clamav.net (IP: 130.133.110.67)
 +--------------------------------------</code>
 +=== automatisches Starten des Daemon beim Systemstart ===
 +Damit nun unser freshcam-Daemon beim Booten automatisch gestartet wird, nehmen wir noch folgende Konfigurationsschritte vor.
 +   # chkconfig freshclamd on
 +Anschließend überprüfen wir noch unsere Änderung:
 +   # chkconfig --list | grep freshclamd
 +   freshclamd      0:Aus   1:Aus   2:Ein   3:Ein   4:Ein   5:Ein   6:Aus
 +===== clamav Start =====
 +Da unsere Virendatenbank nun uptodate ist können wir den clamav-Daemon nun ohne Fehlermeldung starten:
 +   # service clamd start
 +   Starting Clam AntiVirus Daemon:                            [  OK  ]
 +Im Logfile **///var/log/clamav/clamd.log//** wir der Programmstart entsprechend dokumentiert:
 +<code>Sun May 17 22:20:12 2009 -> +++ Started at Sun May 17 22:20:12 2009
 +Sun May 17 22:20:12 2009 -> clamd daemon 0.99.1 (OS: linux-gnu, ARCH: i386, CPU: i386)
 +Sun May 17 22:20:12 2009 -> Running as user clamav (UID 101, GID 105)
 +Sun May 17 22:20:12 2009 -> Log file size limit disabled.
 +Sun May 17 22:20:12 2009 -> Reading databases from /var/clamav
 +Sun May 17 22:20:12 2009 -> Not loading PUA signatures.
 +Sun May 17 22:20:13 2009 -> Loaded 549731 signatures.
 +Sun May 17 22:20:13 2009 -> TCP: Bound to address 127.0.0.1 on port 3310
 +Sun May 17 22:20:13 2009 -> TCP: Setting connection queue length to 30
 +Sun May 17 22:20:13 2009 -> LOCAL: Unix socket file /var/run/clamav/clamd.sock
 +Sun May 17 22:20:13 2009 -> LOCAL: Setting connection queue length to 30
 +Sun May 17 22:20:13 2009 -> Limits: Global size limit set to 104857600 bytes.
 +Sun May 17 22:20:13 2009 -> Limits: File size limit set to 26214400 bytes.
 +Sun May 17 22:20:13 2009 -> Limits: Recursion level limit set to 16.
 +Sun May 17 22:20:13 2009 -> Limits: Files limit set to 10000.
 +Sun May 17 22:20:13 2009 -> Archive support enabled.
 +Sun May 17 22:20:13 2009 -> Algorithmic detection enabled.
 +Sun May 17 22:20:13 2009 -> Portable Executable support enabled.
 +Sun May 17 22:20:13 2009 -> ELF support enabled.
 +Sun May 17 22:20:13 2009 -> Detection of broken executables enabled.
 +Sun May 17 22:20:13 2009 -> Mail files support enabled.
 +Sun May 17 22:20:13 2009 -> OLE2 support enabled.
 +Sun May 17 22:20:13 2009 -> PDF support enabled.
 +Sun May 17 22:20:13 2009 -> HTML support enabled.
 +Sun May 17 22:20:13 2009 -> Self checking every 600 seconds.
 +</code>
 +===== manueller Scanlauf =====
 +==== clamscan ====
 +Um auf der Konsole ein Verzeichnis zu scannen rufen wir einfach **clamscan** auf:
 +<code>$ clamscan 
 +/home/django/.bash_history: OK
 +/home/django/.bash_profile: OK
 +/home/django/.bash_logout: OK
 +/home/django/.viminfo: OK
 +/home/django/.bashrc: OK
 +/home/django/eicarcom2.zip: Eicar-Test-Signature FOUND
 +
 +----------- SCAN SUMMARY -----------
 +Known viruses: 549731
 +Engine version: 0.95.1
 +Scanned directories: 1
 +Scanned files: 6
 +Infected files: 1
 +Data scanned: 0.00 MB
 +Data read: 0.00 MB (ratio 0.00:1)
 +Time: 1.047 sec (0 m 1 s)</code>
 +In dem oben genannten Beispiel wurde eine Datei bemängelt, in der sich die **//Eicar-Test-Signatur//** befindet. Diese Virensignaturen können zum testen direkt von der [[http://www.eicar.com|Eicar-Webseite]] herunter geladen werden.
 +<WRAP round important>Möchte man ein ganzes Verzeichnis __und__ die Unterverzeichnisse durchsuchen, so muss man beim Aufruf die Option **-r** angeben.
 +
 +<code>$ clamscan -r /home/django/</code>
 +</WRAP>
 +
 +==== clamtk ====
 +Alternativ kann man auch das Programm **clamtk** einem **GUI**((Graphical User Interface)) nutzen.
 +
 +
 +{{  :centos:clamtk.png?400 |GUI für ClamAV}}
 +
 +
 +===== automatischer Scanlauf =====
 +==== virusscan ====
 +Wollen wir einen automatischen Scan-Lauf eines Verzeichnisses in regelmäßigen Abständen vornehmen, bedienen wir uns eines einfachen Shell-Scripts.
 +
 +Im Verzeichnis **/usr/local/bin/** legen wir uns nun das entsprechende Script an.
 +
 +  # vim /usr/local/bin/virusscan
 +
 +<file bash virusscan>
 +#!/bin/bash
 +
 +##############################################################################
 +# Script-Name : virusscan                                                    # 
 +# Description : CLamAV-Scan for a directory. When a virus was found a e-Mail # 
 +#               will be send to the Administration.                          # 
 +#                                                                            # 
 +# Last update : 19.10.2009                                                   # 
 +# Version     : 0.01                                                         # 
 +##############################################################################
 +
 +##############################################################################
 +#                                H I S T O R Y                               # 
 +##############################################################################
 +# Version     : 0.01                                                         # 
 +# Description : initial release                                              #
 +# -------------------------------------------------------------------------- # 
 +##############################################################################
 +
 +# Source function library.
 +. /etc/init.d/functions
 +
 +# Source variable declarations.
 +SCAN_DIRECTORY="/home/"
 +SCAN_TEMP_FILE="/tmp/virusscan.tmp"
 +HOST=$(hostname)
 +MAIL="/bin/mail"
 +MAIL_TO="root@nausch.org"
 +
 +
 +##############################################################################
 +# Check if temp file exist, and delete them.                                 #
 +##############################################################################
 +if [ -e "$SCAN_TEMP_FILE" ]; then
 +        echo -n $"Lösche temporäre Datei $SCAN_TEMP_FILE... "
 +        `rm $SCAN_TEMP_FILE -f`
 +        # Check if delete of temp file was successful.
 +        if [ "$?" != "0" ]; then
 +                failure; echo
 +                exit 3
 +        else
 +                success; echo
 +        fi
 +fi
 +
 +##############################################################################
 +# Scan a directory recursly.                                                 #
 +##############################################################################
 +echo -n $"Scanne das Verzeichnis: $SCAN_DIRECTORY... "
 +
 +/usr/bin/clamscan -r $SCAN_DIRECTORY > $SCAN_TEMP_FILE
 +if [ "$?" -gt 1 ]; then
 +        failure; echo
 +        echo "Return-Code clamscan: [$?], (man clamscan) !"
 +        exit 4
 +else
 +        success; echo
 +fi
 +
 +##############################################################################
 +# Check if a virus was found, and send a e-Mail if true.                     #
 +##############################################################################
 +echo -n $"Ergebnis des Virenscanns "
 +
 +if [ -n "`grep FOUND $SCAN_TEMP_FILE`" ]; then
 +        warning; echo
 +        cat ${SCAN_TEMP_FILE} | ${MAIL} -s "!!! VIRUS GEFUNDEN @ ${HOST} !!!" ${MAIL_TO}
 +else
 +        success; echo
 +fi
 +
 +# End of script;
 +exit 0
 +</file>
 +Möchten wir einzelne Verzeichnisse nur teilweise, oder auch mehrere verschiedene Verzeichnisse scannen, so nutzen wir einfach eine klein wenig erweiterte Version des vorgenannten Scriptes.
 +
 +<file bash /usr/local/bin/virusscan>
 +#!/bin/bash
 +
 +##############################################################################
 +# Script-Name : virusscan.sh                                                 # 
 +# Description : Automatisierter CLamAV-Scan für Verzeichnisse.               #
 +# Sollte ein Virus gefunden werden, wird der System-           #
 +# administrator per eMail informiert.                          # 
 +#                                                                            # 
 +# Last update : 17.06.2011                                                   # 
 +# Version     : 0.02                                                         # 
 +##############################################################################
 +
 +##############################################################################
 +#                                H I S T O R Y                               # 
 +##############################################################################
 +# -------------------------------------------------------------------------- #
 +# Version     : 0.02                                                         # 
 +# Description : Umstellung auf einzeln zu definierende Scanbereiche          #
 +# -------------------------------------------------------------------------- # 
 +# Version     : 0.01                                                         # 
 +# Description : initiale Version mit Definition eines einzelnen      # 
 +# Verzeichnisses, welches gescannt werden soll.                #
 +##############################################################################
 +
 +# Source function library.
 +. /etc/init.d/functions
 +
 +# Source variable declarations.
 +ARRAY=( "/home/admin/"
 + "/home/django/"
 + "/root/"
 +        "/var/www/html/")
 +SCAN_DIRECTORY="/home/"
 +SCAN_TEMP_FILE="/tmp/virusscan.tmp"
 +HOST=$(hostname)
 +MAIL="/bin/mailx"
 +MAIL_TO="root@nausch.org"
 +
 +##############################################################################
 +# Check if dms directory is mounted via DRBD                                 #
 +##############################################################################
 +#if [ ! -d "$SCAN_DIRECTORY" ]; then
 +#        echo -n $"Server ist nicht der aktive DRBD-Knoten! "
 +#        success; echo
 +#        exit 2
 +#fi
 +
 +##############################################################################
 +# Check if temp file exist, and delete them.                                 #
 +##############################################################################
 +if [ -e "$SCAN_TEMP_FILE" ]; then
 +        echo -n $"Lösche temporäre Datei                $SCAN_TEMP_FILE ... "
 +        `rm $SCAN_TEMP_FILE -f`
 + touch $SCAN_TEMP_FILE 
 +        # Check if delete of temp file was successful.
 +        if [ "$?" != "0" ]; then
 +                failure; echo
 +                exit 3
 +        else
 +                success; echo
 +        fi
 +fi
 +
 +##############################################################################
 +# Scan a directory recursly.                                                 #
 +##############################################################################
 +ELEMENTS=${#ARRAY[@]}
 +echo    $"Anzahl der definierten Verzeichnisse: $ELEMENTS"
 +
 +for (( i=0;i<$ELEMENTS;i++)); do
 + echo -n $"Scanne das Verzeichnis:               ${ARRAY[${i}]} ..."
 + /usr/bin/clamscan -r ${ARRAY[${i}]} >> $SCAN_TEMP_FILE
 + if [ "$?" -gt 1 ]; then
 +        failure; echo
 +        echo "Return-Code clamscan: [$?], (man clamscan) !"
 +        exit 4
 + else
 +        success; echo
 + fi
 +done
 +
 +#echo -n $"Scanne das Verzeichnis: $SCAN_DIRECTORY... "
 +#
 +#/usr/bin/clamscan -r $SCAN_DIRECTORY > $SCAN_TEMP_FILE
 +#if [ "$?" -gt 1 ]; then
 +#        failure; echo
 +#        echo "Return-Code clamscan: [$?], (man clamscan) !"
 +#        exit 4
 +#else
 +#        success; echo
 +#fi
 +
 +##############################################################################
 +# Check if a virus was found, and send a e-Mail if true.                     #
 +##############################################################################
 +echo -n $"Ergebnis des Virenscanns "
 +
 +if [ -n "`grep FOUND $SCAN_TEMP_FILE`" ]; then
 +        warning; echo
 +        grep FOUND ${SCAN_TEMP_FILE} | ${MAIL} -s "!!! VIRUS GEFUNDEN @ ${HOST}!!!" ${MAIL_TO}
 +# cat ${SCAN_TEMP_FILE} | ${MAIL} -s "!!! VIRUS GEFUNDEN @ ${HOST} !!!" ${MAIL_TO}
 +else
 +        success; echo
 +fi
 +
 +# End of script;
 +exit 0
 +
 +
 +</file>
 +
 +
 +Anschließend setzen wir nun die e**X**ecutable-Dateiberechtigungen unseres shell-scriptes.
 +  # chmod +x /usr/local/bin/virusscan
 +
 +Damit nun das oder die gewählten Verzeichnisse regelmäßig gescannt werden, brauchen wir lediglich einen symbolischen link in das gewünschte Verzeichnis **/etc/cron.daily/** oder **/etc/cron.hourly/**. Möchten wir das gewählte Verzeichnis stündlich durchsuchen, setzen wird demnach:
 +  # ln -s /usr/local/bin/virusscan /etc/cron.hourly/
 +Wollen wir 1x am Tag den Scanvorgang anstoßen lautet der Aufruf entsprechend:
 +  # ln -s /usr/local/bin/virusscan /etc/cron.daily/
 +====== Links ======
 +  * **[[wiki:start|Zurück zu Projekte und Themenkapitel]]**
 +  * **[[http://dokuwiki.nausch.org/doku.php/|Zurück zur Startseite]]**
 +
  
  • centos/clamav_centos_host.txt
  • Zuletzt geändert: 22.07.2019 14:48.
  • von django