A report is not a defence
You have read the report, mapped it, written it as STIX and shared it. Nothing on your network has changed. Copper Lantern's implant could still be calling home tonight.
Intelligence earns its keep when it becomes a detection that fires on the right thing and nothing else. You build them from the made-up bundle, in your own lab copy.
By the end of this lesson
Note
I can turn the indicators in a threat report into tested detection rules.
Key words
| Word | What it means | Example |
|---|---|---|
| Detection rule | a test that raises an alert on matching data | |
| Expiry | the date after which an indicator is no longer trusted | valid_until |
| Confidence | how sure the source is, from 0 to 100 | |
| Retro hunt | running a new rule over old data | |
| Feedback | telling the source what a rule found |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
3 questionsThe one rule
Important
Test rules only on your own lab copy and its captures. Blocking a real address can cut off innocent people who share it. So a real rule is tested first, as here.
Not every indicator becomes a rule
An indicator becomes a rule only if three things hold. It is still valid: an expired one, like 203.0.113.99, catches whoever rents the address next. Its source is confident enough. And your data can see it: a file hash needs a file log, and the lab's sensors watch the network.
The Runs write the bundle again, in case you start here, and a script that turns its indicators into Suricata rules.
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 lesson 4's 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 lesson 4's 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 lesson 4's 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.
Write the rule maker, part 1
printf '%s\n' 'import json, sys' 'today, Q = sys.argv[1], chr(39)' 'B = json.load(open("intel/bundle.json"))' 'MAKE = {' ' "[domain-name": "alert dns any any -> any any (msg:~intel VAL~; dns.query; dotprefix; content:~.VAL~; endswith; sid:SID; rev:1;)",' ' "[ipv4-addr": "alert tcp any any -> VAL any (msg:~intel VAL~; flags:S; sid:SID; rev:1;)",' ' "[network-traffic": "alert http any any -> any any (msg:~intel VAL~; flow:established,to_server; http.user_agent; content:~VAL~; startswith; sid:SID; rev:1;)",' '}' 'rules, sid = [], 3000001' 'for o in B["objects"]:' ' if not o["type"] == "indicator":' ' continue' ' value, kind = o["pattern"].split(Q)[-2], o["pattern"].split(":")[0]' ' if o.get("valid_until", "9999") < today:' ' print("skipped, expired:", value)' ' elif kind not in MAKE:' ' print("skipped, not on the network:", value[:12])' ' else:' > intel/torules.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the rule maker, part 2
printf '%s\n' ' rules.append(MAKE[kind].replace("~", chr(34)).replace("SID", str(sid)).replace("VAL", value))' ' print("sid", sid, kind[1:], value)' ' sid += 1' 'open("rules/intel.rules", "w").write(chr(10).join(rules) + chr(10))' 'print(len(rules), "rules written to rules/intel.rules")' >> intel/torules.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
Make rules for 4 November 2026
python3 intel/torules.py 2026-11-04Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Read the three rules
cat rules/intel.rulesShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsTest a rule before you trust it
A new rule runs first on data where you know the answer. The office capture holds the implant's traffic. known-bad.pcap holds only bad traffic and known-good.pcap only normal traffic, with look-alike names such as cdn-updates.example.
A good rule fires on the bad and stays silent on the good. Running it over old captures is a retro hunt.
Count the rules' alerts on the office capture
det count pcaps/office.pcap rules/intel.rulesShown here, not run. Press Start lab to type it into your own lab’s terminal.
Test them on known-bad and known-good
det test rules/intel.rulesShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsA common mistake
Warning
Many people think an alert on an intelligence indicator proves an intrusion. An address can be shared by many sites, and a report can be wrong. Treat the alert as a lead: check the machine, the time and the other indicators, as the diamond model's pivots do.
Detect the behaviour as well as the values
Values sit low on the pyramid of pain, so the group can change them by next week. The report's behaviour, Word starting hidden encoded PowerShell, already has a Sigma rule in the lab. It finds the group whatever server it uses.
Then tell the source what fired, as a sighting: feedback is how the next report gets better.
Run the behaviour rule on the events
det sigma sigma/office-powershell.ymlShown here, not run. Press Start lab to type it into your own lab’s terminal.
Try it: which indicators may be deployed today?
indicators = [
["cdn-update.example", "2027-01-31", 85],
["203.0.113.99", "2026-10-31", 70],
["198.51.100.40", "2027-01-31", 30],
]
today = "2026-11-04"
for value, until, confidence in indicators:
if until >= today and confidence >= 50:
print("deploy", value)
# Change today to "2027-02-01", then press Run.
Make a free account to save your work and track your progress.
Assignment: indicators to rules
An indicator is a dictionary with kind ("domain", "ip", "useragent" or another), value, until (a date like "2026-10-31", or None for no end) and confidence (0 to 100).
rule_for(indicator, sid) returns one Suricata rule, exactly as the lab's script writes it, with the value for V and the number for N: alert dns any any -> any any (msg:"intel V"; dns.query; dotprefix; content:".V"; endswith; sid:N; rev:1;) for a domain, alert tcp any any -> V any (msg:"intel V"; flags:S; sid:N; rev:1;) for an ip, and alert http any any -> any any (msg:"intel V"; flow:established,to_server; http.user_agent; content:"V"; startswith; sid:N; rev:1;) for a useragent. Any other kind gives None.
build(indicators, today, first_sid) returns the rules for the indicators that are not expired (no until, or until on or after today), have a confidence of at least 50 and have a rule. Number them from first_sid up, in order.
def rule_for(indicator, sid):
return None
def build(indicators, today, first_sid):
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go