GNU/Linux >> Linux Esercitazione >  >> Debian

Come scansionare un server Debian per i rootkit con Rkhunter

Rkhunter sta per "Rootkit Hunter" è uno scanner di vulnerabilità gratuito e open source per i sistemi operativi Linux. Esegue la scansione dei rootkit e di altre possibili vulnerabilità inclusi file nascosti, autorizzazioni errate impostate sui binari , stringhe sospette nel kernel, ecc. Confronta gli hash SHA-1 di tutti i file nel tuo sistema locale con gli hash noti in un database online. Controlla anche i comandi del sistema locale, i file di avvio e le interfacce di rete per i servizi di ascolto e le applicazioni .

In questo tutorial spiegheremo come installare e utilizzare Rkhunter sul server Debian 10.

Prerequisiti

  • Un server che esegue Debian 10.
  • Sul server è configurata una password di root.

Installa e configura Rkhunter

Per impostazione predefinita, il pacchetto Rkhunter è disponibile nel repository predefinito di Debian 10. Puoi installarlo semplicemente eseguendo il seguente comando:

apt-get install rkhunter -y

Una volta completata l'installazione, dovrai configurare Rkhunter prima di scansionare il tuo sistema. Puoi configurarlo modificando il file /etc/rkhunter.conf.

nano /etc/rkhunter.conf

Modifica le seguenti righe:

#Enable the mirror checks.
UPDATE_MIRRORS=1

#Tells rkhunter to use any mirror.
MIRRORS_MODE=0

#Specify a command which rkhunter will use when downloading files from the Internet
WEB_CMD=""

Salva e chiudi il file quando hai finito. Quindi, verifica Rkhunter per qualsiasi errore di sintassi di configurazione con il seguente comando:

rkhunter -C

Aggiorna Rkhunter e imposta la base di sicurezza

Successivamente, dovrai aggiornare il file di dati dal mirror Internet. Puoi aggiornarlo con il seguente comando:

rkhunter --update

Dovresti ottenere il seguente output:

[ Rootkit Hunter version 1.4.6 ]

Checking rkhunter data files...
  Checking file mirrors.dat                                  [ Updated ]
  Checking file programs_bad.dat                             [ No update ]
  Checking file backdoorports.dat                            [ No update ]
  Checking file suspscan.dat                                 [ No update ]
  Checking file i18n/cn                                      [ Skipped ]
  Checking file i18n/de                                      [ Skipped ]
  Checking file i18n/en                                      [ No update ]
  Checking file i18n/tr                                      [ Skipped ]
  Checking file i18n/tr.utf8                                 [ Skipped ]
  Checking file i18n/zh                                      [ Skipped ]
  Checking file i18n/zh.utf8                                 [ Skipped ]
  Checking file i18n/ja                                      [ Skipped ]

Quindi, verifica le informazioni sulla versione di Rkhunter con il seguente comando:

rkhunter --versioncheck

Dovresti ottenere il seguente output:

[ Rootkit Hunter version 1.4.6 ]

Checking rkhunter version...
  This version  : 1.4.6
  Latest version: 1.4.6

Quindi, imposta la baseline di sicurezza con il seguente comando:

rkhunter --propupd

Dovresti ottenere il seguente output:

[ Rootkit Hunter version 1.4.6 ]
File updated: searched for 180 files, found 140

Esegui test di esecuzione

A questo punto, Rkhunter è installato e configurato. Ora è il momento di eseguire la scansione di sicurezza sul tuo sistema. Lo fai eseguendo il seguente comando:

rkhunter --check

Dovrai premere Invio per ogni controllo di sicurezza come mostrato di seguito:

System checks summary
=====================

File properties checks...
    Files checked: 140
    Suspect files: 3

Rootkit checks...
    Rootkits checked : 497
    Possible rootkits: 0

Applications checks...
    All checks skipped

The system checks took: 2 minutes and 10 seconds

All results have been written to the log file: /var/log/rkhunter.log

One or more warnings have been found while checking the system.
Please check the log file (/var/log/rkhunter.log)

È possibile utilizzare l'opzione –sk per evitare di premere Invio e l'opzione –rwo per visualizzare solo gli avvisi come mostrato di seguito:

rkhunter --check --rwo --sk

Dovresti ottenere il seguente output:

Warning: The command '/usr/bin/egrep' has been replaced by a script: /usr/bin/egrep: POSIX shell script, ASCII text executable
Warning: The command '/usr/bin/fgrep' has been replaced by a script: /usr/bin/fgrep: POSIX shell script, ASCII text executable
Warning: The command '/usr/bin/which' has been replaced by a script: /usr/bin/which: POSIX shell script, ASCII text executable
Warning: The SSH and rkhunter configuration options should be the same:
         SSH configuration option 'PermitRootLogin': yes
         Rkhunter configuration option 'ALLOW_SSH_ROOT_USER': no

Puoi anche controllare i log di Rkhunter usando il seguente comando:

tail -f /var/log/rkhunter.log

Programma scansione regolare con Cron

Si consiglia di configurare Rkhunter per eseguire regolarmente la scansione del sistema. Puoi configurarlo modificando il file /etc/default/rkhunter:

nano /etc/default/rkhunter

Modifica le seguenti righe:

#Perform security check daily
CRON_DAILY_RUN="true"

#Enable weekly database updates.
CRON_DB_UPDATE="true"

#Enable automatic database updates
APT_AUTOGEN="true"

Salva e chiudi il file quando hai finito.

Conclusione

Congratulazioni! hai installato e configurato con successo Rkhunter sul server Debian 10. Ora puoi utilizzare Rkhunter regolarmente per proteggere il tuo server dai malware.


Debian
  1. Come installare Vai su Debian 9

  2. Come faccio a scansionare il mio sistema Linux per rootkit, worm, trojan, ecc.?

  3. Come distribuire un server DNS dinamico con Docker su Debian 10

  4. Come installare HTTP Git Server con Nginx su Debian 11

  5. Come configurare un firewall con CSF su Debian 9

Come installare il server FTP vsftpd con TLS su Debian 10

Come configurare un server FTP sicuro su Debian 10 con Pure-FTPd

Come configurare il server di geocodifica OSM Nominatim su Debian 10

Come configurare LAMP con Debian 11

Come configurare Samba Server con Debian 11

Come installare Nginx con PHP-FPM su Debian 11