Sécurité système · 7 min read · Jan 30, 2026

Chkrootkit-Portsentry-Howto

Chkrootkit-Portsentry-Howto

Version 1.0
Auteur : Falko Timme

Ce document décrit comment installer chkrootkit et portsentry. Il devrait fonctionner (peut-être avec quelques modifications concernant les chemins, etc.) sur tous les systèmes d’exploitation *nix.

Chkrootkit “est un outil pour vérifier localement les signes d’un rootkit” (provenant de http://www.chkrootkit.org).

“Les outils Sentry fournissent des services de sécurité au niveau de l’hôte pour la plateforme Unix. PortSentry, Logcheck/LogSentry et HostSentry protègent contre les analyses de ports, automatisent l’audit des fichiers journaux et détectent l’activité de connexion suspecte de manière continue” (provenant de http://sourceforge.net/projects/sentrytools/).

Ce howto est destiné comme un guide pratique ; il ne couvre pas les bases théoriques. Elles sont traitées dans de nombreux autres documents sur le web.

Ce document est fourni sans garantie d’aucune sorte !

1 Obtenir les Sources

Nous avons besoin des logiciels suivants : chkrootkit, portsentry et logcheck. Nous allons installer le logiciel depuis le répertoire /tmp.

cd /tmp
wget –passive-ftp ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
wget http://heanet.dl.sourceforge.net/sourceforge/sentrytools/portsentry-1.2.tar.gz
wget http://heanet.dl.sourceforge.net/sourceforge/sentrytools/logcheck-1.1.1.tar.gz

2 Installer Chkrootkit

mv chkrootkit.tar.gz /usr/local/
cd /usr/local/
tar xvfz chkrootkit.tar.gz
ln -s chkrootkit-0.43/ chkrootkit (remplacez 0.43 par le bon numéro de version) cd chkrootkit/ make sense*

Vous trouverez maintenant le programme chkrootkit sous /usr/local/chkrootkit. Exécutez-le en tapant

cd /usr/local/chkrootkit/ && ./chkrootkit

Votre sortie ressemblera à quelque chose comme ceci :

| ROOTDIR is `/` Checking `amd`... not found Checking `basename`... not infected Checking `biff`... not infected Checking `chfn`... not infected Checking `chsh`... not infected Checking `cron`... not infected Checking `date`... not infected Checking `du`... not infected Checking `dirname`... not infected Checking `echo`... not infected Checking `egrep`... not infected Checking `env`... not infected Checking `find`... not infected Checking `fingerd`... not found Checking `gpm`... not found Checking `grep`... not infected Checking `hdparm`... not found Checking `su`... not infected Checking `ifconfig`... not infected Checking `inetd`... not infected Checking `inetdconf`... not infected Checking `identd`... not found Checking `init`... not infected Checking `killall`... not infected Checking `ldsopreload`... not infected Checking `login`... not infected Checking `ls`... not infected Checking `lsof`... not infected Checking `mail`... not infected Checking `mingetty`... not found Checking `netstat`... not infected Checking `named`... not infected Checking `passwd`... not infected Checking `pidof`... not infected Checking `pop2`... not found Checking `pop3`... not found Checking `ps`... not infected Checking `pstree`... not infected Checking `rpcinfo`... not infected Checking `rlogind`... not found Checking `rshd`... not found Checking `slogin`... not infected Checking `sendmail`... not infected Checking `sshd`... not infected Checking `syslogd`... not infected Checking `tar`... not infected Checking `tcpd`... not infected Checking `tcpdump`... not infected Checking `top`... not infected Checking `telnetd`... not found Checking `timed`... not found Checking `traceroute`... not found Checking `vdir`... not infected Checking `w`... not infected Checking `write`... not infected Checking `aliens`... no suspect files Searching for sniffer's logs, it may take a while... nothing found Searching for HiDrootkit's default dir... nothing found Searching for t0rn's default files and dirs... nothing found Searching for t0rn's v8 defaults... nothing found Searching for Lion Worm default files and dirs... nothing found Searching for RSHA's default files and dir... nothing found Searching for RH-Sharpe's default files... nothing found Searching for Ambient's rootkit (ark) default files and dirs... nothing found Searching for suspicious files and dirs, it may take a while... /usr/lib/perl/5.6.1/auto/Test/Harness/.packlist /usr/lib/perl/5.6.1/auto/DB_File/.packlist Searching for LPD Worm files and dirs... nothing found Searching for Ramen Worm files and dirs... nothing found Searching for Maniac files and dirs... nothing found Searching for RK17 files and dirs... nothing found Searching for Ducoci rootkit... nothing found Searching for Adore Worm... nothing found Searching for ShitC Worm... nothing found Searching for Omega Worm... nothing found Searching for Sadmind/IIS Worm... nothing found Searching for MonKit... nothing found Searching for Showtee... nothing found Searching for OpticKit... nothing found Searching for T.R.K... nothing found Searching for Mithra... nothing found Searching for OBSD rk v1... nothing found Searching for LOC rootkit ... nothing found Searching for Romanian rootkit ... nothing found Searching for Suckit rootkit ... nothing found Searching for Volc rootkit ... nothing found Searching for Gold2 rootkit ... nothing found Searching for TC2 Worm default files and dirs... nothing found Searching for Anonoying rootkit default files and dirs... nothing found Searching for ZK rootkit default files and dirs... nothing found Searching for ShKit rootkit default files and dirs... nothing found Searching for AjaKit rootkit default files and dirs... nothing found Searching for zaRwT rootkit default files and dirs... nothing found Searching for anomalies in shell history files... nothing found Checking `asp`... not infected Checking `bindshell`... not infected Checking `lkm`... nothing detected Checking `rexedcs`... not found Checking `sniffer`... eth0: not promisc and no PF_PACKET sockets eth0:0: not promisc and no PF_PACKET sockets eth0:1: not promisc and no PF_PACKET sockets eth0:2: not promisc and no PF_PACKET sockets eth0:3: not promisc and no PF_PACKET sockets eth0:4: not promisc and no PF_PACKET sockets Checking `w55808`... not infected Checking `wted`... nothing deleted Checking `scalper`... not infected Checking `slapper`... not infected Checking `z2`... nothing deleted |

Si un ver, un rootkit, etc. est trouvé, cela est indiqué par la chaîne INFECTED (en lettres majuscules).

Si vous souhaitez obtenir la sortie de chkrootkit une fois par jour par email à 3 heures du matin, vous pouvez mettre la ligne suivante dans le fichier cron de root (l’emplacement dépend de votre distribution ; sous Debian, il se trouve sous /var/spool/cron/crontabs/root ; vous pourriez également le trouver sous /var/spool/cron/tabs/root ou quelque chose de similaire) :

0 3 (cd /usr/local/chkrootkit; ./chkrootkit 2>&1 | mail -s “chkrootkit output” [email protected])*

Puis exécutez

chmod 600 /var/spool/cron/crontabs/root
/etc/init.d/cron restart

3 Installer Portsentry

cd /tmp
tar xvfz portsentry-1.2.tar.gz
cd portsentry_beta/
make linux
make install

Portsentry sera installé sous /usr/local/psionic/portsentry/.

Éditez /usr/local/psionic/portsentry/portsentry.conf et spécifiez les ports que vous souhaitez que portsentry protège :

| # Décommentez ceci si vous êtes vraiment pointilleux : #TCP_PORTS="1,7,9,11,15,70,79,80,109,110,111,119,138,139,143,512,513,514,515,540,635,1080,1524,2000,[...]" #UDP_PORTS="1,7,9,66,67,68,69,111,137,138,161,162,474,513,517,518,635,640,641,666,700,2049,31335,[...]" # # Utilisez ceci si vous voulez juste être au courant : TCP_PORTS="1,11,15,79,111,119,143,540,635,1080,1524,2000,5742,6667,12345,12346,20034,27665,31337,[...]" UDP_PORTS="1,7,9,69,161,162,513,635,640,641,700,37444,34555,31335,32770,32771,32772,32773,32774,[...]" # # Utilisez ceci pour juste les éléments de base #TCP_PORTS="1,11,15,110,111,143,540,635,1080,1524,2000,12345,12346,20034,32771,32772,32773,32774,[...]" #UDP_PORTS="1,7,9,69,161,162,513,640,700,32770,32771,32772,32773,32774,31337,54321" |

Il devrait s’agir de ports qui ne sont pas utilisés sur le système. Par exemple, si vous utilisez IMAP (port 143 TCP) sur le serveur, vous devez retirer 143 de la liste ci-dessus. Le reste de portsentry.conf est bien commenté, mais normalement les valeurs par défaut devraient fonctionner.

Maintenant, nous devons créer un script d’initialisation pour portsentry (/etc/init.d/portsentry). Nous allons exécuter portsentry en mode furtif avancé car c’est le moyen le plus puissant de détecter les analyses de ports :

| #!/bin/bash case "$1" in start) echo "Démarrage de Portsentry..." ps ax | grep -iw '/usr/local/psionic/portsentry/portsentry -atcp' | grep -iv 'grep' > /dev/null if [ $? != 0 ]; then /usr/local/psionic/portsentry/portsentry -atcp fi ps ax | grep -iw '/usr/local/psionic/portsentry/portsentry -audp' | grep -iv 'grep' > /dev/null if [ $? != 0 ]; then /usr/local/psionic/portsentry/portsentry -audp fi echo "Portsentry est maintenant en cours d'exécution !" ;; stop) echo "Arrêt de Portsentry..." array=(`ps ax | grep -iw '/usr/local/psionic/portsentry/portsentry' | grep -iv 'grep' \ | awk '{print $1}' | cut -f1 -d/ | tr ' ' ' '`) element_count=${#array[@]} index=0 while [ "$index" -lt "$element_count" ] do kill -9 ${array[$index]} let "index = $index + 1" done echo "Portsentry arrêté !" ;; restart) $0 stop && sleep 3 $0 start ;; *) echo "Usage: $0 {start|stop|restart}" exit 1 esac exit 0 |

chmod 755 /etc/init.d/portsentry

Pour démarrer portsentry au démarrage, faites ce qui suit :

ln -s /etc/init.d/ portsentry /etc/rc2.d/S20 portsentry
ln -s /etc/init.d/
portsentry /etc/rc3.d/S20 portsentry
ln -s /etc/init.d/
portsentry /etc/rc4.d/S20 portsentry
ln -s /etc/init.d/
portsentry /etc/rc5.d/S20 portsentry
ln -s /etc/init.d/
portsentry /etc/rc0.d/K20 portsentry
ln -s /etc/init.d/
portsentry /etc/rc1.d/K20 portsentry
ln -s /etc/init.d/
portsentry /etc/rc6.d/K20 portsentry*

Maintenant, nous démarrons portsentry :

/etc/init.d/portsentry start

Veuillez noter : Si vous exécutez portsentry, chkrootkit pourrait se plaindre d’un bindshell infecté :

Checking bindshell… INFECTED (PORTS: 31337)

C’est normal et il n’y a pas de quoi s’inquiéter.

4 Installer Logcheck

cd /tmp
tar xvfz logcheck-1.1.1.tar.gz
cd logcheck-1.1.1/systems/

Maintenant, changez la variable SYSADMIN dans logcheck.sh. SYSADMIN est la personne qui recevra la sortie de logcheck par email (cela peut être une adresse email ou un utilisateur sur le système où vous installez logcheck) :

| [...] # SECTION DE CONFIGURATION PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ucb:/usr/local/bin # Logcheck est pré-configuré pour fonctionner sur la plupart des systèmes de type BSD, cependant c'est # un programme plutôt basique et peut avoir besoin d'aide pour fonctionner sur d'autres # systèmes. Veuillez vérifier les chemins de commande suivants pour vous assurer qu'ils sont # corrects. # Personne à qui envoyer l'activité des journaux. [email protected] # Chemin complet vers le programme logtail. # Ce programme est requis pour exécuter ce script et est fourni avec le paquet. LOGTAIL=/usr/local/bin/logtail [...] |

cd ../../
mkdir -p /usr/local/etc/tmp
make

Cela installera logcheck sous /usr/local/etc.

Maintenant, nous devons créer un travail cron afin d’exécuter logcheck périodiquement. Éditez le fichier cron de root (par exemple /var/spool/cron/crontabs/root, voir section 2 “Installer Chkrootkit”) et entrez la ligne suivante :

0 3 /usr/local/etc/logcheck.sh*

Puis exécutez

chmod 600 /var/spool/cron/crontabs/root
/etc/init.d/cron restart

Cela invoquera logcheck une fois par jour à 3 heures du matin. Il vous informera maintenant des événements système inhabituels, des violations de sécurité, des attaques système, etc. Si votre système est exposé directement à Internet, vous remarquerez qu’il y a beaucoup d’activités malveillantes sur Internet, et vous comprendrez pourquoi la sécurité est très importante.

Liens

Chkrootkit : http://www.chkrootkit.org/

Portsentry : http://sourceforge.net/projects/sentrytools/

Emplacement original de ce document :

http://www.falkotimme.com/howtos/chkrootkit_portsentry/

Share: X/Twitter LinkedIn

Recevez de nouveaux articles dans votre boîte de réception.

Aucun spam. Désabonnez-vous à tout moment.