UnixDroid

Intermediate · 4 missions

SOC: read a server log — Linux terminal practice

Defensive SOC analyst work: read auth.log, spot repeated failed logins, find the noisiest IP and write a short report.

student@unixdroid: ~

Missions in this track

SOC analyst ki tarah logs padh kar failed logins aur sabse zyada try karne wala IP pakdo.

  1. 1

    The alert

    An alert says "many failed SSH logins". Look at the last 10 lines of /var/log/auth.log.

    Show the command
    tail /var/log/auth.log

    Without -n, tail shows 10 lines.

  2. 2

    Pull out the IPs

    Print only the IP addresses from the Failed password lines.

    Show the command
    grep "Failed password" /var/log/auth.log | grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+"

    -o prints only the matching part, -E turns on extended regex.

  3. 3

    Top attacker

    Count attempts per IP (sort | uniq -c | sort -nr) and submit the IP with the most attempts.

    Show the command
    grep "Failed password" /var/log/auth.log | grep -oE "[0-9.]{7,}" | sort | uniq -c | sort -nr

    This one-liner is in every SOC analyst's toolbox.

  4. 4

    Write the report

    Save your finding: echo "many failed logins from 185.220.101.7" > ~/incident.txt.

    Show the command
    echo "many failed logins from 185.220.101.7" > ~/incident.txt

    Typical fixes: block the IP in the firewall, set PermitRootLogin no, use SSH keys and fail2ban.