Rootkit是一個特殊的惡意軟體,它可隱藏自身以及指定的文件、進程、網路、鏈接、埠等信息。Rootkit可通過載入特殊的驅動修改系統內核,進而達到隱藏信息的目的。
Rootkit的三要素就是:隱藏、操縱、收集數據。不同的操作系統會有不同的Rootkit,Linux系統中的Rootkit就被稱為LinuxRootkit。
Rootkit具有隱身功能,無論靜止時作為文件存在,還是活動時作為進程存在,都不會被察覺,它可能永遠存在於計算機中。
無論是那種形式的Rootkit,都需要實現以下功能:
1,遠程指令執行
通過網路向Rootkit所駐留的系統發送指令,從而控制遠程主機;
2,信息收集
收集系統的活動信息、網路上其它主機的數據信息等;
3,文件隱藏
把目標主機上的特定文件隱藏起來,使其不能通過常規方法查看到,這樣就可以隱藏一部分系統被控制的痕迹;
4,進程隱藏
在控制目標主機或收集系統信息時會啟動相關的進程,通過Rootkit可以實現對進程的隱藏;
5,網路連接隱藏
將網路連接的埠信息隱藏,利用netstat等工具無法顯示隱藏的信息,這樣就可以隱秘地向遠端發送信息;
6,內核模塊隱藏
將Rootkit自身在系統中安裝的模塊隱藏起來,提高自身生存能力。
Chkrootkit是一種Linux後門入侵檢測工具,可以用來檢測rootkit後門的工具,rootkit常被入侵者用來入侵控制別人的電腦,危險性很強。而,Chkrootkit工具可以很好的檢測到rootkit程序。Chkrootkit運行環境為linux,可以直接通過ftp://chkrootkit.org/pub/seg/pac/chkrootkit.tar.gz地址來下載。
┌──(taiji㉿kali)-[~]
└─$ wget ftp://chkrootkit.org/pub/seg/pac/chkrootkit.tar.gz
--2023-02-10 15:15:31-- ftp://chkrootkit.org/pub/seg/pac/chkrootkit.tar.gz
=> 「chkrootkit.tar.gz」
正在解析主機 chkrootkit.org (chkrootkit.org)... 187.33.4.179
正在連接 chkrootkit.org (chkrootkit.org)|187.33.4.179|:21... 已連接。正在以 anonymous 登錄 ... 登錄成功!==> SYST ... 完成。 ==> PWD ... 完成。==> TYPE I ... 完成。 ==> CWD (1) /pub/seg/pac ... 完成。==> SIZE chkrootkit.tar.gz ... 41948
==> PASV ... 完成。 ==> RETR chkrootkit.tar.gz ... 完成。長度:41948 (41K) (非正式數據)
chkrootkit.tar.gz 100%[=========================================>] 40.96K 39.8KB/s 用時 1.0s
2023-02-10 15:15:43 (39.8 KB/s) - 「chkrootkit.tar.gz」 已保存 [41948]
隨後進行解壓縮:
┌──(taiji㉿kali)-[~]
└─$ tar zxvf chkrootkit.tar.gz
chkrootkit-0.57/ACKNOWLEDGMENTS
chkrootkit-0.57/check_wtmpx.c
chkrootkit-0.57/chkdirs.c
chkrootkit-0.57/chklastlog.c
chkrootkit-0.57/chkproc.c
chkrootkit-0.57/chkrootkit
chkrootkit-0.57/chkrootkit.lsm
chkrootkit-0.57/chkutmp.c
chkrootkit-0.57/chkwtmp.c
chkrootkit-0.57/COPYRIGHT
chkrootkit-0.57/ifpromisc.c
chkrootkit-0.57/Makefile
chkrootkit-0.57/README
chkrootkit-0.57/README.chklastlog
chkrootkit-0.57/README.chkwtmp
chkrootkit-0.57/strings.c
打開文件夾,輸入make命令進行編譯:
┌──(taiji㉿kali)-[~]
└─$ cd chkrootkit-*
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ make
cc -DHAVE_LASTLOG_H -o chklastlog chklastlog.c
chklastlog.c: In function 『main』:
chklastlog.c:112:9: warning: 『memcpy』 reading 127 bytes from a region of size 14 [-Wstringop-overread]
112 | memcpy(wtmpfile, WTMP_FILENAME, 127);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
chklastlog.c:113:9: warning: 『memcpy』 reading 127 bytes from a region of size 17 [-Wstringop-overread]
113 | memcpy(lastlogfile, LASTLOG_FILENAME, 127);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -DHAVE_LASTLOG_H -o chkwtmp chkwtmp.c
chkwtmp.c: In function 『main』:
chkwtmp.c:73:8: warning: 『memcpy』 reading 127 bytes from a region of size 14 [-Wstringop-overread]
73 | memcpy(wtmpfile, WTMP_FILENAME, 127);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc -DHAVE_LASTLOG_H -D_FILE_OFFSET_BITS=64 -o ifpromisc ifpromisc.c
cc -o chkproc chkproc.c
cc -o chkdirs chkdirs.c
cc -o check_wtmpx check_wtmpx.c
cc -static -o strings-static strings.c
cc -o chkutmp chkutmp.c
直接運行其chkrootkit可執行文件即可,它會對系統進行全面的rootkit檢測:
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ sudo ./chkrootkit
[sudo] taiji 的密碼:ROOTDIR is `/'
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
上面是chkrootkit基本用法,下面再來加深些印象,首先chkrootkit可通過h參數來查看基本的幫助信息,了解其他參數及用法,如下:
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ chkrootkit -h
Usage: /usr/sbin/chkrootkit [options] [test ...]
Options:
-h show this help and exit
-V show version information and exit
-l show available tests and exit
-d debug
-q quiet mode
-x expert mode
-e 'FILE1 FILE2' exclude files/dirs from results. Must be followed by a space-separated list of files/dirs.
Read /usr/share/doc/chkrootkit/README.FALSE-POSITIVES first.
-s REGEXP filter results of sniffer test through 'grep -Ev REGEXP' to exclude expected
PACKET_SNIFFERs. Read /usr/share/doc/chkrootkit/README.FALSE-POSITIVES first.
-r DIR use DIR as the root directory
-p DIR1:DIR2:DIRN path for the external commands used by chkrootkit
-n skip NFS mounted dirs
示例1:chkrootkit默認檢索整個系統,我們可以通過管道去搜索INFECTED(被感染)關鍵字,方便查看:
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ ./chkrootkit | grep INFECTED
我這裡是剛裝的新系統,chkrootkit不應該報結果,如果有報結果,就注意查看可執行文件。
示例2:Chkrootkit也可檢查系統命令是否受感染,例如ps、ls,如下
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ ./chkrootkit ps ls
./chkrootkit needs root privileges
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ sudo ./chkrootkit ps ls
ROOTDIR is `/'
Checking `ps'... not infected
Checking `ls'... not infected
示例3:chkrootkit可傳入sniffer參數來檢查網路介面是否處於混雜模式,混雜模式下的網路介面會接受所有經過自己的數據流,一般管理員調試或者黑客入侵搜集信息時會用到,而正常情況下網路介面都處於非混雜模式,即只接受目標地址是自己的數據流,wireshark抓包即混雜模式接受所有數據流。
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ ./chkrootkit sniffer
./chkrootkit needs root privileges
┌──(taiji㉿kali)-[~/chkrootkit-0.57]
└─$ sudo ./chkrootkit sniffer
ROOTDIR is `/'
Checking `sniffer'... eth0: PF_PACKET(/usr/sbin/NetworkManager, /usr/sbin/NetworkManager)