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 structured4 framework for analyzing cyber intrusions by examining four core features - Adversary,5 Capability, Infrastructure, and Victim. This skill covers implementing the Diamond6 Model programmatically to classify and correlate intrusion events, build activity7 threads, and generate pivot-ready intelligence.8domain: cybersecurity9subdomain: threat-intelligence10tags:11- threat-intelligence12- cti13- ioc14- mitre-attack15- stix16- diamond-model17- intrusion-analysis18version: '1.0'19author: oyi7720license: Apache-2.021nist_csf:22- ID.RA-0123- ID.RA-0524- DE.CM-0125- DE.AE-0226category: cybersecurity27metadata:28 source: https://skillmd.com/skills/oyi77/implementing-diamond-model-analysis29---3031# Implementing Diamond Model Analysis3233## Overview3435The 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.363738## When to Use39**Trigger phrases:**40- "implementing diamond model analysis"41- "The Diamond Model of Intrusion Analysis provides a structured framework for anal"424344- When deploying or configuring implementing diamond model analysis capabilities in your environment45- When establishing security controls aligned to compliance requirements46- When building or improving security architecture for this domain47- When conducting security assessments that require this implementation4849## Prerequisites5051- Python 3.9+ with `networkx`, `stix2`, `graphviz` libraries52- Understanding of the Diamond Model core and meta-features53- Access to threat intelligence data (MISP/OpenCTI events)54- Familiarity with MITRE ATT&CK for capability mapping5556## Key Concepts5758This section covers key concepts for implementing diamond model analysis.5960- Ensure all prerequisites are met before proceeding61- Follow the documented workflow steps in sequence62- Record results and any anomalies encountered during this phase63### Diamond Model Core Features64- **Adversary**: The threat actor or operator conducting the intrusion65- **Capability**: The tools, techniques, and malware used (maps to ATT&CK)66- **Infrastructure**: C2 servers, domains, email addresses, hosting providers67- **Victim**: Target organization, system, person, or data asset6869### Meta-Features70- **Timestamp**: When the event occurred71- **Phase**: Kill chain stage (recon, delivery, exploitation, etc.)72- **Result**: Success, failure, or unknown73- **Direction**: Adversary-to-infrastructure, infrastructure-to-victim, etc.74- **Methodology**: Social engineering, technical exploit, insider threat75- **Resources**: Financial, human, technical resources required7677### Activity Threads and Groups78- **Activity Thread**: Sequence of Diamond events from a single adversary operation79- **Activity Group**: Cluster of threads attributed to the same adversary8081## Workflow82831. **Scope the task** — define objectives, boundaries, and success criteria842. **Gather information** — collect all necessary data and context before proceeding853. **Execute the core workflow** — follow the domain-specific steps methodically864. **Validate results** — verify outputs against expected outcomes or baselines875. **Document findings** — record results, anomalies, and recommendations88### Step 1: Define Diamond Event Data Structure8990```python91from dataclasses import dataclass, field92from datetime import datetime93from typing import Optional94import json95import uuid9697@dataclass98class DiamondEvent:99 adversary: str = ""100 capability: str = ""101 infrastructure: str = ""102 victim: str = ""103 timestamp: str = ""104 phase: str = ""105 result: str = ""106 direction: str = ""107 methodology: str = ""108 confidence: int = 0109 notes: str = ""110 event_id: str = field(default_factory=lambda: str(uuid.uuid4())[:8])111 mitre_techniques: list = field(default_factory=list)112 iocs: list = field(default_factory=list)113114 def to_dict(self):115 return {116 "event_id": self.event_id,117 "adversary": self.adversary,118 "capability": self.capability,119 "infrastructure": self.infrastructure,120 "victim": self.victim,121 "timestamp": self.timestamp,122 "phase": self.phase,123 "result": self.result,124 "direction": self.direction,125 "methodology": self.methodology,126 "confidence": self.confidence,127 "mitre_techniques": self.mitre_techniques,128 "iocs": self.iocs,129 "notes": self.notes,130 }131```132133### Step 2: Build Activity Thread from Events134135```python136import networkx as nx137138class DiamondAnalysis:139 def __init__(self):140 self.events = []141 self.graph = nx.DiGraph()142143 def add_event(self, event: DiamondEvent):144 self.events.append(event)145 self.graph.add_node(event.event_id, **event.to_dict())146147 def build_activity_thread(self):148 """Link events chronologically into activity threads."""149 sorted_events = sorted(self.events, key=lambda e: e.timestamp)150 for i in range(len(sorted_events) - 1):151 self.graph.add_edge(152 sorted_events[i].event_id,153 sorted_events[i + 1].event_id,154 relationship="followed_by",155 )156157 def find_pivots(self):158 """Find pivot points where events share infrastructure or capabilities."""159 pivots = {"infrastructure": {}, "capability": {}, "adversary": {}}160161 for event in self.events:162 if event.infrastructure:163 pivots["infrastructure"].setdefault(event.infrastructure, []).append(event.event_id)164 if event.capability:165 pivots["capability"].setdefault(event.capability, []).append(event.event_id)166 if event.adversary:167 pivots["adversary"].setdefault(event.adversary, []).append(event.event_id)168169 return {170 k: {pk: pv for pk, pv in v.items() if len(pv) > 1}171 for k, v in pivots.items()172 }173174 def generate_report(self):175 return {176 "total_events": len(self.events),177 "unique_adversaries": len(set(e.adversary for e in self.events if e.adversary)),178 "unique_victims": len(set(e.victim for e in self.events if e.victim)),179 "unique_infrastructure": len(set(e.infrastructure for e in self.events if e.infrastructure)),180 "pivots": self.find_pivots(),181 "events": [e.to_dict() for e in self.events],182 }183```184185## Validation Criteria186187- Diamond events capture all four core features with meta-features188- Activity threads link related events chronologically189- Pivot analysis identifies shared infrastructure and capabilities across events190- Graph visualization renders the activity-attack graph correctly191- Events map to MITRE ATT&CK techniques for capability classification192193## When NOT to Use194195- You need to test the implementation (use performing-* skills)196- Task is about configuring existing tools (use configuring-* skills)197- You need to analyze security events (use analyzing-* skills)198- Task is about building detection rules (use building-* skills)199- You don't have access to the target environment200- Task requires vendor-specific expertise (consult vendor docs)201202203## Red Flags204205- Performing actions without explicit written authorization from the asset owner206- Testing against production systems without a defined scope and rules of engagement207- Sharing sensitive findings or credentials in unencrypted communications208- Failing to properly scope and contain the assessment before starting209210## Verification211212- All steps executed successfully against a test environment before production use213- Output documented with screenshots or logs demonstrating expected behavior214- Results validated against known-good baselines or reference implementations215- Documentation complete enough for another analyst to reproduce findings216217## References218219- [Diamond Model Paper](https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf)220- [MITRE ATT&CK](https://attack.mitre.org/)221- [STIX 2.1 Campaign Object](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)222223## Process2242251. Analyze the task requirements2262. Apply domain expertise2273. Verify output quality228229## Anti-Rationalization Table230231| Rationalization | Reality |232|---|---|233| "We are too small to be targeted" | Automated attacks target everyone. Size does not matter. |234| "Security slows us down" | A breach slows you down 100x more. Build security in from the start. |235| "We will fix it after launch" | Vulnerabilities in production are exploited within hours. Fix before deploy. |