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
消息,起初我虽然这是一个身份问题,但现在我已经无能为力
答案 0 :(得分:2)
肯定会打印'PRIVSG [..]碰撞'并在'PRIVSG [...]给出的散列后'。
你要做的是:
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
答案 1 :(得分:1)
如果您不希望在检测到冲突后发送“hash is not correspondence”消息,则需要在“Collision!”之后从函数返回(或以其他方式防止代码掉落)。 “消息已发送。