Lion Cipher Lab

Write a Python brute-force detector for auth.log

Why it matters

A busy Linux server can log thousands of failed SSH logins a day, and scrolling them by eye is hopeless. The move that separates a defender from a spectator is writing a few lines of code that read the raw log for you and hand back a short, ranked list of who is hammering the door. This lab teaches that move on the most common real signal there is — SSH brute force — and the exact same shape (read → extract → count → rank → threshold) is how log detection is written everywhere, from a five-line script to a SIEM rule. Learn it once here and you can point it at web logs, firewall logs, anything.

What you'll learn

Steps in this lab

  1. What we're building, and why the log looks the way it does
  2. Get Python on your machine (or confirm it's already there)
  3. Make the sample log to practise on
  4. First code: read the file and count the failures
  5. Pull the IP out of a line with a regex
  6. Count per IP with collections.Counter
  7. Rank the suspects and raise the alert
  8. What you just proved — and where to point it next

Open the full interactive lab →