- Notifications
You must be signed in to change notification settings - Fork74
0xlane/BypassUAC
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
利用Autoelevated
属性的COM
接口配合PEB
伪装实现BypassUAC
,分成了C
和C#
版本!
代码摘自:
以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
属性:这里的
Enabled
和Auto 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
个函数ShellExec
从IDA
中看到该函数调用了ShellExecuteEx
这个Windows API
实现了命令执行:
通过对ICMLuaUtil
接口的分析,可以看出可以用来BypassUAC
执行命令的COM
组件需要有两个特点:
elevation
属性启用,且开启Auto Approval
;COM
组件中的接口存在可以命令执行的地方,例如ICMLuaUtil
的ShellExec
;
除了通过上面的方式在OleView
中手动去找,还可以通过UACMe
项目提供的Yuubari
工具快速查看系统UAC
设定信息以及所有可以利用的程序和COM
组件,使用方法如下:
使用VS2019
加载Yuubari
,生成后会得到二进制文件UacInfo64.exe
,运行后在同目录生成一个log
文件记录所有输出结果:从这里面可以找到所有的
Autoelevated COM objects
,包括CMSTPLUA
组件的信息:
通过分析UACMe
中的ucmCMLuaUtilShellExecMethod
实现可以知道想要利用COM
接口,需要知道这几个东西:
- 标识
COM
组件的GUID
,即CLSID
- 标识
interface
的GUID
,即IID
- 该接口的虚函数表,主要用来找到
ShellExec
的函数偏移
前两个可以很容易找到,虚函数表可以通过OleView
提示的虚函数表位置偏移找到,这里再说一种通用的方法,完全利用IDA
。
第一步,用IDA
打开cmlua.dll
;第二步,在左侧函数列表中搜索destructor
或者constructor
,双击后跳转后,上下找找可以看到调用vftable
的地方:双击跳转到变量定义位置,就可以找到虚函数表!
直接参考代码实现。
About
Use ICMLuaUtil to Bypass UAC!
Topics
Resources
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.