/etc/passwd and /etc/shadow
Adversaries read /etc/passwd and /etc/shadow on Linux and Unix systems to extract password hashes for offline cracking. /etc/passwd contains usernames and user information (world-readable), while /etc/shadow contains the actual password hashes (root-readable only). Together they can be combined with `unshadow` and cracked with John the Ripper or Hashcat. Tools include LaZagne (shadow.py module), direct cat commands, and Python one-liners. Also includes reading from backup copies (/etc/shadow-, /etc/shadow.bak) and cloud instance metadata for default credentials. Used by multiple threat actors as a standard post-exploitation step on Linux systems.
let ShadowFileAccess = DeviceFileEvents
| where Timestamp > ago(24h)
| where FolderPath in~ ("/etc/shadow", "/etc/shadow-", "/etc/shadow.bak",
"/etc/master.passwd", "/etc/security/passwd")
| where InitiatingProcessFileName !in~ ("passwd", "chpasswd", "useradd", "usermod",
"chage", "pam_unix.so", "shadow", "login")
| project Timestamp, DeviceName, AccountName, FolderPath, ActionType,
InitiatingProcessFileName, InitiatingProcessCommandLine;
let UnshadowCommand = DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has "unshadow"
or (ProcessCommandLine has "/etc/shadow" and ProcessCommandLine has "/etc/passwd")
or ProcessCommandLine has_any ("john", "hashcat") and ProcessCommandLine has "shadow"
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine;
let LaZagneShadow = DeviceProcessEvents
| where Timestamp > ago(24h)
| where ProcessCommandLine has "lazagne"
and ProcessCommandLine has_any ("shadow", "linux", "all")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine;
union ShadowFileAccess, UnshadowCommand, LaZagneShadow
| sort by Timestamp desc Data Sources
Required Tables
False Positives
- System package managers (apt, yum, dnf) modifying /etc/shadow during user account package installations
- Configuration management tools (Ansible, Puppet, Chef) managing user accounts and updating /etc/shadow
- Legitimate password change operations by passwd, chpasswd, or chage tools — these access /etc/shadow by design
- Backup software with root access reading /etc/shadow as part of full system configuration backup
- Security scanning tools (Lynis, OpenSCAP) performing compliance checks that read /etc/shadow metadata
References (6)
- https://attack.mitre.org/techniques/T1003/008/
- https://github.com/AlessandroZ/LaZagne
- https://linux.die.net/man/8/unshadow
- https://www.openwall.com/john/
- https://linux-audit.com/monitoring-of-etc-shadow-using-linux-audit/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1003.008/T1003.008.md
Unlock Pro Content
Get the full detection package for T1003.008 including response playbook, investigation guide, and atomic red team tests.