0xlane BypassUAC Save

Use ICMLuaUtil to Bypass UAC!

Project README

BypassUAC

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

代码摘自:

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

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

Author: Oddvar Moe
Type: Elevated COM interface
Method: ICMLuaUtil
Target(s): Attacker defined
Component(s): Attacker defined
Implementation: ucmCMLuaUtilShellExecMethod
Works 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(_GUID const &,void * *)
02 AddRef(void)
03 Release(void)
04 SetRasCredentials(ushort const *,ushort const *,ushort const *,int)
05 SetRasEntryProperties(ushort const *,ushort const *,ushort * *,ulong)
06 DeleteRasEntry(ushort const *,ushort const *)
07 LaunchInfSection(ushort const *,ushort const *,ushort const *,int)
08 LaunchInfSectionEx(ushort const *,ushort const *,ulong)
09 CreateLayerDirectory(ushort const *)
10 ShellExec(ushort const *,ushort const *,ushort const *,ulong,ulong)
11 SetRegistryStringValue(int,ushort const *,ushort const *,ushort const *)
12 DeleteRegistryStringValue(int,ushort const *,ushort const *)
13 DeleteRegKeysWithoutSubKeys(int,ushort const *,int)
14 DeleteRegTree(int,ushort const *)
15 ExitWindowsFunc(void)
16 AllowAccessToTheWorld(ushort const *)
17 CreateFileAndClose(ushort const *,ulong,ulong,ulong,ulong)
18 DeleteHiddenCmProfileFiles(ushort const *)
19 CallCustomActionDll(ushort const *,ushort const *,ushort const *,ushort const *,ulong *)
20 RunCustomActionExe(ushort const *,ushort const *,ushort * *)
21 SetRasSubEntryProperties(ushort const *,ushort const *,ulong,ushort * *,ulong)
22 DeleteRasSubEntry(ushort const *,ushort const *,ulong)
23 SetCustomAuthData(ushort const *,ushort const *,ushort const *,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

实现部分

直接参考代码实现。

Open Source Agenda is not affiliated with "0xlane BypassUAC" Project. README Source: 0xlane/BypassUAC
Stars
434
Open Issues
0
Last Commit
4 years ago
Repository

Open Source Agenda Badge

Open Source Agenda Rating