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

Cara Tambahkan Stiker Add Yours di WhatsApp Status

WhatsApp Status kembali mendapatkan fitur baru. Setelah cukup lama diuji coba, WhatsApp akhirnya merilis fitur 'Add…

3 jam ago

Mark Zuckerberg Ingin AI Jadi Teman untuk Orang yang Kesepian

Chatbot AI saat ini sudah umum dipakai menjadi asisten digital. Tapi menurut Mark Zuckerberg, AI juga bisa…

13 jam ago

Polytron Itu Mobil Listrik Nasional atau Bukan?

Polytron jadi merek Indonesia yang terjun dalam industri mobil listrik. Polytron disebut-sebut bakal menjadi mobil…

16 jam ago

Pesaing China Muncul, Bikin AI Pakai GPU Murah Meriah

Fastino, startup kecerdasan buatan asal Amerika Serikat, memamerkan model AI barunya yang ditujukan untuk bisnis. Menariknya, model AI…

16 jam ago

Jangan Terima Kasih dan Minta Tolong ke ChatGPT, Bikin Boncos

Sopan terhadap AI seperti ChatGPT mungkin dilakukan beberapa orang karena memang mirip bicara pada manusia. Namun siapa…

16 jam ago

Rockstar Klaim Cuplikan Keren Trailer Kedua GTA 6 dari In-Game PS5

Trailer kedua GTA 6 sudah rilis. Menariknya, kualitas yang disuguhkan sungguh memesona dan memanjakan mata. Namun…

17 jam ago