Rkhunter significa "Rootkit Hunter" y es un escáner de vulnerabilidades gratuito y de código abierto para sistemas operativos Linux. Busca rootkits y otras posibles vulnerabilidades, incluidos archivos ocultos, permisos incorrectos establecidos en archivos binarios. , cadenas sospechosas en el kernel, etc. Compara los hashes SHA-1 de todos los archivos en su sistema local con los buenos hashes conocidos en una base de datos en línea. También verifica los comandos del sistema local, los archivos de inicio y las interfaces de red para escuchar servicios y aplicaciones. .
En este tutorial, explicaremos cómo instalar y usar Rkhunter en el servidor Debian 10.
Requisitos
- Un servidor que ejecuta Debian 10.
- Se configura una contraseña raíz en el servidor.
Instalar y configurar Rkhunter
De forma predeterminada, el paquete Rkhunter está disponible en el repositorio predeterminado de Debian 10. Puede instalarlo simplemente ejecutando el siguiente comando:
apt-get install rkhunter -y
Una vez que se complete la instalación, deberá configurar Rkhunter antes de escanear su sistema. Puede configurarlo editando el archivo /etc/rkhunter.conf.
nano /etc/rkhunter.conf
Cambie las siguientes líneas:
#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=""
Guarde y cierre el archivo cuando haya terminado. A continuación, verifique el Rkhunter por cualquier error de sintaxis de configuración con el siguiente comando:
rkhunter -C
Actualice Rkhunter y establezca la línea base de seguridad
A continuación, deberá actualizar el archivo de datos desde el espejo de Internet. Puede actualizarlo con el siguiente comando:
rkhunter --update
Deberías obtener el siguiente resultado:
[ 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 ]
A continuación, verifique la información de la versión de Rkhunter con el siguiente comando:
rkhunter --versioncheck
Deberías obtener el siguiente resultado:
[ Rootkit Hunter version 1.4.6 ] Checking rkhunter version... This version : 1.4.6 Latest version: 1.4.6
A continuación, establezca la línea base de seguridad con el siguiente comando:
rkhunter --propupd
Deberías obtener el siguiente resultado:
[ Rootkit Hunter version 1.4.6 ] File updated: searched for 180 files, found 140
Ejecutar prueba
En este punto, Rkhunter está instalado y configurado. Ahora, es hora de realizar el escaneo de seguridad contra su sistema. Lo haces ejecutando el siguiente comando:
rkhunter --check
Deberá presionar Enter para cada control de seguridad como se muestra a continuación:
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)
Puede usar la opción –sk para evitar presionar Enter y la opción –rwo para mostrar solo una advertencia como se muestra a continuación:
rkhunter --check --rwo --sk
Deberías obtener el siguiente resultado:
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
También puede verificar los registros de Rkhunter usando el siguiente comando:
tail -f /var/log/rkhunter.log
Programar escaneo regular con Cron
Se recomienda configurar Rkhunter para escanear su sistema regularmente. Puede configurarlo editando el archivo /etc/default/rkhunter:
nano /etc/default/rkhunter
Cambie las siguientes líneas:
#Perform security check daily CRON_DAILY_RUN="true" #Enable weekly database updates. CRON_DB_UPDATE="true" #Enable automatic database updates APT_AUTOGEN="true"
Guarde y cierre el archivo cuando haya terminado.
Conclusión
¡Felicidades! ha instalado y configurado con éxito Rkhunter en el servidor Debian 10. Ahora puede usar Rkhunter regularmente para proteger su servidor contra malware.