Communitygithub.com

使用 Cuckoo Sandbox 分析惡意軟體行為

在 Cuckoo Sandbox 中引爆惡意軟體樣本,以觀察其執行時期行為。

使用 Cuckoo Sandbox 分析惡意軟體行為 是什麼?

此技能提供一個完整的工作流程,用於在 Cuckoo Sandbox 中安全地執行和分析可疑的惡意軟體樣本。它會引導使用者完成從提交樣本、即時監控執行、分析程序活動、網路流量、檔案系統和登錄檔修改,到檢視行為特徵和威脅評分的整個過程。此技能支援 Cuckoo 的命令列介面和 REST API,並針對自動化批量分析進行了最佳化。它還整合了 Volatility 等工具進行記憶體分析,並詳細說明了如何分析多階段的惡意軟體下載器。此技能是為熟悉 Cuckoo 架構並尋求結構化方法以產生全面行為報告的威脅分析師和惡意軟體研究人員設計的。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/analyzing-malware-behavior-with-cuckoo-sandbox

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

使用 Cuckoo Sandbox 分析惡意軟體行為 是做什麼的?

使用時機

  • 可疑樣本已通過靜態分析篩選,需要在受控環境中進行行為觀察時
  • 需要從惡意軟體執行過程中擷取網路流量、檔案掉落、登錄檔修改和 API 呼叫時
  • 需要判斷完整的感染鏈,包括第二階段酬載下載和持續性機制時
  • 需要根據觀察到的執行時期活動產生行為特徵和 YARA 規則時
  • 需要對大量惡意軟體樣本進行自動化分析並產出一致報告時

請勿使用 於已知會透過網路共享在配置不當的沙箱中擴散的勒索軟體變種;請先驗證網路隔離。

先決條件

  • 在專用分析伺服器(建議使用 Ubuntu 22.04)上安裝 Cuckoo Sandbox 3.x
  • 配置 Windows 10/11 快照的 Guest VM(已安裝 Cuckoo agent,並在乾淨狀態下建立快照)
  • 將 VirtualBox、KVM 或 VMware 配置為 Cuckoo 的虛擬化後端
  • 使用 InetSim 或 FakeNet-NG 建立隔離網路,以模擬網際網路服務
  • 整合 Suricata 或 Snort,以便在分析過程中進行網路層級的特徵比對
  • 足夠的磁碟空間用於儲存 PCAP 封包和記憶體傾印(建議至少 500 GB)

工作流程

步驟 1:提交樣本至 Cuckoo

提交惡意軟體樣本進行自動化分析:

# 透過命令列提交
cuckoo submit /path/to/suspect.exe

# 指定分析逾時時間提交(300 秒)
cuckoo submit --timeout 300 /path/to/suspect.exe

# 指定特定 VM 和分析套件提交
cuckoo submit --machine win10_x64 --package exe --timeout 300 /path/to/suspect.exe

# 透過 REST API 提交
curl -F "[email protected]" -F "timeout=300" -F "machine=win10_x64" \
  http://localhost:8090/tasks/create/file

# 提交 URL 進行分析
curl -F "url=http://malicious-site.com/payload" -F "timeout=300" \
  http://localhost:8090/tasks/create/url

# 檢查任務狀態
curl http://localhost:8090/tasks/view/1 | jq '.task.status'

步驟 2:即時監控執行

追蹤分析進度並觀察即時行為:

# 查看 Cuckoo 分析日誌
tail -f /opt/cuckoo/log/cuckoo.log

# 監控分析任務狀態
cuckoo status

# 存取 Cuckoo 網頁介面查看即時螢幕截圖和程序樹
# 導覽至 http://localhost:8080/analysis/<task_id>/

執行期間需關注的關鍵行為事件:

  • 程序建立鏈(父子關係)
  • 對外部 IP 的網路連線嘗試
  • 暫存目錄或系統資料夾中的檔案掉落
  • 對 Run 機碼或服務項目的登錄檔修改
  • 與加密(CryptEncrypt)、注入(WriteProcessMemory)或規避相關的 API 呼叫

步驟 3:分析程序活動

從 Cuckoo 報告中檢視程序樹和 API 呼叫追蹤:

# 以程式碼方式解析 Cuckoo JSON 報告
import json

with open("/opt/cuckoo/storage/analyses/1/reports/report.json") as f:
    report = json.load(f)

# 程序樹分析
for process in report["behavior"]["processes"]:
    pid = process["pid"]
    ppid = process["ppid"]
    name = process["process_name"]
    print(f"PID: {pid} PPID: {ppid} Name: {name}")

    # 提取可疑的 API 呼叫
    for call in process["calls"]:
        api = call["api"]
        if api in ["CreateRemoteThread", "VirtualAllocEx", "WriteProcessMemory",
                    "NtCreateThreadEx", "RegSetValueExA", "URLDownloadToFileA"]:
            args = {arg["name"]: arg["value"] for arg in call["arguments"]}
            print(f"  [!] {api}({args})")

步驟 4:檢視網路活動

檢查網路連線、DNS 查詢和 HTTP 請求:

# 從 Cuckoo 報告進行網路分析
network = report["network"]

# DNS 解析
print("DNS 查詢:")
for dns in network.get("dns", []):
    print(f"  {dns['request']} -> {dns.get('answers', [])}")

# HTTP 請求
print("\nHTTP 請求:")
for http in network.get("http", []):
    print(f"  {http['method']} {http['uri']} (主機: {http['host']})")
    if http.get("body"):
        print(f"    內容:{http['body'][:200]}")

# TCP 連線
print("\nTCP 連線:")
for tcp in network.get("tcp", []):
    print(f"  {tcp['src']}:{tcp['sport']} -> {tcp['dst']}:{tcp['dport']}")

# 提取 PCAP 進行更深入的 Wireshark 分析
# PCAP 位置:/opt/cuckoo/storage/analyses/1/dump.pcap

步驟 5:檢查檔案系統和登錄檔變更

記錄持續性機制和掉落的檔案:

# 檔案操作
print("建立的/修改的檔案:")
for f in report["behavior"].get("summary", {}).get("files", []):
    print(f"  {f}")

# 掉落的檔案及其雜湊值
print("\n掉落的檔案:")
for dropped in report.get("dropped", []):
    print(f"  路徑:{dropped['filepath']}")
    print(f"  SHA-256:{dropped['sha256']}")
    print(f"  大小:{dropped['size']} bytes")
    print(f"  類型:{dropped['type']}")

# 登錄檔修改
print("\n修改的登錄檔機碼:")
for key in report["behavior"].get("summary", {}).get("keys", []):
    print(f"  {key}")

步驟 6:檢視特徵與評分

檢查 Cuckoo 的行為特徵和威脅評分:

# 觸發的行為特徵
print("觸發的特徵:")
for sig in report.get("signatures", []):
    severity = sig["severity"]
    name = sig["name"]
    description = sig["description"]
    marker = "[!]" if severity >= 3 else "[*]"
    print(f"  {marker} [{severity}/5] {name}: {description}")
    for mark in sig.get("marks", []):
        if mark.get("call"):
            print(f"      API:{mark['call']['api']}")
        if mark.get("ioc"):
            print(f"      IOC:{mark['ioc']}")

# 總體評分
score = report.get("info", {}).get("score", 0)
print(f"\n總體威脅評分:{score}/10")

步驟 7:提取記憶體傾印工件

分析執行期間擷取的完整記憶體傾印:

# 記憶體傾印儲存於:
# /opt/cuckoo/storage/analyses/1/memory.dmp

# 使用 Volatility 分析記憶體傾印
vol3 -f /opt/cuckoo/storage/analyses/1/memory.dmp windows.pslist
vol3 -f /opt/cuckoo/storage/analyses/1/memory.dmp windows.malfind
vol3 -f /opt/cuckoo/storage/analyses/1/memory.dmp windows.netscan

關鍵概念

術語定義
動態分析在受控環境中執行惡意軟體,以觀察其執行時期行為,包括系統呼叫、網路活動和檔案操作
沙箱規避惡意軟體用來偵測虛擬/沙箱環境並改變行為以避免分析的手法(睡眠計時器、VM 檢查、使用者互動檢查)
API HookCuckoo 攔截惡意軟體所呼叫的 Windows API 以記錄函式名稱、參數和回傳值的方法
InetSim網際網路服務模擬工具,可在隔離的分析網路中回應惡意軟體的網路請求(HTTP、DNS、SMTP)
程序注入惡意軟體將程式碼注入合法程序的技術;透過監控 VirtualAllocEx 和 WriteProcessMemory API 序列來偵測
行為特徵基於規則的偵測,將特定的 API 呼叫、檔案操作或網路活動序列與已知的惡意軟體行為進行比對
分析套件Cuckoo 模組,定義如何在 Guest VM 中執行特定檔案類型(exe、dll、pdf、doc)以進行正確的行為擷取

工具與系統

  • Cuckoo Sandbox:開源自動化惡意軟體分析系統,提供行為報告、網路封包和記憶體傾印
  • InetSim:網際網路服務模擬套件,為隔離的惡意軟體分析網路提供假的 HTTP、DNS、SMTP 等服務
  • FakeNet-NG:FLARE 團隊的網路模擬工具,可攔截並重導所有網路流量以進行分析
  • Suricata:網路 IDS/IPS,與 Cuckoo 整合,用於即時基於特徵的惡意網路流量偵測
  • Volatility:記憶體鑑識框架,用於分析 Cuckoo 分析期間擷取的記憶體傾印

常見情境

情境:分析多階段下載器

背景:靜態分析顯示一個經過加殼的可執行檔,導入函式極少且熵值高。需要在沙箱中執行該樣本,以觀察脫殼、酬載傳遞和 C2 建立的過程。

方法:

  1. 將樣本提交至 Cuckoo,設定較長的逾時時間(600 秒),以捕捉動作較慢的行為
  2. 檢視程序樹中的子程序建立過程(下載器產生酬載程序)
  3. 識別 %TEMP%、%APPDATA% 或系統目錄中的掉落檔案
  4. 提取掉落的檔案並計算其雜湊值,以供後續獨立分析
  5. 對應網路連線,識別初始執行後所聯繫的 C2 基礎設施
  6. 檢查登錄檔修改中的持續性機制(Run 機碼、排程工作、服務)
  7. 將行為特徵與已知的惡意軟體家族進行比較

常見陷阱:

  • 分析逾時設定不足,導致沙箱在第二階段酬載執行前終止
  • 未配置 InetSim 回應 DNS 和 HTTP 請求,阻止惡意軟體通過 C2 檢查點
  • 忽略沙箱規避偵測;如果樣本立即退出,可能是在偵測虛擬環境
  • 未單獨分析掉落的檔案;初始的下載器可能不如最終的酬載來得重要

輸出格式

動態分析報告 - CUCKOO SANDBOX
==========================================
任務 ID:          1547
樣本:             suspect.exe (SHA-256: e3b0c44298fc1c149afbf4c8996fb924...)
分析時間:         300 秒
VM:               win10_x64 (Windows 10 21H2)
評分:             8.5/10

程序樹
suspect.exe (PID: 2184)
  └── cmd.exe (PID: 3456)
      └── powershell.exe (PID: 4012)
          └── svchost_fake.exe (PID: 4568)

檔案系統活動
[建立]  C:\Users\Admin\AppData\Local\Temp\payload.dll
[建立]  C:\Windows\System32\svchost_fake.exe
[修改] C:\Windows\System32\drivers\etc\hosts

登錄檔修改
[設定] HKCU\Software\Microsoft\Windows\CurrentVersion\Run\WindowsUpdate = "C:\Windows\System32\svchost_fake.exe"
[設定] HKLM\SYSTEM\CurrentControlSet\Services\FakeService\ImagePath = "C:\Windows\System32\svchost_fake.exe"

網路活動
DNS:    update.malicious[.]com -> 185.220.101.42
HTTP:   POST hxxps://185.220.101[.]42/gate.php (beacon)
TCP:    10.0.2.15:49152 -> 185.220.101.42:443 (237 個連線)

行為特徵
[!] [4/5] injection_createremotethread:將程式碼注入遠端程序
[!] [4/5] persistence_autorun:修改 Run 登錄機碼以建立持續性
[!] [3/5] network_cnc_http:執行 HTTP C2 通訊
[*] [2/5] antiav_detectfile:檢查防毒軟體產品檔案

掉落檔案
payload.dll    SHA-256: abc123... 大小:98304  類型:PE32 DLL
svchost_fake.exe SHA-256: def456... 大小:184320 類型:PE32 EXE

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

相關技能