linux杀毒软件clamav

linux杀毒软件clamav

开源官网地址:https://www.clamav.net/about

模拟病毒文件

wget http://www.eicar.org/download/eicar.com

1 或者使用yum安装

yum -y install epel-release
yum -y install clamav
clamscan --version

centos8版本

wget  https://www.clamav.net/downloads/production/clamav-0.102.3.tar.gz
wget ftp://ftp.pbone.net/mirror/ftp.scientificlinux.org/linux/scientific/7.1/x86_64/updates/security/libcurl-devel-7.29.0-35.el7.x86_64.rpm

以下链接失效
wget http://mirror.centos.org/altarch/7/os/aarch64/Packages/libcurl-devel-7.29.0-57.el7.aarch64.rpm

2我使用低版本 centos7

wget https://www.clamav.net/downloads/production/clamav-0.100.1.tar.gz

以下是执行步骤

cat > clamav-install.sh <<-"EOF"
#/bin/bash

#clamav普通用户
groupadd clamav && useradd -g clamav clamav && id clamav

#创建目录
mkdir -p /usr/local/clamav/logs     
touch /usr/local/clamav/logs/clamd.log
touch /usr/local/clamav/logs/freshclam.log
chown clamav.clamav /usr/local/clamav/logs/clamd.log
chown clamav.clamav /usr/local/clamav/logs/freshclam.log

#授权
mkdir -p /usr/local/clamav/updata
chown -R root.clamav /usr/local/clamav/
chown -R clamav.clamav /usr/local/clamav/updata/

#解压
cd /opt
rpm -ivh libcurl-devel-7.29.0-35.el7.x86_64.rpm
tar -zxvf clamav-0.100.1.tar.gz
cd clamav-0.100.1


#安装依赖
yum install gcc gcc-c++ openssl openssl-devel  -y

#编译安装
./configure --prefix=/usr/local/clamav
make && make install

cd /usr/local/clamav/etc
cp clamd.conf.sample clamd.conf
cp freshclam.conf.sample freshclam.conf

#替换设置
sed -i "8s/^/#/g" /usr/local/clamav/etc/clamd.conf
sed -i "8s/^/#/g" /usr/local/clamav/etc/freshclam.conf

echo "
LogFile /usr/local/clamav/logs/clamd.log    
PidFile /usr/local/clamav/updata/clamd.pid     
DatabaseDirectory /usr/local/clamav/updata
">>/usr/local/clamav/etc/clamd.conf

echo "
DatabaseDirectory /usr/local/clamav/updata
UpdateLogFile /usr/local/clamav/logs/freshclam.log
PidFile /usr/local/clamav/updata/freshclam.pid
">>/usr/local/clamav/etc/freshclam.conf

chown -R clamav.clamav /usr/local/clamav/

#启动
systemctl start clamav-freshclam.service
systemctl enable clamav-freshclam.service 
systemctl status clamav-freshclam.service

#定时任务
echo "
10 2  * * *  /usr/local/clamav/bin/freshclam --quiet
20 3  * * *  /usr/local/clamav/bin/clamscan  -r /home  --remove -l /var/log/clamscan.log
">>/etc/crontab
EOF

具体用法

参数:
    -r 递归扫描子目录
    -i 只显示发现的病毒文件
    –no-summary 不显示统计信息

用法:
    # 帮助
    /usr/local/clamav/bin/clamscan --help     

    # 默认扫描当前目录下的文件,并显示扫描结果统计信息            
    /usr/local/clamav/bin/clamscan

    #扫描当前目录下的所有目录和文件,并显示结果统计信息
    /usr/local/clamav/bin/clamscan -r

    #扫描data目录下的所有目录和文件,并显示结果统计信息                  
    /usr/local/clamav/bin/clamscan -r /data  

    #扫描data目录下的所有目录和文件,只显示有问题的扫描结果            
    /usr/local/clamav/bin/clamscan -r --bell -i /data  

    #扫描data目录下的所有目录和文件,不显示统计信息  
    /usr/local/clamav/bin/clamscan --no-summary -ri /data

clamav杀毒软件安装.png