Foundations / Security operations basics
Security operations basics cheat sheet
Read logs (lesson 1)
| Task | Command |
|---|---|
| Count lines of the logs | wc -l data/* |
| Count lines that match | grep -c "Failed password" data/auth.log |
| Lines that do not match | grep -v "CRON" data/syslog |
| Address of a failed login (fourth field from the end) | grep "Failed password" data/auth.log | awk '{print $(NF-3)}' |
| Count equal lines, biggest first | sort | uniq -c | sort -rn |
| Status of a web request (field 9), size (field 10) | awk '{print $9}' data/access.log |
| Requests larger than 1,000,000 bytes | awk '$10 > 1000000 {print $7}' data/access.log |
Make events (lesson 2)
| Task | Command |
|---|---|
| Parse the logs of a host into events, in UTC | python3 logparse.py data 2026 events.jsonl |
| Same, for a host whose clock runs 5 hours behind UTC | python3 logparse.py ironwood 2026 out.jsonl -5 |
| Count events by action and outcome | python3 count_events.py |
| Fields of every event | ts source host process action outcome user ip port method path status bytes agent msg ref |
Detection rules (lesson 3)
| Task | Command or key |
|---|---|
| Run the rules over the events | python3 rules.py events.jsonl rules.json |
| Condition: equal, contains, at least | where, contains, at_least |
| Count for each address in a window | group_by, count, window_s |
| Skip known-good values | allow |
| Public rule format (lessons 7 and 8) and attack knowledge base | Sigma, MITRE ATT&CK (T1110.001 password guessing, T1110.003 password spraying) |
| Read a URL code in a web path | %27 is ', %20 is a space, %3B is ;, %3D is = |
Triage (lesson 4)
| Task | Command or idea |
|---|---|
| Triage the alerts of a day | python3 triage.py events.jsonl rules.json CONTEXT_FOLDER |
| The four questions | Who is it? Is it expected? Did it work? What first? |
| Context files | assets.csv, staff.csv, known_bad.csv, changes.csv |
| Priorities | P1 impact, P2 medium, P3 low, P4 false positive |
Windows events (lesson 5)
| Task | Command or idea |
|---|---|
| Export the 100 newest events as XML (on Windows) | wevtutil qe Security /f:xml /e:Events /c:100 /rd:true |
| Parse and count the events of an export | python3 winevents.py data/win/export.xml |
| Find a guessed password, an odd logon and a cleared log | python3 win_hunt.py data/win/export.xml |
| Fields of every parsed event | id ts computer channel record data |
| Namespace of the tags | {http://schemas.microsoft.com/win/2004/08/events/event} |
Events that keep their fields in UserData | 1102, 104 |
| ID | What it says | Fields to read |
|---|---|---|
| 4624 | Logon session created | LogonType, TargetUserName, IpAddress, TargetLogonId |
| 4625 | Logon failed | Status, SubStatus, LogonType, TargetUserName, IpAddress |
| 4672 | Sensitive privileges for a new logon | SubjectUserName, PrivilegeList |
| 4688 | Process created | NewProcessName, ParentProcessName, CommandLine |
| 4720, 4722, 4726 | Account created, enabled, deleted | TargetUserName, SubjectUserName |
| 4732 | Member added to a local group | TargetUserName (group), MemberSid |
| 4698 | Scheduled task created | TaskName, TaskContent |
| 1102 | Security log cleared | SubjectUserName |
| 104 | Another log cleared (System) | Channel |
| 7045 | Service installed (System log) | ServiceName, ImagePath |
| 4104 | PowerShell script block | ScriptBlockText |
| 4768, 4769, 4776 | Kerberos ticket, Kerberos service ticket, NTLM check (a wrong Kerberos password is 4771) | TargetUserName, Status (0x0 is success) |
| Logon type | Meaning |
|---|---|
| 2, 3 | Keyboard, network |
| 4, 5 | Batch job, service |
| 7, 11 | Unlock, cached credentials |
| 8, 9 | Network with cleartext password, new outbound credentials |
| 10 | Remote Desktop |
| Failure code | Meaning |
|---|---|
0xC0000064 | No such user |
0xC000006A | Bad password |
0xC000006D | Generic logon failure |
0xC0000234, 0xC0000072 | Account locked out, account disabled |
Endpoint alerts (lesson 6)
| Task | Command or idea |
|---|---|
| Score and explain the alerts of a set | python3 endpoint_triage.py data/edr |
| Print the ticket of one alert | python3 endpoint_triage.py data/edr E01 |
| Odd pairs | Office program starts a shell; server program starts a shell; regsvr32 with /i:http; rundll32 with a DLL in AppData or Temp |
Decode -EncodedCommand | base64.b64decode(text).decode("utf-16-le") |
| Decisions | 5 or more true positive, 3 or 4 needs review, 2 or less false positive |
| Requests | Isolate the host, disable the account, collect a triage package; the owner decides for a host of criticality 4 or 5 |
| Ticket parts | Title, seen, command, evidence, decision, asked, not known yet |
Sigma rules (lessons 7 and 8)
| Task | Command or idea |
|---|---|
| Run one Sigma rule over events in JSON lines | python3 sigma_lite.py RULE.yml EVENTS.jsonl |
| Write the events of a Windows export as JSON lines | python3 win_jsonl.py data/win/export.xml win-events.jsonl |
| Test every rule of a folder against its samples (exit code 0 or 1) | python3 sigma_test.py detections |
Samples of the rule NAME.yml | tests/NAME/match.jsonl (all must match), tests/NAME/nomatch.jsonl (none may match) |
| Convert rules with the real tool (not in this lab) | sigma convert --target splunk --pipeline splunk_windows ./rules |
| Part of a rule | Meaning |
|---|---|
title, logsource, detection | The mandatory parts: the name, which logs (category, product, service), the search |
id, status, description, author, date, references | A UUID; experimental, test, stable, deprecated or unsupported; the facts for the team |
level | informational, low, medium, high, critical |
tags | Lower case, with a namespace: attack.t1110, attack.credential-access |
| Map in a selection | Every entry must fit (AND) |
| List of values | One item must fit (OR); with |all every item |
|contains, |startswith, |endswith | The value is anywhere, at the start, at the end; case does not matter |
|re, |cidr, |gt, |gte, |lt, |lte | Regular expression, address in a network, comparisons of numbers |
*, ? | Any text, one character |
condition | selection and not filter, 1 of selection_*, all of selection_*, and, or, not, brackets |
| Count in a time span (a correlation rule, not run in this lab) | type: event_count, rules, group-by, timespan: 5m, condition: gte: 10; other types: value_count, temporal, temporal_ordered, and in 2.1.0 value_sum, value_avg, value_percentile |
Vulnerabilities and patching (lessons 9 and 10)
| Task | Command or idea |
|---|---|
| Names | CVE (which flaw), CWE (what kind), CVSS (how bad), KEV (exploited now), EPSS (likely next 30 days) |
| Bands of a CVSS score | None 0.0, Low 0.1 to 3.9, Medium 4.0 to 6.9, High 7.0 to 8.9, Critical 9.0 to 10.0 |
| Join severity and exploitation data | python3 vulns.py |
| Rank the findings | python3 patchrank.py inventory.csv installed.csv |
| Compare versions as numbers | tuple(int(p) for p in "4.10.0".split(".")) |
Incidents (lessons 11 to 13)
| Task | Command or idea |
|---|---|
| Classify incidents, check an incident log | python3 incident.py incidents.json phase_log.csv |
| States, in order | detected, analysing, contained, eradicated, recovered, closed |
| Seal evidence, with hashes and custody notes | python3 evidence.py seal data auth.log access.log syslog |
| Verify the sealed copies | python3 evidence.py verify |
| Check the manifest with the standard tool | (cd case/evidence && sha256sum -c ../manifest.sha256) |
| Lists to block and disable | python3 contain.py events.jsonl rules.json CONTEXT_FOLDER |
| Timeline of one address | python3 timeline.py ADDRESS events.jsonl |
| Incident report from the facts and your notes | python3 report.py case.json events.jsonl rules.json |
| Check the shape of a runbook | python3 runbook_check.py runbook.txt |
The tool (lesson 14)
| Task | Command |
|---|---|
| Logs in, ranked alerts out | python3 analyse.py --logs data --context . --year 2026 --offset 1 --rules rules.json |
| Exit codes | 0 nothing urgent, 1 at least one priority 1, 2 input cannot be read or holds no events |
| Outputs | ranked.csv, summary.txt |
Safety habits
- Seal the evidence before you touch anything, and analyse a copy.
- Move every log to UTC before you join logs, and name the clock of each source.
- Count the lines that you could not read, and report the count.
- Keep allow-lists and filters narrow, with an owner and an end date.
- Ship no rule without samples that must match and samples that must not.
- A feed that does not list an address says nothing about it.
- A score is not a risk: add exposure, evidence of exploitation and the value of the asset.
- A tool ranks and reports. A person decides to block, disable or shut down.
- Write facts and assumptions apart, and name the source of every fact.
- Treat everything in a log, such as a user name, a path or a command line, as input from an attacker.
- A cleared log, or a service account that logs on by Remote Desktop, is a sign to follow up and never proof.
- Ask for isolation and disabling with a reason in the ticket. For a critical host, the owner decides.