🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101

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. 1

    Get logs

    Use your own Linux VM (/var/log/auth.log) or a public sample log dataset.

  2. 2

    Parse

    Regex for "Failed password for (invalid user )?(\S+) from (\S+)" and "Accepted password ..."; parse timestamps.

  3. 3

    Load into pandas

    Columns: time, event, user, ip.

  4. 4

    Rule 1

    Same IP with 10+ failures within 5 minutes (rolling window with groupby + rolling("5min")).

  5. 5

    Rule 2

    Any successful login from an IP that failed 5+ times before: high priority.

  6. 6

    Report

    Top offending IPs, targeted usernames, timeline chart, and recommended actions (key-only SSH, fail2ban).

  7. 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