【问题标题】:MD5 Cracker not working python3MD5 破解器不工作 python3
【发布时间】:2016-11-06 09:33:19
【问题描述】:
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.

哪里出错了?我看不见。但如果只有单词表:

ahmet

输出:

MD5 Hash: cdb5efc9c72196c1bd8b7a594b46b44f
Wordlist: md.txt
MD5 HASH CRACKED :  ahmet
Sorry :( Don't Cracked.

【问题讨论】:

    标签: python python-3.x md5 python-3.5


    【解决方案1】:

    文件中的行包含换行符。该换行符很重要:

    >>> 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'))
    

    我也添加了行的解码,用于打印。

    【讨论】:

    • @Ahmet:你还在编码。删除.encode() 调用。
    • @Ahmet:我的代码实际上也有错误;我忘记将bytes 对象传递给bytes.rstrip()。现已更正。
    • 抱歉无法正常工作.. Python 版本 3.5.2。方法不起作用,代码:liste = input("Wordlist: ") with open(liste, 'rb') as ac: for line in ac: hs = hashlib.md5(line.bytes.rstrip('\n') ).hexdigest() if hs == md: print("MD5 HASH CRACKED : ", line)
    • @Ahmet:你从哪里得到.bytes 属性?这不在我的答案中。
    猜你喜欢
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 2023-03-12
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2021-03-12
    • 2011-08-11
    相关资源
    最近更新 更多