A report a machine can read
A PDF report is easy for a person and useless to a firewall. Somebody has to copy each address out by hand, and somebody else makes a typo.
If the report is written as structured data, a tool can load it, link it and act on it in seconds. You write the made-up Copper Lantern report that way, in your own lab copy.
By the end of this lesson
Note
I can write a threat report as a STIX 2.1 bundle of linked objects.
Key words
| Word | What it means | Example |
|---|---|---|
| STIX | a JSON language for threat intelligence | |
| Object | one thing in STIX, with a type and an id | indicator--8f1c... |
| Pattern | the test an indicator applies to data | [ipv4-addr:value = '198.51.100.23'] |
| Relationship | an object that links two others | |
| Bundle | a set of objects sent together | |
| TAXII | the protocol that carries STIX between servers |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
3 questionsThe one rule
Important
Write and test only in your own lab copy. Every object here is made up. A real bundle can name victims and people. Share it only as its label allows, which is the next lesson.
A report becomes typed objects
STIX 2.1, from the standards body OASIS, describes intelligence as JSON objects. Every object has a type and an id, made of the type, two dashes and a UUID. It also has a spec_version of 2.1 and created and modified times.
Some describe the threat: a threat-actor, a malware family, an attack-pattern, an indicator. Two kinds connect them: a relationship and a sighting.
Worked example: the objects of the report
| type | name | What it says |
|---|---|---|
| identity | Northgate CERT | Who wrote the report |
| identity | Riverside office | Where it was seen |
| threat-actor | Copper Lantern | The group, made up |
| malware | updater | Its implant, a family |
| attack-pattern | Web Protocols | T1071.001, by external_id |
| indicator | cdn-update.example and four more | What to look for |
| relationship | eight of them | uses, targets, indicates |
| sighting | of cdn-update.example | Seen 5 times at Riverside |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsThe script builds and links the bundle
The Runs write a script with only Python's standard library. It makes each object, gives it an id from its type and name, links the objects and writes intel/bundle.json.
The ids are made from the names (uuid5) and every time is fixed. So your bundle is byte for byte the same as everybody else's.
Move into the lab's folder
cd ~/detectShown here, not run. Press Start lab to type it into your own lab’s terminal.
Make sure the intelligence folder exists
mkdir -p intelShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the bundle script, part 1
printf '%s\n' 'import json, uuid' 'NS, T, Q = uuid.UUID("6f6e3a5c-1d2b-4c8e-9a7f-3b5d0c2e1a90"), "2026-11-03T10:00:00.000Z", chr(39)' 'objs = []' 'def add(kind, key, **more):' ' obj = {"type": kind, "spec_version": "2.1", "id": kind + "--" + str(uuid.uuid5(NS, kind + key)), "created": T, "modified": T}' ' obj.update(more)' ' objs.append(obj)' ' return obj["id"]' 'def ind(name, path, until=None):' ' more = {"valid_until": until} if until else {}' ' return add("indicator", name, name=name, pattern="[" + path + " = " + Q + name + Q + "]", pattern_type="stix", valid_from="2026-09-01T00:00:00Z", **more)' 'cert = add("identity", "Northgate CERT", name="Northgate CERT", identity_class="organization")' 'office = add("identity", "Riverside office", name="Riverside office", identity_class="organization")' 'actor = add("threat-actor", "Copper Lantern", name="Copper Lantern")' 'implant = add("malware", "updater", name="updater", is_family=True)' > intel/bundle.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the bundle script, part 2
printf '%s\n' 'web = add("attack-pattern", "Web Protocols", name="Web Protocols", external_references=[{"source_name": "mitre-attack", "external_id": "T1071.001"}])' 'dom = ind("cdn-update.example", "domain-name:value")' 'ips = [ind("198.51.100.23", "ipv4-addr:value"), ind("203.0.113.99", "ipv4-addr:value", "2026-10-31T00:00:00Z")]' 'ua = ind("updater/1.4", "network-traffic:extensions." + Q + "http-request-ext" + Q + ".request_header." + Q + "User-Agent" + Q)' 'doc = ind("60065055603b91d13dc69c589f08730dd503f0d86f354d0b07ce3a9607814e3d", "file:hashes." + Q + "SHA-256" + Q)' 'for src, rel, dst in [[actor, "uses", implant], [actor, "targets", office], [implant, "uses", web], [dom, "indicates", implant], [ips[0], "indicates", implant], [ips[1], "indicates", implant], [ua, "indicates", implant], [doc, "indicates", actor]]:' ' add("relationship", src + rel + dst, relationship_type=rel, source_ref=src, target_ref=dst)' >> intel/bundle.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the bundle script, part 3
printf '%s\n' 'add("sighting", "sighting" + dom, sighting_of_ref=dom, where_sighted_refs=[office], count=5)' 'bundle = {"type": "bundle", "id": "bundle--" + str(uuid.uuid5(NS, "bundle")), "objects": objs}' 'json.dump(bundle, open("intel/bundle.json", "w"), indent=2)' 'kinds = [o["type"] for o in objs]' 'for kind in sorted(set(kinds)):' ' print(kinds.count(kind), kind)' 'print(len(objs), "objects in the bundle")' >> intel/bundle.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Build the bundle
python3 intel/bundle.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsAn indicator holds a pattern
An indicator does not hold a bare value. It holds a pattern, a test in square brackets. A pattern names an object type and a property, then compares it with a value in single quotes.
It also has valid_from and can have valid_until. The old address 203.0.113.99 stopped being valid on 31 October 2026.
Read the five patterns
grep '"pattern"' intel/bundle.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Find the indicator that has expired
grep -B 4 '"valid_until"' intel/bundle.json | grep '"name"'Shown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think STIX is a feed you subscribe to. STIX is only the language of the objects. TAXII is the protocol that carries them: a server offers collections and a client fetches bundles over HTTPS. A bundle in a file or an email is still STIX.
Try it: write a pattern
q = chr(39)
kind = "domain-name"
value = "cdn-update.example"
pattern = "[" + kind + ":value = " + q + value + q + "]"
print(pattern)
# Make the pattern for the address 198.51.100.23, whose kind is ipv4-addr.
Make a free account to save your work and track your progress.
Check
Have a go
Check
3 questionsAssignment: write patterns and check a bundle
Write two functions.
pattern_for(kind, value) returns a STIX pattern: for "domain", [domain-name:value = 'VALUE']; for "ipv4", [ipv4-addr:value = 'VALUE']; for "sha256", [file:hashes.'SHA-256' = 'VALUE']. For any other kind return None.
problems(bundle) checks a bundle, a dictionary with a list under "objects", and returns a list of problems in the objects' order. For each object: "bad id ID" when its id does not start with its type and --; "bad version ID" when spec_version is not "2.1"; for a relationship, "missing REF" for a source_ref or target_ref that is no object's id; for an indicator, "no pattern ID" when it has no pattern. An empty list means the bundle is fine.
def pattern_for(kind, value):
return None
def problems(bundle):
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go