2011年11月4日 星期五

john the ripper (發生No Password hashed loaded錯誤時,需刪john.pot和john.log)




絕大部分unix系統都使用DES加密方式,經過處理的密碼應該是13位,而JTR正是用來解開DES加密密碼的工具


John the ripper


首先先安裝John the ripper
http://www.openwall.com/john/
下載John the ripper


Download the latest community-enhanced version (release notes):
cd /tmp 
mkdir john
cd john 
下載檔案在john資料夾中
解壓縮後 進入john-1.7.8
cd john-1.7.8
cd src/
make 
make linux-x86-sse2
編譯完後 進入run資料夾

cd /tmp/john/john-1.7.8/run

sudo ./unshadow /etc/passwd /etc/shadow  >/tmp/john/john-1.7.8/run/hack.me
./john hack.me
開始執行破解
Loaded 9 password hashes with 9 different salts (generic crypt(3) [?/32])
guesses: 0  time: 0:00:00:13 8% (1)  c/s: 28.76  trying: xxxxxxxxx- xxxxxxxxx
guesses: 0  time: 0:00:01:44 22% (1)  c/s: 27.62  trying: xxxxxxxxx` - xxxxxxxxx!!
guesses: 0  time: 0:00:01:48 22% (1)  c/s: 27.49  trying: xxxxxxxxx~ - xxxxxxxxx!!!
pass123          (myUserName1)
123321           (OtherUserName)
guesses: 2  time: 0:00:28:22 3% (2)  c/s: 24.79  trying: Support - Leslie
guesses: 2  time: 0:00:30:40 4% (2)  c/s: 24.76  trying: Warrior - Butch
guesses: 2  time: 0:00:32:58 4% (2)  c/s: 24.72  trying: Snowflake - Zombie
guesses: 2  time: 0:00:34:33 4% (2)  c/s: 24.70  trying: Canela - Dammit





<不同模式>
./unshadow /etc/passwd /etc/shadow >crack.db     #用./unshadow 轉成john可接受的檔案crack.db
./john --incremental:alpha --users:root crack.db #字母暴力破解模式


#字典暴力破解模式 ()
#/root/passwords.db裡面放所有的username 
#/root/pass-hashs.db 裡面放的是內容同於/etc/shadow檔




#開始執行
./john --wordlist:/root/passwords.db  /root/pass-hashs.db


#閱讀破解結果
./john show crack.db


#也可閱讀john.pot知道破解結果
cat john.pot







<額外補充>

linux的/etc/shadow是專門用於存放用戶口令的,以前一直聽說口令是用md5加密(其實是hash)過的,但裡連的格式和md5sum生成的並不一樣。可以查看下/etc/shadow,對該文件不了解的話可以上網查詢。
下面來看第二列(這個是我隨便生成的,並不是系統的):
$1$eCeLr51L$/1EEtFr8iQ.TySiJKHQRQ/
可以看出格式比較奇怪,裡邊有三個$,還有./等東西,而md5sum生成的hash類似這樣
1$ echo -n password|md5sum
25f4dcc3b5aa765d61d8327deb882cf99 -
是十六進制串。顯然shadow不是將口令直接md5sum得到的。其餘可以man 3 crypt 了解一下,內容太多,只貼一部分:
-------------
       If salt is a character string starting with the characters "$id$" fol‐ 
       lowed by a string terminated by "$": 

              $id$salt$encrypted
       then instead of using the DES machine, id identifies the encryption 
       method used and this then determines how the rest of the password 
       string is interpreted. The following values ​​of id are supported:
              ID | Method 
              ───────────────────────────────────────── 
              1 | MD5 
              2a | Blowfish (not in mainline glibc; added in some 
                  | Linux distributions) 
              5 | SHA-256 (since glibc 2.7) 
              6 | SHA-512 (since glibc 2.7) 


john the rippeer No Password hashes loaded錯誤

在使用john the ripper成功破解了口令後再次執行john,提示錯誤:No Password hashes loaded 
遂猛擊谷狗,得知答案是這樣的,在john下生成了2個文件導致該問題的出現,只要重命名或者刪除即可。
這2個文件為john.pot和john.log,刪除後恢復正常。
上一個john.log的文件: 另外寫了個小程序,來方面執行檢查是否存在這2個文件,如果存在則刪除,木有技術含量:-D

1
2
3
4
5
6
7
8
9
#!/usr/bin/perl
@file = ( "/pentest/passwords/john/john.pot" , "/pentest/passwords/john/john.log" );
foreach $john ( @file ) {
        if ( -e $john ) {
            unlink $john ;
        }       else     {
            print "$john is still existsn" ;
        }
}

沒有留言:

張貼留言