翻譯自:https://pentestlab.blog/2023/03/07/persistence-event-log-online-help/
事件檢視器是 Microsoft Windows 的一個元件,用于顯示與應用程式、安全性、系統和安裝事件相關的資訊。盡管該事件檢視器主要用于管理者對視窗錯誤進行故障排除,但也可以在紅隊操作期間用作持久性的形式。為了幫助管理者通過 Web 檢索特定事件 ID 的直接資訊,Microsoft 嵌入了稱為事件日志聯機幫助的功能。
事件日志聯機幫助将使用者重定向到 Microsoft URL,并從以下系統資料庫位置進行控制。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Event Viewer
如果已獲得本地管理者通路權限,則可以修改三個系統資料庫項,以便在使用者單擊事件日志聯機幫助後執行任意有效負載。這些鍵可以在下面找到:
- 微軟重定向程式
- MicrosoftRedirectionProgramCommandLineParameters
- 微軟重定向網址
一個非常簡單的概念證明是觸發一個消息框。
#include <windows.h>
#pragma comment (lib, "user32.lib")
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
MessageBox(NULL, "pentestlab.blog", "Pentestlab", MB_OK);
return 0;
}
上面的代碼可以使用MinGW編譯以生成可執行檔案。
x86_64-w64-mingw32-g++ -O2 messagebox.cpp -o messagebox.exe -I/usr/share/mingw-w64/include/ -s -ffunction-sections -fdata-sections -Wno-write-strings
-fno-exceptions -fmerge-all-constants -static-libstdc++ -static-libgcc -fpermissive
系統資料庫項“MicrosoftRedirectionProgram”可以修改以包含已編譯的可執行檔案的位置。單擊事件日志聯機幫助将顯示消息框,訓示代碼已執行。
事件日志聯機幫助 – 消息框
以類似的方式,“msfvenom”可用于生成有效載荷。
msfvenom – 有效載荷生成
修改下面的系統資料庫項以映射到以前生成的有效負載在磁盤上的位置将執行有效負載。
微軟重定向計劃 – 系統資料庫項
單擊“事件日志聯機幫助”時,将建立連接配接。
事件日志聯機幫助 – 計量器
第二個系統資料庫項“MicrosoftRedirectionProgramCommandLineParameters”允許使用者修改資料值以執行指令。一個非常常見的陸地二進制檔案,如“regsvr32”,可以用來執行無檔案有效載荷。
Microsoft Redirection Program Command Line Parameters
Once the Event Log Online Help is clicked the command will be executed and a communication channel will established.
Meterpreter – regsvr32
The last registry key is the “MicrosoftRedirectionURL” which by default it points out to a Microsoft location. The registry value could be changed to point either to a malicious URL or to a payload which is dropped on the disk.
微軟重定向網址
在上述所有方案中,将建立以下條件:
- 父程序 (mmc.exe) – > 子程序(有效負載)
MMC – 父程序
EDR 應該标記 mmc 何時嘗試生成不受信任的程序。此外,監視上述系統資料庫項的更改可能會産生檢測機會。由于需要通路Windows圖形界面,并且考慮到普通使用者通常不會打開事件檢視器并單擊Windows事件日志聯機幫助,是以這種技術不太可能普及。但是,在假定的違規或惡意内部方案中,它可以用作通過 C2 通道維護活動連接配接的簡單方法。