Linux 鑑識工具– DataRecovery

Download Report

Transcript Linux 鑑識工具– DataRecovery

作業系統鑑識
Unix-Like/Linux
蔡一郎
2010/12/29
大綱




何謂Linux鑑識
OpenSource 工具說明
Linux 系統的鑑識重點說明
Linux鑑識待解決的問題
National Center for High-performance Computing
www.nchc.org.tw
2
何謂 Linux鑑識









使用Linux的工具去做數位證據的搜尋及鑑識
目前的現狀
有多少好用的工具 ? (Open Source)
跟商用Forensics工具的比較
Linux 系統本身的鑑識重點
繼 ePC 銷售大賣後
(目前已有Acer/廣達/HP/Mac等大廠陸續跟進…)
ePC/Mac等作業系統為何 ?
要面臨的鑑識重點 Windows  Linux ?
National Center for High-performance Computing
www.nchc.org.tw
3
Linux 鑑識工具 – 案例

台灣一家美國上市公司真實案例


電子郵件 = 偽造否 ?


E-mail log
是否為本人所犯 ?



星期六利用電子郵件將重要資訊外洩
Physical ?
從網路 ?
證物範圍

VPN/FireWall log ?
嫌犯家裏的電腦 ?
ISP 業者的通聯紀錄 ?

Mail Server


National Center for High-performance Computing
www.nchc.org.tw
4
Linux 鑑識工具現狀

Linux 鑑識工具可以做什麼 ?

製作映像檔(Imaging)
資料復原 (刪除檔復原/分割區/毀損檔案)
證據搜尋 (Data Analysis & Search)
密碼破解 (Password Crack)
檔案檢視 (FileViewer)

More as you think …




National Center for High-performance Computing
www.nchc.org.tw
5
Linux 鑑識工具現狀

目前世界上有名的Linux 鑑識工具有哪些 ?








Helix
Smart Linux
FCCU Forensic(比利時)
MI-4n6(德國)
F.I.R.E
Deft
Knoppix-Std(德國)
哪些單位在用?

美國法務部/FBI/白領犯罪中心(NW3c)/ 比利時聯邦犯罪中心/澳洲警
方…
National Center for High-performance Computing
www.nchc.org.tw
6
Linux 鑑識工具 現狀

目前世界上有名的Linux 鑑識工具要錢嗎 ?








Helix
Smart Linux
FCCU Forensic(比利時)
MI-4n6(德國)
F.I.R.E
Deft
Knoppix-std(德國)
Free 代表可以任意使用嗎 ?


GPL license的定義
這些工具靠何收入維持競爭性 ?
National Center for High-performance Computing
www.nchc.org.tw
7
Linux 鑑識工具 – 製作映像檔

如何確認使用的鑑識工具在分析目標證物時不會破壞證據貯
存資料 ?




公認被接受的製作映像檔及Digest演算法?



如何驗證
大部份使用Live CD Boot 後將檔案系統放在 Ramdisk
Boot後不會touch 證據碟(直到mount readonly)
dd like(ddfldd,dd_rescue,dccidd)
Md5/sha1
 Md5sum
 Shasum
是否每個Case均可製作Image ?
National Center for High-performance Computing
www.nchc.org.tw
8
Linux 鑑識工具 – DataRecovery


資料貯存的基本方式說明
C:\temp\readme.txt
FAT/FDT/MFT/InodeTable
C:
\temp\readme.txt
MBR


阿Sir, 你好! 我
是yilang
Data Content
當把檔案readme.txt刪除時,檔案系統作何處理?
僅在FAT/FDT/MFT/Inode 等相關區域作標示處理,主要告訴
檔案系統目前資料實體貯存位置己空出來可供使用,但真正
裏面的資料內容並未刪除
National Center for High-performance Computing
www.nchc.org.tw
9
Linux 鑑識工具 – DataRecovery

若資料內容超過一個Cluster的大小則必需存到另一個
Cluster但若貯存不連續 (如下例:readme.txt)
FAT/FDT/MFT/InodeTable
C:
\temp\readme.txt
老大,請今天把
貨送到老地方
阿郎留
MBR
Data Content Fragment
•如何找到兩段資料為具有關聯性?而回愎為原來的檔案
(Unallocated 區Recover)
National Center for High-performance Computing
www.nchc.org.tw
10
Linux 鑑識工具 – DataRecovery

Data Revovery 案例說明:Unallocate 區的資料回復

多困難 ?
 拼圖
 手工藝
 損毀檔案的搶救…
National Center for High-performance Computing
www.nchc.org.tw
Linux 鑑識工具 – DataRecovery

資料貯存的基本方式說明
C:\temp\readme.txt

什麼狀況下資料無法救回?

當實體貯存Data的資料磁區被覆寫


FBI標準, 需要覆寫7次 ?
National Center for High-performance Computing
www.nchc.org.tw
12
Linux 鑑識工具 – DataRecovery

資料有可能在瞬間刪除嗎 ?



Partition table (1秒)
FAT/MFT/Inode table (1分鐘)
所有的Data(1小時 or more…)
HardDisk
National Center for High-performance Computing
www.nchc.org.tw
如何救回已刪除的檔案

目前救回已刪除檔案的方式主要有兩種:


修改檔案系統的索引區(FAT/FDT/MFT/InodeTable),將標示已刪除
的Tag及相關資料回復為未刪除的型態
在Unallocate資料區搜尋符合的資料取出另存在新的檔案系統中
National Center for High-performance Computing
www.nchc.org.tw
Linux 資料救援回復的主要工具 (Open
Source)

Linux資料救援回復的主要工具 (Open source)







Partition table recovery - testdisk
NTFS files recovery – Sleuth Kit
FAT files Recovery – Fatback / Sleuth Kit
Linux ext2 – E2undel
Linux ext3 (僅能從Unallocate區找File Pattern嘗試把資料救回)
檢視Windows 資源回收筒的檔案 – Rifruti
從Unallocate區救回資料– revit(ReviveIt)/foremost
National Center for High-performance Computing
www.nchc.org.tw
Linux 鑑識工具 – 證據搜尋

數位證據資料搜尋的方式主要有兩種:



Linear search(字串比對方式) ,例如:encase string search
 優點: 可以搜尋磁碟的 file slack及 unallocate 區
 缺點: 每次搜尋均要花相同的時間
String Token Indexing Search, 例如:全文檢索
 優點:可以在做完一次Indexing後,每次搜尋均可以在數秒內完成
 缺點:只適用於File System中存在的檔案,delete 檔案必先Recover
回來
無法搜尋File slack 及 unallocate 區
National Center for High-performance Computing
www.nchc.org.tw
16
何謂 Linear Search (字串比對方式)
以下列檔案內容舉例說明:
Hi Bob,
I am ready to ship the drug pills. The drug-dealer
李 大牛 will contact with you ; Pls give me a call,
My phone number is 02-1234-5678.






輸入以下字串,搜尋結果為何 ?
drug = ?
12345678 ?
李大牛 ?
one ?
National Center for High-performance Computing
www.nchc.org.tw
何謂 String Token indexing Search (全
文檢索)
以下列檔案為例,只要遇到空白則視為一個String Token:
Hi Bob,
I am ready to ship the drug pills. The drug-dealer
李 大牛 will contact with you ; Pls give me a call,
My phone number is 02-1234-5678.






輸入以下字串,搜尋結果為何 ?
drug = ?
12345678 ?
李大牛 ?
one ?
National Center for High-performance Computing
www.nchc.org.tw
Linux Linear Search 的解決方式







Step 1:把輸入字串 轉成必要的各語系字串
Step 2:把每個目標檔案先用file命令得知檔案格式
Step 3:遇到壓縮檔格式則先使用解壓縮的工具解開
Step 4:遇到各種AP檔案則使用對應的extracter 將檔案內容
轉為txt
例如:Antiword/pdftotext/regp.pl/ripmime/
Step 5:遇到binary的格式檔案則使用string指令將binary內
容中有text的內容取出
Step 6:使用grep的方式來搜尋內容
National Center for High-performance Computing
www.nchc.org.tw
證據搜尋-檔案格式問題

同樣的內容在不同應用軟體所貯存的格式即不同
Text formate HexCode
Office 97 Doc formate HexCode
Office 2007 Doc formate HexCode
National Center for High-performance Computing
www.nchc.org.tw
證據搜尋-其它問題

語系問題




壓縮檔問題


Registry/Database
Binary執行檔搜尋問題


zip/rar/gz/tar.gz/bzip/Z...等
資料結構問題


一個搜尋字串,在作Linear Search 時必需要同時轉成各種不同的語系
中文字至少的表示有: Big5,UniCode (UTF-8 Linux,UTF16Windows),UniCode Big-Endian
字母大小寫問題
Exe/dll…
加密檔案搜尋問題
National Center for High-performance Computing
www.nchc.org.tw
Linux String Token Indexing Search
的解決方式






Step 1:把每個目標檔案先用file命令得知檔案格式
Step 2:遇到壓縮檔格式則先使用解壓縮的工具解開
Step 3:使用各種檔案的extracter 將檔案內容轉為txt
Step 4:遇到binary的格式檔案則使用string指令將binary內
容中有string的內容取出
Step 5:使用全文檢索引擎 (Lucene -Free)或(Googleindexing engine non-open)來將每個字串當成Token取出作
為indexing檔案
Step 6:把輸入字串轉成必要的各語系字串送到檢索引擎做
搜尋
National Center for High-performance Computing
www.nchc.org.tw
Linux Unallocated區搜尋的解決方式





Step 1:先將磁碟以bit-stream的方式轉為Image檔
Step 2:將Image檔案使用string的指令找出各種語系編碼的
純字串轉出
Step 3:使用grep方式進行搜尋及定位
案例一:如何證明此顆硬碟為某人遺失的硬碟?
案例二:在智財權的侵權訴訟中如何證明某個軟體並非原創
有抄襲的情形?
National Center for High-performance Computing
www.nchc.org.tw
Linux 鑑識工具 – 密碼破解

先瞭解你的目標對象


柿子挑軟的吃 – 先從簡單著手 ?





PGP/SSL/AES/WEP/3DES…
Social Engineering
使用習慣
先破 MSN/DOC/RAR 密碼
非不得已,不用暴力破解
Linux 知名破解工具

John the Ripper (破解windows/linux密碼檔)
National Center for High-performance Computing
www.nchc.org.tw
Linux 或 Window 密碼遺忘

使用更改而非破解,此為 Non-forensics 作法




Windows Administrator密碼忘了如何?
Linux root密碼忘了如何?
VMWare 內的作業系統該如何?
使用chntpw 製作開機光碟後可更改windows的密碼,linux
只要mount檔案系統後更改/etc/shadow即可
National Center for High-performance Computing
www.nchc.org.tw
Linux 檔案檢視

應用檔檢視


電子郵件檢視




Outlook/outlook express/Notes/Exchange
Browser 瀏覽行為檢視


pdf/office(2007/2003…)/xml/mp3/avi/mpeg/…
History/Cache/Cookie/Typed URL address
Windows Registry 檢視
Windows Event/Security log檢視
檔案Hexcode檢視
National Center for High-performance Computing
www.nchc.org.tw
Linux系統本身的鑑識重點

瞭解Linux的重要性及淵源




現行Linux 版本的差異性

RedHat/Suse/Slackware/Debian(Ubuntu/Knoppix…)
Kernel 版本編號關係 (http://www.kernel.org/)

2.6.13-1.1532_FC


商業版的Unix跟Linux的關係
 HP Unix/AIX/Solaris
Mac跟Linux的關係
繼ePC銷售大賣後,未來的趨勢 ?
作Live Forensics 時會有影響
National Center for High-performance Computing
www.nchc.org.tw
Linux系統本身的鑑識重點

Linux 系統應用的現狀

超過90% Linux 系統,大多使用於網路伺服器應用

Web/Database/Mail/DNS/Ftp/Firewall/Proxy/…
作鑑識前先瞭解目標證物的應用為何?
要找的證據方向為何?
 找應用系統曾經被使用的紀錄 ?




還是系統本身被駭客入侵 ?


Log & AP files location
All systems & Locate Unknown files first
還是系統軟體的侵權問題 ?

Object code comparing
National Center for High-performance Computing
www.nchc.org.tw
目標證物Linux系統的Live重現

目標Linux 系統的Live重現


目的 ?
 方便觀察
 較快速找出應用系統程式中相關聯的開啟檔案
 較快速瞭解網路行為(開啟的Port及傳送的封包)
作法:
 製作多一份的映像檔並倒入某顆備用硬碟
 選擇一個通用性的硬體
(注意CPU規格) 網路卡(Intel/Realtek)
將映像檔的硬碟設為boot的開機碟
在Live重現系統中所採集證物具法律效力嗎 ?


National Center for High-performance Computing
www.nchc.org.tw
Linux Live 系統中的證物採集/觀察


Live 採集適用於何時 ? 重現的狀態只適用於觀察
Network Connection & Open Port


是哪些程式開啟這些 Port ?



pstree
ps -e --forest --format=pid,ppid,args
封包搜集 ?


lsof
系統中有哪些程式正在執行 ?


netstat -an
tcpdump
Memory Dump

dd if=/proc/memxx of=/mnt/usbdisk/memdump
National Center for High-performance Computing
www.nchc.org.tw
Linux 系統中的資料搜尋

當系統映像檔製作完成後,如何作資料搜尋?



方法一: 將bitstream的映像檔複製到其它硬碟,將被複製的硬碟以唯讀
方式mount來分析
方法二: 以loopback的方式將映像檔直接mount來進行分析
資料搜尋及刪除檔救回的方法如先前章節所述


但linux filesystem的搜尋會比windows filesystem的搜尋更容易
主要由於 linux 大部份的系統檔均為text base 格式,且應用程式大多
為open source 可找到原始程式來拆解分析
National Center for High-performance Computing
www.nchc.org.tw
Linux系統本身的鑑識重點 - Log


Linux 應用系統的log: /var/log 下的所有紀錄均採集
/var/log/secure:
記錄登入系統存取資料的檔案,例如 pop3, ssh, telnet, ftp 等都會記錄在此檔案中;

/var/log/wtmp:
記錄登入者的訊息資料,由於本檔案已經被編碼過,所以必須使用 last 這個指令來取出檔案的
內容;

/var/log/messages:
這個檔案相當的重要,幾乎系統發生的錯誤訊息(或者是重要的資訊)都會記錄在這個檔案中;

/var/log/boot.log:
記錄開機或者是一些服務啟動的時候,所顯示的啟動或關閉訊息;

/var/log/maillog 或 /var/log/mail/*:
紀錄郵件存取或往來( sendmail 與 pop3 )的使用者記錄;

/var/log/cron:
這個是用來記錄 crontab 這個例行性服務的內容的!

/var/log/httpd, /var/log/news, /var/log/mysqld.log, /var/log/samba, /var/log/procmail.log:
分別是幾個不同的網路服務的記錄(可能分佈在不同地方)
National Center for High-performance Computing
www.nchc.org.tw
Linux 系統中的證物採集 – 駭客入侵

重現Live的作業環境 ,主要用來確認搜證的重點






使用Sniffer側錄所有的封包
作live程式的觀察
Check rookit (rkhunter/chkrootkit)
可做初步的確認是否已被駭客入侵及相關程式
從history 及 系統log中觀察可能被植入的程式
移除所有的Known files


確認系統的kernel及patch level
重建相同的系統,比對所有系統binary 程式的md5把可疑的檔找出
National Center for High-performance Computing
www.nchc.org.tw
Linux 鑑識工具– 軟體侵權案例

如何比較兩個程式執行檔的相似度:


很多抄襲會把程式一模一樣作複製,包含程式輸出的錯誤訊息/程式執
行某個參數的版權宣告/及程式執行會輸出的提示訊息 均可比對.
 strings -a program1 > result1.txt
 #strings -a program2 > result2.txt
 將result1.txt的每個字串來對result2.txt作比對
 對於#加殼的程式,則必需比對執行中的Memory Dump資訊
抄襲時連function() name 均一樣
 # nm program1 > func_name1.txt
 # nm program2 > func_name2.txt
 將兩個output 作比較看是否有自已命名非系統命名的function
name一樣.
National Center for High-performance Computing
www.nchc.org.tw
Linux 系統鑑識待解決問題

Linux 介面不Friendly


中文語系的問題


很多工具均是command line的執行方式,必需有一個親和的操作介面
可以讓使用人員輕易上手
很多forensics好用的工具均預設只考慮single bytes 或 unicode的搜
尋,並不會有big5編碼support,必需自已 Hacking程式作修改(簡體中
文亦類似)
Windows檔案格式支援的問題

由於AP的廠商很多僅支援windows platform或不公開檔案實作格式
文件,因此必需有人去hacking 檔案拆解內容(office
document/registry/notes mail/…)
National Center for High-performance Computing
www.nchc.org.tw
Q&A
National Center for High-performance Computing
www.nchc.org.tw
36