CVE-2018-8174双杀漏洞分析复现及防御
来源:岁月联盟
时间:2020-01-29
if ( !result_1 ) // 当认为当下的Object的引用计数已经为0时,进入系统析构程序
{
if ( this_1 )
(*(void (__thiscall **)(VBScriptClass *, signed int))(*(_DWORD *)this_1 + 0x68))(this_1, 1);// 调用析构函数释放VBScriptClass的内存
}
}
return result_1;
}
2.1.2 溯源
// 在winDbg中这样下断点
bp vbscript!VBScriptClass::TerminateClass ".printf /"Class %mu at %x, terminate called//n/", poi(@ecx + 0x24), @ecx; g";
bp vbscript!VBScriptClass::Release ".printf /"Class %mu at: %x ref counter, release called: %d//n/", poi(@eax + 0x24), @ecx, poi(@eax + 0x4); g";
bp vbscript!VBScriptClass::Create+0x55 ".printf /"Class %mu created at %x//n/", poi(@esi + 0x24), @esi; g";
bp vbscript!VbsIsEmpty
第一次断点:
//即可输出VBScriptClass对象名称,对象地址,虚函数表地址,以及引用计数:
0:013> g
Class Trigger created at 178afd0
Class Trigger at: 6fb61748 ref counter, release called: 2
Class Trigger at: 6fb61748 ref counter, release called: 2
Class Trigger at: 6fb61748 ref counter, release called: 2
//类对象地址
0:005> ln poi (0178afd0 )
(6fb61748) vbscript!VBScriptClass::`vftable' | (6fb6c518) vbscript!__pfnDefaultDliNotifyHook2
Exact matches:
vbscript!VBScriptClass::`vftable' =
0:005> dd 0178afd0
0178afd0 6fb61748 00000002 05fd1f78 08477f88 //02是引用计数的值
0178afe0 00000e08 00000000 00000000 05fd5efc
0178aff0 00000000 088d6fe4 00000000 00000000
0:005> du 088d6fe4 //类的名字
088d6fe4 "Trigger"
//也可以通过vbscript!VbsIsEmpty断点追溯到类的地址。如下:
Breakpoint 3 hit
eax=6fb6185c ebx=044bd284 ecx=6fbba9d8 edx=044bd1fc esi=05faf54c edi=00000001
eip=6fb7c206 esp=044bd118 ebp=044bd128 iopl=0 nv up ei pl zr na pe nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000246
vbscript!VbsIsEmpty:
6fb7c206 8bff mov edi,edi
0:005> dd poi(esp+c)
05fbbf60 044b004a 77431fd0 0174bfe8 01721020 //0174bfe8是数据结构地址
05fbbf70 c0c00000 c0c0c0c0 c0c0c0c0 c0c0c0c0
05fbbf80 044bd578 05fbbfa0 c0c0c0c0 c0c0c0c0
05fbbf90 c0c00000 c0c0c0c0 c0c0c0c0 c0c0c0c0
05fbbfa0 044bd7bc 05fbbfe0 c0c00001 c0c0c0c0
05fbbfb0 0000400c 00000000 05fc5ec8 00000000
05fbbfc0 0000400c 00000000 05fc5e88 00000000
05fbbfd0 c0c00000 c0c0c0c0 c0c0c0c0 c0c0c0c0
0:005> dd 0174bfe8 l8
0174bfe8 044b200c 77431fd0 0833efe8 01721020//200c这两个字节表示的是VBScript变量类型,表示的是SAFEARRAY类型,ARRAY在07f4dfe8存放
0174bff8 00000000 c0c0c0c0 ???????? ????????
0:005> dt ole32!safearray 0833efe8 //解析safearray结构,pvdata表示数据地址
+0x000 cDims : 1 //cDims表示维数
+0x002 fFeatures : 0x880
+0x004 cbElements : 0x10
+0x008 cLocks : 0
+0x00c pvData : 0x08346fe0 Void //array_a数据元素地址
+0x010 rgsabound : [1] tagSAFEARRAYBOUND
0:005> dd 0x08346fe0
08346fe0 00000000 00000000 00000000 00000000 //array_a(0)没有定义
08346ff0 c0c00009 c0c0c0c0 0178afd0 c0c0c0c0 //array_a(1)type==0x9表示是一个object,值为0178afd0
08347000 ???????? ???????? ???????? ????????
//即找到类对象的地址,也就是说array_a(1)已经指向了Trigger对象
0:005> dd 0178afd0
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] 下一页