Implementing Diamond Model Analysis
Overview
The Diamond Model of Intrusion Analysis provides a structured framework for analyzing cyber intrusions by examining four core features: Adversary, Capability, Infrastructure, and Victim. This skill covers implementing the Diamond Model programmatically to classify and correlate intrusion events, build activity threads linking related events, create activity-attack graphs, and generate pivot-ready intelligence from intrusion data.
When to Use
Trigger phrases:
"implementing diamond model analysis"
"The Diamond Model of Intrusion Analysis provides a structured framework for anal"
When deploying or configuring implementing diamond model analysis capabilities in your environment
When establishing security controls aligned to compliance requirements
When building or improving security architecture for this domain
When conducting security assessments that require this implementation
Prerequisites
- Python 3.9+ with
networkx, stix2, graphviz libraries
- Understanding of the Diamond Model core and meta-features
- Access to threat intelligence data (MISP/OpenCTI events)
- Familiarity with MITRE ATT&CK for capability mapping
Key Concepts
This section covers key concepts for implementing diamond model analysis.
- Ensure all prerequisites are met before proceeding
- Follow the documented workflow steps in sequence
- Record results and any anomalies encountered during this phase
Diamond Model Core Features
- Adversary: The threat actor or operator conducting the intrusion
- Capability: The tools, techniques, and malware used (maps to ATT&CK)
- Infrastructure: C2 servers, domains, email addresses, hosting providers
- Victim: Target organization, system, person, or data asset
Meta-Features
- Timestamp: When the event occurred
- Phase: Kill chain stage (recon, delivery, exploitation, etc.)
- Result: Success, failure, or unknown
- Direction: Adversary-to-infrastructure, infrastructure-to-victim, etc.
- Methodology: Social engineering, technical exploit, insider threat
- Resources: Financial, human, technical resources required
Activity Threads and Groups
- Activity Thread: Sequence of Diamond events from a single adversary operation
- Activity Group: Cluster of threads attributed to the same adversary
Workflow
- Scope the task — define objectives, boundaries, and success criteria
- Gather information — collect all necessary data and context before proceeding
- Execute the core workflow — follow the domain-specific steps methodically
- Validate results — verify outputs against expected outcomes or baselines
- Document findings — record results, anomalies, and recommendations
Step 1: Define Diamond Event Data Structure
from dataclasses import dataclass, field
from datetime import datetime
from typing import Optional
import json
import uuid
@dataclass
class DiamondEvent:
adversary: str = ""
capability: str = ""
infrastructure: str = ""
victim: str = ""
timestamp: str = ""
phase: str = ""
result: str = ""
direction: str = ""
methodology: str = ""
confidence: int = 0
notes: str = ""
event_id: str = field(default_factory=lambda: str(uuid.uuid4())[:8])
mitre_techniques: list = field(default_factory=list)
iocs: list = field(default_factory=list)
def to_dict(self):
return {
"event_id": self.event_id,
"adversary": self.adversary,
"capability": self.capability,
"infrastructure": self.infrastructure,
"victim": self.victim,
"timestamp": self.timestamp,
"phase": self.phase,
"result": self.result,
"direction": self.direction,
"methodology": self.methodology,
"confidence": self.confidence,
"mitre_techniques": self.mitre_techniques,
"iocs": self.iocs,
"notes": self.notes,
}
Step 2: Build Activity Thread from Events
import networkx as nx
class DiamondAnalysis:
def __init__(self):
self.events = []
self.graph = nx.DiGraph()
def add_event(self, event: DiamondEvent):
self.events.append(event)
self.graph.add_node(event.event_id, **event.to_dict())
def build_activity_thread(self):
"""Link events chronologically into activity threads."""
sorted_events = sorted(self.events, key=lambda e: e.timestamp)
for i in range(len(sorted_events) - 1):
self.graph.add_edge(
sorted_events[i].event_id,
sorted_events[i + 1].event_id,
relationship="followed_by",
)
def find_pivots(self):
"""Find pivot points where events share infrastructure or capabilities."""
pivots = {"infrastructure": {}, "capability": {}, "adversary": {}}
for event in self.events:
if event.infrastructure:
pivots["infrastructure"].setdefault(event.infrastructure, []).append(event.event_id)
if event.capability:
pivots["capability"].setdefault(event.capability, []).append(event.event_id)
if event.adversary:
pivots["adversary"].setdefault(event.adversary, []).append(event.event_id)
return {
k: {pk: pv for pk, pv in v.items() if len(pv) > 1}
for k, v in pivots.items()
}
def generate_report(self):
return {
"total_events": len(self.events),
"unique_adversaries": len(set(e.adversary for e in self.events if e.adversary)),
"unique_victims": len(set(e.victim for e in self.events if e.victim)),
"unique_infrastructure": len(set(e.infrastructure for e in self.events if e.infrastructure)),
"pivots": self.find_pivots(),
"events": [e.to_dict() for e in self.events],
}
Validation Criteria
- Diamond events capture all four core features with meta-features
- Activity threads link related events chronologically
- Pivot analysis identifies shared infrastructure and capabilities across events
- Graph visualization renders the activity-attack graph correctly
- Events map to MITRE ATT&CK techniques for capability classification
When NOT to Use
- You need to test the implementation (use performing-* skills)
- Task is about configuring existing tools (use configuring-* skills)
- You need to analyze security events (use analyzing-* skills)
- Task is about building detection rules (use building-* skills)
- You don't have access to the target environment
- Task requires vendor-specific expertise (consult vendor docs)
Red Flags
- Performing actions without explicit written authorization from the asset owner
- Testing against production systems without a defined scope and rules of engagement
- Sharing sensitive findings or credentials in unencrypted communications
- Failing to properly scope and contain the assessment before starting
Verification
- All steps executed successfully against a test environment before production use
- Output documented with screenshots or logs demonstrating expected behavior
- Results validated against known-good baselines or reference implementations
- Documentation complete enough for another analyst to reproduce findings
References
Process
- Analyze the task requirements
- Apply domain expertise
- Verify output quality
Anti-Rationalization Table
| Rationalization |
Reality |
| "We are too small to be targeted" |
Automated attacks target everyone. Size does not matter. |
| "Security slows us down" |
A breach slows you down 100x more. Build security in from the start. |
| "We will fix it after launch" |
Vulnerabilities in production are exploited within hours. Fix before deploy. |
1---2name: implementing-diamond-model-analysis3description: Use when the Diamond Model of Intrusion Analysis provides a structured framework for analyzing cyber intrusions by examining four core features - Adversary, Capability, Infrastructure, and Victim. This skill covers implementing the Diamond Model programmatically to classify and correlate intrusion events, build activity threads, and generate pivot-ready intelligence.4license: Apache-2.05---67# Implementing Diamond Model Analysis89## Overview1011The Diamond Model of Intrusion Analysis provides a structured framework for analyzing cyber intrusions by examining four core features: Adversary, Capability, Infrastructure, and Victim. This skill covers implementing the Diamond Model programmatically to classify and correlate intrusion events, build activity threads linking related events, create activity-attack graphs, and generate pivot-ready intelligence from intrusion data.121314## When to Use15**Trigger phrases:**16- "implementing diamond model analysis"17- "The Diamond Model of Intrusion Analysis provides a structured framework for anal"181920- When deploying or configuring implementing diamond model analysis capabilities in your environment21- When establishing security controls aligned to compliance requirements22- When building or improving security architecture for this domain23- When conducting security assessments that require this implementation2425## Prerequisites2627- Python 3.9+ with `networkx`, `stix2`, `graphviz` libraries28- Understanding of the Diamond Model core and meta-features29- Access to threat intelligence data (MISP/OpenCTI events)30- Familiarity with MITRE ATT&CK for capability mapping3132## Key Concepts3334This section covers key concepts for implementing diamond model analysis.3536- Ensure all prerequisites are met before proceeding37- Follow the documented workflow steps in sequence38- Record results and any anomalies encountered during this phase39### Diamond Model Core Features40- **Adversary**: The threat actor or operator conducting the intrusion41- **Capability**: The tools, techniques, and malware used (maps to ATT&CK)42- **Infrastructure**: C2 servers, domains, email addresses, hosting providers43- **Victim**: Target organization, system, person, or data asset4445### Meta-Features46- **Timestamp**: When the event occurred47- **Phase**: Kill chain stage (recon, delivery, exploitation, etc.)48- **Result**: Success, failure, or unknown49- **Direction**: Adversary-to-infrastructure, infrastructure-to-victim, etc.50- **Methodology**: Social engineering, technical exploit, insider threat51- **Resources**: Financial, human, technical resources required5253### Activity Threads and Groups54- **Activity Thread**: Sequence of Diamond events from a single adversary operation55- **Activity Group**: Cluster of threads attributed to the same adversary5657## Workflow58591. **Scope the task** — define objectives, boundaries, and success criteria602. **Gather information** — collect all necessary data and context before proceeding613. **Execute the core workflow** — follow the domain-specific steps methodically624. **Validate results** — verify outputs against expected outcomes or baselines635. **Document findings** — record results, anomalies, and recommendations64### Step 1: Define Diamond Event Data Structure6566```python67from dataclasses import dataclass, field68from datetime import datetime69from typing import Optional70import json71import uuid7273@dataclass74class DiamondEvent:75 adversary: str = ""76 capability: str = ""77 infrastructure: str = ""78 victim: str = ""79 timestamp: str = ""80 phase: str = ""81 result: str = ""82 direction: str = ""83 methodology: str = ""84 confidence: int = 085 notes: str = ""86 event_id: str = field(default_factory=lambda: str(uuid.uuid4())[:8])87 mitre_techniques: list = field(default_factory=list)88 iocs: list = field(default_factory=list)8990 def to_dict(self):91 return {92 "event_id": self.event_id,93 "adversary": self.adversary,94 "capability": self.capability,95 "infrastructure": self.infrastructure,96 "victim": self.victim,97 "timestamp": self.timestamp,98 "phase": self.phase,99 "result": self.result,100 "direction": self.direction,101 "methodology": self.methodology,102 "confidence": self.confidence,103 "mitre_techniques": self.mitre_techniques,104 "iocs": self.iocs,105 "notes": self.notes,106 }107```108109### Step 2: Build Activity Thread from Events110111```python112import networkx as nx113114class DiamondAnalysis:115 def __init__(self):116 self.events = []117 self.graph = nx.DiGraph()118119 def add_event(self, event: DiamondEvent):120 self.events.append(event)121 self.graph.add_node(event.event_id, **event.to_dict())122123 def build_activity_thread(self):124 """Link events chronologically into activity threads."""125 sorted_events = sorted(self.events, key=lambda e: e.timestamp)126 for i in range(len(sorted_events) - 1):127 self.graph.add_edge(128 sorted_events[i].event_id,129 sorted_events[i + 1].event_id,130 relationship="followed_by",131 )132133 def find_pivots(self):134 """Find pivot points where events share infrastructure or capabilities."""135 pivots = {"infrastructure": {}, "capability": {}, "adversary": {}}136137 for event in self.events:138 if event.infrastructure:139 pivots["infrastructure"].setdefault(event.infrastructure, []).append(event.event_id)140 if event.capability:141 pivots["capability"].setdefault(event.capability, []).append(event.event_id)142 if event.adversary:143 pivots["adversary"].setdefault(event.adversary, []).append(event.event_id)144145 return {146 k: {pk: pv for pk, pv in v.items() if len(pv) > 1}147 for k, v in pivots.items()148 }149150 def generate_report(self):151 return {152 "total_events": len(self.events),153 "unique_adversaries": len(set(e.adversary for e in self.events if e.adversary)),154 "unique_victims": len(set(e.victim for e in self.events if e.victim)),155 "unique_infrastructure": len(set(e.infrastructure for e in self.events if e.infrastructure)),156 "pivots": self.find_pivots(),157 "events": [e.to_dict() for e in self.events],158 }159```160161## Validation Criteria162163- Diamond events capture all four core features with meta-features164- Activity threads link related events chronologically165- Pivot analysis identifies shared infrastructure and capabilities across events166- Graph visualization renders the activity-attack graph correctly167- Events map to MITRE ATT&CK techniques for capability classification168169## When NOT to Use170171- You need to test the implementation (use performing-* skills)172- Task is about configuring existing tools (use configuring-* skills)173- You need to analyze security events (use analyzing-* skills)174- Task is about building detection rules (use building-* skills)175- You don't have access to the target environment176- Task requires vendor-specific expertise (consult vendor docs)177178179## Red Flags180181- Performing actions without explicit written authorization from the asset owner182- Testing against production systems without a defined scope and rules of engagement183- Sharing sensitive findings or credentials in unencrypted communications184- Failing to properly scope and contain the assessment before starting185186## Verification187188- All steps executed successfully against a test environment before production use189- Output documented with screenshots or logs demonstrating expected behavior190- Results validated against known-good baselines or reference implementations191- Documentation complete enough for another analyst to reproduce findings192193## References194195- [Diamond Model Paper](https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf)196- [MITRE ATT&CK](https://attack.mitre.org/)197- [STIX 2.1 Campaign Object](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)198199## Process2002011. Analyze the task requirements2022. Apply domain expertise2033. Verify output quality204205## Anti-Rationalization Table206207| Rationalization | Reality |208|---|---|209| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |210| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |211| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |