Python 3 md5破解

时间:2016-12-12 08:41:28

标签: python-3.x md5

我正在尝试"转换"一个简单的python 2 md5密码破解到python 3.我尝试了2to3但它不起作用,因为导入md5在python 3中不存在,而是使用hashlib。更不用说它想要将我所有的"打印输入("")更改为eval?我已经查找了hashlib语法,但我仍然对如何将原始代码转换为python 3感到茫然。这可能吗?

以下是原始代码:

import md5

counter = 1

pass_in = input("Please enter the MD5 Hash: ")
pwfile = input("Please enter your wordlist file name: ")

try:
    pwfile = open(pwfile, "r")
except:
    print("\nFile Not Found. \nPlease provide a valid path to your wordlist.")
    input("Press Enter to Exit:")
    print("")
    quit()

for password in pwfile:
    filemd5 = md5.new(password.strip()).hexdigest()
    print("Trying password number %d: %s " % (counter, password.strip()))

    counter += 1

    if pass_in == filemd5:
        print("\nMatch Found. \nPassword is: %s" % password)
        break

else:
    print("Password Not Found. \nPlease try another wordlist.")

input("Please press Enter to exit:")

现在这是我的代码:

    import hashlib

counter = 1

pass_in = input("Please enter the MD5 Hash: ")
pwfile = input("Please enter your wordlist file name: ")

try:
    pwfile = open(pwfile, "r")
except:
    print("\nFile Not Found. \nPlease provide a valid path to your wordlist.")
    input("Press Enter to Exit:")
    print("")
    quit()

for password in pwfile:
    filemd5 = hashlib.new(password.strip()).hexdigest()
    print("Trying password number %d: %s " % (counter, password.strip()))

    counter += 1

    if pass_in == filemd5:
        print("\nMatch Found. \nPassword is: %s" % password)
        break

else:
    print("Password Not Found. \nPlease try another wordlist.")

input("Please press Enter to exit:")

这是我不断得到的错误:

Traceback (most recent call last):
  File "D:/Python/Hacking/passwordcrack/md5crack.py", line 17, in <module>
    filemd5 = hashlib.new(password.strip()).hexdigest()
  File "C:\Python\Python35-32\lib\hashlib.py", line 128, in __hash_new
    return __get_builtin_constructor(name)(data)
  File "C:\Python\Python35-32\lib\hashlib.py", line 95, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type 123456

我可以告诉它不喜欢hashlib.new行,但是我不知道还有什么可以改变才能使它工作?

Noob在这里,非常感谢任何帮助。

0 个答案:

没有答案