Communitygithub.com

使用Cuckoo Sandbox分析恶意软件行为

在Cuckoo Sandbox中引爆恶意软件样本,观察其运行时行为。

使用Cuckoo Sandbox分析恶意软件行为 是什么?

该技能指导用户如何利用Cuckoo Sandbox对恶意软件样本进行自动化动态分析。它涵盖了从样本提交、执行监控到报告解读的完整工作流程,支持命令行和REST API两种提交方式。用户可以通过该技能提取进程活动、网络流量、文件系统与注册表变更、行为签名等关键指标,并利用Volatility等工具分析内存转储。技能适用于需要深度行为分析的场景,如多阶段释放器、勒索软件初步排查(在隔离验证后)或批量样本分析。

兼容平台~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调用
  • 需要确定完整的感染链,包括第二阶段payload下载和持久化机制
  • 基于观察到的运行时行为生成行为签名和YARA规则
  • 需要一致报告的批量恶意软件样本自动化分析

请勿使用 当样本是已知的勒索软件变种,可能通过网络共享在配置不当的沙箱中传播时;请先验证网络隔离。

先决条件

  • 在专用分析服务器上安装Cuckoo Sandbox 3.x(推荐Ubuntu 22.04)
  • 配置Windows 10/11快照的客户机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

# 指定虚拟机和分析包提交
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 Web界面查看实时截图和进程树
# 导航到 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 Queries:")
for dns in network.get("dns", []):
    print(f"  {dns['request']} -> {dns.get('answers', [])}")

# HTTP请求
print("\nHTTP Requests:")
for http in network.get("http", []):
    print(f"  {http['method']} {http['uri']} (Host: {http['host']})")
    if http.get("body"):
        print(f"    Body: {http['body'][:200]}")

# TCP连接
print("\nTCP Connections:")
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("Files Created/Modified:")
for f in report["behavior"].get("summary", {}).get("files", []):
    print(f"  {f}")

# 掉落文件及其哈希值
print("\nDropped Files:")
for dropped in report.get("dropped", []):
    print(f"  Path: {dropped['filepath']}")
    print(f"  SHA-256: {dropped['sha256']}")
    print(f"  Size: {dropped['size']} bytes")
    print(f"  Type: {dropped['type']}")

# 注册表修改
print("\nRegistry Keys Modified:")
for key in report["behavior"].get("summary", {}).get("keys", []):
    print(f"  {key}")

步骤 6:查看签名和评分

检查Cuckoo的行为签名和威胁评分:

# 触发的行为签名
print("Triggered Signatures:")
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"\nOverall Threat Score: {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挂钩Cuckoo截获恶意软件所作出的Windows API调用的方法,用于记录函数名、参数和返回值
InetSim互联网服务模拟工具,在隔离的分析网络中响应恶意软件的网络请求(HTTP、DNS、SMTP)
进程注入恶意软件将代码注入合法进程的技术;通过监控VirtualAllocEx和WriteProcessMemory API序列来检测
行为签名基于规则的检测,将特定API调用序列、文件操作或网络活动与已知恶意软件行为匹配
分析包Cuckoo模块,定义如何在客户机VM中执行特定文件类型(exe、dll、pdf、doc)以正确捕获行为

工具与系统

  • Cuckoo Sandbox:开源自动化恶意软件分析系统,提供行为报告、网络捕获和内存转储
  • InetSim:互联网服务模拟套件,为隔离的恶意软件分析网络提供虚假的HTTP、DNS、SMTP等服务
  • FakeNet-NG:FLARE团队的网络模拟工具,拦截并重定向所有网络流量以供分析
  • Suricata:网络IDS/IPS,集成Cuckoo用于对恶意网络流量进行实时基于签名的检测
  • Volatility:内存取证框架,用于分析Cuckoo分析期间捕获的内存转储

常见场景

场景:分析多阶段释放器

上下文:静态分析显示一个打包的可执行文件,导入少且熵值高。该样本需要在沙箱中执行以观察解包、payload交付和C2建立过程。

方法:

  1. 提交样本到Cuckoo,设置较长超时(600秒)以捕获慢速行为
  2. 查看进程树中的子进程创建(释放器生成payload进程)
  3. 识别在%TEMP%、%APPDATA%或系统目录中掉落的文件
  4. 提取掉落文件并计算哈希值以供单独分析
  5. 映射网络连接以识别初始执行后联系的C2基础设施
  6. 在注册表修改中检查持久化机制(Run键、计划任务、服务)
  7. 将行为签名与已知恶意软件家族进行比较

陷阱:

  • 使用不足的分析超时,导致沙箱在第二阶段payload执行前终止
  • 未配置InetSim响应DNS和HTTP请求,阻止恶意软件在C2签入后继续执行
  • 忽略沙箱规避检测;如果样本立即退出,可能正在检测虚拟环境
  • 未单独分析掉落文件;初始释放器可能不如最终payload有趣

输出格式

DYNAMIC ANALYSIS REPORT - CUCKOO SANDBOX
==========================================
Task ID:          1547
Sample:           suspect.exe (SHA-256: e3b0c44298fc1c149afbf4c8996fb924...)
Analysis Time:    300 seconds
VM:               win10_x64 (Windows 10 21H2)
Score:            8.5/10

PROCESS TREE
suspect.exe (PID: 2184)
  └── cmd.exe (PID: 3456)
      └── powershell.exe (PID: 4012)
          └── svchost_fake.exe (PID: 4568)

FILE SYSTEM ACTIVITY
[CREATED]  C:\Users\Admin\AppData\Local\Temp\payload.dll
[CREATED]  C:\Windows\System32\svchost_fake.exe
[MODIFIED] C:\Windows\System32\drivers\etc\hosts

REGISTRY MODIFICATIONS
[SET] HKCU\Software\Microsoft\Windows\CurrentVersion\Run\WindowsUpdate = "C:\Windows\System32\svchost_fake.exe"
[SET] HKLM\SYSTEM\CurrentControlSet\Services\FakeService\ImagePath = "C:\Windows\System32\svchost_fake.exe"

NETWORK ACTIVITY
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 connections)

BEHAVIORAL SIGNATURES
[!] [4/5] injection_createremotethread: Injects code into remote process
[!] [4/5] persistence_autorun: Modifies Run registry key for persistence
[!] [3/5] network_cnc_http: Performs HTTP C2 communication
[*] [2/5] antiav_detectfile: Checks for antivirus product files

DROPPED FILES
payload.dll    SHA-256: abc123... Size: 98304  Type: PE32 DLL
svchost_fake.exe SHA-256: def456... Size: 184320 Type: 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,

相关技能