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: The Diamond Model of Intrusion Analysis provides a structured framework4 for analyzing cyber intrusions by examining four core features - Adversary, Capability,5 Infrastructure, and Victim. This skill covers implementing the Diamond Model programmatically6 to classify and correlate intrusion events, build activity threads, and generate7 pivot-ready intelligence.8domain: cybersecurity9subdomain: threat-intelligence10tags:11- threat-intelligence12- cti13- ioc14- mitre-attack15- stix16- diamond-model17- intrusion-analysis18version: '1.0'19author: mahipal20license: Apache-2.021nist_csf:22- ID.RA-0123- ID.RA-0524- DE.CM-0125- DE.AE-0226mitre_attack:27- T159128- T159229- T159330- T158931- T081632metadata:33 source: https://skillmd.com/skills/mukul975/implementing-diamond-model-analysis34---3536# Implementing Diamond Model Analysis3738## Overview3940The 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.414243## When to Use4445- When deploying or configuring implementing diamond model analysis capabilities in your environment46- When establishing security controls aligned to compliance requirements47- When building or improving security architecture for this domain48- When conducting security assessments that require this implementation4950## Prerequisites5152- Python 3.9+ with `networkx`, `stix2`, `graphviz` libraries53- Understanding of the Diamond Model core and meta-features54- Access to threat intelligence data (MISP/OpenCTI events)55- Familiarity with MITRE ATT&CK for capability mapping5657## Key Concepts5859### Diamond Model Core Features60- **Adversary**: The threat actor or operator conducting the intrusion61- **Capability**: The tools, techniques, and malware used (maps to ATT&CK)62- **Infrastructure**: C2 servers, domains, email addresses, hosting providers63- **Victim**: Target organization, system, person, or data asset6465### Meta-Features66- **Timestamp**: When the event occurred67- **Phase**: Kill chain stage (recon, delivery, exploitation, etc.)68- **Result**: Success, failure, or unknown69- **Direction**: Adversary-to-infrastructure, infrastructure-to-victim, etc.70- **Methodology**: Social engineering, technical exploit, insider threat71- **Resources**: Financial, human, technical resources required7273### Activity Threads and Groups74- **Activity Thread**: Sequence of Diamond events from a single adversary operation75- **Activity Group**: Cluster of threads attributed to the same adversary7677## Workflow7879### Step 1: Define Diamond Event Data Structure8081```python82from dataclasses import dataclass, field83from datetime import datetime84from typing import Optional85import json86import uuid8788@dataclass89class DiamondEvent:90 adversary: str = ""91 capability: str = ""92 infrastructure: str = ""93 victim: str = ""94 timestamp: str = ""95 phase: str = ""96 result: str = ""97 direction: str = ""98 methodology: str = ""99 confidence: int = 0100 notes: str = ""101 event_id: str = field(default_factory=lambda: str(uuid.uuid4())[:8])102 mitre_techniques: list = field(default_factory=list)103 iocs: list = field(default_factory=list)104105 def to_dict(self):106 return {107 "event_id": self.event_id,108 "adversary": self.adversary,109 "capability": self.capability,110 "infrastructure": self.infrastructure,111 "victim": self.victim,112 "timestamp": self.timestamp,113 "phase": self.phase,114 "result": self.result,115 "direction": self.direction,116 "methodology": self.methodology,117 "confidence": self.confidence,118 "mitre_techniques": self.mitre_techniques,119 "iocs": self.iocs,120 "notes": self.notes,121 }122```123124### Step 2: Build Activity Thread from Events125126```python127import networkx as nx128129class DiamondAnalysis:130 def __init__(self):131 self.events = []132 self.graph = nx.DiGraph()133134 def add_event(self, event: DiamondEvent):135 self.events.append(event)136 self.graph.add_node(event.event_id, **event.to_dict())137138 def build_activity_thread(self):139 """Link events chronologically into activity threads."""140 sorted_events = sorted(self.events, key=lambda e: e.timestamp)141 for i in range(len(sorted_events) - 1):142 self.graph.add_edge(143 sorted_events[i].event_id,144 sorted_events[i + 1].event_id,145 relationship="followed_by",146 )147148 def find_pivots(self):149 """Find pivot points where events share infrastructure or capabilities."""150 pivots = {"infrastructure": {}, "capability": {}, "adversary": {}}151152 for event in self.events:153 if event.infrastructure:154 pivots["infrastructure"].setdefault(event.infrastructure, []).append(event.event_id)155 if event.capability:156 pivots["capability"].setdefault(event.capability, []).append(event.event_id)157 if event.adversary:158 pivots["adversary"].setdefault(event.adversary, []).append(event.event_id)159160 return {161 k: {pk: pv for pk, pv in v.items() if len(pv) > 1}162 for k, v in pivots.items()163 }164165 def generate_report(self):166 return {167 "total_events": len(self.events),168 "unique_adversaries": len(set(e.adversary for e in self.events if e.adversary)),169 "unique_victims": len(set(e.victim for e in self.events if e.victim)),170 "unique_infrastructure": len(set(e.infrastructure for e in self.events if e.infrastructure)),171 "pivots": self.find_pivots(),172 "events": [e.to_dict() for e in self.events],173 }174```175176## Validation Criteria177178- Diamond events capture all four core features with meta-features179- Activity threads link related events chronologically180- Pivot analysis identifies shared infrastructure and capabilities across events181- Graph visualization renders the activity-attack graph correctly182- Events map to MITRE ATT&CK techniques for capability classification183184## References185186- [Diamond Model Paper](https://www.activeresponse.org/wp-content/uploads/2013/07/diamond.pdf)187- [MITRE ATT&CK](https://attack.mitre.org/)188- [STIX 2.1 Campaign Object](https://docs.oasis-open.org/cti/stix/v2.1/stix-v2.1.html)