Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 36 ยท Projects and Practice

Project: Build a Log Triage Tool

Build a small log triage tool in Python: parse mixed web and SSH logs, normalize time, apply detection rules, rank suspicious sources and print an evidence-ready summary.

In this project you build a compact log triage tool: a program that reads raw logs, extracts events, applies a few transparent rules, and ranks the sources most worth a human's attention. Triage means deciding what to look at first when there is far too much data. The tool does not decide guilt; it produces leads and records why each was raised.

You will combine ideas from web log analysis and authentication logs. Everything runs on synthetic logs inside the page.

Requirements

  1. Parse two formats: web access lines and SSH auth lines.
  2. Normalize each into the same event shape: time (UTC), source address, kind, detail.
  3. Apply rules: scanning (many 404s), password guessing (many failures), success after failures.
  4. Score each address and rank them.
  5. Report every rule that fired, with the evidence lines, and count unparsed lines.

Step 1: Parse into one event shape

Python Step 1: parsers and the event shape

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The two assumptions (the year and the host time zone) are written in the code and must go in the report. Real data requires you to confirm them.

Step 2: Detection rules

Each rule is a small function that returns findings with the lines that support them. Keeping rules separate makes them easy to explain and tune.

Python Step 2: rules, scoring and ranking

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The address with a success after failures ranks first, because that rule signals possible access, while the scanner ranks lower since it only probed. Scores are judgment calls: write down your reasoning and keep them adjustable.

Step 3: Make it an evidence-ready summary

A good tool prints an output you could attach to a report: what was read, what was ignored, assumptions, and the ranked leads. Extend your program so its final section prints:

  • the total lines read, parsed and unparsed (never hide unparsed lines);
  • the time range of the data in UTC;
  • the assumptions (syslog year, time zone);
  • the ranked table with the rule names;
  • the hash of the input file you analyzed, so another examiner can confirm it is the same data.
Python Step 3: summary header with coverage and input hash

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Extensions

  1. Add a rule for injection strings in web paths (', ../, <script>).
  2. Add a time-window check: flag five or more failures within one minute.
  3. Read a second format (Windows event IDs 4625 and 4624).
  4. Output a CSV or a markdown table for the report.
  5. Write unit tests with a few known-good and known-bad lines.

Reflect

  • Which rules would produce false positives on a busy site? How would you tune them?
  • What does a clean result prove? (Very little: logs may be missing or edited.)
  • What would you check next for the top-ranked address (timeline)?

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why keep detection rules as separate small functions?

    Separate rules make findings transparent and easy to adjust.
  2. 2. Why must the tool report unparsed lines?

    Coverage must be known; unparsed lines may be relevant or indicate a format problem.
  3. 3. What does hashing the input file achieve in the summary?

    The hash identifies the exact data used for the analysis.
  4. 4. A high score for an address means:

    Triage ranks leads; interpretation requires further evidence.

Summary

  • Triage ranks leads from large logs using explainable rules.
  • Normalize heterogeneous logs into one event shape with UTC time and documented assumptions.
  • Report coverage: parsed, unparsed, time range and input hash.
  • Scores are judgments; findings are leads, not verdicts.

Next: Project: Evidence Manifest and Hashing