Skip to main content

Overview

/etc/passwd defines user accounts. If writable, you can add a root-level user or modify existing entries. Even read access helps — password hashes may still be stored here on older systems.

Check Permissions

If writable by current user → direct edit.

/etc/passwd Format


Generate Password Hash

OpenSSL

mkpasswd

Python


Add Root User

Writable /etc/passwd

Switch to new user:

One-liner


Add User Without Password

Empty password field = no password required.

Modify Existing User to Root

Change UID/GID of current user to 0:
Re-login or:

Overwrite Root Password

Replace x with actual hash — bypasses /etc/shadow:

Remove Root Password


Read-Only /etc/passwd (Hash Cracking)

Even without write access, if hashes are in /etc/passwd (not x):
Crack with john:

Via Other Write Primitives

SUID cp

Capability cap_dac_override

NFS no_root_squash


Polkit — CVE-2021-3560

Exploit polkit race condition to create privileged user.

Check Vulnerable

Affected Systems

  • Ubuntu 20.04
  • Debian 11
  • Fedora 33
  • CentOS 8

Exploit

Timing-dependent — may need multiple attempts:

Automated Exploit