使用John the Ripper破解sha512加密的shadow文件密碼


John the Ripper

shadow文件解析

文件的格式為:
{用戶名}:{加密后的口令密碼}:{口令最后修改時間距原點(1970-1-1)的天數}:{口令最小修改間隔(防止修改口令,如果時限未到,將恢復至舊口令):{口令最大修改間隔}:{口令失效前的警告天數}:{賬戶不活動天數}:{賬號失效天數}:{保留}

其中{加密后的口令密碼}的格式為 $id$salt$encrypted

id為1時,采用md5算法加密
id為5時,采用SHA256算法加密
id為6時,采用SHA512算法加密
salt為鹽值,是對密碼進行hash的一個干擾值
encrypted為散列值

下載安裝

wget https://www.openwall.com/john/k/john-1.9.0.tar.gz #下載安裝包 (官網:John the Ripper password cracker

tar -xvf john-1.9.0.tar.gz

cd john-1.9.0/src/

make   #找到屬於自己的系統

make clean linux-x86-64  #正常linux64位系統就是這個

 

root:$6$RaPWxCGV$Z54bUhH9xccb9X580RP/cIgUVp3u6vKM2jJCaHme.fav0VnDs7UolXznMkPNAUu/dOhEDrdEmyTDNf1tIBMR./:17770:0:99999:7:::

 進入run目錄:

  

 默認這些文件:

  

 復制shadow密文到一個文件中ppp,用./john ppp命令即可,出來后用./john --show ppp查看密碼:

 

john的所有參數:

[root@iZb3kuz33l2fzfZ run]# ./john
John the Ripper password cracker, version 1.9.0 Copyright (c) 1996-2019 by Solar Designer Homepage: http://www.openwall.com/john/  Usage: john [OPTIONS] [PASSWORD-FILES] --single "single crack" mode --wordlist=FILE --stdin wordlist mode, read words from FILE or stdin --rules enable word mangling rules for wordlist mode --incremental[=MODE] "incremental" mode [using section MODE] --external=MODE external mode or word filter --stdout[=LENGTH] just output candidate passwords [cut at LENGTH] --restore[=NAME] restore an interrupted session [called NAME] --session=NAME give a new session the NAME --status[=NAME] print status of a session [called NAME] --make-charset=FILE make a charset, FILE will be overwritten --show show cracked passwords --test[=TIME] run tests and benchmarks for TIME seconds each --users=[-]LOGIN|UID[,..] [do not] load this (these) user(s) only --groups=[-]GID[,..] load users [not] of this (these) group(s) only --shells=[-]SHELL[,..] load users with[out] this (these) shell(s) only --salts=[-]N load salts with[out] at least N passwords only --save-memory=LEVEL enable memory saving, at LEVEL 1..3 --node=MIN[-MAX]/TOTAL this node's number range out of TOTAL count --fork=N fork N processes --format=NAME force hash type NAME: descrypt/bsdicrypt/md5crypt/ bcrypt/LM/AFS/tripcode/dummy/crypt

 

可以指定自己的密碼本

--wordlist=mima.txt

 測試本機的破解速度

-test

 

做個測試

新建一個用戶abc,密碼123456,指定一個簡單的密碼本mima.txt,刪除歷史john.log文件

mima.txt:

abc
abcd
abcde
123456
123
1234
12345

abc用戶的shadow密文單獨保存到abc文件中:

abc:$6$.rsMQzX5$31imN2bMPitKad5kTfJxk8.yCMos0ocAG9rfJna/hv9KaDzCXTqvM57v1/Zk/v7SbFqvemhdijVdTqtE4Y3RX1:18813:0:99999:7:::

使用下面命令指定mima.txt去破解abc用戶

./john --wordlist=mima.txt pwd/abc

幾秒鍾很快就出來了,畢竟字典那么短。。

 

 解出密碼后有個標記,就是會更新文件john.pot和john.log

 

 看下john.log文件

 

再看下john.pot文件,--show參數就是從這里取解密好的明文

 

  

PS:用雲服務器跑的可以使用screen保持會話,不間斷的跑,還可以隨時進去查看進度!

 

 

參考:

/etc/shadow文件破解,密碼破解,md5,SHA256,SHA512破解_NetRookieX的博客-CSDN博客_sha512解密 

利用John the Ripper破解密碼 - 逍遙人y - 博客園 

著名密碼破解利器John the Ripper使用方法詳解_不斷攀登-CSDN博客 

安全工具——John the Ripper - 先知社區 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM