Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

The diamond model of intrusion analysis

After this lesson: I can describe an intrusion event with the diamond model and pivot from one corner to find related events.

60 min lesson9 commandsDetection engineering lab: Suricata rules, Sigma rules and Zeek-style logs on one private Ubuntu VM

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

One address, two colleges

Your office saw one machine calling 198.51.100.23. A week ago another college, in a report shared with you, saw the same address. Is it the same attacker? What else should you look for?

A simple four-cornered picture turns each sighting into a record you can join to others. The colleges and the attacker are made up, and you work in your own lab copy.

By the end of this lesson

Note

I can describe an intrusion event with the diamond model and pivot from one corner to find related events.

Key words

WordWhat it meansExample
Diamond modelan event described by four linked corners
Adversarywho carries out the intrusion
Capabilitythe tool or method used
Infrastructurewhat the capability travels through198.51.100.23
Victimthe person, machine or organisation attacked
Pivotto search from one known value to related ones

The cells students fill in are left blank in this preview.

Starter

Have a go

Starter

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

The one rule

Important

Pivot only through data you hold: your own logs and reports shared with you. Looking an address up in a public record is fine. Connecting to it or scanning it is not, and without permission it can be an offence under the Computer Misuse Act 1990.

Every event has four corners

The diamond model (Caltagirone, Pendergast and Betz, 2013) records each step of an intrusion as an event with four corners. An adversary uses a capability over infrastructure against a victim.

Each event also carries a time, a phase and a result. A corner can be unknown, written ?. Most local events start with the adversary unknown.

Worked example: the office's command-and-control event

CornerValueWhere it came from
Adversary?Nothing local names who
Capabilityupdater/1.4http.log, its user agent
Infrastructurecdn-update.example, 198.51.100.23dns.log and conn.log
VictimPC-15, 10.20.1.15conn.log and the office's asset list
Time and phase2026-11-02 09:00, command and controlThe capture

The cells students fill in are left blank in this preview.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

A pivot starts from one corner

To pivot is to take one known value and search for what else shares it. From the address, find the names that pointed to it. From the victim machine, find what else happened on it.

The Runs do both on the lab's own data. The office's asset list says PC-15 is 10.20.1.15, used by amira.

Move into the lab's folder

Command
cd ~/detect

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Make the logs from the capture

Command
zeek-lite -r pcaps/office.pcap

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Pivot from the address to its names

Command
zeek-cut query answers < dns.log | grep 198.51.100.23 | sort | uniq -c

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Pivot from the victim to its events

Command
sqlite3 logs/events.db "SELECT UtcTime, User, CommandLine FROM logs WHERE Computer = 'PC-15'"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

A common mistake

Warning

Many people think one shared corner proves one attacker. Addresses are rented, reused and shared, so a shared address is a lead, not a proof. Two events linked by several corners, here the address and an implant of the same family, make a stronger case.

Events join into threads and groups

Events on one victim, ordered by phase, form an activity thread: delivery, execution, discovery, command and control. Events on different victims that share corners can be grouped, which is how a report comes to name one adversary.

The script holds five events: four in the office and one from Hillside College's report.

Make sure the intelligence folder exists

Command
mkdir -p intel

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the diamond events, part 1

Command
printf '%s\n' 'import sys' 'EVENTS = [' '    ["E1", "?", "delivery", "Copper Lantern", "invoice-0412.docx", "[email protected]", "[email protected]"],' '    ["E2", "2026-11-02 09:00", "command-and-control", "?", "updater/1.4", "cdn-update.example 198.51.100.23", "PC-15 10.20.1.15"],' '    ["E3", "2026-11-02 15:00", "execution", "?", "powershell -nop -w hidden -enc", "?", "PC-15 amira"],' '    ["E4", "2026-11-02 15:10", "discovery", "?", "whoami /all", "?", "PC-15 amira"],' '    ["E5", "2026-10-28 11:20", "command-and-control", "Copper Lantern", "updater/1.5", "198.51.100.23", "Hillside College"],' ']' 'NAMES = ["adversary", "capability", "infrastructure", "victim"]' 'want = sys.argv[1]' 'found = 0' 'for event in EVENTS:' '    if any(want in vertex for vertex in event[3:]):' '        found += 1' '        print(event[0], event[1], event[2])' '        for name, vertex in zip(NAMES, event[3:]):' '            print("   ", name.ljust(16), vertex)' > intel/diamond.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the diamond events, part 2

Command
printf '%s\n' 'if found == 0:' '    print("No event has", want)' >> intel/diamond.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Pivot on the address

Command
python3 intel/diamond.py 198.51.100.23

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Pivot on the user

Command
python3 intel/diamond.py amira

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Try it: which corners do two events share?

Code: python
e2 = {"capability": "updater/1.4", "infrastructure": "198.51.100.23", "victim": "PC-15"}
e5 = {"capability": "updater/1.5", "infrastructure": "198.51.100.23", "victim": "Hillside College"}

for vertex in ["capability", "infrastructure", "victim"]:
    if e2[vertex] == e5[vertex]:
        print("E2 and E5 share their", vertex, e2[vertex])
# Change e5's capability to "updater/1.4", then press Run.

Make a free account to save your work and track your progress.

Assignment: pivot and build a thread

Each event is a dictionary with the keys id, phase, adversary, capability, infrastructure and victim. An unknown corner is "?".

pivot(events, value) returns the ids of the events where any of the four corners contains value, in the order given.

thread(events, victim, phases) returns the ids of the events whose victim contains victim, ordered by where their phase is in the list phases. Events with the same phase keep their order.

shared(a, b) returns the names of the corners where two events have the same value, leaving out "?", in the order adversary, capability, infrastructure, victim.

Code: python
def pivot(events, value):
    return []

def thread(events, victim, phases):
    return []

def shared(a, b):
    return []

Make a free account to save your work and track your progress.

Exit quiz

Have a go

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.