Linux後門檢測工具chkrootkit
1、安裝chkrootkit
# apt-get update # apt install chkrootkit # chkrootkit -V chkrootkit version 0.52
#指令碼定時任務 出現命令修改時自動傳送郵件
#!/bin/bash
#-------------------------------------------------------------------------
#application: 檢查linux是否被cc的工具,監控命令是否被替換
#Filename: chkrootkit_everyday.sh
#Revision: 0.1
#Date: 2018/12/03
#Author: hanye
#Email: [email protected]
#Website: hz7726.com
#Description:Check whether the site is rootkit infection
#Notes:
#crontab: */5 * * * * chkrootkit_everyday.sh
#------------------------------------------------------------------------
#Copyright:201 (c) www.1fangxin.cn
#License:GPL
TIME="`date +%Y%m%d%H%M`"
/usr/sbin/chkrootkit -n > /data/sh/.chkrootkitLog/.chkrootkit_$TIME.log
if [ "`grep 'INFECTED' /data/sh/.chkrootkitLog/.chkrootkit_$TIME.log`" != "" ];then
echo "Dangerous"
EMAIL='/data/soft/sendEmail-v1.56/sendEmail'
FEMAIL="[email protected]" #發件郵箱
MAILP="PASSWD"
MAILSMTP="smtp.163.com" #發件郵箱的SMTP
MAILT="[email protected],.......,...." #收件郵箱
MAILmessage=" server command change ERROR"
$EMAIL -q -f $FEMAIL -t $MAILT -u "您伺服器有人登入修改命令,請使用chkrootkit來檢測" -m "$MAILmessage" -s $MAILSMTP -o message-charset=utf-8 -xu $FEMAIL -xp $MAILP -o tls=no
else
echo "OK"
fi
2、使用chkrootkit
安裝完的chkrootkit程式位於/usr/local/chkrootkit目錄下,執行如下命令即可顯示chkrootkit的詳細用法:
[email protected]# chkrootkit -h
chkrootkit各個引數的含義如下所示。
引數含義
-h顯示幫助資訊
-v顯示版本資訊
-l顯示測試內容
-ddebug模式,顯示檢測過程的相關指令程式
-q安靜模式,只顯示有問題的內容
-x高階模式,顯示所有檢測結果
-r dir設定指定的目錄為根目錄
-p dir1:dir2:dirN指定chkrootkit檢測時使用系統命令的目錄
-n跳過NFS連線的目錄