Passwd, Shadow & Opasswd in Linux
Linux authentication systems are often built on PAM (Pluggable Authentication Modules). One of the most commonly used modules is pam_unix.so
, which is responsible for managing user authentication, sessions, and password changes using key files like /etc/passwd
, /etc/shadow
, and /etc/security/opasswd
.
PAM Modules Overview
PAM modules manage authentication and password policies.
Located in:
/usr/lib/x86_64-linux-gnu/security/
(Debian-based)
πΉ Modules like pam_unix.so
or pam_unix2.so
interact with:
/etc/passwd
/etc/shadow
/etc/security/opasswd
/etc/passwd
File
/etc/passwd
FileThe /etc/passwd
file stores user account details, accessible by all users:
Format
Example:
Security Implications
x
indicates the encrypted password is in/etc/shadow
.If password is directly present, itβs a security risk.
If
root
has a blank password field, no prompt is shown.
Before & After Edit Example
Before:
After:
Now su
command will grant direct root access:
etc/shadow File
The /etc/shadow
file is restricted to root/admin and holds encrypted password data.
π Format
Example:
Password Field Symbols
x
Password stored in shadow
*
or !
Account is locked
(empty)
No password required
Encryption Types
$1$
MD5
$2a$
Blowfish
$2y$
Eksblowfish
$5$
SHA-256
$6$
SHA-512 (default in modern distros)
/etc/security/opasswd
Used by PAM to store old passwords, preventing password reuse.
Reading the /etc/security/opasswd
Example:
Stores multiple hashes
Notice older, weaker hashes (like MD5)
Cracking Linux Password Hashes
Once you obtain hashes from passwd
+ shadow
, you can attempt to crack them.
1. Unshadowing Files
2. Cracking with Hashcat
Unshadowed Hashes (SHA-512)
MD5 Hashes
Prepare MD5 hash list:
Example:
Run hashcat:
β
Summary
/etc/passwd
Stores user account metadata
/etc/shadow
Stores encrypted passwords securely
/etc/security/opasswd
Stores old passwords for reuse prevention
π§ Be cautious of:
Misconfigured permissions (e.g., writable
/etc/passwd
)Weak hashes (e.g., MD5 in opasswd)
Password reuse patterns
π§° Tools used:
unshadow
hashcat
rockyou.txt
(wordlist)
Let me know if you'd like to merge this with the previous credential hunting notes or export it as a file!
Last updated