Detect /etc/passwd and /etc/shadow in Microsoft Sentinel
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.
MITRE ATT&CK
- Tactic
- Credential Access
- Technique
- T1003 OS Credential Dumping
- Sub-technique
- T1003.008 /etc/passwd and /etc/shadow
- Canonical reference
- https://attack.mitre.org/techniques/T1003/008/
KQL Detection Query
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 Detects /etc/shadow and /etc/passwd credential harvesting via direct file access by non-system processes, unshadow command combining the two files for offline cracking, John the Ripper and Hashcat invocation targeting shadow files, and LaZagne Linux shadow module execution. Access to /etc/shadow by any process other than system authentication tools is highly suspicious.
Data Sources
Required Tables
False Positives & Tuning
- 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
Other platforms for T1003.008
Testing Methodology
Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Direct /etc/shadow Read with cat
Expected signal: Auditd file watch event (type=SYSCALL, syscall=openat) for /etc/shadow with exe=/bin/cat. DeviceFileEvents (if MDE Linux agent) for /etc/shadow read by cat. Process creation event for cat command with /etc/shadow argument.
- Test 2Unshadow and Password Hash Preparation
Expected signal: Auditd SYSCALL events for openat on both /etc/passwd and /etc/shadow with exe=/usr/bin/unshadow. File creation event for /tmp/atomic_hashes.txt. DeviceProcessEvents for unshadow execution. DeviceFileEvents for shadow and passwd access.
- Test 3LaZagne Linux Shadow Module
Expected signal: DeviceNetworkEvents for GitHub download connection. DeviceProcessEvents for lazagne execution with 'linux -shadow' arguments. Auditd openat events for /etc/shadow with exe=/tmp/lazagne. DeviceFileEvents for /etc/shadow access.
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.