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
- 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
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
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
References
1---
2name: implementing-diamond-model-analysis
3description: The Diamond Model of Intrusion Analysis provides a structured framework
4 for analyzing cyber intrusions by examining four core features - Adversary, Capability,
5 Infrastructure, and Victim. This skill covers implementing the Diamond Model programmatically
6 to classify and correlate intrusion events, build activity threads, and generate
7 pivot-ready intelligence.
8domain: cybersecurity
9subdomain: threat-intelligence
10tags:
11- threat-intelligence
12- cti
13- ioc
14- mitre-attack
15- stix
16- diamond-model
17- intrusion-analysis
18version: '1.0'
19author: mahipal
20license: Apache-2.0
21nist_csf:
22- ID.RA-01
23- ID.RA-05
24- DE.CM-01
25- DE.AE-02
26mitre_attack:
27- T1591
28- T1592
29- T1593
30- T1589
31- T0816
32source: https://github.com/mukul975/Anthropic-Cybersecurity-Skills
33source_commit: 04450304b12645cb2b974ab96d28c0664758a88d
34metadata:
35 source: https://skillmd.com/skills/yanacuti1121/implementing-diamond-model-analysis
36---
37
38# Implementing Diamond Model Analysis
39
40## Overview
41
42The 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.
43
44
45## When to Use
46
47- When deploying or configuring implementing diamond model analysis capabilities in your environment
48- When establishing security controls aligned to compliance requirements
49- When building or improving security architecture for this domain
50- When conducting security assessments that require this implementation
51
52## Prerequisites
53
54- Python 3.9+ with `networkx`, `stix2`, `graphviz` libraries
55- Understanding of the Diamond Model core and meta-features
56- Access to threat intelligence data (MISP/OpenCTI events)
57- Familiarity with MITRE ATT&CK for capability mapping
58
59## Key Concepts
60
61### Diamond Model Core Features
62- **Adversary**: The threat actor or operator conducting the intrusion
63- **Capability**: The tools, techniques, and malware used (maps to ATT&CK)
64- **Infrastructure**: C2 servers, domains, email addresses, hosting providers
65- **Victim**: Target organization, system, person, or data asset
66
67### Meta-Features
68- **Timestamp**: When the event occurred
69- **Phase**: Kill chain stage (recon, delivery, exploitation, etc.)
70- **Result**: Success, failure, or unknown
71- **Direction**: Adversary-to-infrastructure, infrastructure-to-victim, etc.
72- **Methodology**: Social engineering, technical exploit, insider threat
73- **Resources**: Financial, human, technical resources required
74
75### Activity Threads and Groups
76- **Activity Thread**: Sequence of Diamond events from a single adversary operation
77- **Activity Group**: Cluster of threads attributed to the same adversary
78
79## Workflow
80
81### Step 1: Define Diamond Event Data Structure
82
83```python
84from dataclasses import dataclass, field
85from datetime import datetime
86from typing import Optional
87import json
88import uuid
89
90@dataclass
91class DiamondEvent:
92 adversary: str = ""
93 capability: str = ""
94 infrastructure: str = ""
95 victim: str = ""
96 timestamp: str = ""
97 phase: str = ""
98 result: str = ""
99 direction: str = ""
100 methodology: str = ""
101 confidence: int = 0
102 notes: str = ""
103 event_id: str = field(default_factory=lambda: str(uuid.uuid4())[:8])
104 mitre_techniques: list = field(default_factory=list)
105 iocs: list = field(default_factory=list)
106
107 def to_dict(self):
108 return {
109 "event_id": self.event_id,
110 "adversary": self.adversary,
111 "capability": self.capability,
112 "infrastructure": self.infrastructure,
113 "victim": self.victim,
114 "timestamp": self.timestamp,
115 "phase": self.phase,
116 "result": self.result,
117 "direction": self.direction,
118 "methodology": self.methodology,
119 "confidence": self.confidence,
120 "mitre_techniques": self.mitre_techniques,
121 "iocs": self.iocs,
122 "notes": self.notes,
123 }
124```
125
126### Step 2: Build Activity Thread from Events
127
128```python
129import networkx as nx
130
131class DiamondAnalysis:
132 def __init__(self):
133 self.events = []
134 self.graph = nx.DiGraph()
135
136 def add_event(self, event: DiamondEvent):
137 self.events.append(event)
138 self.graph.add_node(event.event_id, **event.to_dict())
139
140 def build_activity_thread(self):
141 """Link events chronologically into activity threads."""
142 sorted_events = sorted(self.events, key=lambda e: e.timestamp)
143 for i in range(len(sorted_events) - 1):
144 self.graph.add_edge(
145 sorted_events[i].event_id,
146 sorted_events[i + 1].event_id,
147 relationship="followed_by",
148 )
149
150 def find_pivots(self):
151 """Find pivot points where events share infrastructure or capabilities."""
152 pivots = {"infrastructure": {}, "capability": {}, "adversary": {}}
153
154 for event in self.events:
155 if event.infrastructure:
156 pivots["infrastructure"].setdefault(event.infrastructure, []).append(event.event_id)
157 if event.capability:
158 pivots["capability"].setdefault(event.capability, []).append(event.event_id)
159 if event.adversary:
160 pivots["adversary"].setdefault(event.adversary, []).append(event.event_id)
161
162 return {
163 k: {pk: pv for pk, pv in v.items() if len(pv) > 1}
164 for k, v in pivots.items()
165 }
166
167 def generate_report(self):
168 return {
169 "total_events": len(self.events),
170 "unique_adversaries": len(set(e.adversary for e in self.events if e.adversary)),
171 "unique_victims": len(set(e.victim for e in self.events if e.victim)),
172 "unique_infrastructure": len(set(e.infrastructure for e in self.events if e.infrastructure)),
173 "pivots": self.find_pivots(),
174 "events": [e.to_dict() for e in self.events],
175 }
176```
177
178## Validation Criteria
179
180- Diamond events capture all four core features with meta-features
181- Activity threads link related events chronologically
182- Pivot analysis identifies shared infrastructure and capabilities across events
183- Graph visualization renders the activity-attack graph correctly
184- Events map to MITRE ATT&CK techniques for capability classification
185
186## References
187
188- [Diamond Model Paper](https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf)
189- [MITRE ATT&CK](https://attack.mitre.org/)
190- [STIX 2.1 Campaign Object](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)