Windows Print Spooler权限提升漏洞(CVE-2021-1675)

admin 2022年6月8日07:03:10评论32 views字数 3732阅读12分26秒阅读模式

01


漏洞介绍



Windows Print Spooler权限提升漏洞(CVE-2021-1675)
Windows Print Spooler权限提升漏洞(CVE-2021-1675)





Print Spooler是Windows系统中用于管理打印相关事务的服务。

该漏洞在域环境中合适的条件下,无需任何用户交互,未经身份验证的远程攻击者就可以利用该漏洞以SYSTEM权限在域控制器上执行任意代码,从而获得整个域的控制权。






Windows Print Spooler权限提升漏洞(CVE-2021-1675)
Windows Print Spooler权限提升漏洞(CVE-2021-1675)


02


复现环境



攻击机:192.168.75.223

目标:192.168.75.224

工具:相关exp

版本:Windows server 2016


03


影响范围



- Windows Server 2012 R2(Server Core installation)

- Windows Server 2012 R2

- 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 2008 for x64-based Systems Service Pack 2(Server Core installation)

- Windows Server 2008 for x64-based Systems Service Pack 2

- Windows Server 2008 for 32-bit Systems Service Pack 2(Server Core installation)

- Windows Server 2008 for 32-bit Systems Service Pack 2

- 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 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 Server, version 20H2(Server Core Installation)

- 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, version 2004(Server Core installation)

- Windows 10 Version 2004 for x64-based Systems

- Windows 10 Version 2004 for ARM64-based Systems

- Windows 10 Version 2004 for 32-bit Systems

- Windows 10 Version 21H1 for 32-bit Systems

- Windows 10 Version 21H1 for ARM64-based Systems

- Windows 10 Version 21H1 for x64-based Systems

- Windows 10 Version 1909 for ARM64-based Systems

- Windows 10 Version 1909 for x64-based Systems

- Windows 10 Version 1909 for 32-bit 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


04


漏洞原理



一、动态查看CVE调用,通过Process Moniter抓取到EXP加载DLL时,执行过程中的堆栈调用。

该漏洞点在于,调用YAddPrinterDriverEx函数时,没有对参数dwFileCopyFlags做校验,能够使用APD_INSTALL_WARNED_DRIVER标志,导致后面对驱动合法性校验失效,可以任意的加载DLL,并且为system权限。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

二、功能分析

EXP会通过RpcBindingSetAuthInfoExW函数,绑定句柄的认证,授权和安全质量的服务信息。当函数执行成功时,identity.User设置用户名,代表了权限。如果是低权限用户,执行ValidateObjectAccess函数后结果为0,administrator用户的权限执行ValidateObjectAccess函数后结果为1。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)


1)绕过ValidateObjectAccess检测

CVE-2021-1675是逻辑漏洞,通过RPC添加打印机驱动程序的时候,参数dwFileCopyFlags(v7)的标志位APD_INSTALL_WARNED_DRIVER(0x8000)为1时,_bittest函数的结果为1,则v12被赋值为0,从而不执行ValidateObjectAccess的检查。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

但在Server 12的中,a7的值是固定为1,一定会执行ValidateObjectAccess检测。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

2)检查驱动基本信息

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

MyName:检查驱动名称是否合法,ValidateDriverInfo的执行流程。

a.检查是否为本地文件

b.核对初始化key

c.校验驱动文件的合法性

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

但是当dwFileCopyFlags含有 APD_INSTALL_WARNED_DRIVER(0x8000)标志位时,dwFileCopyFlags & 0x8000的结果为0x8000,0x8000取非后值为0,将会跳过驱动进一步的校验。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

3)获取文件句柄

v13的值是由dwFileCopyFlags的低8位取反后,右移4位,再跟1做与运算得出。v13的值决定CreateInternalDriverFileArray函数的第5个参数(a5)。经过计算,当dwFileCopyFlags低8位的值为0x1X时(X可为0-F中任意值),可以使a5为0。当a5的值为0,可以规避对驱动文件的合法性检查。

通过CreateFile打开文件,得到3个文件句柄,并保存到DllAllocSplMem申请的空间中,用于后面文件更新使用。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

4)拷贝文件到驱动空间

dwFileCopyFlags的成员pConfigFile、pDataFile、pDriverPath分别保存了配置文件、数据文件、驱动文件的文件路径。将上述成员中的文件路径下的文件,移动到

C:WindowsSystem32spooldriversx643下时,需要经过以下操作

a.文件句柄的文件信息进行核对

b.将文件拷贝到

C:WindowsSystem32spooldriversx643new

c.通过WaitRequiredForDriverUnload函数下的MoveNewDriverRelatedFiles函数,将spooldriversx643下的同名文件移动到spooldriversx643oldx (x∈[1,3] ) 目录下,再把spooldriversx643new目录文件,移动到spooldriversx643下,从而实现更新文件。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

5)更新驱动文件

通过更新Config文件,将spooldriversx643下新的配置文件加载起来。

Windows Print Spooler权限提升漏洞(CVE-2021-1675)


05


漏洞复现



1. 开启kali smb 匿名访问

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

2. 生成payload

(注意:只能使用64位的dll文件,否则会发现,dll文件可以上传但不会被执行)

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

3. 监听4444端口

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

4. 执行exp

(其中test为域的名字,test1:123@qwe分别是域控任意用户的账号密码,192.168.75.224是域控ip,192.168.75.223smbshell.dll为可访问unc路径,也是共享文件的路径)

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

5. 利用成功

Windows Print Spooler权限提升漏洞(CVE-2021-1675)


06


安全建议



1. 更新漏洞补丁

2. 禁用Print Spooler服务缓解

往期精彩推荐
Windows Print Spooler权限提升漏洞(CVE-2021-1675)


记一次搭建靶场渗透过程(1)

记一次搭建靶场渗透过程(2)

记一次搭建靶场渗透过程(3)

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

Windows Print Spooler权限提升漏洞(CVE-2021-1675)

           团队介绍

银河护卫队super,是一个致力于红队攻防实战、内网渗透、代码审计、安卓逆向、安全运维等技术干货分享的队伍,定期分享常用渗透工具、复现教程等资源。欢迎有想法、乐于分享的具备互联网分享精神的安全人士进行交流学习。
Windows Print Spooler权限提升漏洞(CVE-2021-1675)

点击关注银河护卫队super

原文始发于微信公众号(银河护卫队super):Windows Print Spooler权限提升漏洞(CVE-2021-1675)

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年6月8日07:03:10
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Windows Print Spooler权限提升漏洞(CVE-2021-1675)http://cn-sec.com/archives/763440.html

发表评论

匿名网友 填写信息