md = input("MD5 Hash: ")
if len(md) != 32:
print("Don't MD5 Hash.")
else:
liste = input("Wordlist: ")
ac = open(liste).readlines()
for new in ac:
hs = hashlib.md5(new.encode()).hexdigest()
if hs == md:
print("MD5 HASH CRACKED : ", new)
print("Sorry :( Don't Cracked.")
执行不工作。 单词表:
sadasda
asdasda
sdasd
as
da
sdasd
asd
ahmet
asdasf
knknkjnbhb
klasda
输出:
MD5 Hash: cdb5efc9c72196c1bd8b7a594b46b44f
Wordlist: md.txt
Sorry :( Don't Cracked.
错误在哪里?我看不到。但仅限于wordlist:
ahmet
输出:
MD5 Hash: cdb5efc9c72196c1bd8b7a594b46b44f
Wordlist: md.txt
MD5 HASH CRACKED : ahmet
Sorry :( Don't Cracked.
答案 0 :(得分:2)
您文件中的行包含换行符。这个换行很重要:
>>> from hashlib import md5
>>> md5(b'ahmet').hexdigest()
'cdb5efc9c72196c1bd8b7a594b46b44f'
>>> md5(b'ahmet\n').hexdigest()
'ac5bd810592f14278b5e06fc20d88c23'
首先删除换行符:
hs = hashlib.md5(new.rstrip('\n').encode()).hexdigest()
不要让Python解码你的文件行,然后再次编码,只需以二进制模式打开文件。您可以直接循环文件,无需在此处调用fileobj.readlines()
:
with open(liste, 'rb') as ac:
for line in ac:
line = line.rstrip(b'\n')
hs = hashlib.md5(line).hexdigest()
if hs == md:
print("MD5 HASH CRACKED : ", line.decode('utf8'))
我也添加了该行的解码,用于打印。