-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClamAV.sh
executable file
·67 lines (50 loc) · 1.79 KB
/
ClamAV.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
# Install ClamAV antivirus
yum install clamav-daemon clamav-scanner-systemd -y
# Enable and start ClamAV service
systemctl enable clamav-daemon
systemctl start clamav-daemon
# Update ClamAV virus definitions
freshclam
# Configure ClamAV to scan specific directories
echo "/var/www/html" >> /etc/clamav/scan.d/local.ign
echo "/home/*/.bashrc" >> /etc/clamav/scan.d/local.ign
# Schedule regular scans
crontab -l > mycron
echo "0 0 * * * clamscan -r /" >> mycron
crontab mycron
rm mycron
# Configure ClamAV to automatically take action on infected files
sed -i 's/Action = "Clean"/Action = "Quarantine"/g' /etc/clamav/clamd.conf
# Add ClamAV quarantine directory to firewall rules
firewall-cmd --permanent --zone=public --add-port=3310/tcp
# Restart firewall and ClamAV service
firewall-cmd --reload
systemctl restart clamav-daemon
# Display completion message
echo "ClamAV antivirus setup completed. Remember to review and adapt as needed."
#!/bin/bash
# Ensure ClamAV is running
systemctl restart clamav-daemon
# Update virus definitions
freshclam
# Perform a deep scan of all files
clamscan -r --recursive --move=/var/lib/clamav/quarantine/ /
# Analyze quarantined files
for file in /var/lib/clamav/quarantine/*; do
# Check for scripts
if file "$file" | grep -q "script"; then
# Take action on script, e.g., log and delete
echo "Found script: $file" >> /var/log/clamav.log
rm -rf "$file"
fi
done
# Report results
echo "Deep scan completed. Quarantined files: $(ls -l /var/lib/clamav/quarantine/ | wc -l)"
# Schedule regular deep scans
crontab -l > mycron
echo "0 0 * * * clamscan -r --recursive --move=/var/lib/clamav/quarantine/ /" >> mycron
crontab mycron
rm mycron
# Display completion message
echo "Deep scan and action script completed. Review quarantined files and logs carefully."