Detect /etc/passwd and /etc/shadow in Elastic Security
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/
Elastic Detection Query
any where
(
event.category == "file" and
event.type in ("access", "creation", "change") and
file.path in ("/etc/shadow", "/etc/shadow-", "/etc/shadow.bak", "/etc/master.passwd", "/etc/security/passwd") and
not process.name in ("passwd", "chpasswd", "useradd", "usermod", "chage", "pam_unix.so", "shadow", "login", "chsh", "chfn", "newusers")
) or
(
event.category == "process" and
event.type == "start" and
(
process.name in ("unshadow", "lazagne") or
(process.name in ("john", "hashcat") and process.command_line : "*shadow*") or
(process.command_line : "*/etc/shadow*" and process.command_line : "*/etc/passwd*") or
(process.name in ("python", "python3", "perl", "ruby") and process.command_line : "*/etc/shadow*") or
(process.name in ("cat", "cp", "scp", "dd") and process.args : "/etc/shadow*")
)
) Detects unauthorized read access to /etc/shadow and related credential files, as well as execution of password-cracking tools (unshadow, john, hashcat, lazagne) targeting shadow hashes. Uses ECS-normalized file and process events from Elastic Agent or Auditbeat.
Data Sources
Required Tables
False Positives & Tuning
- Legitimate system account management tools (useradd, usermod, chpasswd) accessing shadow — excluded by process name filter but edge-case wrappers may trigger
- Security auditing tools such as Lynis, AIDE, or Tripwire that validate shadow file integrity and permissions as part of scheduled compliance scans
- Configuration management agents (Ansible, Puppet, Chef) executing user provisioning playbooks that read or modify /etc/shadow as root on managed nodes
- Backup agents (Bacula, Amanda, rsync run as root) that include /etc/ in full system backups and open shadow files for archival
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.