Rootkit簡介

Download Report

Transcript Rootkit簡介

ROOTKIT偵測
蔡一郎
2010/12/29
Outline



Rootkit簡介
駭客的攻擊行為模式
相關偵測工具


rootkit hunter
AIDE
National Center for High-performance Computing
www.nchc.org.tw
Rootkit簡介





為一組工具,方便駭客用來隱藏入侵行為及取得電腦或電腦
網路系統之管理者權限
通常為kernel based
會改寫正常的系統命令,如ls、ps、netstat等來隱藏入侵的
行為
用來進行網路攻擊,如DDoS
用來盜取重要資訊
National Center for High-performance Computing
www.nchc.org.tw
Rootkit與特洛伊木馬

木馬程式的來源,大概可分為以下幾種:





系統被入侵(root-compromise), 遭 cracker 植入
中了主機系統中, 某位一般權限使用者精心設計的陷井
執行了來路不明的程式
安裝了被竄改過的程式套件
被 network worm (網路蠕蟲) 感染.
National Center for High-performance Computing
www.nchc.org.tw
駭客的攻擊行為模式

攻擊流程圖
攻擊者
工具
駭客
間諜
有心人士
…
網路分析
系統分析
弱點偵測
入侵程式
自動化工具
…
存取
應用程式的漏洞
程式設計上的漏洞
組態設定上的漏洞
…
National Center for High-performance Computing
非經授權
存取
使用
…
結果
目的
資料毀損
資訊外洩
盜用服務
阻絕服務
影響形象
…
經濟利益
虛榮心
政治意圖
挑戰
…
www.nchc.org.tw
1-網路探勘



主要是駭客不熟悉攻擊目標的網路架構,因此利用whois查
詢、nslookup查詢等,以發掘一些潛在的IP位址範圍、員工
姓名、電話號碼、網域名稱伺服器、郵件伺服器等等的資訊。
藉由所搜集到之初始資訊,雖可知道潛在的IP位址範圍或伺
服器位址,但並不能確定這些主機是否存活(alive)、有什麼
漏洞等,因此仍需經過掃描的動作才能具體確定這些事實。
常用的工具

nslookup、ping、whois…
National Center for High-performance Computing
www.nchc.org.tw
2-偽裝/欺騙

攻擊者為了隱藏自己的身分,往往會利用某
些技術(如傳送假造位址或利用主機架構),
造成目標主機的誤以為其為受信任的主機,
因而達到其攻擊行為。
National Center for High-performance Computing
www.nchc.org.tw
3-掃瞄
當駭客確定目標位址後,便會利用掃描軟體
(Scanners),從遠端掃描偵測目標主機的
各類資訊。
 這些資訊包括主機之作業系統類型及版本、
開啟的網路服務、系統弱點、主機間信任關
係等。
 由於這些掃描結果是駭客用以入侵目標網路
系統的重要資訊,因此,此攻擊行為極具威
脅性。

National Center for High-performance Computing
www.nchc.org.tw
4-竊聽
駭客可以藉一些竊聽程式(如Sniffer等)竊聽
流經該其所在位址網路區塊之封包,藉以收
集到重要的資訊,如帳號、通行碼等資訊,
以便做進一步之入侵。
 一般而言,駭客能夠藉由竊聽作為攻擊手段,
主要是資料未經加密(即在不安全之通道上)
傳送。因此,使得駭客輕易藉由此項攻擊取
得大部份通訊內容。

National Center for High-performance Computing
www.nchc.org.tw
5-密碼破解
駭客利用了掃描技術,得知目標系統一些弱
點後,便可入侵該系統複製其通行碼檔,以
試圖找出該系統使用者的通行碼。
 通行碼破解程式是利用通行碼在系統裏加密
的演算法,模擬加密程序,將字典檔
(Dictionary File)中所猜測的明文字串加密成
密文,再和通行碼檔裏的密文欄位作比對。

National Center for High-performance Computing
www.nchc.org.tw
6-利用漏洞

漏洞利用是指程式或軟體的不當設計或實作,
以及在設定上的錯誤,使得非授權者可以藉
以利用此漏洞來獲取資訊、取得使用者或管
理者權限等等,例如緩衝區溢位(buffer
overflow)即是這類問題。
National Center for High-performance Computing
www.nchc.org.tw
6-利用漏洞(續)

取得初步權限
 密碼猜測
 不安全的密碼
 NTIS(空白密碼)
 administrator、adm
、test….
 字典攻擊法
 Legion、NetBIOS Audition
Tool…
 網路監聽
National Center for High-performance Computing
www.nchc.org.tw
6-利用漏洞(續)

提昇權限
 密碼猜測
 網路監聽
 密碼檔破解工具
 Tools:
pwdump2, L0phtCrack, John
 將使用者加入管理者群組
 getadmin、Sechole
 鍵盤敲擊記錄(側錄)
National Center for High-performance Computing
www.nchc.org.tw
緩衝區溢位(Buffer Overflow)
緩衝區溢位(Buffer Overflow)是由於程式撰
寫人員的疏忽,使得攻擊者的輸入大於程式
撰寫人員的預期,造成緩衝區容量的不足,
導致系統會執行攻擊者欲執行的攻擊程式。
 例如:送入一個256字元的使用者名稱、在
舊版本IE的URL中輸入超過128字元的網址
等都會造成緩衝區溢位。

National Center for High-performance Computing
www.nchc.org.tw
7-存取主機
主要是針對目標被駭客入侵後(利用通行碼破
解或漏洞),駭客使用取得之使用者或管理者
權限,對主機各檔案之存取行為。
 包括:

 複製(copy)
 讀取(read)
 篡改(modify)
 移除(delete)
 竊取(steal)
National Center for High-performance Computing
www.nchc.org.tw
8-安置後門
攻擊者還會再回去該主機做存取或作為入侵
其他主機之跳板。
 駭客擔心系統管理者發現入侵行為後,修正
該項漏洞,使得他們無法重新登入該主機,
因此透過安置的後門程式,讓自己可以在未
來重新獲得存取的權限。
 啟動的操控

 HKLM\SOFTWARE\Microsoft\Windows\Current
Version, \Run, \RunOnce, \RunOnceEx,
\RunServices

遠端控制
National Center for High-performance Computing
www.nchc.org.tw
8-安置後門(續)

啟動的操控
 HKLM\SOFTWARE\Microsoft\Windows\Current
Version、\Run、\RunOnce、\RunOnceEx、
\RunServices

遠端控制
 Telnet
service
 VNC、Terminal services、pcanywhere
National Center for High-performance Computing
www.nchc.org.tw
9-消滅證據
駭客完成環境的佈署後,清除系統與相關設
備的紀錄,避免被系統管理人員稽核時發現。
 隱藏惡意程式或是後門程式。

 變更屬性
 利用工具
 系統特性
 隱藏至NTFS file streaming
 隱藏至MRB
National Center for High-performance Computing
www.nchc.org.tw
10-阻絕服務
駭客可能花了很多心思,都無法入侵目標系
統,使他們利用阻絕服務的程式,對目標系
統發動阻絕服務攻擊。
 雖然攻擊結果不致於讓資料流失,但卻讓系
統癱瘓或讓網路塞車,而造成該網路系統無
法提供服務之目的。
 常用的阻絕手法:

 SYN
Flood、IP Spoofing、DDOS、郵件炸彈…
 Tools:Ping of death、land、teardrop、
mailbomb、spam mail
National Center for High-performance Computing
www.nchc.org.tw
Rootkit的預防措施

基本的系統與網路安全防護

設定防火牆

Access control
套件更新
監控系統記錄



為重要檔案上鎖



chattr +i filename : set the immutable flag
chattr -i filename : unsets the immutable flag
lsattr filename :display attributes set to a file
National Center for High-performance Computing
www.nchc.org.tw
偵測rootkit

檔案一致性檢查工具



RPM套件的校驗功能



rpm -V package
rpm -Vf filename
Rootkit檢查工具



Tripwire:http://www.tripwire.com/
Aide:http://www.cs.tut.fi/~rammer/aide.html
chkrootkit:http://www.chkrootkit.org/
Rootkit hunter:http://www.rootkit.nl/projects/rootkit_hunter.html
nmap或nessus進行掃描
National Center for High-performance Computing
www.nchc.org.tw
RPM套件的校驗功能
# rpm -Vf /etc/inittab
..5....T c /etc/inittab
 檢查項目








S:檔案大小是否已改變
M:檔案型及權限是否已改變
5:MD5 sum值是否已改變
D:裝置名稱是否已改變
L:Link屬性是否已改變
U:檔案的擁有者是否已改變
G:檔案的所屬群組是否已改變
:T檔案建立的時間是否已改變
National Center for High-performance Computing
www.nchc.org.tw
安裝rootkit hunter

至官方網站下載最新套件
# wget http://downloads.rootkit.nl/rkhunter-1.2.9.tar.gz
http://sourceforge.net/projects/rkhunter/

解開套件後安裝
# tar -zxvf rkhunter-1.2.9.tar.gz
# cd rkhunter
# ./installer.sh

套件架構


執行檔:/usr/local/bin/rkhunter --checkall
安裝目錄:/usr/local/rkhunter
National Center for High-performance Computing
www.nchc.org.tw
使用rootkit hunter


/usr/local/bin/rkhunter --checkall
檢查分成以下幾個部份






Checking binaries
Check rootkits
Networking
System checks
Application advisories
最後會顯示檢查總結報告
National Center for High-performance Computing
www.nchc.org.tw
掃描結果
---------------------------- Scan results ---------------------------MD5
MD5 compared: 0
Incorrect MD5 checksums: 0
File scan
Scanned files: 342
Possible infected files: 0
Application scan
Vulnerable applications: 1
Scanning took 308 seconds
----------------------------------------------------------------------Do you have some problems, undetected rootkits, false positives, ideas
or suggestions?
Please e-mail me by filling in the contact form (@http://www.rootkit.nl)
-----------------------------------------------------------------------
National Center for High-performance Computing
www.nchc.org.tw
IF…













清查後門
追查入侵原因
追蹤入侵來源
做好重灌系統的心理準備
備份重要檔案
重灌系統
事後更要, 加強安全防駭知識
善用工具 (如: 安裝: 檢查檔案系統完整性的工具: Tripware; 安裝任何程
式套件之前, 使用 MD5 checksum 比對)
注意相關安全訊息
勤補系統
養成良好的網管習慣 (如: 避免用 telnet / ftp, 改用 ssh2, sftp2, scp)
持續的關心監控
努力維護主機安全
National Center for High-performance Computing
www.nchc.org.tw
AIDE簡介





Advanced Intrusion Detection Environment
可取代tripwire的open source 套件
可以藉由檔案完整性檢查,協助管理者早期發現系統入侵跡
象的安全工具
管理者可自定檔案範圍及檢查項目,藉由比對方式,產生檔
案變動的報告。
產生系統檔案特徵的資料庫(aide.db),已作為日後核對之
用。
National Center for High-performance Computing
www.nchc.org.tw
AIDE簡介

AIDE可以檢查檔案特性項目


AIDE用來檢查檔案完整性的演算法


存取權限設定(permissions), inode編號(inode number), 檔案擁有者
(user), 檔案擁有群組(group), 檔案大小(file size),檔案最近被修改時
間(mtime and ctime), 檔案最近被修改時間(atime), 檔案大小的改變
(growing size)及檔案鏈結數(number of links)
sha1, md5, rmd160, tiger (crc32, haval and gost can be compiled in
if mhash support is available)
AIDE的安裝時機

檔案檢查原理是比對,因此你必須在確定系統是乾淨的時候 來進行
資料庫的初值化或更新
National Center for High-performance Computing
www.nchc.org.tw
安裝AIDE

由原始碼安裝


由http://sourceforge.net/projects/aide下載原始碼
以RPM方式安裝

由http://rpm.pbone.net/下載AIDE的RPM套件
安裝套件
修改設定檔/etc/aide.conf
進行AIDE資料庫初值化

yum install aide



National Center for High-performance Computing
www.nchc.org.tw
AIDE的設定檔--/etc/adie.conf

系統參數







@@define DBDIR /var/lib/aide
database=file:@@{DBDIR}/aide.db.gz
database_out=file:@@{DBDIR}/aide.db.new.gz
gzip_dbout=yes
verbose=5
report_url=file:/var/log/aide.log
report_url=stdout
National Center for High-performance Computing
www.nchc.org.tw
AIDE的設定檔--/etc/adie.conf

Rules:包括檔案特性及檢查檔案完整性的演算法


















p:
permissions
i:
inode:
n:
number of links
u:
user
g:
group
s:
size
b:
block count
m:
mtime
a:
atime
c:
ctime
S:
check for growing size
md5: md5 checksum
sha1: sha1 checksum
rmd160: rmd160 checksum
tiger: tiger checksum
haval: haval checksum
gost: gost checksum
crc32: crc32 checksum
National Center for High-performance Computing
www.nchc.org.tw
AIDE的設定檔--/etc/adie.conf

自訂rule







R:
p+i+n+u+g+s+m+c+md5
L:
p+i+n+u+g
E:
Empty group
>:
Growing logfile p+u+g+i+n+S
NORMAL = R+b+sha1
DIR = p+i+n+u+g
設定檢查項目: [目錄/檔案] [rule]


/boot NORMAL
/etc/passwd NORMAL
National Center for High-performance Computing
www.nchc.org.tw
AIDE的用法

資料庫初始化


檢查系統檔案是否遭修改


/usr/sbin/aide --init
/usr/sbin/aide --check
資料庫更新

/usr/sbin/aide --update
National Center for High-performance Computing
www.nchc.org.tw
AIDE資料庫初值
1. 建立新的AIDE資料庫
# aide --init
AIDE, version 0.10
### AIDE database initialized.
2. 將產生的AIDE資料庫轉存成/var/lib/aide/aide.db.gz
# cd /var/lib/aide
# mv aide.db.new.gz aide.db.gz
National Center for High-performance Computing
www.nchc.org.tw
範例

1.
2.
使用AIDE檢查檔案是否被修改
完成AIDE資料庫初值化
修改受監控的檔案
#chmod 664 /etc/passwd
3.
以aide --check指令檢查
# aide --check
AIDE found differences between database and filesystem!!
Start timestamp: 2005-09-21 12:05:10
Summary:
Total number of files=106605,added files=0,removed files=0,changed files=1
Changed files:
changed:/etc/passwd
Detailed information about changes:
File: /etc/passwd
Permissions: -rw-r--r-Ctime : 2005-08-05 10:09:09
National Center for High-performance Computing
, -rw-rw-r-, 2005-09-21 12:00:01
www.nchc.org.tw
Q&A
National Center for High-performance Computing
www.nchc.org.tw
36