Detect /etc/passwd and /etc/shadow in Splunk
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/
SPL Detection Query
index=linux_logs
(sourcetype="linux_auditd" OR sourcetype="auditd")
(syscall=open OR syscall=openat OR syscall=read)
(name="/etc/shadow" OR name="/etc/shadow-" OR name="/etc/master.passwd"
OR name="/etc/security/passwd")
NOT (exe="/usr/bin/passwd" OR exe="/usr/sbin/chpasswd" OR exe="/usr/sbin/useradd"
OR exe="/usr/sbin/usermod" OR exe="/usr/sbin/chage" OR exe="/sbin/login")
| eval risk=case(
match(exe, "python|perl|ruby|bash|sh|cat|cp|scp"), "HIGH",
match(exe, "john|hashcat|unshadow|lazagne"), "CRITICAL",
1==1, "MEDIUM"
)
| table _time, host, exe, uid, pid, name, risk
| sort - _time
| union
[search index=linux_logs (sourcetype="linux_secure" OR sourcetype="syslog")
("unshadow" OR "lazagne" OR "john" OR "hashcat")
("shadow" OR "passwd")
| table _time, host, process, message
| sort - _time] Detects /etc/shadow access via auditd syscall events filtering out legitimate system authentication processes, with risk scoring based on the accessing executable. Also catches offline cracking tool invocations (unshadow, john, hashcat) and LaZagne in syslog entries mentioning shadow or passwd files.
Data Sources
Required Sourcetypes
False Positives & Tuning
- System authentication stack (PAM, login, su, sudo) accessing /etc/shadow during legitimate user authentication
- useradd, usermod, chage, and chpasswd accessing /etc/shadow during account management operations
- Automated provisioning tools (cloud-init, Ansible) writing /etc/shadow during initial system configuration
- Backup agents with root access reading /etc/shadow as part of system state capture
- Security auditing tools performing authorized password policy compliance checks
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.