Edukasi

ClamAV Autoscan (Telegram and email alerts)

Daily virus and malware scan with ClamAV. This script will send notifications by Telegram and / or email when malware is detected.

This script is designed and tested in Debian 9.

Installation

  • Install ClamAV and all its components:
sudo apt-get update && apt-get install clamav clamav-docs clamav-daemon clamav-freshclam
  • Install different packages so that ClamAV can also analyze the compressed files:
sudo apt-get install arc arj bzip2 cabextract lzop nomarch p7zip pax tnef unrar-free unzip zoo
  • Install the sendmail package (to send notifications by email), curl package (to send notifications to Telegram) and cpulimit (so that the scan doesn’t consume all the CPU):
sudo apt-get install sendmail curl cpulimit

ClamAV configuration

  • Edit the /etc/clamav/freshclam.conf file and modify the number of daily checks (replace 24 by 1):
sudo vi /etc/clamav/freshclam.conf
...
Checks 1
...
  • Restart service:
sudo service clamav-freshclam restart

Install and configure the script

  • Insert the script “clam_scan.sh” in the /root directory.

  • Edit the configuration variables (sudo vi /root/clam_scan.sh):

    • LOG_FILE: Name for the log files.
    • HOST_NAME: Name of the host.
    • CPU_LIMIT: Maximum percentage of CPU to be consumed by malware scanning.
    • MSG_SUBJECT: Subject of notifications when malware is detected.
    • MSG_INFO: Notification information when malware is detected. Some HTML tags (those allowed by Telegram) can be used.
    • EMAIL: If an email notification should be sent when detecting malware (true) or not (false).
    • EMAIL_FROM: Sender email address.
    • EMAIL_TO: Recipient email address.
    • TELEGRAM: If a malware notification should be sent to Telegram (true) or not (false).
    • TELEGRAM_TOKEN: Token of the Telegram bot to be able to notifications.
    • TELEGRAM_CHATID: Id of the Telegram chat to send the notifications to.
    • DIR_TO_SCAN: Directory/s to scan. Several can be indicated separated by a blank space.
  • Give script permissions:

chmod 0755 /root/clam_scan.sh
  • Create a cron to run the script at the time you want:
crontab -e
00 03 * * * /root/clam_scan.sh
  • To verify that the script works correctly, run:
/root/clam_scan.sh
ryan

Recent Posts

Jadwal Imsak dan Buka Puasa Ramadhan 2025 Kota Serang Selama Sebulan

Berikut jadwal imsak dan buka puasa Ramadhan 2025 di Kota Serang dari tanggal 1 Ramadhan -…

1 minggu ago

Jadwal Resmi Awal Puasa Ramadan 2025 Pemerintah, NU, Muhammadiyah

Jakarta - Pemerintah telah menetapkan awal Ramadan 2025 berdasarkan hasil sidang isbat oleh Kemenag. Begitu pula dengan organisasi masyarakat…

1 minggu ago

Meta AI Ditanya Luas Kebakaran Los Angeles, Hasilnya Mengejutkan Sama dengan Luas Gaza

Siapa sangka, salah satu warganet justru mendapat informasi tak terduga yang berasal dari Meta AI.…

2 bulan ago

Tebak-tebakan pelesetan kata ini lucu abis, awas ketawa ngakak

Ketika menjalani rutinitas sehari-hari tentu saja kamu pernah merasa suntuk atau jenuh. Supaya kamu bisa…

2 bulan ago

Kapal China Diduga Biang Kerok Internet Mati Total di Berbagai Negara

Sebuah kapal kargo komersial China diduga sengaja menyeret jangkarnya untuk memotong kabel bawah laut yang…

3 bulan ago

Ini Sumber Kekayaan Nabi Sulaiman, Sungguh di Luar Dugaan

Nabi Sulaiman dikenal sebagai raja yang kaya raya. Para ilmuwan arkeologi kini mengungkap apa sumber kekayaannya,…

3 bulan ago