LastLog-Audit
Linux authentication log forensics: lastlog, wtmp, auth.log parsing and cross-source correlation.
Stars License Python

Overview

LastLog-Audit is a zero-dependency Python parser for the binary /var/log/lastlog database on Linux systems. It extracts the most recent login timestamp, terminal, and originating host for every UID, enabling security teams to identify stale accounts, detect credential abuse, and support forensic triage during incident response.

Stale and dormant accounts are a persistent blind spot in enterprise environments. Adversaries routinely leverage forgotten local accounts for initial access (T1078) and persistence, knowing these credentials often escape rotation policies and active monitoring. LastLog-Audit makes this exposure immediately visible.

Quick Start

# Parse lastlog with usernames
$ sudo python3 LastLogAudit.py -u

# Parse wtmp (full login/logout history)
$ python3 LastLogAudit.py --wtmp /var/log/wtmp

# Parse auth.log (SSH successes/failures + sudo)
$ python3 LastLogAudit.py --auth-log /var/log/auth.log

# Cross-reference all 3 sources
$ python3 LastLogAudit.py -f /var/log/lastlog --wtmp /var/log/wtmp --auth-log /var/log/auth.log --correlate

Parameters

Parameter Description
-f / --filePath to lastlog binary (default: /var/log/lastlog)
--wtmpParse wtmp binary for full login/logout history
--auth-logParse auth.log for SSH events and sudo commands
--correlateCross-reference lastlog + wtmp + auth.log (requires all three)
-u / --include-usernameResolve UIDs to usernames (lastlog mode only)
-d / --displayOutput format: table or line
-e / --exportExport to file
-F / --export-formatcsv or txt

MITRE ATT&CK Mapping

ID Technique Relevance
T1078 Valid Accounts Surfaces accounts with recent login activity indicating potential credential abuse.
T1078.003 Local Accounts Dormant local accounts with unexpected recent logins are high-fidelity indicators.
T1136 Create Account New UIDs with no lastlog record may indicate adversary-created accounts.
T1070.006 Timestomp Active accounts with zeroed lastlog records suggest evidence destruction.
T1021 Remote Services Hostname/IP fields reveal the origin of SSH and remote authentications.
T1531 Account Access Removal Missing records relative to a baseline may indicate passwd or lastlog tampering.

Training Lab

9 pre-built lastlog scenarios in samples/ for hands-on forensic training. Analyze offline without root access. Use as SOC analyst exercises, DFIR training, or CTF challenges.

ScenarioKey IndicatorsMITRE
clean_serverBaseline: internal IPs, business hours-
compromisedRoot from Tor exit, dormant account reactivatedT1078, T1021
timestompedRoot record zeroed, future timestampT1070.006
apt_cozy_bear9-month dwell, rotating C2, business hoursAPT29
apt_lazarusRapid multi-account, single C2, NK hoursAPT38
insider_threat2-3 AM access from home IPInsider
brute_force5 accounts + root, same IP, 13 minutesT1110
supply_chainCI/CD service accounts from GCP IPsT1195
pentest_engagement10.10.14.x, methodical privesc chainRed team
# Analyze an APT29 scenario
$ python3 LastLogAudit.py --file samples/apt_cozy_bear.lastlog

[+] 7 login record(s) parsed

Terminal       From                Last Login
----------------------------------------------------------------
pts/0          10.0.1.50           2026-03-25 10:15:00
pts/3          193.29.56.122       2025-06-14 09:32:00
pts/3          91.219.236.18       2025-09-03 10:47:00
pts/3          5.45.65.52          2025-12-11 11:05:00
pts/3          45.133.1.71         2026-03-22 09:58:00

Forensic Learning Lab

Interactive training module: explore the binary structure of lastlog records at the byte level, compare the same compromise across all 3 log sources, and test your IOC detection skills.

Open Learning Lab

Requirements

Python 3.7 or later. Standard library only, no external dependencies.

Read access to /var/log/lastlog (requires root or adm group membership).

License

Released under the GNU Affero General Public License v3.0.