Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Use ICMLuaUtil to Bypass UAC!

NotificationsYou must be signed in to change notification settings

0xlane/BypassUAC

Repository files navigation

利用Autoelevated属性的COM接口配合PEB伪装实现BypassUAC,分成了CC#版本!

代码摘自:

什么类型的COM interface可以利用?

UACMe项目中索引为41的方法为例:

Author: Oddvar MoeType: Elevated COM interfaceMethod: ICMLuaUtilTarget(s): Attacker definedComponent(s): Attacker definedImplementation: ucmCMLuaUtilShellExecMethodWorks from: Windows 7 (7600)Fixed in: unfixed 🙈How: -

该方法的目标接口是ICMLuaUtil,对应Akagi项目中具体实现函数为ucmCMLuaUtilShellExecMethod,在项目中的methods/api0cradle.c文件中可以找到该方法的定义:观察发现这里利用的是CMSTPLUA组件的ICMLuaUtil接口。

我的测试系统Windows 10 (1909),使用OleViewDotNet工具可以查看系统中的COM接口属性信息,注意需要以管理员权限运行。

打开CLSIDs窗口搜索cmstplua,可以快速定位该组件:右键查看CMSTPLUA组件的Elevation属性:这里的EnabledAuto Approval值都是True表示这个组件可以用来绕过UAC认证,这是第一点。

第二点是目标接口ICMLuaUtil需要有一个可以执行命令的地方,通过在CISIDs窗口鼠标悬浮在ICMLuaUtil上,可以看到该接口对应的二进制文件为cmlua.dll

虚函数偏移为cmlua.dll+0x6360,通过IDA打开该系统文件(c:\windows\system32\cmlua.dll),跳到虚函数表的位置,可以看到ICMLuaUtil接口的虚函数表:

摘出来看接口函数如下:

01 QueryInterface(_GUIDconst&,void**)02AddRef(void)03Release(void)04SetRasCredentials(ushortconst*,ushortconst*,ushortconst*,int)05SetRasEntryProperties(ushortconst*,ushortconst*,ushort**,ulong)06DeleteRasEntry(ushortconst*,ushortconst*)07LaunchInfSection(ushortconst*,ushortconst*,ushortconst*,int)08LaunchInfSectionEx(ushortconst*,ushortconst*,ulong)09CreateLayerDirectory(ushortconst*)10ShellExec(ushortconst*,ushortconst*,ushortconst*,ulong,ulong)11SetRegistryStringValue(int,ushortconst*,ushortconst*,ushortconst*)12DeleteRegistryStringValue(int,ushortconst*,ushortconst*)13DeleteRegKeysWithoutSubKeys(int,ushortconst*,int)14DeleteRegTree(int,ushortconst*)15ExitWindowsFunc(void)16AllowAccessToTheWorld(ushortconst*)17CreateFileAndClose(ushortconst*,ulong,ulong,ulong,ulong)18DeleteHiddenCmProfileFiles(ushortconst*)19CallCustomActionDll(ushortconst*,ushortconst*,ushortconst*,ushortconst*,ulong*)20RunCustomActionExe(ushortconst*,ushortconst*,ushort**)21SetRasSubEntryProperties(ushortconst*,ushortconst*,ulong,ushort**,ulong)22DeleteRasSubEntry(ushortconst*,ushortconst*,ulong)23SetCustomAuthData(ushortconst*,ushortconst*,ushortconst*,ulong)

其中第10个函数ShellExecIDA中看到该函数调用了ShellExecuteEx这个Windows API实现了命令执行:

通过对ICMLuaUtil接口的分析,可以看出可以用来BypassUAC执行命令的COM组件需要有两个特点:

  1. elevation属性启用,且开启Auto Approval
  2. COM组件中的接口存在可以命令执行的地方,例如ICMLuaUtilShellExec

如何快速找到系统中的所有可利用的COM组件?

除了通过上面的方式在OleView中手动去找,还可以通过UACMe项目提供的Yuubari工具快速查看系统UAC设定信息以及所有可以利用的程序和COM组件,使用方法如下:

使用VS2019加载Yuubari,生成后会得到二进制文件UacInfo64.exe,运行后在同目录生成一个log文件记录所有输出结果:从这里面可以找到所有的Autoelevated COM objects,包括CMSTPLUA组件的信息:

定位ICMLuaUtil的虚函数表vftable

通过分析UACMe中的ucmCMLuaUtilShellExecMethod实现可以知道想要利用COM接口,需要知道这几个东西:

  • 标识COM组件的GUID,即CLSID
  • 标识interfaceGUID,即IID
  • 该接口的虚函数表,主要用来找到ShellExec的函数偏移

前两个可以很容易找到,虚函数表可以通过OleView提示的虚函数表位置偏移找到,这里再说一种通用的方法,完全利用IDA

第一步,用IDA打开cmlua.dll;第二步,在左侧函数列表中搜索destructor或者constructor,双击后跳转后,上下找找可以看到调用vftable的地方:双击跳转到变量定义位置,就可以找到虚函数表!

参考:Get interface definition of undocumented COM objects

实现部分

直接参考代码实现。

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp