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