Skip to content
Tutorials Center
My learning

Topics

Lesson 22 of 36 ยท Network and Log Forensics

Authentication Log Investigation

Investigate logins with Linux auth.log, syslog and Windows Security event IDs 4624 and 4625: spot brute force, impossible travel and privilege changes with Python.

Almost every intrusion involves an identity: a stolen password, a guessed key, a reused token. Authentication logs record who tried to sign in, from where, and whether it worked, so they answer the questions "how did they get in?" and "which account did they use?". This lesson covers Linux and Windows login records and shows how to turn them into findings with a short script.

All log lines below are invented examples. Analyze only systems and logs you are authorized to examine.

Where the records live

Platform Location Notes
Debian/Ubuntu /var/log/auth.log SSH, sudo, su, PAM
RHEL/Fedora /var/log/secure Same content, different name
Linux (systemd) journalctl -u ssh Binary journal, can be exported
Login history last, lastb, wtmp, btmp Successful and failed logins as binary files
Windows Security event log (Security.evtx) Needs auditing enabled
Web apps and VPNs Application logs, identity provider logs Often hold the cloud sign-ins

Reading Linux SSH entries

TEXT
Nov 12 14:03:01 web1 sshd[2210]: Failed password for invalid user admin from 203.0.113.9 port 51512 ssh2
Nov 12 14:03:05 web1 sshd[2214]: Failed password for root from 203.0.113.9 port 51514 ssh2
Nov 12 14:09:40 web1 sshd[2301]: Accepted password for deploy from 198.51.100.4 port 40112 ssh2
Nov 12 14:10:02 web1 sudo:   deploy : TTY=pts/0 ; PWD=/home/deploy ; USER=root ; COMMAND=/bin/bash

Key words: Failed password (wrong password), invalid user (the account does not exist, typical of guessing), Accepted password / publickey (success), and sudo lines that show privilege use and the command run.

Note that syslog lines have no year and no time zone. Find the year from the file's modification date or rotation, and confirm the zone from the host configuration.

Parse and count

Python Summarize SSH failures and successes

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.

One address trying admin, root and test is a password spraying or dictionary pattern. The successful logins come from a different address, so this log alone does not show a breach; it shows that the attack was noise and the real login needs separate review (is deploy expected from that address?).

Windows Security events

Windows records authentication as numbered events. The most useful for investigators:

Event ID Meaning
4624 Successful logon (check the logon type)
4625 Failed logon
4634 / 4647 Logoff
4648 Logon using explicit credentials
4672 Special privileges assigned (administrator-like logon)
4720 A user account was created
4732 Member added to a security-enabled local group
1102 The audit log was cleared

Logon types matter: 2 is interactive at the keyboard, 3 is network (file shares), 10 is Remote Desktop, and 5 is a service. A type 10 logon at 03:00 from an unexpected address is worth a closer look. Event 1102 (log cleared) is a strong sign someone tried to hide activity.

TEXT
EventID=4625  Account=Administrator  LogonType=10  SourceIP=203.0.113.9
EventID=4625  Account=Administrator  LogonType=10  SourceIP=203.0.113.9
EventID=4624  Account=Administrator  LogonType=10  SourceIP=203.0.113.9
EventID=4672  Account=Administrator

Example only: failures then a type 10 success and a privileged logon from the same address.

Spotting impossible travel

If one account signs in from two distant places within minutes, one of them is not the owner. With distances precomputed, a speed check is simple.

Python Impossible travel check

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.

VPNs and mobile carriers produce false positives, so treat the result as a lead and confirm with the user and other logs.

Good practice

  • Collect from a central log server when possible; local logs can be edited by an intruder.
  • Keep the raw file, hash it, and work on a copy.
  • Record what was absent: a gap in auth.log or a cleared event log is evidence too.
  • Correlate with web logs and place events on a timeline.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which Windows event ID records a failed logon?

    4625 is a failed logon, 4624 a successful one, 4672 special privileges and 1102 a cleared audit log.
  2. 2. A syslog line has no year. What should you do?

    Traditional syslog timestamps omit the year and zone, so establish them from other evidence and state your assumption.
  3. 3. What does 'Failed password for invalid user' tell you?

    Invalid user means the attacker guessed a username that is not defined, which is typical of guessing attacks.
  4. 4. Windows event 1102 means:

    Clearing the log is a classic anti-forensic step and should be investigated.
  5. 5. Which Windows logon type is Remote Desktop?

    Type 10 is RemoteInteractive (Remote Desktop); 2 is console, 3 network, 5 service.

Summary

  • Auth logs show who tried to sign in, from where, and how.
  • Linux: auth.log, secure, journald, wtmp/btmp; Windows: events 4624, 4625, 4672, 4720, 1102.
  • Failures then a success from one address, or a cleared log, are priority leads.
  • Syslog lacks year and zone; document your assumptions.
  • Impossible-travel checks are leads, not proof.

Next: Mobile Forensics Fundamentals