歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> Linux資訊 >> 更多Linux >> 系統遭受入侵後使用TCT進行緊急恢復並分析

系統遭受入侵後使用TCT進行緊急恢復並分析

日期:2017/2/27 14:19:05   编辑:更多Linux
  從事系統管理工作,就算你非常小心翼翼地做好了一切防護,還是可能有入侵者能夠突破你 的防護進入系統,並且更改或者刪除一些文件。這裡,我們借用honeynet project裡面的一些實 例,來對一個unix下的實用工具軟件tct及其相關輔助軟件做簡要說明。並且在最後再介紹另外 一個比較不錯的能恢復ext2文件系統的軟件recover。 首先說一下相關的軟件: 1、The Coroners Toolkit:也就是我們所說的TCT,想要在國內下載的話,您可以到安全焦 點(http://xfocus.org/tool/other/tct-1.07.tar.gz)下載。這是一個unix下的命令行文件系統 工具集,支持FFS及ext2fs,從塊及結點處來對數據進行恢復。它能夠針對文件的最後修改、訪 問或者改變(MAC)的時間來進行分析,並且根據數據節點的值提取出文件列表以進行恢復。 2、TCTUTILs:在http://xfocus.org/tool/other/tctutils-1.01.tar.gz可以下載當前最新 版本。它是對TCT的補充,提供了根據文件名對數據進行恢復的命令行工具。這兩個工具都需要 使用者對一些底層基本知識比較了解。 3、Autopsy Forensic Browser:可以從http://xfocus.org/tool/other/autopsy-1.01.tar.gz 下載。它提供了一個友好的Html界面給tct及tctutils。它能使枯燥的分析工作相對輕松些:) 一、安裝:TCT在各種unix平台下都經過了比較好的測試。現在能夠支持FreeBSD、OpenBSD、 SunOS、Linux等平台。TCTUTILs和Autopsy則不一定能跑得起來,我測試的平台是一台默認安裝 的Red Hat 6.2系統。 1、tct # tar zvfx tct-1.07.tar.gz -C /usr/local/tct/; cd /usr/local/tct/tct*; make 這樣把tct展開到/usr/local/tct/tct-1.07/的目錄下,並且進入,make。這裡,如果是make 過之後,需要重新在編譯的話,需要運行perl reconfig命令重新配置。 2、tctutils: # tar zvfx tctutils-1.01.tar.gz -C /usr/local/tct;cd /usr/local/tct/tctu*;make 現在tctutils似乎只在OpenBSD 2.8、Debian Linux 2.2、Solaris 2.7下經過詳盡測試,而 對FreeBSD還支持不好。通常make不會出現什麼問題,如果有,自己改下代碼或者Makefile即可。 3、Autopsy: 解包後運行./configure後,它會自己尋找一些實用工具如grep、strings、md5sum的路徑, 並要求確認tct以及tctutils的路徑(如果沒找到會要求你輸入正確路徑)。最後要求輸入需要檢 查的文件系統所在,才生成程序autopsy。 二、honeynet scan15簡介: 關於honeynet project的詳情,可以參見安全焦點(http://xfocus.org/honeynet/),他們 現在維護著國外honeynet項目的中文鏡像。 scan15是honeynet在2001年3月15日於一台受入侵的Linux機器上搜集到的數據而面臨的問題。 入侵者下載了一些rootkit放在根目錄下,成功安裝後刪除了。而honeynet project將當時的原始 數據鏡像下來,作為題目出給網絡安全愛好者,要求對這一被刪除的rootkit進行恢復。 詳情可以參見http://xfocus.org/honeynet/scans/。 根據要求,我下載了honeynet.tar.gz的包,約13M,解壓後是一個270M左右的文件honeypot.hda8.dd 及一個README文件,README如下: ===================================================================


SUMMARY ------- You have download the / partition of a compromised RH 6.2 Linux box. Your mission is to recover the deleted rootkit from the / partition. Below are a list of all the partitions that made up the compromised system. /dev/hda8 / <----- The partition you downloaded /dev/hda1 /boot /dev/hda6 /home /dev/hda5 /usr /dev/hda7 /var /dev/hda9 swap - The Honeynet Project http://project.honeynet.org ==================================================================== 圖一 任務非常明確。 三、操作過程 1、確認下載數據無誤 # md5sum honeynet.tar.gz 0dff8fb9fe022ea80d8f1a4e4ae33e21 honeynet.tar.gz # md5sum honeypot.hda8.dd 5a8ebf5725b15e563c825be85f2f852e honeypot.hda8.dd 這些md5校驗值同honeynet網站上貼出來的一樣,說明文件下載無誤,未經篡改。 2、將下載下來的鏡像掛接到系統上 # mount honeypot.hda8.dd /mnt/ -oloop,ro 3、配置autopsy並運行之(其實在上面autopsy的configure過程中就做這步了) ==================================================================== [root@test autopsy-1.01]# ./configure Autopsy Forensic Browser v.1.01 Installation MD5 found: /usr/bin/md5sum strings found: /usr/bin/strings grep found: /bin/grep Enter TCT Directory: /usr/local/tct TCT bin directory was found Enter TCTUTILs Directory: /usr/local/tctutils TCTUTILs bin directory was found Enter Morgue Directory: /home/inburst Enter Default Investigator Name (for the Autopsy Reports): inburst Settings saved to conf.pl [root@test autopsy-1.01]# ==================================================================== 圖二 然後進入/home/inburst/,你存放honeypot.hda8.dd的地方,編輯文件fsmorgue,使其看來象 下面這樣: ==================================================================== # fsmorgue file for Autopsy Forensic Browser # # local_file name can contain letters, digits, '-', '_', and '.' # # local_file mount_point honeypot.hda8.dd /mnt/ ==================================================================== 圖三 並且編輯zoneinfo,確定時間信息。 然後可以運行命令: # ./autopsy 9999 192.168.168.130 這裡192.168.168.130是我所用的工作機,9999是端口號,屏幕上會輸出: ==================================================================== Autopsy Forensic Browser ver 1.01

Investigator: inburst Paste this as your browser URL on 192.168.168.130: 192.168.168.130:9999/1727589285/autopsy ==================================================================== 圖四 將192.168.168.130:9999/1727589285/autopsy粘貼到你的浏覽器url裡,就可以開始進一步的分析了。 4、恢復被刪除的rootkit,這裡我們先純用命令行來解決問題,其實利用autopsy可以令這些麻煩事 看起來相對直觀些。 a、搜集信息 ==================================================================== # ils honeypot.hda8.dd > ilsdump.txt # cat ilsdump.txt classhostdevicestart_time ilstest.inburst.com.cnhoneypot.hda8.dd992134159 st_inost_allocst_uidst_gidst_mtimest_atimest_ctimest_dtimest_modest_nlinkst_sizest_block0st_block1 23f009847066089847070909847071059847071051006440520333307308 2038f1031100984707105984707105984707105984707169407550084810 …… …… ==================================================================== 圖五 ils命令是用來顯示inode信息的,它顯示了每個被刪除的文件節點的原始資料。上面顯示的第一個域是 結點號。後面數據恢復時需要用到,關於這個輸出的詳細信息如下: st_ino:The inode number. st_alloc:Allocation status: `a' for allocated inode, `f' for free inode. st_uid:Owner user ID. st_gid:Owner group ID. st_mtime:UNIX time (seconds) of last file modification. st_atime:UNIX time (seconds) of last file Access. st_ctime:UNIX time (seconds) of last inode status change. st_dtime:UNIX time (seconds) of file deletion (LINUX only). st_mode:File type and permissions (octal). st_nlink:Number of hard links. st_size:File size in bytes. st_block0,st_block1:The first two entries in the direct block address list. ==================================================================== # /usr/local/tct/extras/ils2mac ilsdump.txt > deletedfiles.txt # cat deletedfiles.txt classhostdevicestart_time



st_dtime:UNIX time (seconds) of file deletion (LINUX only). st_mode:File type and permissions (octal). st_nlink:Number of hard links. st_size:File size in bytes. st_block0,st_block1:The first two entries in the direct block address list. ==================================================================== # /usr/local/tct/extras/ils2mac ilsdump.txt > deletedfiles.txt # cat deletedfiles.txt classhostdevicestart_time



# /usr/local/tct/extras/ils2mac ilsdump.txt > deletedfiles.txt # cat deletedfiles.txt classhostdevicestart_time



Copyright © Linux教程網 All Rights Reserved