linux下發生了入侵檢測的方法



chkrootkit

1、安裝:wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz

#tar zxvf chkrootkit.tar.gz
#cd chkrootkit*
#make sense
#cd ..
#cp -r chkrootkit* /usr/local/chkrootkit
#

2、運行檢測:
#/usr/local/chkrootkit/chkrootkit


得到的結果全是INFECTED的全被感染了。

3、chkrootkit參數說明

Usage: ./chkrootkit [options] [test ...]
 Options:
        -h                顯示幫助信息
        -V                顯示版本信息
        -l                顯示測試內容
        -d                debug模式,顯示檢測過程的相關指令程序
        -q                安靜模式,只顯示有問題部分,
        -x                高級模式,顯示所有檢測結果
        -r dir            設定指定的目錄爲根目錄
        -p dir1:dir2:dirN 檢測指定目錄
        -n                跳過NFS連接的目錄


rootkit hunter

下載 wget http://downloads.sourceforge.net/rkhunter/rkhunter-1.3.4.tar.gz?use_mirror=jaist

 

1、安裝
#tar -zxvf rkhunter-1.3.4.tar.gz
#cd rkhunter-1.3.4
#./installer.sh -h(安裝幫助)

Usage: ./installer.sh <parameters>

Ordered valid parameters:
 --help (-h)      : 顯示幫助
--examples       : 顯示安裝實例
--layout <value> : 選擇安裝模板(安裝必選參數).
                    模板選擇:
                    - default: (FHS compliant),
                     - /usr,
                     - /usr/local,
                     - oldschool: 之前版本安裝路徑,
                     - custom: 自定義安裝路徑,
                     - RPM: for building RPM's. Requires $RPM_BUILD_ROOT.
                     - DEB: for building DEB's. Requires $DEB_BUILD_ROOT.
 --striproot      : Strip path from custom layout (for package maintainers).
 --install        : 根據選擇目錄安裝

--show           : 顯示安裝路徑
--remove         : 卸載rkhunter
 --version        : 顯示安裝版本


 使用的安裝指令
#./installer.sh --layout default --install

 
2、 rkhunter操作

#/usr/local/bin/rkhunter --propupd

#/usr/local/bin/rkhunter -c --sk -rwo


檢測後帶有“waring”,表示有異常。
如果讓程序每天定時檢測,加入到crontab裏去就可以(每天9點半運行一次)
09 3 * * * root  /usr/local/bin/rkhunter --check --cronjob

指令參數說明

#/usr/local/bin/rkhunter

Usage: rkhunter {--check | --update | --versioncheck |
                  --propupd [{filename | directory | package name},...] |
                  --list [{tests | {lang | languages} | rootkits},...] |
                  --version | --help} [options]

Current options are:
          --append-log                  在日誌文件後追加日誌,而不覆蓋原有日誌
         --bindir <directory>...       Use the specified command directories
      -c, --check                       檢測當前系統
  --cs2, --color-set2                  Use the second color set for output
          --configfile <file>           使用特定的配置文件
         --cronjob                     作爲cron定期運行
                                       (包含參數 -c, --sk , --nocolors )
          --dbdir <directory>           Use the specified database directory
          --debug                       Debug模式(不要使用除非要求使用)
          --disable <test>[,<test>...]  跳過指定檢查對象(默認爲無)
          --display-logfile             在最後顯示日誌文件內容
         --enable  <test>[,<test>...]  對指定檢測對象進行檢查
                                       (默認檢測所有對象)
          --hash {MD5 | SHA1 | NONE |   使用指定的文件哈希函數
                 <command>}            (Default is SHA1)
      -h, --help                        顯示幫助菜單
 --lang, --language <language>         指定使用的語言
                                       (Default is English)
          --list [tests | languages |   羅列測試對象明朝,使用語言,可檢測的木馬程序
                 rootkits]            
      -l, --logfile [file]              寫到指定的日誌文件名

                                       (Default is /var/log/rkhunter.log)
          --noappend-log                不追加日誌,直接覆蓋日誌文件
         --nocolors                    輸出只顯示黑白兩色
         --nolog                       不寫入日誌文件
--nomow, --no-mail-on-warning          如果有警告信息,不發送郵件
   --ns, --nosummary                   不顯示檢查結果的統計數據
 --novl, --no-verbose-logging          不顯示詳細記錄
         --pkgmgr {RPM | DPKG | BSD |  使用特定的包管理用於文件的哈希值驗證
                   NONE}               (Default is NONE)
          --propupd [file | directory | 更新整個文件屬性數據庫或僅僅更新指定條目
                    package]...       
      -q, --quiet                       安靜模式(no output at all)
   --rwo, --report-warnings-only        只顯示警告信息
     -r, --rootdir <directory>         使用指定的root目錄
   --sk, --skip-keypress               自動完成所有檢測,跳過鍵盤輸入

         --summary                     顯示檢測結果的統計信息
                                       (This is the default)
          --syslog [facility.priority]  記錄檢測啓動和結束時間到系統日誌中
                                       (Default level is authpriv.notice)
          --tmpdir <directory>          使用指定的臨時目錄
         --update                      檢測更新內容
   --vl, --verbose-logging             使用詳細日誌記錄 (on by default)
      -V, --version                     顯示版本信息
         --versioncheck                檢測最新版本
     -x, --autox                       當X在使用時,自動啓動檢測
     -X, --no-autox                    當X在使用時,不自啓檢測

受到攻擊後處理方式:

1、切斷網絡
2、查找攻擊源,一般是查看相關日誌,端口,運行程序等
3、分析入侵原因與途經
4、備份用戶數據
5、重新安裝系統
6、修復程序或漏洞
7、恢復數據與網絡

方法:
1、w命令,查看登錄過的用戶
2、鎖定用戶,並強制下線
#passwd -l nobody
#ps- ef |grep @pts/3(用戶怕TTY)
#kill -9 6021
3、關閉可疑的進程,ps,top出來後,kill掉
#pidof abc
13256 15698 5654
#ls -al /proc/13256/exe  #進入內存目錄查找
#ls -al /proc/13256/fd   #查看文件句柄
4、檢查文件系統的完整性:
#rpm -Va

S表示長度發生了變化
M表示訪問權限或文件類型發生了變化
5表示md5檢驗發生了變化
D表示設備節點屬性發生了變化
L表示符號連接發生變化
U表示文件、子目錄、設備節點的owner發生了變化
G表示文件、子目錄、設備節點的group發生了變化
T表示最後一次修改時間發生了變化

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章