Difendersi con rkhunter
by admin on Feb.14, 2010, under Hacking, Linux, Sicurezza, Tools
Rkhunter opera in maniera abbastanza simile a chkrootkit in quanto analizza un sistema alla ricerca di rootkits, tuttavia esso controlla anche altri tipi di exploits.
Con ciò non intendo affatto affermare che rkhunter sia migliore rispetto a chkrootkit.
A parer mio, anzi dovrebbero essere entrambi utilizzati per un reciproco completamento.
Rkhunter è in grado di eseguire controlli come:
- Confronto hash MD5
- Controllo di files normalmente usati da rootkits
- Errate file permissions per binari
- Ricerca di stringhe sospette nei moduli LKM e KLD
- Ricerca di hidden files
- Scansione opzionale di files plaintext e binari
Rkhunter utilizza a sua volta il package Unhide, un “forensic” tool in grado di rilevare processi e porte TCP/UDP nascoste da rootkits, Linux kernel modules o altre tecniche. Esso si avvale infatti di altre due utilities: unhide e unhide-tcp.
Il primo, unhide, rileva processi nascosti utilizzando tre diverse tecniche:
- confrontando il contenuto di /proc e l’ output di /bin/ps
- confrontando le informazioni ottenute tramite /bin/ps con quelle ottenute tramite system calls (syscall scanning)
- full scan del process ID space (PIDs bruteforcing)
Il secondo, unhide-tcp identifica le eventuali porte TCP/UDP in ascolto non rilevate da /bin/netstat, tramite brute forcing di tutte le porte TCP/UDP possibili.
Lanciato con la opzióne -c rkhunter effettua un controllo completo del sistema:
# rkhunter -c
[ Rootkit Hunter version 1.3.4 ]
Checking system commands...
Performing 'strings' command checks
Checking 'strings' command [ OK ]
Performing 'shared libraries' checks
Checking for preloading variables [ None found ]
Checking for preload file [ Not found ]
Checking LD_LIBRARY_PATH variable [ Not found ]
Performing file properties checks
Checking for prerequisites [ OK ]
/bin/bash [ OK ]
/bin/cat [ OK ]
/bin/chmod [ OK ]
/bin/chown [ OK ]
/bin/cp [ OK ]
/bin/date [ OK ]
/bin/df [ OK ]
/bin/dmesg [ OK ]
/bin/echo [ OK ]
/bin/ed [ OK ]
/bin/egrep [ OK ]
/bin/fgrep [ OK ]
/bin/fuser [ OK ]
/bin/grep [ OK ]
/bin/ip [ OK ]
/bin/kill [ OK ]
/bin/less [ OK ]
/bin/login [ OK ]
/bin/ls [ OK ]
/bin/lsmod [ OK ]
/bin/mktemp [ OK ]
/bin/more [ OK ]
/bin/mount [ OK ]
/bin/mv [ OK ]
/bin/netstat [ OK ]
/bin/ps [ OK ]
/bin/pwd [ OK ]
[...]
È possibile personalizare i test da effettuare selezionandoli fra quelli disponibili:
# rkhunter --list
Available test names:
additional_rkts all apps attributes avail_modules deleted_files
filesystem group_accounts group_changes hashes hidden_procs immutable
known_rkts loaded_modules local_host malware network none
os_specific other_malware packet_cap_apps passwd_changes ports possible_rkt_files
possible_rkts possible_rkt_strings promisc properties rootkits running_procs
scripts shared_libs shared_libs_path startup_files startup_malware strings
suspscan system_commands system_configs trojans
Grouped test names:
additional_rkts => possible_rkt_files possible_rkt_strings
group_accounts => group_changes passwd_changes
local_host => filesystem group_changes passwd_changes startup_malware system_configs
malware => deleted_files hidden_procs other_malware running_procs suspscan
network => packet_cap_apps ports promisc
os_specific => avail_modules loaded_modules
possible_rkts => possible_rkt_files possible_rkt_strings
properties => attributes hashes immutable scripts
rootkits => avail_modules deleted_files hidden_procs known_rkts loaded_modules other_malware possible_rkt_files possible_rkt_strings running_procs suspscan trojans
shared_libs => shared_libs_path
startup_files => startup_malware
system_commands => attributes hashes immutable scripts shared_libs_path strings
Available languages:
cn en zh zh.utf8
Rootkits checked for:
55808 Trojan - Variant A, AjaKit, Ambient (ark), Apache Worm, aPa Kit, Balaur,
BeastKit, beX2, BOBKit, CiNIK Worm (Slapper.B variant), Danny-Boy's Abuse Kit, Devil,
Dica, Dreams, Duarawkz, Enye LKM, Flea Linux, FreeBSD,
Fuck`it, GasKit, Heroin LKM, HjC Kit, ignoKit, ImperalsS-FBRK,
IntoXonia-NG, Irix, Kitko, Knark, Li0n Worm, Lockit / LJK2,
Mood-NT, MRK, Ni0, Ohhara, Optic Kit (Tux), Oz,
Phalanx, Phalanx2, Portacelo, R3dstorm Toolkit, RH-Sharpe's, RSHA's,
Scalper Worm, Shutdown, SHV4, SHV5, Sin, SInAR,
Slapper, Sneakin, Suckit, SunOS / NSDAP, SunOS Rootkit, Superkit,
T0rn, TBD (Telnet BackDoor), TeLeKiT, Trojanit Kit, Tuxtendo, URK,
Vampire, VcKit, Volc, X-Org SunOS, zaRwT.KiT
Ad esempio:
# rkhunter --enable hidden_procs,loaded_modules
[ Rootkit Hunter version 1.3.4 ]
Checking for rootkits...
Performing malware checks
Checking for hidden processes [ None found ]
Performing Linux specific checks
Checking loaded kernel modules [ OK ]
[Press to continue]
System checks summary
=====================
File properties checks...
All checks skipped
Rootkit checks...
Rootkits checked : 0
Possible rootkits: 0
Applications checks...
All checks skipped
The system checks took: 1 minute and 13 seconds
All results have been written to the logfile (/var/log/rkhunter.log)
No warnings were found while checking the system.
[...]
Come per altri tool di controllo, è una buona idea attivare rkhunter nell’ambito di un cron job come il seguente, che utilizza uno script inserito nella directory /etc/cron.daily, in modo da essere lanciato automaticamente ogni giorno alla stessa ora.
#!/bin/sh
( /usr/local/bin/rkhunter --cronjob --update --rwo && echo "" )
| /bin/mail -s "Rkhunter giornaliero su `uname -n`" root
exit 0


