PDA

Afficher la version complète : chkrootkit : lancement régulier, rapport, etc...



ChrisdR
26/12/2007, 21h44
Comment lancer régulièrement chkrootkit avec un petit script kivabien , dans /etc/cron.daily , par exemple.... ?
Et comment le faire pour qu'il rapporte sous forme de mail tout anomalie repérée ???
Merci de vos réponses.

thveillon
26/12/2007, 23h49
Et bien, le "script qui va bien" existe déjà, il est installé en même temps que chkrootkit ou rkhunter dans /etc/cron.daily ou /etc/cron.weekly , pour savoir exactement où en fonction de la distribution il suffit d'aller voir les fichiers installés par chkrootkit ou rkhunter dans le gestionnaire de paquet (Yast ou Smart).

Dans ces fichiers on peu tchanger la fréquence, le type de recherche, la priorité (nice) et le type "d'output" : c'est Sendmail par défaut vers un compte local (root ou user), mais ça peut être n'importe quoi, comme une console virtuelle tty8 par exemple.

ChrisdR
27/12/2007, 10h00
Eh bien, si il est vrai que rkhunter comporte dans son rpm un script /etc/cron.daily/suse.de-rkhunter, qui permet son lancement quotidien, chkrootkit n'est pas livré avec un script du même genre (rpm -ql chkrootkit) . C'est pour ça, d'ailleurs, que je posais la question.

thveillon
28/12/2007, 02h01
OUUUPS, désolé, sur ma Debian il est "livré" avec, c'est donc un raffinement suse qui m'avait échappé.

Pour me faire pardonner un exemple de script cron tiré de la FAQ de l'auteur


Can I run chkrootkit from********cron?**************** Yes.**For example, to run chkrootkit every day at 3am********and mail the output to root:********

**********0****** 3****** ******* ******* ******* (cd /path/to/chkrootkit; ./chkrootkit 2>&1 | mail -s "chkrootkit output" root)

Et un autre customisé, version quotidienne et log des éventuels warning


#!/bin/sh -e

CHKROOTKIT=/usr/sbin/chkrootkit
CF=/etc/chkrootkit.conf
LOG_DIR=/var/cache/chkrootkit

if [ ! -x $CHKROOTKIT ]; then
**exit 0
fi

if [ -f $CF ]; then
****. $CF
fi

if [ "$RUN_DAILY" = "true" ]; then
****if [ "$DIFF_MODE" = "true" ]; then
********$CHKROOTKIT $RUN_DAILY_OPTS > $LOG_DIR/log.new 2>&1
********if [ ! -f $LOG_DIR/log.old ] \
********** || ! diff -q $LOG_DIR/log.old $LOG_DIR/log.new > /dev/null 2>&1; then
************cat $LOG_DIR/log.new
********fi
********mv $LOG_DIR/log.new $LOG_DIR/log.old
****else
********$CHKROOTKIT $RUN_DAILY_OPTS
****fi
fi

Voilà voilà, encore tout désolé de la mauvaise info...

ChrisdR
28/12/2007, 22h47
Merci, je vais tenter ça quand j'ai le temps et je rapporte les résultats dès que je les ai.

ChrisdR
31/12/2007, 14h38
Je me suis fait un petit script dans /etc/cron.daily/chkrootkit :

#!/bin/sh
chkrootkit 2>&1 | mail -s "chkrootkit output" root

Et ça m'envoie un mail quotidien qui contient :

Checking `amd'... not found
Checking `basename'... not infected
Checking `biff'... not found
Checking `chfn'... not infected
Checking `chsh'... not infected
Checking `cron'... not infected
Checking `crontab'... 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 infected
Checking `grep'... not infected
Checking `hdparm'... not infected
Checking `su'... not infected
Checking `ifconfig'... not infected
Checking `inetd'... not tested
Checking `inetdconf'... not found
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 infected
Checking `netstat'... not infected
Checking `named'... not found
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 tested
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 infected
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...=20
/usr/lib/perl5/5.8.8/i586-linux-thread-multi/.packlist /usr/lib/perl5/v=
endor_perl/5.8.8/i586-linux-thread-multi/auto/IO/Zlib/.packlist /usr/li=
b/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/IO/Multiplex/.pa=
cklist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/IO=
/Compress/Base/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-th=
read-multi/auto/IO/Compress/Zlib/.packlist /usr/lib/perl5/vendor_perl/5=
.8.8/i586-linux-thread-multi/auto/IO/Socket/SSL/.packlist /usr/lib/perl=
5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/IO/Stringy/.packlist /=
usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/DBD/SQLite=
/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/aut=
o/DBI/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-mult=
i/auto/CVT/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread=
-multi/auto/LWP/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-t=
hread-multi/auto/Net/IP/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586=
-linux-thread-multi/auto/Net/DNS/.packlist /usr/lib/perl5/vendor_perl/5=
.8.8/i586-linux-thread-multi/auto/Net/Daemon/.packlist /usr/lib/perl5/v=
endor_perl/5.8.8/i586-linux-thread-multi/auto/Net/SSLeay/.packlist /usr=
/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Net/Server/.p=
acklist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/R=
PC/XML/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-mul=
ti/auto/RPC/PlServer/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-li=
nux-thread-multi/auto/SPP/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i5=
86-linux-thread-multi/auto/SaX/.packlist /usr/lib/perl5/vendor_perl/5.8=
.8/i586-linux-thread-multi/auto/URI/.packlist /usr/lib/perl5/vendor_per=
l/5.8.8/i586-linux-thread-multi/auto/XML/Bare/.packlist /usr/lib/perl5/=
vendor_perl/5.8.8/i586-linux-thread-multi/auto/XML/XPath/.packlist /usr=
/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/XML/Parser/.p=
acklist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/X=
ML/Writer/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-=
multi/auto/ycp/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-th=
read-multi/auto/DCOP/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-li=
nux-thread-multi/auto/Date/Manip/.packlist /usr/lib/perl5/vendor_perl/5=
.8.8/i586-linux-thread-multi/auto/HTML/Parser/.packlist /usr/lib/perl5/=
vendor_perl/5.8.8/i586-linux-thread-multi/auto/HTML/Tagset/.packlist /u=
sr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/File/Tail/.=
packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/=
Mail/SpamAssassin/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux=
-thread-multi/auto/Mail/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586=
-linux-thread-multi/auto/PLog/.packlist /usr/lib/perl5/vendor_perl/5.8.=
8/i586-linux-thread-multi/auto/RRDp/.packlist /usr/lib/perl5/vendor_per=
l/5.8.8/i586-linux-thread-multi/auto/RRDs/.packlist /usr/lib/perl5/vend=
or_perl/5.8.8/i586-linux-thread-multi/auto/X500/DN/.packlist /usr/lib/p=
erl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Term/ReadKey/.packl=
ist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Term/=
ReadLine/Gnu/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thre=
ad-multi/auto/Unix/Syslog/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i5=
86-linux-thread-multi/auto/Config/Crontab/.packlist /usr/lib/perl5/vend=
or_perl/5.8.8/i586-linux-thread-multi/auto/Digest/MD4/.packlist /usr/li=
b/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Digest/HMAC/.pac=
klist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Dig=
est/SHA1/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-m=
ulti/auto/FBSet/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-t=
hread-multi/auto/Crypt/SSLeay/.packlist /usr/lib/perl5/vendor_perl/5.8.=
8/i586-linux-thread-multi/auto/Crypt/SmbHash/.packlist /usr/lib/perl5/v=
endor_perl/5.8.8/i586-linux-thread-multi/auto/Image/ExifTool/.packlist =
/usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/SDL_perl/=
.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto=
/Parse/RecDescent/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux=
-thread-multi/auto/XFree/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i58=
6-linux-thread-multi/auto/Archive/Tar/.packlist /usr/lib/perl5/vendor_p=
erl/5.8.8/i586-linux-thread-multi/auto/Archive/Zip/.packlist /usr/lib/p=
erl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Locale/gettext/.pac=
klist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Com=
press/Raw/Zlib/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-th=
read-multi/auto/Compress/Zlib/.packlist /usr/lib/perl5/vendor_perl/5.8.=
8/i586-linux-thread-multi/auto/Pidgin/.packlist /usr/lib/perl5/vendor_p=
erl/5.8.8/i586-linux-thread-multi/auto/Purple/.packlist /usr/lib/perl5/=
vendor_perl/5.8.8/i586-linux-thread-multi/auto/HTML-TableExtract/.packl=
ist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Conve=
rt/TNEF/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-mu=
lti/auto/Convert/UUlib/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-=
linux-thread-multi/auto/MIME-tools/.packlist /usr/lib/perl5/vendor_perl=
/5.8.8/i586-linux-thread-multi/auto/TimeDate/.packlist /usr/lib/perl5/v=
endor_perl/5.8.8/i586-linux-thread-multi/auto/BerkeleyDB/.packlist /usr=
/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/auto/Finance/Quote=
/.packlist /usr/lib/perl5/vendor_perl/5.8.8/i586-linux-thread-multi/aut=
o/Bootloader/.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 Madalin rootkit default files... nothing found
Searching for Fu rootkit default files... nothing found
Searching for ESRK rootkit default files... nothing found
Searching for rootedoor... nothing found
Searching for ENYELKM rootkit default files... nothing found
Searching for anomalies in shell history files... Warning: `' is linked=
to another file
Checking `asp'... not infected
Checking `bindshell'... not infected
Checking `lkm'... chkproc: nothing detected
Checking `rexedcs'... not found
Checking `sniffer'... eth0: not promisc and no PF_PACKET sockets
Checking `w55808'... not infected
Checking `wted'... chkwtmp: nothing deleted
Checking `scalper'... not infected
Checking `slapper'... not infected
Checking `z2'... chklastlog: nothing deleted
Checking `chkutmp'...**The tty of the following user process(es) were n=
ot found
in /var/run/utmp !
! RUID**********PID TTY****CMD
! root******** 3026 tty7** /usr/bin/Xorg -br -nolisten tcp :0 vt7 -auth=
/var/lib/xdm/authdir/authfiles/A:0-pwFPM5
chkutmp: nothing deleted

Les lignes :

Searching for anomalies in shell history files... Warning: `' is linked=
to another file
sont inquiétantes mais je ne sais pas comment les interprêter... ?