部落格遷移至:
http://creeds2239.blogspot.com/
Rootkit Hunter安裝說明
先進行下載:
rkhunter 官方下載點: http://www.rootkit.nl/projects/rootkit_hunter.html 可使用wget 網址 的方式下載 或者使用apt-get install rkhunter 和yum rkhunter的方式下載必須要有 bash shell
*預設下載下來的檔案在下列目錄
[root@localhost /]# cd /usr/home/creeds/
[root@localhost /]# tar –zxvf rkhunter-版本編號.tar.gz
[root@localhost /]# cd rkhunter/
利用installer腳本語言進行安裝
安裝到預設的目錄去
[root@localhost /]# ./installer.sh –layout default –install
安裝到想要安裝的目錄去(如/usr/local)
[root@localhost /]# ./installer.sh –layout /usr/local –install
產生rkhunter安裝目錄內含MD5編碼資料和腳本語言執行檔等資料
Rootkit Hunter參數介紹
輸入rkhunter --help可顯示詳細的參數介紹
Usage: rkhunter {--check | --update | --propupd | --versioncheck | --list [tests | languages | rootkits] | --version | --help} [options]
--append-log 附加到記錄檔案,不要複寫 --bindir <directory>... 使用詳細的指令目錄 -c, --check 檢查本機系統 --cs2, --color-set2 使用輔助的色彩在輸出結果上 --configfile <file> 使用進階的檔案配置 --cronjob 執行一個排程工作,可以使用 crontab 來執行,不會有顏色顯示 (包含 -c, --sk and --nocolors 選項) --dbdir <directory> 使用詳細的資料庫目錄 --debug 除錯模式 (不要使用,除非有要求這樣做的時候) --disable <test>[,<test>...] 關閉詳細的測試 (預設是關閉沒有測試) --display-logfile 在結束的時候顯示紀錄檔 --enable <test>[,<test>...] 開啟詳細的測試 (預設是開啟所有測試) --hash {MD5 | SHA1 | NONE | 使用詳細的檔案Hash功能 <command>} (預設是使用SHA1) -h, --help 顯示協助功能表然後離開 --lang, --language <language> 語言的使用 (預設是英文) --list [tests | languages | 列出有效的測試名稱, 語言, rootkits] 或者rookit的檢查,然後離開 -l, --logfile [file] 寫入紀錄檔 (預設是/var/log/rkhunter.log) --noappend-log 不要附加紀錄到紀錄擋上,採複寫方式 --nocolors 使用黑底白字模式 --nolog 不要寫入到紀錄檔--nomow, --no-mail-on-warning 如果警告出現,則不要傳送訊息(眼不見為靜模式) --ns, --nosummary 不要顯示出檢查結果的結論 --novl, --no-verbose-logging 不要顯示冗長的紀錄 --pkgmgr {RPM | DPKG | BSD | 使用詳細的封裝管理(得到、通用、存在)或 NONE} 驗證檔案的Hash值. (預設是NONE) --propupd 更新檔案特性資料庫 -q, --quiet 安靜模式 (不會輸出全部),僅顯示有問題的訊息,比 --report-warnings-only 更少訊息 --rwo, --report-warnings-only 只顯示出有問題的訊息 -r, --rootdir <directory> 使用詳細的根目錄 --sk, --skip-keypress 不要等到按鍵後才進行測試 --summary 顯示出系統檢查結果的結論報告 (這是預設值) --syslog [facility.priority] 紀錄檢查開始和結束的時間的系統紀錄 (預設等即是authpriv.notice) --tmpdir <directory> 使用詳細的暫時目錄 --update 檢查資料庫更新檔案 --vl, --verbose-logging 使用冗長的紀錄模式 (預設) -V, --version 呈現出版本號碼然後離開 --versioncheck 檢查程式最後的版本 -x, --autox 如果使用x參數則自動檢查 -X, --no-autox 如果x參數被使用則不要自動檢查
Rootkit Hunter使用說明
建議在開始進行系統檢測前先進行一次更新
rkhunter --update --propupd
以避免誤判
確認目前最新版本的rkhunter
rkhunter --versioncheck
一般來說單純的檢查系統僅使用
rkhunter --checkall 或rkhunter –checkall就可以進行全系統檢測
預設檢測結果預設為英文
可加上參數顯示為中文
BIG5 編碼環境下, 請執行:
rkhunter --check --lang zh
UTF-8 編碼環境下, 請執行:
rkhunter --check --lang zh.utf8
在檢測的過程中會要求按下Enter鍵已進行下一個步驟的檢測
可加上參數直接進行檢測而不要由按下Enter
rkhunter --checkall --skip-keypress
在檢測的過程中會顯示出所有檢測過的檔案,過於冗長,可以加上參數僅顯示可疑的檔案
rkhunter --checkall --report-warnings-only(或者加 --quiet可以獲得更精簡的訊息)
最後可以搭配排程程式進行每日的系統檢測
編輯/etc/crontab
並且加入下列程式片段每日進行掃描檢測
?分 ?點 * * * root /usr/local/bin/rkhunter --checkall --cronjob
檢測後發送訊息通知檢查報告
首先增加一個新的檔案到排程資料夾下面
vim /etc/cron.daily/rkhunter.sh
增加下列程式片段
#!/bin/bash(/usr/local/bin/rkhunter -c --cronjob 2>&1 | mail -s "RKhunter Scan Details" replace-this@with-your-email.com)
或者
---------/etc/cron.daily/rkhunter---------------
#!/bin/sh(/usr/local/bin/rkhunter --versioncheck/usr/local/bin/rkhunter --update/usr/local/bin/rkhunter --cronjob --report-warnings-only) | /bin/mail -s 'rkhunter Daily Run' replace-this@with-your-email.com
chmod +x /etc/cron.daily/rkhunter.sh
整合應用
針對Root設定# crontab -e 針對一般使用者設定# crontab -e -u username0 3 * * * (./usr/local/bin/rkhunter –checkall 2>&1 | mail -s "chkrootkit output" -c mailadresscopy1@host.com This e-mail address is being protected from spambots. You need JavaScript enabled to view it This e-mail address is being protected from spambots. You need JavaScript enabled to view it )
但是前提要先進去修改rkhunter.conf設定檔中的下列兩項參數
MAIL-ON-WARNING=me@mydomain root@mydomain
MAIL_CMD=mail -s "[rkhunter] Warnings found for ${HOST_NAME}"
Rootkit Hunter報告檢視
more /var/log/rkhunter.log
可以看到檢測完的系統報告
最後進行一項簡單的測試,就是隨意的更改系統中任一項系統檔案,權限改為777,檢驗看看rkhunter是否真的有精準的發現不正確的權限檔案設定
本例以/usr/bin/中的who檔案為例:
結果顯示rkhunter發現了不正確的權限設定並且提示問題所在
參考資源:Rootkit Hunter官方網站
#Script written by digenVERSION="1.3.2"URL="http://downloads.sourceforge.net/rkhunter/rkhunter-$VERSION.tar.gz?modtime=1204134588&big_mirror=0"TARBALL="rkhunter-$VERSION.
ref : http://nixcraft.com/shell-scripting/835-rkhunter-installer-script.html
php.ini的安全性設定參考safe_mode = on限制system, exec等系統執行的能力,限制某些function只能處理與自己同一個UID的檔案。safe_mode受限制的功能請參考http://tw2.php.net/manual/en/features.safe-mode.functions.php因為mail()的第五個參數有漏洞,可突破safe_mode的限制,執行系統命令,最好disable,以SMTP的方式替代寄信。register_globals = offallow_url_fopen = Off (很重要的設定)allow_url_fopen 打開的時候, 如果有人傳入一個參數為 xxx=http://xxx/xxx 之類的東西,如果這個 php 的程式, 沒有檢查這個變數, 或是 register_globals 是開啟的情形下, 也許會造成這個 php 使用include() 去把遠端那個 URL 的檔案給引入執行.... 也就是執行到了別人寫的程式, 這時... 自然別人想在那裡頭做什麼,就能夠做什麼了.display_errors = off盡量不要在正式上線的主機直接顯示錯誤在頁面上,以避免暴露系統資訊。如需有debug的需要則開啟log_errors = On ,並以error_log = filename指定錯誤訊息要記錄到哪個檔案。magic_quotes_gpc = on默認是on,但需檢查一遍open_basedir =web目錄盡量將網站的起路徑限制在web的路徑,並免駭客去引用web路徑以外的檔案。disable_functions = (很重要的設定,對外的Web建議要把可以執行系統指令的functions拿掉) system,exec,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,dl,set_time_limit非必要一定要關閉的funciton,不然駭客會利用來執行檔案來取得你的管理權限。能的話盡量將php檔案編碼過,可避免駭客在得到你的程式後,進一步分析程式的漏洞。盡量限制可上傳檔案的folder,其他的目錄都不要讓web server有寫入的權限。php檔案的owner不能是root,配合safe_mode使用,可以避免駭客利用來以root身份執行命令。fsockopen能的話也關掉,但是因為有部分套裝程式會用到,例如Horde Webmail,如果關掉fsockopen imap會連不上。
出處:http://forum.icst.org.tw/phpbb/viewtopic.php?f=16&t=15523&p=50198&hilit=rkhunter#p50198
./configure出現"C compiler cannot create executables"執行apt-get install gcc libc6-dev"checking for termcap functions library...configure:error:No curses/termcap library found"執行apt-get install libncurses5-dev從安裝過程中檢視缺乏的套件以
apt-get install 套件名 安裝看看