如何在 Ubuntu 18.04/Centos 7 上安裝 CHKROOTKIT

在本教程中,我將解釋如何在我們最新的 Ubuntu 18.04 和 CentOS 7 系統上安裝 chkrootkit。 chkrootkit 是一種常見的安全掃描程序,可幫助管理員搜索本地系統是否有感染“rootkit”的跡象。 Rootkit 可以被視為一種惡意程序,它可以在計算機系統用戶不知情的情況下控制計算機系統。 這意味著 rootkit 能夠在目標機器上執行文件和更改系統配置,並且只有作為 Linux 機器的超級用戶才能完成更多操作。

請記住,您可以使用 chkrootkit 來查找與 rootkit 關聯的文件和進程,但您不能 100% 確定找到並刪除了所有的 rootkit。 您可以通過確保所有應用程序和軟件都是最新的,並針對所有已知漏洞對系統進行修補,從而保護您的系統免受 rootkit 的侵害。

在 Ubuntu 18.04 上安裝 chkrootkit

在 Ubuntu 18.04 服務器上安裝 chkrootkit 要容易得多,因為它在 Ubuntu 存儲庫包本身中可用。 我們可以通過運行以下命令來安裝它:

# apt-get update
# apt install chkrootkit
# chkrootkit -V
chkrootkit version 0.52

我們只需要確保我們有在那裡使用 chkrootkit 的 root 權限。

啟用自動服務器掃描

Ubuntu 存儲庫中的 hkrootkit 包帶有 crontab 配置。 此 crontab 計劃每天運行。 要啟用每日檢查,您可以打開 /etc/chkrootkit.conf 並修改此文件,如下所示:

替換第一行:

RUN_DAILY=”假”

RUN_DAILY=”真”

在 CentOS 7.5 上安裝 chkrootkit

此工具在 CentOS 存儲庫軟件包中不可用。 因此,我們需要下載最新的可用版本並進行配置。

1. 安裝 C/C++ 編譯器和庫

Chkrootkit 有 C 程序。 在編譯chkrootkit源碼包之前需要安裝GCC(C和C++編譯器)和glibc-static包,以避免在編譯過程中出現任何錯誤。

#yum update
#yum install wget gcc-c++ glibc-static

2.下載最新可用的chkrootkit

如前所述,您可以從以下位置下載最新的 chkrootkit 下載 chkrootkit 網站.

# wget -c ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz

3.下載包md5哈希文件

接下來,我們可以下載與 chkrootkit 下載相關的 md5 哈希文件,以驗證它是否未被篡改或損壞。

# wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.md5
# md5sum -c chkrootkit.md5
chkrootkit.tar.gz: OK

4.解壓壓縮文件並安裝

現在您可以移動到下載的文件夾並將其解壓縮。 您可以將其解壓縮到同一路徑並將 chkrootkit 二進製文件移動到 /usr/bin 文件夾,或者您可以按照此處所述將解壓縮的內容移動到該名稱的單獨文件夾中並安裝它。 無論哪種方式都會起作用。

#tar –xzf chkrootkit.tar.gz
#mkdir /usr/local/chkrootkit
#mv chkrootkit-0.52/* /usr/local/chkrootkit
#cd /usr/local/chkrootkit
#make sense

現在,您可以運行 chkrootkit 來掃描服務器。

/usr/local/chkrootkit/chkrootkit

5. 啟用自動服務器掃描

您可以添加用於自動運行 chkrootkit 的 cron 條目並將掃描報告發送到您的郵件地址。 創建以下條目並將其添加到“/etc/cron.daily/chkrootkit.sh”

#!/bin/sh
 (
 /usr/local/chkrootkit/chkrootkit
 ) | /bin/mail -s 'CHROOTKIT Daily Run (ServerName)' [email protected]

您還可以在系統上安裝其他安全掃描程序,例如 rkhunter,以提高安全性。

了解 chkrootkit

Chkrootkit 是一個執行 rootkit 檢查的工具。 最重要的是,它包含一個名為 chkrootkit 的 shell 腳本,它會掃描所有系統二進製文件以查找任何 rootkit 修改。 此外,它還包含幾個 C 程序,它們執行各種安全檢查,如下所示:

ifpromisc.c:檢查網絡接口是否處於混雜模式。

chklastlog.c:檢查 lastlog 刪除。

chkwtmp.c:檢查 wtmp 刪除。

chkproc.c:這會檢查 LKM 木馬的跡象。

chkdirs.c:這會檢查 LKM 木馬的跡象。

strings.c:這會執行快速且臟的字符串替換。

chkutmp.c:檢查 utmp 刪除。

用法

運行此工具的最簡單方法是以 root 身份使用命令“chkrootkit”。 這將執行所有任務。 但是如果你想在運行這個命令時選擇任何特定的選項,你有如下列出的各種選項:

-h: Print a short help message and exit.

# 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 exclude known false positive files/dirs, quoted,
space separated, READ WARNING IN README
-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

-V: Print version information and exit.

# chkrootkit -V
chkrootkit version 0.52

-l: Print available tests.

# chkrootkit -l
/usr/sbin/chkrootkit: tests: aliens asp bindshell lkm rexedcs sniffer w55808 wted scalper slapper z2 chkutmp OSX_RSPLUG amd basename biff chfn chsh cron crontab date du dirname echo egrep env find fingerd gpm grep hdparm su ifconfig inetd inetdconf identd init killall ldsopreload login ls lsof mail mingetty netstat named passwd pidof pop2 pop3 ps pstree rpcinfo rlogind rshd slogin sendmail sshd syslogd tar tcpd tcpdump top telnetd timed traceroute vdir w write

-d: Enter debug mode.
-x: Enter expert mode.
-e: Exclude known false positive files/dirs, quoted, space separated.

-q: Enter quiet mode. In this mode only output messages with `infected' status are shown.

# chkrootkit -q
Checking `tcpd'... INFECTED

/lib/modules/4.15.0-20-generic/vdso/.build-id /lib/modules/4.15.0-23-generic/vdso/.build-id
/lib/modules/4.15.0-20-generic/vdso/.build-id /lib/modules/4.15.0-23-generic/vdso/.build-id
not tested
INFECTED PORTS: ( 465)
eth0: PACKET SNIFFER(/lib/systemd/systemd-networkd[536])
not tested

-r dir: Use dir as the root directory.

# chkrootkit -r /mnt/ ; This will check all files under this specified directory.

-p dir1:dir2:dirN:您可以使用此選項添加更多以冒號分隔的二進制路徑。

# ./chkrootkit -p /cdrom/bin:/floppy/mybin

-n: skip NFS mounted dirs

結論

如今,我們的系統通過互聯網連接到各種網絡,因此非常需要監控我們的服務器免受任何可疑攻擊或入侵的重要性。 Chkrootkit 是一個簡單的工具,它執行定期安全檢查並保護我們的服務器免受任何類型的入侵。 希望您喜歡閱讀,請在評論部分留下您的建議。