SSZcreate/Pentab_server / .agents/skills/cybersecurity/skills/implementing-diamond-model-analysis
implementing-diamond-model-analysis
VerifiedThe 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.
| File | Kind | Size |
|---|---|---|
| LICENSE | other | 11.0 KB |
| SKILL.md | skill md | 6.4 KB |
| assets/template.md | markdown | 996 B |
| references/api-reference.md | markdown | 1.7 KB |
| references/standards.md | markdown | 1.1 KB |
| references/workflows.md | markdown | 1.4 KB |
| scripts/agent.py | script | 5.0 KB |
| scripts/process.py | script | 4.1 KB |
scripts/process.py
View on GitHub#!/usr/bin/env python3
"""
Diamond Model of Intrusion Analysis Implementation
Creates Diamond Model events, builds activity threads, and performs pivot analysis.
Requirements: pip install networkx stix2
Usage:
python process.py --events events.json --output analysis.json
python process.py --demo --output demo_analysis.json
"""
import argparse
import json
import uuid
from collections import defaultdict
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class DiamondEvent:
adversary: str = ""
capability: str = ""
infrastructure: str = ""
victim: str = ""
timestamp: str = ""
phase: str = ""
result: str = "success"
confidence: int = 0
mitre_techniques: list = field(default_factory=list)
iocs: list = field(default_factory=list)
event_id: str = field(default_factory=lambda: str(uuid.uuid4())[:8])
def to_dict(self):
return vars(self)
class DiamondModelAnalyzer:
def __init__(self):
self.events = []
def add_event(self, event: DiamondEvent):
self.events.append(event)
def load_events(self, filepath):
with open(filepath) as f:
data = json.load(f)
for e in data:
self.events.append(DiamondEvent(**e))
def find_pivots(self):
pivots = {"infrastructure": defaultdict(list), "capability": defaultdict(list),
"adversary": defaultdict(list), "victim": defaultdict(list)}
for e in self.events:
for feature in pivots:
val = getattr(e, feature, "")
if val:
pivots[feature][val].append(e.event_id)
return {k: {pk: pv for pk, pv in v.items() if len(pv) > 1} for k, v in pivots.items()}
def build_activity_threads(self):
threads = defaultdict(list)
for e in sorted(self.events, key=lambda x: x.timestamp):
key = e.adversary or "unknown"
threads[key].append(e.to_dict())
return dict(threads)
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(),
"activity_threads": self.build_activity_threads(),
"events": [e.to_dict() for e in self.events],
}
def run_demo():
analyzer = DiamondModelAnalyzer()
analyzer.add_event(DiamondEvent(
adversary="APT29", capability="Cobalt Strike", infrastructure="198.51.100.1",
victim="Gov Agency A", timestamp="2025-06-01T10:00:00Z", phase="initial-access",
mitre_techniques=["T1566.001"], confidence=80,
))
analyzer.add_event(DiamondEvent(
adversary="APT29", capability="Custom Backdoor", infrastructure="198.51.100.1",
victim="Gov Agency A", timestamp="2025-06-01T12:00:00Z", phase="persistence",
mitre_techniques=["T1547.001"], confidence=85,
))
analyzer.add_event(DiamondEvent(
adversary="APT29", capability="Mimikatz", infrastructure="198.51.100.2",
victim="Gov Agency A", timestamp="2025-06-02T09:00:00Z", phase="credential-access",
mitre_techniques=["T1003.001"], confidence=90,
))
return analyzer.generate_report()
def main():
parser = argparse.ArgumentParser(description="Diamond Model Analyzer")
parser.add_argument("--events", help="Events JSON file")
parser.add_argument("--demo", action="store_true", help="Run demo analysis")
parser.add_argument("--output", default="diamond_analysis.json")
args = parser.parse_args()
if args.demo:
report = run_demo()
elif args.events:
analyzer = DiamondModelAnalyzer()
analyzer.load_events(args.events)
report = analyzer.generate_report()
else:
parser.print_help()
return
print(json.dumps(report, indent=2))
with open(args.output, "w") as f:
json.dump(report, f, indent=2)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 319k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 117k | Updated | Claude CodeCodex | Verified | Install |