我对Python还比较陌生,我正在尝试创建一个简单的程序,收集MD5散列密码,然后将它们与我创建的一个字典相匹配,字典中有常用密码。
我可以收集MD5密码没问题,问题是当我试图将它们与字典进行比较时,我根本无法让它工作。
任何提示或方向都是值得赞赏的,我不知道下一步该做什么,我已经在网上搜索了很多天,才求助于寻求帮助。
我的代码如下
import sys, re, hashlib
def dict_attack(passwd_hash):
print 'dict_attack(): Cracking hash:', passwd_hash
#set up list of common password words
passwords = open('J:/dictionary.txt')
passwd_found = False
if passwd_found:
print 'dict_attack(): Password recovered: ' (passwd)
def main():
print'[dict_crack] Tests'
passwd_hash = '4297f44b13955235245b2497399d7a93'
dict_attack(passwd_hash)
if __name__ == '__main__':
main()
进一步问题的相关代码
hash_to_crack = password
dict_file = "J:/dictionary.txt"
with open(dict_file) as fileobj:
for line in fileobj:
line = line.strip()
if hashlib.md5(line).hexdigest() == hash_to_crack:
print "Successfully cracked the hash %s: It's %s" % (hash_to_crack, line)
return ""
print "Failed to crack the file."
目前没有回答
相关问题 更多 >
编程相关推荐