mcpField
I
implementing-threat-modeling-with-mitre-attack

implementing-threat-modeling-with-mitre-attack

github.com/mukul975安全35.2k82 次安装8 周前更新
代码仓库

关于 implementing-threat-modeling-with-mitre-attack

面向 SOC 团队和安全负责人,指导使用 MITRE ATT&CK 建立并持续更新威胁模型。通过对照威胁行为与现有检测覆盖,识别缺口、规划修复并验证防御。

主要功能

  1. 01识别相关威胁组织及其 TTP
  2. 02生成 ATT&CK Navigator 威胁图层
  3. 03映射检测规则并分析覆盖缺口
  4. 04制定检测修复优先级
  5. 05通过对手模拟验证覆盖情况

适用场景

  1. 01评估针对行业威胁组织的检测能力
  2. 02为云迁移规划检测策略
  3. 03依据覆盖缺口制定紫队演练
  4. 04以检测盲点支持预算论证

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill implementing-threat-modeling-with-mitre-attack

安装后在 Claude Code 中输入/implementing-threat-modeling-with-mitre-attack确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
scripts/
agent.py

详细介绍

使用 MITRE ATT&CK 实施威胁建模

使用时机

在以下情况下使用此技能:

  • SOC 团队需要评估针对相关威胁行为者及其 TTP 的检测覆盖情况
  • 安全负责人需要根据威胁情报确定防御优先级
  • 新环境(云迁移、OT 集成)需要规划检测策略
  • 紫队演练需要基于威胁模型开展结构化的对手模拟
  • 年度风险评估需要基于 ATT&CK 分析威胁态势

请勿将其作为一次性练习使用——随着对手 TTP 的演变和组织攻击面变化,必须持续更新威胁模型。

前提条件

  • 了解 MITRE ATT&CK 框架(Enterprise、ICS、Mobile 或 Cloud 矩阵)
  • ATT&CK Navigator 工具(网页版或本地版),用于可视化图层
  • 已映射到 ATT&CK 技术 ID 的当前检测规则清单
  • 关于攻击你所在行业的对手团体的威胁情报
  • 包含关键性分类的组织资产清单

工作流

步骤 1:识别相关威胁行为者

使用 MITRE ATT&CK Groups 研究攻击你所在行业的对手团体:

import requests
import json

# Download ATT&CK STIX data
response = requests.get(
    "https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json"
)
attack_data = response.json()

# Extract groups and their techniques
groups = {}
for obj in attack_data["objects"]:
    if obj["type"] == "intrusion-set":
        group_name = obj["name"]
        aliases = obj.get("aliases", [])
        description = obj.get("description", "")
        groups[group_name] = {
            "aliases": aliases,
            "description": description[:200],
            "techniques": []
        }

# Map techniques to groups via relationships
relationships = [obj for obj in attack_data["objects"] if obj["type"] == "relationship"]
techniques = {obj["id"]: obj for obj in attack_data["objects"]
              if obj["type"] == "attack-pattern"}

for rel in relationships:
    if rel["relationship_type"] == "uses":
        source = rel["source_ref"]
        target = rel["target_ref"]
        for group_name, group_data in groups.items():
            if source == group_data.get("id") and target in techniques:
                tech = techniques[target]
                ext_refs = tech.get("external_references", [])
                for ref in ext_refs:
                    if ref.get("source_name") == "mitre-attack":
                        group_data["techniques"].append(ref["external_id"])

# Example: Financial sector threat actors
financial_actors = ["FIN7", "FIN8", "Carbanak", "APT38", "Lazarus Group"]
for actor in financial_actors:
    if actor in groups:
        print(f"{actor}: {len(groups[actor]['techniques'])} techniques")
        print(f"  Top techniques: {groups[actor]['techniques'][:10]}")
步骤 2:构建威胁行为者 TTP 概况

为优先级较高的威胁行为者创建 ATT&CK Navigator 图层:

import json

def create_attack_layer(actor_name, techniques, color="#ff6666"):
    """Generate ATT&CK Navigator JSON layer for a threat actor"""
    layer = {
        "name": f"{actor_name} TTP Profile",
        "versions": {
            "attack": "15",
            "navigator": "5.0",
            "layer": "4.5"
        },
        "domain": "enterprise-attack",
        "description": f"Techniques associated with {actor_name}",
        "techniques": [
            {
                "techniqueID": tech_id,
                "tactic": "",
                "color": color,
                "comment": f"Used by {actor_name}",
                "enabled": True,
                "score": 1
            }
            for tech_id in techniques
        ],
        "gradient": {
            "colors": ["#ffffff", color],
            "minValue": 0,
            "maxValue": 1
        }
    }
    return layer

# Create layers for top threat actors
fin7_techniques = ["T1566.001", "T1059.001", "T1053.005", "T1547.001",
                    "T1078", "T1021.001", "T1003", "T1071.001", "T1041"]
layer = create_attack_layer("FIN7", fin7_techniques, "#ff6666")

with open("fin7_layer.json", "w") as f:
    json.dump(layer, f, indent=2)
步骤 3:映射当前检测覆盖情况

导出已映射到 ATT&CK 的当前检测规则:

--- Extract ATT&CK technique mappings from Splunk ES correlation searches
| rest /services/saved/searches
  splunk_server=local
| where match(title, "^(COR|ESCU|RBA):")
| eval techniques = if(isnotnull(action.correlationsearch.annotations),
                       spath(action.correlationsearch.annotations, "mitre_attack"),
                       "unmapped")
| stats count by techniques
| mvexpand techniques
| stats count by techniques
| rename techniques AS technique_id, count AS rule_count

创建检测覆盖图层:

def create_coverage_layer(detection_rules):
    """Generate coverage layer from detection rule inventory"""
    technique_counts = {}
    for rule in detection_rules:
        for tech in rule.get("techniques", []):
            technique_counts[tech] = technique_counts.get(tech, 0) + 1

    layer = {
        "name": "SOC Detection Coverage",
        "versions": {"attack": "15", "navigator": "5.0", "layer": "4.5"},
        "domain": "enterprise-attack",
        "techniques": [
            {
                "techniqueID": tech_id,
                "color": "#31a354" if count >= 2 else "#a1d99b" if count == 1 else "",
                "score": count,
                "comment": f"{count} detection rule(s)"
            }
            for tech_id, count in technique_counts.items()
        ],
        "gradient": {
            "colors": ["#ffffff", "#a1d99b", "#31a354"],
            "minValue": 0,
            "maxValue": 3
        }
    }
    return layer
步骤 4:执行差距分析

将威胁行为者的 TTP 与检测覆盖情况进行叠加比较:

def gap_analysis(threat_techniques, covered_techniques):
    """Identify detection gaps for specific threat actor"""
    gaps = set(threat_techniques) - set(covered_techniques)
    covered = set(threat_techniques) & set(covered_techniques)

    print(f"Threat Actor Techniques: {len(threat_techniques)}")
    print(f"Detected: {len(covered)} ({len(covered)/len(threat_techniques)*100:.0f}%)")
    print(f"Gaps: {len(gaps)} ({len(gaps)/len(threat_techniques)*100:.0f}%)")

    # Prioritize gaps by kill chain phase
    priority_order = {
        "TA0001": 1, "TA0002": 2, "TA0003": 3, "TA0004": 4,
        "TA0005": 5, "TA0006": 6, "TA0007": 7, "TA0008": 8,
        "TA0009": 9, "TA0010": 10, "TA0011": 11, "TA0040": 12
    }

    gap_details = []
    for tech_id in gaps:
        gap_details.append({
            "technique": tech_id,
            "priority": "HIGH" if tech_id.split(".")[0] in ["T1003", "T1021", "T1059"] else "MEDIUM",
            "recommendation": f"Build detection for {tech_id}"
        })

    return {
        "total_actor_techniques": len(threat_techniques),
        "covered": len(covered),
        "gaps": len(gaps),
        "coverage_pct": round(len(covered)/len(threat_techniques)*100, 1),
        "gap_details": sorted(gap_details, key=lambda x: x["priority"])
    }

# Run analysis
result = gap_analysis(fin7_techniques, current_coverage)
步骤 5:制定优先级整改计划

构建检测工程路线图:

threat_model_remediation_plan:
  assessed_date: 2024-03-15
  primary_threats:
    - FIN7 (Financial sector)
    - APT38 (DPRK financial)
    - Lazarus Group (Destructive)

  current_coverage: 64%
  target_coverage: 80%

  priority_1_gaps: # 30-day target
    - technique: T1021.002
      name: SMB/Windows Admin Shares
      data_source: Windows Security Event 5140
      effort: Low
      detection_approach: Monitor admin share access from non-admin workstations

    - technique: T1003.006
      name: DCSync
      data_source: Windows Security Event 4662
      effort: Medium
      detection_approach: Detect DS-Replication-Get-Changes from non-DC sources

  priority_2_gaps: # 60-day target
    - technique: T1055
      name: Process Injection
      data_source: Sysmon EventCode 8, 10
      effort: High
      detection_approach: Monitor cross-process memory access patterns

    - technique: T1071.001
      name: Web Protocols (C2)
      data_source: Proxy/Firewall logs
      effort: Medium
      detection_approach: Detect beaconing patterns in HTTP/S traffic

  priority_3_gaps: # 90-day target
    - technique: T1070.004
      name: File Deletion
      data_source: Sysmon EventCode 23
      effort: Low
      detection_approach: Monitor mass file deletion in sensitive directories
步骤 6:通过对手模拟进行验证

使用 MITRE Caldera 或 Atomic Red Team 测试覆盖情况:

# Using Atomic Red Team to validate coverage for FIN7 techniques
# T1566.001 — Spearphishing Attachment
Invoke-AtomicTest T1566.001

# T1059.001 — PowerShell
Invoke-AtomicTest T1059.001 -TestNumbers 1,2,3

# T1053.005 — Scheduled Task
Invoke-AtomicTest T1053.005

# T1547.001 — Registry Run Keys
Invoke-AtomicTest T1547.001

# T1003 — Credential Dumping
Invoke-AtomicTest T1003 -TestNumbers 1,2

# Verify detections
# Check SIEM for corresponding alerts within 15 minutes

记录模拟结果,以验证威胁模型的准确性。

核心概念

术语定义
MITRE ATT&CK基于现实观察构建的对手战术、技术和流程知识库
TTP战术、技术和流程——对手团体的行为模式
ATT&CK Navigator用于将 ATT&CK 矩阵可视化为分层热力图的 Web 工具,可展示覆盖情况或威胁概况
差距分析将威胁行为者的 TTP 与检测覆盖情况进行比较,以识别盲区的过程
威胁知情防御根据真实对手行为而非理论风险确定防御优先级的安全策略
对手模拟对威胁行为者的 TTP 进行受控模拟,以验证检测和响应能力

工具和系统

  • MITRE ATT&CK Navigator:基于 Web 的可视化工具,用于创建和叠加 ATT&CK 技术图层
  • MITRE Caldera:自动化对手模拟平台,可大规模测试检测覆盖情况
  • Atomic Red Team:用于验证安全控制的 ATT&CK 技术开源测试库
  • CTID ATT&CK Workbench:MITRE 工具,可结合组织情境自定义 ATT&CK 知识库
  • Tidal Cyber:基于 ATT&CK 框架制定威胁知情防御计划的商业平台

常见场景

  • 年度威胁评估:将排名前 5 的威胁行为者映射到 ATT&CK,与检测覆盖情况叠加比较,并生成差距分析
  • 云迁移规划:建模云环境特定威胁(T1078.004、T1537),并规划检测覆盖情况
  • 并购安全评估:针对相关威胁行为者,对被收购公司的环境进行威胁建模
  • 预算论证:利用差距分析展示需要投入工具的检测盲区
  • 紫队规划:根据威胁模型中优先级最高的差距,选择对手模拟场景

输出格式

THREAT MODEL ASSESSMENT — Financial Services Division
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Date:             2024-03-15
Threat Actors:    FIN7, APT38, Lazarus Group
Techniques Total: 87 unique techniques across all actors

DETECTION COVERAGE:
  Covered:     56/87 (64%)
  Gaps:        31/87 (36%)

  Tactic Coverage Breakdown:
    Initial Access:      78%  ████████░░
    Execution:           82%  █████████░
    Persistence:         71%  ████████░░
    Priv Escalation:     65%  ███████░░░
    Defense Evasion:     52%  ██████░░░░  <-- Priority gap
    Credential Access:   58%  ██████░░░░  <-- Priority gap
    Discovery:           45%  █████░░░░░
    Lateral Movement:    61%  ███████░░░
    Collection:          50%  ██████░░░░
    Exfiltration:        55%  ██████░░░░
    C2:                  67%  ███████░░░

TOP PRIORITY GAPS (30-day remediation):
  1. T1055 Process Injection — used by all 3 actors, 0 detections
  2. T1003.006 DCSync — used by FIN7 and Lazarus, 0 detections
  3. T1070.004 File Deletion — evidence destruction, 0 detections

INVESTMENT RECOMMENDATION:
  Closing top 10 gaps requires: 2 detection engineer FTEs, 60 days
  Expected coverage improvement: 64% -> 76%

评论

支持 Markdown