TExcelTAD

Defensive Security Exercises

Sixteen exercises across the whole course, in the order of its sections. They are the decisions a SOC makes every week: how many people, which metric, which log source, which rule, which threshold, which indicator, which hunt, which priority. Try each before opening the answer. Two answers include a program you can edit and run; all data is synthetic.

# Exercise Practises
1 Staff the night shift SOC Roles, Tiers and Shifts, Playbooks and Runbooks
2 Read the metrics slide SOC Metrics
3 Precision on a real volume Alert Fatigue and the Base-Rate Problem
4 Which log source? Log Sources, Collecting, Shipping and Retaining Logs
5 Normalise and order Normalisation and Schemas, Time Sync and Time Zones
6 The Sysmon exclusion review Sysmon and auditd
7 Pick the correlation pattern SIEM Search and Correlation, A Correlation Engine
8 Impossible or not? Impossible Travel
9 Failures, then success Brute Force Followed by Success
10 A beacon with heavy jitter DNS Beaconing, Enrichment
11 Fix the Sigma rule Sigma Rules, A Small Sigma Evaluator
12 Tests, coverage and tuning Testing Detections, Coverage Mapping, Tuning
13 What the sensors saw IDS Recap and Zeek Hunting, EDR and XDR, What EDR Sees
14 Intelligence in, decisions out Threat Intelligence, STIX and TLP, IOC Decay
15 Hunt with statistics Hunting Loop, Baselining, A Hunt End to End
16 From alert to handoff Triage and Cases, Evidence Handoff, Wazuh Incident

Exercise 1: Staff the night shift

Between 22:00 and 06:00 the SOC receives 120 alerts: 75 % close as false positives in 5 minutes each, 25 % need 20 minutes. Analysts spend 65 % of their time on alerts. How many analysts are needed on the night shift, and what must the night playbooks say that the day ones may leave out?

Answer

Work = 120 × (0.75 × 5 + 0.25 × 20) / 60 = 120 × 8.75 / 60 = 17.5 hours. One analyst provides 8 × 0.65 = 5.2 productive hours, so 17.5 / 5.2 ≈ 3.4: four analysts, or fewer analysts plus tuning or an MDR partner. Night playbooks must state who may approve disruptive actions (isolation of servers) when owners are asleep, the escalation phone tree, and the criteria for waking the incident lead.

Exercise 2: Read the metrics slide

A slide says: "MTTD fell from 40 h to 9 h; MTTR is 3 h; 0 incidents reported by third parties." The quarter had 7 incidents; one was found by a hunt and had started 70 days earlier, but was excluded "because it is an outlier". What is wrong, and what would you show instead?

Answer

Excluding the hunt-found incident is survivorship made worse: the long-dwell cases are exactly what MTTD should expose. With 7 incidents, show every incident's dwell time, the median and the maximum, and say how t_start was established. State what "R" means. Report "found by" (SOC rule, hunt, user, third party) as a metric in its own right.

Exercise 3: Precision on a real volume

A new rule had FPR 0.02 % and recall 90 % in testing. Production: 3 million events a day, about 6 malicious. Estimate the daily alerts and the precision. Then the rule is combined with an independent signal (FPR 2 %, recall 80 %) on the same host. Estimate again.

Answer

Alone: FP ≈ 3,000,000 × 0.0002 = 600, TP ≈ 5.4, precision ≈ 0.9 %. Combined: FP ≈ 3,000,000 × 0.0002 × 0.02 = 12, TP ≈ 6 × 0.9 × 0.8 = 4.3, precision ≈ 26 %, recall 72 %. Keep the single rule as a risk input or hunting query so the 28 % of attacks with only one signal are not completely lost.

Exercise 4: Which log source?

For each question, name the source and whether it is usually on by default: (a) who added a user to Domain Admins; (b) which process on ws15 resolved upd.cdn-lab.example; (c) who downloaded files from a cloud storage bucket; (d) which command deploy ran as root on web01.

Answer

(a) DC Security log, 4728/4732/4756, needs the "Security Group Management" audit subcategory (often enabled, check). (b) Sysmon Event ID 22 or EDR DNS telemetry; resolver logs only give the host, not the process. Not default. (c) Storage data-access logs (data events), usually off by default and billed. (d) sudo in auth.log/journald (default), or auditd execve with auid for the full picture (not default).

Exercise 5: Normalise and order

Three events: VPN "2026-03-29 01:58:00" (local Berlin time, no offset), identity provider 2026-03-29T00:59:30Z, EDR epoch 1774746060. Convert all three to UTC and put them in order. (Berlin switches to summer time at 02:00 local on that day.)

Answer

VPN: 01:58 is still winter time (UTC+1), so 00:58:00Z. IdP: 00:59:30Z. EDR: 1774746060 = 2026-03-29T01:01:00Z. Order: VPN 00:58:00, IdP 00:59:30, EDR 01:01:00. A local timestamp of 02:30 that day would not exist at all, which is why sources should log UTC with an offset.

Exercise 6: The Sysmon exclusion review

A configuration excludes from process creation: (a) Image is C:\Program Files\LabBackup\agent.exe; (b) Image ends with \chrome.exe; (c) CommandLine contains \AppData\Local\Temp\; (d) a Rule groupRelation="and" with ParentImage is C:\Windows\System32\services.exe and Image is C:\Program Files\LabMonitor\probe.exe. Rate each.

Answer

(a) Acceptable: exact path under Program Files (admin-only). (b) Bad: any file named chrome.exe anywhere is hidden; use the full path. (c) Very bad: %TEMP% is where droppers and payloads run; this hides them. (d) Good: narrow, two conditions, admin-only path.

Exercise 7: Pick the correlation pattern

Name the pattern for each: (a) a VPN session from abroad while the user's badge is used in the office; (b) the DC's agent sent nothing for 15 minutes; (c) one account resets passwords of 12 users in 10 minutes; (d) a scheduled task name never seen before on any host.

Answer

(a) Join across sources on the user with a time window (a variant of impossible travel). (b) Absence. (c) Threshold (count per actor in a window), or distinct count of targets. (d) First seen / rare (stacking).

Exercise 8: Impossible or not?

dave signs in from Hanoi (21.03 N, 105.85 E) at 07:00 and from Ho Chi Minh City (10.82 N, 106.63 E) at 08:45. Compute the speed. Then decide what you would alert on.

Answer

The program below gives about 1,138 km and 650 km/h: below the 900 km/h threshold, so a pure speed rule stays quiet. It is still physically unlikely (scheduled flights between the two cities take about two hours, before any time at airports), which is why products also flag "unlikely" speeds. Alert only if context adds up: a new device, a hosting-provider network, no MFA, or a country or city the user has never used.

python · try it yourself
import math
def km(la1, lo1, la2, lo2):
    p1, p2, dp, dl = map(math.radians, (la1, la2, la2 - la1, lo2 - lo1))
    h = math.sin(dp / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(dl / 2) ** 2
    return 2 * 6371 * math.asin(math.sqrt(h))
d = km(21.03, 105.85, 10.82, 106.63)
print(f"{d:.0f} km in 1.75 h = {d / 1.75:.0f} km/h")
1138 km in 1.75 h = 650 km/h

Exercise 9: Failures, then success

In the brute-force-detect lab, set W = 10, A = 10, D = 5. How many alerts, and what happens to the brute force's second alert compared with W = 5? Then explain why the sequence rule from the lesson still adds something the lab's rules don't have.

Answer

The lab shows 3 alerts (2 true positives, 1 false positive): with a 10-minute window, an alert suppresses repeats on the same key for 10 minutes, so the brute force produces one alert instead of two. The threshold rules never look at successes; the sequence rule ("failures, then a success from the same source") separates attempts that failed from the one that got in (admin at minute 23), which is the alert that needs a response in minutes.

Exercise 10: A beacon with heavy jitter

A host resolves cdn-sync.example 280 times in 24 hours, gaps with CV 0.55, MAD ratio 0.42, and no other host has ever resolved the domain, which was registered 6 days ago. The regularity rule (CV < 0.4, MAD ratio < 0.35) did not fire. What do you do?

Answer

Regularity alone fails against heavy jitter, but the other signals are strong: rarity (one host), a newly registered domain, volume (280 lookups), and lookups through the night. Score them together (Enrichment); this host belongs at the top of the hunting queue. Find the process that resolves the name (Sysmon 22 / EDR), check the domain's other intel, and if unexplained, open a case.

Exercise 11: Fix the Sigma rule

yaml
detection:
    selection:
        Image|endswith: 'powershell.exe'
        CommandLine|contains: '-enc'
        CommandLine|contains: '-nop'
    filter:
        User|contains: 'adm'
    condition: selection and not filter

Find three problems.

Answer

(1) The CommandLine|contains key appears twice in one map: the YAML specification forbids duplicate keys, strict parsers reject the file, and many common ones (PyYAML among them) silently keep only the last one, so -enc is ignored; use CommandLine|contains|all: ['-enc', '-nop'] (and consider prefixes such as -e). (2) endswith: 'powershell.exe' without the backslash also matches notpowershell.exe; use '\powershell.exe' and add \pwsh.exe and OriginalFileName. (3) The filter exempts any user whose name contains adm (badminton, admin-test, an attacker-created xadm); restrict to the exact admin naming scheme and, better, to admin workstations.

Exercise 12: Tests, coverage and tuning

A rule for T1003.001 has one positive test and no negative, the coverage report marks the technique "tested", and last week someone added an allow-list entry SourceImage endswith \rundll32.exe to stop false positives. What do you change in the tests, the coverage level and the allow-list?

Answer

Tests: add negatives (Defender and the EDR reading LSASS with their allowed rights) and variants (different access masks, a dump-file creation). Coverage: "tested" requires positive and negative tests and a recent end-to-end validation; until then it is "rule" (level 2). Allow-list: remove the rundll32.exe entry; it hides a classic LSASS dumping method. Replace it with exact paths of the legitimate tools and the rights they use, with an owner and expiry.

Exercise 13: What the sensors saw

From one workstation: Zeek shows a 6-hour TLS session to an IP with no prior DNS answer, a JA4 fingerprint seen on no other host; the EDR shows explorer.exe > powershell.exe > rundll32.exe C:\ProgramData\x.dll, and later a Sysmon 10 event with TargetImage lsass.exe, GrantedAccess 0x1010. Put the observations in ATT&CK terms and in order of urgency.

Answer

Most urgent: LSASS memory read (0x1010 = query limited + VM_READ) by an unexplained process: T1003.001, credentials may already be stolen, so isolate and plan credential resets. Then the execution chain: T1059.001 (PowerShell) and T1218.011 (rundll32 loading a DLL from a writable folder). The network session: T1071.001 (web protocols) / C2 over TLS, with direct-to-IP and a rare fingerprint as supporting evidence. One case, P1.

Exercise 14: Intelligence in, decisions out

You receive a STIX bundle marked TLP:AMBER with 40 IP indicators (confidence 40, valid_from 90 days ago, no valid_until) and a report saying the group "uses scheduled tasks named like Windows services for persistence". What do you do with each part?

Answer

The IPs: low confidence and 90 days old, IPs decay fast: don't block; search 90 days of history for contacts (hunting) and, if used for live matching, apply a decay model so they expire. Share only within your organisation and clients' need-to-know (TLP:AMBER). The TTP is the durable part: it becomes a hunt hypothesis and a detection for scheduled tasks with Windows-like names created by unusual parents (exactly the hunt of A Hunt End to End). Report sightings back to the source.

Exercise 15: Hunt with statistics

Daily outbound MB for one user over 10 days: 20, 22, 19, 21, 950, 20, 23, 18, 22, 21 (day 5 was an approved video upload). Today: 140 MB. Compute the ordinary and the robust z-score of today's value.

Answer

The ordinary score is masked by day 5; the robust one is not:

python · try it yourself
import numpy as np
hist = np.array([20, 22, 19, 21, 950, 20, 23, 18, 22, 21])
x = 140
z = (x - hist.mean()) / hist.std(ddof=1)
med = np.median(hist)
mad = np.median(np.abs(hist - med))
print(f"mean {hist.mean():.1f}, sd {hist.std(ddof=1):.1f}, z = {z:.2f}")
print(f"median {med}, MAD {mad}, robust z = {0.6745 * (x - med) / mad:.1f}")
mean 113.6, sd 293.9, z = 0.09
median 21.0, MAD 1.0, robust z = 80.3

The ordinary z-score of 0.09 calls 140 MB perfectly normal, because the 950 MB day inflated the standard deviation to 293.9 MB. The robust score (80.3) shows that 140 MB is about seven times the user's typical day. Check what was uploaded and where.

Exercise 16: From alert to handoff

Rule 100101 (SSH success after failures) fires on web01 at 03:10; web01 is an important server. List the first five actions in order, with what you record.

Answer

(1) Acknowledge and validate: open the raw auth.log lines behind the alert; record the time. (2) Set priority from the matrix (high on important = P2, raise to P1 if the account is privileged) and open a case with observables (source IP, account, host). (3) Contain with the playbook: block the source, lock the account, kill its sessions; record each action and its time. (4) Preserve: export alerts and logs, copy authorized_keys and other persistence locations, hash the package and write the custody entry. (5) Escalate to the incident lead per the criteria (confirmed account compromise on a server) and hand over the case and evidence package; scope other servers for the same source and the same key.

Practice problems for this course, with tests in 21 languages: Brute-Force Login Alerts.

Test yourself

Exercise 3: why does combining two independent signals raise precision so much?

  1. It increases the number of true positives
  2. The false-positive rates multiply, so false alarms fall far more than true positives
  3. It removes all attacks
  4. It changes the base rate

Exercise 6: which exclusion is the most dangerous?

  1. The exact backup agent path
  2. CommandLine contains \AppData\Local\Temp\
  3. The AND rule for the monitoring probe
  4. None are dangerous

Exercise 11: what happens to a YAML map with the same key twice?

  1. Both values apply with AND
  2. With many parsers only the last value is kept, so one condition silently disappears
  3. Every tool reliably rejects it
  4. Both values apply with OR

Exercise 14: which part of the intelligence report lasts longest?

  1. The IP addresses
  2. The TTP: scheduled tasks named like Windows services
  3. The TLP label
  4. The bundle id