CVE-2018-8174双杀漏洞分析复现及防御
来源:岁月联盟
时间:2020-01-29
774e65f4 ntdll!RtlDebugFreeHeap+0x0000002f
774aa0aa ntdll!RtlpFreeHeap+0x0000005d
774765a6 ntdll!RtlFreeHeap+0x00000142
..
..
//此时分别查看array_b与array_a 的情况:
//array_b(0)的情况:
0:005> dd 0x012edfe0
012edfe0 c0c00009 c0c0c0c0 0178afd0 c0c0c0c0 //array_b(0)依然保存着类对象地址,但是类对象已经被释放了
012edff0 00000000 00000000 00000000 00000000
012ee000 ???????? ???????? ???????? ????????
012ee010 ???????? ???????? ???????? ????????
//array_a的情况:
0:005> dd 0x08346fe0
08346fe0 ???????? ???????? ???????? ???????? //array_a已经被释放
08346ff0 ???????? ???????? ???????? ????????
08347000 ???????? ???????? ???????? ????????
显然有些地方出现了错误,明明 array_b 还保留着对 Trigger Object引用的时候,Trigger Object却随着 Erase array_a被释放了。我们来看看错误的地方:
2.2 验证
在IDA里面查看过 VBScriptClass::Release 的伪代码,以及上面的调试后,我们猜测在脚本中的重载的析构函数中,Setarray_b(0)=array_a(1)这句是否有对 Class Trigger 的引用计数进行操作,
接下来进行验证,在以下位置下断点:
bu vbscript!VbsErase
bu vbscript!VBScriptClass::Release
bu vbscript!VbsIsEmpty
bp vbscript!VBScriptClass::Create+0x55 ".printf /"Class %mu created at %x//n/", poi(@esi + 0x24), @esi; g";
前面的几次 Release 不用看,一直到VbsErase后面的release的时候单步调试
(此时在调试日志中,类对象地址已经被bp vbscript!VBScriptClass::Create+0x55 ".printf /"Class %mu created at %x//n/", poi(@esi + 0x24), @esi; g"; 打印出来了,或者运行到 release 的时候的esp +8也是类对象地址)
0:005> g
Class Trigger created at 189bfd0
..
..
Breakpoint 1 hit
eax=0189bfd0 ebx=00000020 ecx=6d9a1748 edx=00000000 esi=087efff0 edi=00000009
eip=6d9b1ef3 esp=0468c9cc ebp=0468c9dc iopl=0 nv up ei pl nz na po nc
cs=001b ss=0023 ds=0023 es=0023 fs=003b gs=0000 efl=00000202
vbscript!VBScriptClass::Release:
6d9b1ef3 8bff mov edi,edi
0:005> dd 189bfd0
0189bfd0 6d9a1748 00000001 06103f78 08657f88 //此时的引用计数为1
0189bfe0 00000d80 00000000 00000000 06107efc
0189bff0 00000000 071e4fe4 00000000 00000000
0189c000 ???????? ???????? ???????? ????????
单步调试到:
6d9b1efc 56 push esi
6d9b1efd 8b35e4129a6d mov esi,dword ptr [vbscript!_imp__InterlockedDecrement (6d9a12e4)]
6d9b1f03 57 push edi
6d9b1f04 8d7b04 lea edi,[ebx+4]
6d9b1f07 57 push edi //edi 中保存的便是object的引用计数
6d9b1f08 ffd6 call esi {kernel32!InterlockedDecrementStub (775bbbf0)}
6d9b1f0a 894508 mov dword ptr [ebp+8],eax
6d9b1f0d 85c0 test eax,eax //如果此时的引用计数为0,
6d9b1f0f 0f84d8210000 je vbscript!VBScriptClass::Release+0x1e (6d9b40ed)//则进入Release+0x1e,调用析构函数
6d9b1f15 8b4508 mov eax,dword ptr [ebp+8]
//此时的edi 的值为1,然后调用InterlockedDecrementStub 把引用计数减一
0:005> dd edi
0189bfd4 00000001 06103f78 08657f88 00000d80
//继续调试,这里就执行 我们代码中 的Set array_b(0)=array_a(1)这句了
6da140f4 8bcb mov ecx,ebx
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] 下一页