rkhunter(Rootkit獵手)安裝使用

一、rkhunter簡介:

1、中文名叫」Rootkit獵手」,

rkhunter是Linux系統平台下的一款開源入侵檢測工具,具有非常全面的掃描範圍,除了能夠檢測各種已知的rootkit特徵碼以外,還支持埠掃描、常用程序文件的變動情況檢查。

2、rootkit是什麼?

rootkit是Linux平台下最常見的一種木馬後門工具,它主要通過替換系統文件來達到入侵和和隱蔽的目的,這種木馬比普通木馬後門更加危險和隱蔽,普通的檢測工具和檢查手段很難發現這種木馬。rootkit攻擊能力極強,對系統的危害很大,它通過一套工具來建立後門和隱藏行跡,從而讓攻擊者保住許可權,以使它在任何時候都可以使用root 許可權登錄到系統。

3、rootkit主要有兩種類型:文件級別和內核級別。

文件級別的rootkit: 一般是通過程序漏洞或者系統漏洞進入系統後,通過修改系統的重要文件來達到隱藏自己的目的。在系統遭受rootkit攻擊後,合法的文件被木馬程序替代,變成了外殼程序,而其內部是隱藏著的後門程序。通常容易被rootkit替換的系統程序有login、ls、ps、ifconfig、du、find、netstat等。文件級別的rootkit,對系統維護很大,目前最有效的防禦方法是定期對系統重要文件的完整性進行檢查,如Tripwire、aide等。

內核級rootkit: 是比文件級rootkit更高級的一種入侵方式,它可以使攻擊者獲得對系統底層的完全控制權,此時攻擊者可以修改系統內核,進而截獲運行程序向內核提交的命令,並將其重定向到入侵者所選擇的程序並運行此程序。內核級rootkit主要依附在內核上,它並不對系統文件做任何修改。以防範為主。

二、在Linux系統中安裝rkhunter

1、下載rkhunter

wget http://jaist.dl.sourceforge.net/project/rkhunter/rkhunter/1.4.6/rkhunter-1.4.6.tar.gz

2、安裝rkhunter

sudo tar -zxf rkhunter-1.4.6.tar.gz 

cd rkhunter-1.4.6

sudo ./installer.sh --install

3、為基本系統程序建立校對樣本

taiji@taiji:~/rkhunter-1.4.6$ sudo rkhunter --propupd
[ Rootkit Hunter version 1.4.6 ]
File created: searched for 181 files, found 145

4、在線升級rkhunter

rkhunter是通過一個含有rootkit名字的資料庫來檢測系統的rootkits漏洞, 所以經常更新該資料庫非常重要, 你可以通過下面命令來更新該資料庫:

sudo rkhunter --update

三、rkunter使用

常用參數列表
參數 含義
-c, –check 必選參數,表示檢測當前系統
–configfile 使用特定配置文件
–cronjob 作為cron任務定期運行
–sk, –skip-keypress 自動完成所有檢測,跳過鍵盤輸入
–summary 顯示檢測結果的統計信息
–update 檢測更新內容
-V, –version 顯示版本信息
–versioncheck 檢測最新版本
–propupd [file | directory ] 建立樣本文件,建議安裝完系統就建立

1、運行rkhunter檢查系統,它主要執行下面一系列的測試:

  1. MD5校驗測試, 檢測任何文件是否改動.
  2. 檢測rootkits使用的二進位和系統工具文件.
  3. 檢測特洛伊木馬程序的特徵碼.
  4. 檢測大多常用程序的文件異常屬性.
  5. 執行一些系統相關的測試 – 因為rootkit hunter可支持多個系統平台.
  6. 掃描任何混雜模式下的介面和後門程序常用的埠.
  7. 檢測如/etc/rc.d/目錄下的所有配置文件, 日誌文件, 任何異常的隱藏文件等等. 例如, 在檢測/dev/.udev和/etc/.pwd.lock文件時候, 我的系統被警告.
  8. 對一些使用常用埠的應用程序進行版本測試. 如: Apache Web Server, Procmail等.

2、執行檢測命令:

sudo rkhunter --check

如果您不想要每個部分都以 Enter 來繼續,想要讓程序自動持續執行,可以使用:

sudo rkhunter --check --sk

3、命令中的-check選項告訴命令掃描系統,-sk選項會跳過選項按回車鍵繼續掃描,-rwo則是在掃描系統後只顯示警告信息:

taiji@taiji:~/rkhunter-1.4.6$ sudo rkhunter --check --rwo
Warning: The command '/usr/sbin/adduser' has been replaced by a script: /usr/sbin/adduser: Perl script text executable
Warning: The command '/usr/bin/egrep' has been replaced by a script: /usr/bin/egrep: POSIX shell script, ASCII text executable
Warning: The command '/usr/bin/fgrep' has been replaced by a script: /usr/bin/fgrep: POSIX shell script, ASCII text executable
Warning: The command '/usr/bin/ldd' has been replaced by a script: /usr/bin/ldd: Bourne-Again shell script, ASCII text executable
Warning: The command '/usr/bin/lwp-request' has been replaced by a script: /usr/bin/lwp-request: Perl script text executable
Warning: The command '/usr/bin/which.debianutils' has been replaced by a script: /usr/bin/which.debianutils: POSIX shell script, ASCII text executable
Warning: The following processes are using suspicious files:
         Command: cupsd
           UID: 0    PID: 1824
           Pathname: 
           Possible Rootkit: Spam tool component
         Command: snapd-desktop-i
           UID: 1000    PID: 3591
           Pathname: 
           Possible Rootkit: Spam tool component
         Command: snapd-desktop-i
           UID: 1000    PID: 3675
           Pathname: 
           Possible Rootkit: Spam tool component
         Command: snapd-desktop-i
           UID: 3676    PID: 3675
           Pathname: 7526
           Possible Rootkit: Spam tool component
         Command: snapd-desktop-i
           UID: 3677    PID: 3675
           Pathname: 7526
           Possible Rootkit: Spam tool component
         Command: snapd-desktop-i
           UID: 3678    PID: 3675
           Pathname: 7526
           Possible Rootkit: Spam tool component
Warning: Hidden file found: /etc/.resolv.conf.systemd-resolved.bak: ASCII text

4、掃描完成後可以查看以下路徑中的日誌查看警告。

sudo cat /var/log/rkhunter.log

5、有關更多信息和選項,請運行以下命令。

sudo rkhunter --help