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-analysis3description: >-4 The Diamond Model of Intrusion Analysis provides a structured framework for analyzing5 cyber intrusions by examining four core features - Adversary, Capability, Infrastructure,6 and Victim. This skill covers implementing the Diamond Model programmatically to classify7 and correlate intrusion events, build activity threads, and generate pivot-ready intelligence.8domain: cybersecurity9subdomain: threat-intelligence10tags: [threat-intelligence, cti, ioc, mitre-attack, stix, diamond-model, intrusion-analysis]11version: "1.0"12author: mahipal13license: Apache-2.014metadata:15 source: https://skillmd.com/skills/micsapp/implementing-diamond-model-analysis16---1718# Implementing Diamond Model Analysis1920## Overview2122The 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.232425## When to Use2627- When deploying or configuring implementing diamond model analysis capabilities in your environment28- When establishing security controls aligned to compliance requirements29- When building or improving security architecture for this domain30- When conducting security assessments that require this implementation3132## Prerequisites3334- Python 3.9+ with `networkx`, `stix2`, `graphviz` libraries35- Understanding of the Diamond Model core and meta-features36- Access to threat intelligence data (MISP/OpenCTI events)37- Familiarity with MITRE ATT&CK for capability mapping3839## Key Concepts4041### Diamond Model Core Features42- **Adversary**: The threat actor or operator conducting the intrusion43- **Capability**: The tools, techniques, and malware used (maps to ATT&CK)44- **Infrastructure**: C2 servers, domains, email addresses, hosting providers45- **Victim**: Target organization, system, person, or data asset4647### Meta-Features48- **Timestamp**: When the event occurred49- **Phase**: Kill chain stage (recon, delivery, exploitation, etc.)50- **Result**: Success, failure, or unknown51- **Direction**: Adversary-to-infrastructure, infrastructure-to-victim, etc.52- **Methodology**: Social engineering, technical exploit, insider threat53- **Resources**: Financial, human, technical resources required5455### Activity Threads and Groups56- **Activity Thread**: Sequence of Diamond events from a single adversary operation57- **Activity Group**: Cluster of threads attributed to the same adversary5859## Workflow6061### Step 1: Define Diamond Event Data Structure6263```python64from dataclasses import dataclass, field65from datetime import datetime66from typing import Optional67import json68import uuid6970@dataclass71class DiamondEvent:72 adversary: str = ""73 capability: str = ""74 infrastructure: str = ""75 victim: str = ""76 timestamp: str = ""77 phase: str = ""78 result: str = ""79 direction: str = ""80 methodology: str = ""81 confidence: int = 082 notes: str = ""83 event_id: str = field(default_factory=lambda: str(uuid.uuid4())[:8])84 mitre_techniques: list = field(default_factory=list)85 iocs: list = field(default_factory=list)8687 def to_dict(self):88 return {89 "event_id": self.event_id,90 "adversary": self.adversary,91 "capability": self.capability,92 "infrastructure": self.infrastructure,93 "victim": self.victim,94 "timestamp": self.timestamp,95 "phase": self.phase,96 "result": self.result,97 "direction": self.direction,98 "methodology": self.methodology,99 "confidence": self.confidence,100 "mitre_techniques": self.mitre_techniques,101 "iocs": self.iocs,102 "notes": self.notes,103 }104```105106### Step 2: Build Activity Thread from Events107108```python109import networkx as nx110111class DiamondAnalysis:112 def __init__(self):113 self.events = []114 self.graph = nx.DiGraph()115116 def add_event(self, event: DiamondEvent):117 self.events.append(event)118 self.graph.add_node(event.event_id, **event.to_dict())119120 def build_activity_thread(self):121 """Link events chronologically into activity threads."""122 sorted_events = sorted(self.events, key=lambda e: e.timestamp)123 for i in range(len(sorted_events) - 1):124 self.graph.add_edge(125 sorted_events[i].event_id,126 sorted_events[i + 1].event_id,127 relationship="followed_by",128 )129130 def find_pivots(self):131 """Find pivot points where events share infrastructure or capabilities."""132 pivots = {"infrastructure": {}, "capability": {}, "adversary": {}}133134 for event in self.events:135 if event.infrastructure:136 pivots["infrastructure"].setdefault(event.infrastructure, []).append(event.event_id)137 if event.capability:138 pivots["capability"].setdefault(event.capability, []).append(event.event_id)139 if event.adversary:140 pivots["adversary"].setdefault(event.adversary, []).append(event.event_id)141142 return {143 k: {pk: pv for pk, pv in v.items() if len(pv) > 1}144 for k, v in pivots.items()145 }146147 def generate_report(self):148 return {149 "total_events": len(self.events),150 "unique_adversaries": len(set(e.adversary for e in self.events if e.adversary)),151 "unique_victims": len(set(e.victim for e in self.events if e.victim)),152 "unique_infrastructure": len(set(e.infrastructure for e in self.events if e.infrastructure)),153 "pivots": self.find_pivots(),154 "events": [e.to_dict() for e in self.events],155 }156```157158## Validation Criteria159160- Diamond events capture all four core features with meta-features161- Activity threads link related events chronologically162- Pivot analysis identifies shared infrastructure and capabilities across events163- Graph visualization renders the activity-attack graph correctly164- Events map to MITRE ATT&CK techniques for capability classification165166## References167168- [Diamond Model Paper](https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf)169- [MITRE ATT&CK](https://attack.mitre.org/)170- [STIX 2.1 Campaign Object](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)