« LINUX:Chkrootkit » : différence entre les versions

De WIKI sur Linux (ADB)
Aller à la navigation Aller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
 
Ligne 31 : Ligne 31 :
  # détection de RootKits
  # détection de RootKits
  CHEMIN="/manager/chkrootkit"
  CHEMIN="/manager/chkrootkit"
  cd $CHEMIN
# exécution
# exxécution
EXECUTABLE=`ls /usr/lib64 | grep chkrootkit`
  cd /usr/lib64/$EXECUTABLE
  /usr/bin/chkrootkit > $CHEMIN/chkrootkit.lis
  /usr/bin/chkrootkit > $CHEMIN/chkrootkit.lis
  # repérage
  # repérage
cd $CHEMIN
  /usr/bin/grep "infect" $CHEMIN/chkrootkit.lis > $CHEMIN/chkrootkit.temp
  /usr/bin/grep "infect" $CHEMIN/chkrootkit.lis > $CHEMIN/chkrootkit.temp
  /usr/bin/grep -v "not " $CHEMIN/chkrootkit.temp > $CHEMIN/chkrootkit.tmp1
  /usr/bin/grep -v "not " $CHEMIN/chkrootkit.temp > $CHEMIN/chkrootkit.tmp1
Ligne 76 : Ligne 78 :
  10 * * * * root /manager/chkrootkit/chkrootkit.test.bat > /manager/chkrootkit/chkrootkit.log
  10 * * * * root /manager/chkrootkit/chkrootkit.test.bat > /manager/chkrootkit/chkrootkit.log
----
----
Dans cet exemple, on l'exécute toutes les heures mais on pourrait ne l'exécuter qu'une fois par jour
Dans cet exemple, on l'exécute toutes les heures mais on pourrait ne l'exécuter qu'une fois par jour.
.





Dernière version du 31 août 2025 à 13:38


retour au menu pour contrer les attaques


But

"chkrootkit" est un autre programme Unix qui permet de détecter les rootkits.


Installation

Pour installer le logiciel, exécutez la commande:

dnf install chkrootkit


Utilisation

Son utilisation est simple.

  • pour un affichage simple:
chkrootkit
  • pour un affichage détaillé:
chkrootkit -x

Si un problème est rencontré, le message affiché présente de mot "INFEXTED".


Automatisation

Pour automatiser cette recherche, nous proposons une procédure à activer régulièrement via le CRON d'Unix.


Procédure

Voici le script nommé "chkrootkit.test.bat" placé dans le répertoire "/manager/chkrootkit":


#!/bin/bash
# détection de RootKits
CHEMIN="/manager/chkrootkit"
# exécution
EXECUTABLE=`ls /usr/lib64 | grep chkrootkit`
cd /usr/lib64/$EXECUTABLE
/usr/bin/chkrootkit > $CHEMIN/chkrootkit.lis
# repérage
cd $CHEMIN
/usr/bin/grep "infect" $CHEMIN/chkrootkit.lis > $CHEMIN/chkrootkit.temp
/usr/bin/grep -v "not " $CHEMIN/chkrootkit.temp > $CHEMIN/chkrootkit.tmp1
/usr/bin/grep "INFECTED" $CHEMIN/chkrootkit.lis > $CHEMIN/chkrootkit.tmp2
/usr/bin/grep "Vulnerable" $CHEMIN/chkrootkit.lis > $CHEMIN/chkrootkit.tmp3
# test
LISTE=`/usr/bin/ls $CHEMIN/*.tmp*`
TEST=0
for I in $LISTE
do
 if [ -s $I ]; then
  TEST=1
 fi
done
# nettoyage
/usr/bin/rm -f ${CHEMIN}/*.tmp*
/usr/bin/rm -f ${CHEMIN}/*.temp
# si infecté, envoi d'un mail
if [ "$TEST" != "0" ]; then
  echo -n "Serveur - "             >  ${CHEMIN}/sysmail.log
  /usr/bin/hostname                >> ${CHEMIN}/sysmail.log
  echo " "                         >> ${CHEMIN}/sysmail.log
  date                             >> ${CHEMIN}/sysmail.log
  echo " "                         >> ${CHEMIN}/sysmail.log
  echo "Machine infectee (Chkrootkit)"  >> ${CHEMIN}/sysmail.log
  echo " "                         >> ${CHEMIN}/sysmail.log 
  /bin/mail -s "Problemes de rootkit" root < ${CHEMIN}/sysmail.log
  /usr/bin/rm -f ${CHEMIN}/sysmail.log
fi

En cas de détection positive, un mail est envoyé à "root".

Il faut donner les privilèges d'exécution:

chmod 700 /manager/chkrootkit/chkrootkit.test.bat


CRON

Pour l'automatisation, on ajoute une ligne dans le fichier "/etc/crontab":


# Vérification de RootKits
10 * * * * root /manager/chkrootkit/chkrootkit.test.bat > /manager/chkrootkit/chkrootkit.log

Dans cet exemple, on l'exécute toutes les heures mais on pourrait ne l'exécuter qu'une fois par jour.




retour au menu pour contrer les attaques