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

The /etc/passwd file stores user account details, accessible by all users:

Format

username : password : UID : GID : comment : home_directory : shell

Example:

cry0l1t3:x:1000:1000:cry0l1t3,,,:/home/cry0l1t3:/bin/bash

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

Symbol
Meaning

x

Password stored in shadow

* or !

Account is locked

(empty)

No password required

Encryption Types

Prefix
Algorithm

$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

File
Purpose

/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