欢迎来到 黑吧安全网 聚焦网络安全前沿资讯,精华内容,交流技术心得!

CVE-2018-8550分析与复现

来源:本站整理 作者:佚名 时间:2019-03-15 TAG: 我要投稿

这个漏洞属于com组件Unmarshal类型本地权限提升漏洞
复现环境
Windows 10 1709 32位操作系统
需要安装声卡或操作系统自带虚拟声卡
编译环境Visual Studio 2013
 
Poc 分析
原poc作者James Forshaw使用C#实现,我一直未复现成功,不过通过原poc的代码我大致明白了漏洞的成因和触发方法,原poc环境是win10 1803 X64系统.在cve2018-8550更新补丁出来不久,微软就取消了64位ole32.dll和coml2.dll调试符号提供,不过32的仍然可以正常提供.为了方便调试我用vc在32位系统上成功复现了poc.
poc采用的反射从低权限进程(poc进程)向高权限进程(bits服务)Unmarshal方式实现触发bits复制了一个poc进程中的一个句柄至高权限进程从而用来创建进程实现提权,Unmarshal采用的ClassID为CLSID_DfMarshal={ 0x0000030B, 0x0000, 0x0000, { 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, } ,Bits服务器调用了ole32(在win10中被代码迁移到coml2)的DfUnMarshalInterface方法来Unmarshal的数据流中SDfMarshalPacket被poc精心构造的数据包,由于poc使用的是StgCreateDocfile创建IStorage对象,所以最终DfUnMarshalInterface调用了CExposedDocFile::Unmarshal来Unmarshal,下面是逆向的代码:
int __stdcall CExposedDocFile::Unmarshal(IStream *pstm, void **ppv, unsigned int mshlflags)
{
  int hrFinal; // esi
  int hrTempNext; // eax
  CPubDocFile *CPubDocFileObj; // eax
  CGlobalContext *CGlobalContextObj; // eax
  const void *v7; // eax
  CGlobalContext *CGlobalContextObjRef; // eax
  CPubDocFile *CBasedPubDocFileObjFirst; // eax
  unsigned int fUnmarshalOriginalConfig; // eax
  CPubDocFile *CBasedPubDocFileObjFirstRef; // ecx
  int fUnmarshalOriginalConfigRef; // ST10_4
  int IsRootConfig; // eax
  void *ReservedForOleRef; // ebx
  unsigned int CMarshalListObj_baseObj; // ecx
  unsigned int pid; // eax
  CMarshalList *CMarshalListObjFirst; // ecx
  CMarshalList *CMarshalListObjFound; // eax
  CExposedDocFile *CExposedDocFile_MarshalList_Final; // esi
  CExposedDocFile *CExposedDocFileObjNext; // eax MAPDST
  CDFBasis *CBasedDFBasisObj; // esi
  CPubDocFile *CBasedPubDocFileObjNext; // edx
  CSmAllocator *CSmAllocator_A; // eax
  CSmAllocator *CSmAllocator_B; // eax
  unsigned int CBasedMarshalListObj; // eax
  CMarshalList *CBasedMarshalListObjNext; // ecx
  CPubDocFile *CPubDocFileObjNext; // eax
  CDFBasis *BasedDFBasisObj; // eax
  CPerContext *CPerContextObjRef; // ecx
  CSmAllocator *CSmAllocator_C; // eax
  CSmAllocator *CSmAllocator_D; // eax
  CPerContext pcSharedMemory; // [esp+Ch] [ebp-8Ch]
  unsigned int cbRead; // [esp+50h] [ebp-48h]
  SDfMarshalPacket SDfMarshalPacketCurrent; // [esp+54h] [ebp-44h]
  IStorage *pstorgeStd; // [esp+88h] [ebp-10h]
  CDfMutex mtx; // [esp+8Ch] [ebp-Ch]
  CPerContext *CPerContextObj; // [esp+94h] [ebp-4h]
  void *pvBaseOld; // [esp+A0h] [ebp+8h]
  // SDfMarshalPacketCurrent初始化里面的字段指针都是nullptr
  mtx._pGlobalPortion = 0;
  mtx._hLockEvent = 0;
  pstorgeStd = 0;
  SDfMarshalPacketCurrent.CBasedPubDocFileObj._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedPubStreamObj._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedSeekPointerObj._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedMarshalListObj._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedDFBasisObj._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedGlobalContextObj._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedGlobalFileStreamObj._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedGlobalFileStreamDirty._SelftobjectPtr = 0;
  SDfMarshalPacketCurrent.CBasedGlobalFileStreamOriginal._SelftobjectPtr = 0;
  // 构造pcSharedMemory是一个cpercontext,先构造变量
  CPerContext::CPerContext(&pcSharedMemory, 0);
  // 通用marshal方法先CoUnmarshalInterface
  CoUnmarshalInterface(pstm, &IID_IStorage, (IUnknown *)&pstorgeStd);
  if ( (mshlflags & 0x80000000) != 0 )
  {
    // 这里都读流int就是largeint
    hrFinal = ((int (__stdcall *)(IStream *, signed int, _DWORD, signed int, _DWORD))pstm->_SelfStreamVtbl->Seek)(
                pstm,
                96,
                0,
                1,
                0);

[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]  下一页

【声明】:黑吧安全网(http://www.myhack58.com)登载此文出于传递更多信息之目的,并不代表本站赞同其观点和对其真实性负责,仅适于网络安全技术爱好者学习研究使用,学习中请遵循国家相关法律法规。如有问题请联系我们,联系邮箱admin@myhack58.com,我们会在最短的时间内进行处理。
  • 最新更新
    • 相关阅读
      • 本类热门
        • 最近下载