Brute-force login detector (log analysis)
Parse server authentication logs to find brute-force attempts and suspicious logins, and produce an incident report.
Intermediateâą 6â10 hoursđĒ 7 stepsPythonRegexpandas
What you'll learn
- âReading real log formats with regex
- âTime-window detection rules
- âWriting a clear incident summary
What you'll build
- âParses SSH auth logs (or web server logs)
- âFlags IPs with many failures in a short window
- âDetects success after many failures
- âReport and optional block list
Step-by-step guide
- 1
Get logs
Use your own Linux VM (/var/log/auth.log) or a public sample log dataset.
- 2
Parse
Regex for "Failed password for (invalid user )?(\S+) from (\S+)" and "Accepted password ..."; parse timestamps.
- 3
Load into pandas
Columns: time, event, user, ip.
- 4
Rule 1
Same IP with 10+ failures within 5 minutes (rolling window with groupby + rolling("5min")).
- 5
Rule 2
Any successful login from an IP that failed 5+ times before: high priority.
- 6
Report
Top offending IPs, targeted usernames, timeline chart, and recommended actions (key-only SSH, fail2ban).
- 7
Output
Write suspicious IPs to a file a firewall could use; do not auto-block in production without review.
đ Make it stand out
- +Real-time mode tailing the log
- +Geo lookup of IPs with an offline database
- +Send alerts to email or Slack