天天看点

CVE-2020-0787 Windows全版本本地提权漏洞复现

0x00 简介

2020年3月,微软公布了一个影响范围堪称windows全版本的本地提权漏洞CVE-2020-0787,根据微软的漏洞描述,攻击者在使用低权限用户登录系统后,可以利用该漏洞构造恶意程序直接提权到administrator或者system权限。

0x01 漏洞概述

当Windows背景智能传输服务(BITS)没有正确处理符号链接时,存在特权提升漏洞。成功利用此漏洞的攻击者可以改写目标文件,从而提升权限。要利用这个漏洞,攻击者首先必须登录系统,攻击者可以运行EXP,利用该漏洞来提权进而完全控制受影响的系统。漏洞爆出后的安全更新通过纠正Windows BITS处理符号链接的方式修复了这个漏洞。

EXP进行利用的思路是,首先提供给目标服务一个文件夹路径,该路径最初将作为另一个“物理”目录的 junction (连接)点。我们创建了一个新的任务:“下载”一个本地文件,并且在TMP文件上设置 Oplock 。等任务恢复后,该服务会模拟 RPC 客户端身份开始写入 TMP 文件,触发 Oplock 。然后,我们需要将挂载点切换至对象目录(Object Directory),创建2个符号链接。此时TMP文件会指向我们拥有的任意文件,而“本地”文件将指向 System32 目录中的一个新的 dll 文件。在释放 Oplock 后,服务会继续写入原始的 TMP 文件,但会通过我们设置的2个符号链接执行最终的移动操作,这就是近几年来Windows漏洞中的一类 “任意文件移动” 漏洞,相对于内存破坏漏洞而言,这类漏洞不会导致目标主机蓝屏,在执行时有较高的稳定性和隐蔽性。

0x02 影响版本

Windows 10 Version 1809 for ARM64-based Systems
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 1903 (Server Core installation)
Windows 10 Version 1903 for ARM64-based Systems
Windows 10 Version 1903 for x64-based Systems
Windows 10 Version 1903 for 32-bit Systems
Windows 10 Version 1709 for ARM64-based Systems
Windows 10 Version 1709 for x64-based Systems
Windows 10 Version 1709 for 32-bit Systems
Windows Server, version 1909 (Server Core installation)
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 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 10 Version 1809 for x64-based Systems
Windows 10 Version 1809 for 32-bit Systems
Windows 10 Version 1803 for ARM64-based Systems
Windows Server, version 1803 (Server Core Installation)
Windows 10 Version 1803 for x64-based Systems
Windows 10 Version 1803 for 32-bit Systems
           

0x03 环境搭建

1.安装Vmware Workstation 或其他虚拟机软件(本次复现使用的是Vmware Workstation Pro 16)

2.下载安装受漏洞影响的版本的Windows,本次复现使用环境如下:

版本	Windows 10 专业版
版本号	1903
安装日期	‎2021/‎5/‎20
操作系统内部版本	18362.30
           

3.安装 Microsoft Visual Studio(本次复现使用的是 Microsoft Visual Studio Community 2019 版本)

以上软件和系统的具体安装教程可以自行上网搜索

0x04 漏洞复现

1.检查测试靶机有没有打相应的补丁(本次测试为win10 1903系统,对应系统的补丁请对照微软官方给出的列表:https://msrc.microsoft.com/update-guide/en-US/vulnerability/CVE-2020-0787)

systeminfo | findstr KB4540673
           
CVE-2020-0787 Windows全版本本地提权漏洞复现

无回显表示没有查到该补丁相关信息,说明没打补丁

2.下载 EXP 并解压,链接如下:

https://github.com/cbwang505/CVE-2020-0787-EXP-ALL-WINDOWS-VERSION.git
           

3.安装完Visual Studio后双击打开EXP项目中的 .sln 文件。

CVE-2020-0787 Windows全版本本地提权漏洞复现

点击 生成 - 重新生成解决方案,如下图所示:

CVE-2020-0787 Windows全版本本地提权漏洞复现

然后在 .sln 文件同级目录 x64 -> Debug 下即可找到生成的 EXP 文件。

也可以直接下载生成好的 EXP 进行测试,链接如下:

https://github.com/cbwang505/CVE-2020-0787-EXP-ALL-WINDOWS-VERSION/releases/download/1/BitsArbitraryFileMoveExploit.exe
           

4.将生成/下载的EXP程序复制到受漏洞影响的版本的测试靶机上,打开cmd,直接拖动exp到cmd窗口中运行exp,如下图所示:

CVE-2020-0787 Windows全版本本地提权漏洞复现

可以看到exp运行完成后立即弹出一个新的system权限的cmd窗口,如下图所示:

CVE-2020-0787 Windows全版本本地提权漏洞复现

此时就通过该漏洞获取了一个本地系统权限的cmd,可以以system权限执行任意操作。

5.在64位 Win7系统上同样测试成功:

CVE-2020-0787 Windows全版本本地提权漏洞复现

0x05 修复建议

1)根据自己的系统版本打上相应的单独的SSU补丁:http://www.catalog.update.microsoft.com/home.aspx

(本次测试的win10 1903对应的是:http://download.windowsupdate.com/c/msdownload/update/software/secu/2020/03/windows10.0-kb4540673-x64_aefb1592e55950abcaae06f56cdc3e93aed61370.msu)

2)使用Windows更新进行系统安全更新,将自动打上相应安全补丁

继续阅读