0
  if data.find('!mdcrack') != -1:
     nick = data.split('!')[ 0 ].replace(':','')
     m = hashlib.md5()
     hash = ""
     hash_file = str(arg[4])
     wordlist = arg[5]
     try:
         wordlistfile = open(wordlist,"r")
     except IOError:
         sck.send('PRIVMSG ' + chan + " :" 'invalid file' + '\r\n')
     else:
       pass
     for line in wordlistfile:
                 m = hashlib.md5()  
                 line = line.replace("\n","")
                 m.update(line)
                 word_hash = m.hexdigest()
                 if word_hash==hash_file:
                      sck.send('PRIVMSG ' + chan + " :" 'Collision!  The word corresponding to the given hash is ' + line + '\r\n')

     sck.send('PRIVMSG ' + chan + " :" 'The hash given does not correspond to any supplied word in the wordlist' + '\r\n')

このコードは、単語リストの各行をハッシュし、それを指定されたハッシュと比較することによって機能します。

エラーは発生しませんが、ハッシュが見つかると、Collision!メッセージとメッセージが出力されThe hash given does not correspond to any supplied word in the wordlistます。最初はidentの問題だと思っていましたが、今はわかりません。

4

2 に答える 2

2

確かに、「PRIVSG [..] Collision」と「PRIVSG [..] The hash given」の後に出力されます。

あなたがしなければならないことは次のとおりです。

collision = False
[..] 
if word_hash==hash_file:
                      sck.send('PRIVMSG ' + chan + " :" 'Collision!  The word corresponding to the given hash is ' + line + '\r\n')
                      collision = True

if not collision
     sck.send('PRIVMSG ' + chan + " :" 'The hash given does not correspond to any
于 2011-04-26T17:19:41.637 に答える
1

衝突が検出された後に「ハッシュが対応していません」というメッセージを送信したくない場合は、「衝突!」の後に関数から戻る (またはコードがフォールスルーしないようにする) 必要があります。メッセージが送信されます。

于 2011-04-26T17:19:31.427 に答える