LMD, abbreviazione di Linux Malware Detect, è uno scanner open source pensato appositamente per i server Linux — in particolare gli hosting condivisi, dove decine di account utente custodiscono ciascuno file che valgono la pena proteggere. Cerca payload malevoli noti e può ripulire o mettere in quarantena ciò che trova.
Questa guida illustra l'installazione di Linux Malware Detect insieme a ClamAV su Debian 9, Ubuntu 16.04 e LinuxMint 18.
Mettere LMD su Debian
Non esiste un pacchetto pronto nei repository di base, quindi si passa dall'archivio tar disponibile sul sito del progetto.
Scarica la release corrente (v1.6.2):
cd /tmp/ curl -O https://www.rfxn.com/downloads/maldetect-current.tar.gz
Estrailo.
tar -zxvf maldetect-current.tar.gz
Entra nella cartella estratta.
cd maldetect-1.6.2/
Avvia l'installer incluso.
bash install.sh
Output:
Created symlink /etc/systemd/system/multi-user.target.wants/maldet.service → /usr/lib/systemd/system/maldet.service. update-rc.d: error: unable to read /etc/init.d/maldet Linux Malware Detect v1.6 (C) 2002-2017, R-fx Networks <proj@r-fx.org> (C) 2017, Ryan MacDonald <ryan@r-fx.org> This program may be freely redistributed under the terms of the GNU GPL installation completed to /usr/local/maldetect config file: /usr/local/maldetect/conf.maldet exec file: /usr/local/maldetect/maldet exec link: /usr/local/sbin/maldet exec link: /usr/local/sbin/lmd cron.daily: /etc/cron.daily/maldet maldet(933): {sigup} performing signature update check... maldet(933): {sigup} local signature set is version 2017070716978 maldet(933): {sigup} new signature set (201708255569) available maldet(933): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-sigpack.tgz maldet(933): {sigup} downloading https://cdn.rfxn.com/downloads/maldet-cleanv2.tgz maldet(933): {sigup} verified md5sum of maldet-sigpack.tgz maldet(933): {sigup} unpacked and installed maldet-sigpack.tgz maldet(933): {sigup} verified md5sum of maldet-clean.tgz maldet(933): {sigup} unpacked and installed maldet-clean.tgz maldet(933): {sigup} signature set update completed maldet(933): {sigup} 15218 signatures (12485 MD5 | 1954 HEX | 779 YARA | 0 USER)
Regolare la configurazione
Tutto si trova in /usr/local/maldetect/conf.maldet e i valori predefiniti meritano una revisione prima della prima scansione reale.
nano /usr/local/maldetect/conf.maldet
Queste sono le impostazioni che contano di più per un rilevamento e una pulizia affidabili:
# Enable Email Alerting email_alert="1" # Email Address in which you want to receive scan reports email_addr="you@domain.com" # Use with ClamAV scan_clamscan="1" # Enable scanning for root-owned files. Set 1 to disable. scan_ignore_root="0" # Move threats to quarantine quarantine_hits="1" # Clean string based malware injections quarantine_clean="1" # Suspend user if malware found. quarantine_suspend_user="1" # Minimum userid value that be suspended quarantine_suspend_user_minuid="500"
Preferisci usare LMD da solo? Salta pure la prossima sezione.
Aggiungere ClamAV
LMD diventa sensibilmente più rapido su grandi insiemi di file quando ClamAV è disponibile: affiancarli è quindi una buona scelta predefinita. ClamAV è un motore antivirus open source che riconosce virus, trojan e altri file ostili.
È nel repository di base, quindi apt gestisce tutto.
apt-get -y install clamav clamav-daemon clamdscan
LMD rileva e abilita automaticamente l'integrazione con ClamAV.
Eseguire una scansione di test
La firma di test EICAR è il modo standard per dimostrare che uno scanner funziona senza maneggiare malware reale.
cd /tmp wget https://www.eicar.org/download/eicar_com.zip wget https://www.eicar.org/download/eicarcom2.zip
Ora scansiona la directory.
maldet -a /tmp
Output:
Linux Malware Detect v1.6.2 (C) 2002-2017, R-fx Networks <proj@rfxn.com> (C) 2017, Ryan MacDonald <ryan@rfxn.com> This program may be freely redistributed under the terms of the GNU GPL v2 maldet(4209): {scan} signatures loaded: 15218 (12485 MD5 | 1954 HEX | 779 YARA | 0 USER) maldet(4209): {scan} building file list for /tmp, this might take awhile... maldet(4209): {scan} setting nice scheduler priorities for all operations: cpunice 19 , ionice 6 maldet(4209): {scan} file list completed in 0s, found 4 files... maldet(4209): {scan} found clamav binary at /usr/bin/clamscan, using clamav scanner engine... maldet(4209): {scan} scan of /tmp (4 files) in progress... maldet(4209): {scan} processing scan results for hits: 2 hits 0 cleaned maldet(4209): {scan} scan completed on /tmp: files 4, malware hits 2, cleaned hits 0, time 12s maldet(4209): {scan} scan report saved, to view run: maldet --report 171026-1103.4209
Nota la riga che conferma l'uso di ClamAV come motore di scansione e i due hit rilevati.
Leggere un report di scansione
I report sono conservati in /usr/local/maldetect/sess/. Passa lo SCAN ID a maldet per il dettaglio completo.
maldet --report 171026-1103.4209
Output:
HOST: lmd SCAN ID: 171026-1103.4209 STARTED: Oct 26 2017 11:03:16 +0000 COMPLETED: Oct 26 2017 11:03:28 +0000 ELAPSED: 12s [find: 0s] PATH: /tmp TOTAL FILES: 4 TOTAL HITS: 2 TOTAL CLEANED: 0 FILE HIT LIST: {HEX}EICAR.TEST.10 : /tmp/eicar_com.zip => /usr/local/maldetect/quarantine/eicar_com.zip.296395948 {HEX}EICAR.TEST.10 : /tmp/eicarcom2.zip => /usr/local/maldetect/quarantine/eicarcom2.zip.418410660 =============================================== Linux Malware Detect v1.6.2 < proj@rfxn.com >
Mantenere LMD aggiornato
Aggiorna il programma vero e proprio:
maldet -d
Aggiorna solo il database delle firme:
maldet -u
Fatto.