2023年3月14日微软发布了2023年3月月度更新补丁公布了一个在野利用的Outlook远程执行漏洞,利用该漏洞可以通过使用NTLM认证的Outlook发起远程执行代码,关于该漏洞的介绍可以参考:https://msrc.microsoft.com/blog/2023/03/microsoft-mitigates-outlook-elevation-of-privilege-vulnerability/(该漏洞威胁等级评分为9.8分属于高危漏洞,建议及时更新对应补丁),本次想要给大家分享的是使用微软公布出的CVE-2023-23397.ps1脚本去监测企业内部邮箱是否有被该漏洞利用的痕迹。(脚本使用相关介绍:https://microsoft.github.io/CSS-Exchange/Security/CVE-2023-23397/)之所以写这篇文章,是因为我按照官网的执行方法去执行,遇到了一些问题,执行不是很顺利耗费了一些时间去解决这个脚本执行不成功的问题,下面我将我成功执行成功的步骤分享给大家,让大家少走弯路。废话不多说,具体执行步骤如下:
1、下载脚本
https://microsoft.github.io/CSS-Exchange/Security/CVE-2023-23397/
2、下载Microsoft.Exchange.WebServices.2.2.0,下载后将.nupkg 后缀更改为 .zip,然后解压zip文件。
Microsoft.Exchange.WebServices.2.2.0
将解压后的文件放在服务器某个特定目录下面,我这里是放在C:\temp目录下;
C:\temp\microsoft.exchange.webservices.2.2.0\lib\40\Microsoft.Exchange.WebServices.dll
3、创建执行脚本账号所需角色和创建一个限制策略
New-ThrottlingPolicy "CVE-2023-23397-Script"
Set-ThrottlingPolicy "CVE-2023-23397-Script" -EWSMaxConcurrency Unlimited -EWSMaxSubscriptions Unlimited -CPAMaxConcurrency Unlimited -EwsCutoffBalance Unlimited -EwsMaxBurst Unlimited -EwsRechargeRate Unlimited
Set-Mailbox -Identity "这里写执行脚本邮箱samaccountname" -ThrottlingPolicy "CVE-2023-23397-Script"
4、执行脚本
执行脚本的时候需要手动添加如下参数:
-DLLPath 指定microsoft.exchange.webservices.2.2.0位置(例如:-DLLPath "C:\temp\microsoft.exchange.webservices.2.2.0\lib\40\Microsoft.Exchange.WebServices.dll")
-IgnoreCertificateMismatch 忽略证书
-UserMailboxes 指定需要扫描的邮箱
-EWSServerURL 指定EWS访问地址,可以是服务器FQDN
-Credential 指定执行脚本的用户凭据。(可以这样使用:-Credential $cred,而
$cred=Get-Credential administrator@contoso.com ,注意用户名为UPN)
1)、单个邮箱扫描
#打开Exchange powershell进入到脚本所在目录
$cred=Get-Credential administrator@contoso.com
.\CVE-2023-23397.ps1 -Environment Onprem -DLLPath "C:\temp\microsoft.exchange.webservices.2.2.0\lib\40\Microsoft.Exchange.WebServi
ces.dll" -EWSServerURL "https://127.0.0.1/EWS/Exchange.asmx" -IgnoreCertificateMismatch -UserMailboxes "xxx@contoso.com") -Credential $cred
2)、多个邮箱批量执行扫描
$cred=Get-Credential administrator@contoso.com
#定义一个用户CSV列表,里面可以直接放入邮箱名称
$user= import-csv -path "c:\temp\user.csv"
foreach($users in $user){& "c:\temp\CVE-2023-23397.ps1" -Environment Onprem -DLLPath "C:\temp\microsoft.exchange.webservices.2.2.0\lib\40\Microsoft.Exchange.WebServi
ces.dll" -EWSServerURL "https://127.0.0.1/EWS/Exchange.asmx" -IgnoreCertificateMismatch -UserMailboxes "$($_)@contoso.com" -Credential $cred}
5、执行结果