Python Hashlib,调试故障
我试图玩一个hashcracker,在一个安全的沙箱帐户中使用,以达到道德目的。我相信我的代码是正确的,我找不到它不执行的原因。代码显然是不正确的,除非它会运行LOL。然而,我找不到错误Python Hashlib,调试故障,python,Python,我试图玩一个hashcracker,在一个安全的沙箱帐户中使用,以达到道德目的。我相信我的代码是正确的,我找不到它不执行的原因。代码显然是不正确的,除非它会运行LOL。然而,我找不到错误 from urllib.request import urlopen, hashlib sha1hash = input("Please input the hash to crack.\n>") #puts user input on new line in prompt LIST_OF_
from urllib.request import urlopen, hashlib
sha1hash = input("Please input the hash to crack.\n>") #puts user input on new line in prompt
LIST_OF_COMMON_PASSWORDS = str(urlopen('https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-10000.txt').read(), 'utf-8')
for guess in LIST_OF_COMMON_PASSWORDS.split('\n'): # starts the process of looping through all passwords from the above URL until the correct one is matched.(\n) is used to specifiy/split each individual password from list
hashedguess = hashlib.sha1(bytes(guess, 'utf-8')).hexigest() #turns the 'guess' into bytes from string and then turns it into a SHA1 hash// hexigest() prints the current value of the SHA-1 hash
if hashedguess == sha1hash:
print('The password is', str(guess))
quit()
elif hashedguess != sha1hash:
print('Password guess ', str(guess),' does not match, trying next....')
print('Password not in database, better luck next time.')
这是我的错误回溯
回溯(最近一次呼叫最后一次):
文件“hashcracker.py”,第5行,在
常用密码列表=str(urlopen(“”).read(),'utf-8')
urlopen中的文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”,第222行
返回opener.open(url、数据、超时)
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”,第525行,打开
响应=自身打开(请求,数据)
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”,第542行,打开
结果=self.\u调用\u链(self.handle\u打开,协议,协议+
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”,第502行,在调用链中
结果=func(*args)
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”,第1360行,https\u open
返回self.do_open(http.client.HTTPSConnection,req,
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”,第1320行,在do_open中
引发URL错误(err)
urllib.error.urleror:
MBP-00704:SHA1cracker andrewroe$python3 hashcracker.py
请输入要破解的哈希
cbfdac6008f9cab4083784cbd1874f76618d2a97
回溯(最近一次呼叫最后一次):
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py”,第1317行,打开
h、 请求(请求获取方法()、请求选择器、请求数据、标题、,
请求中第1230行的文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py”
self.\u发送\u请求(方法、url、正文、标题、编码\u分块)
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py”,第1276行,在发送请求中
self.endheaders(body,encode\u chunked=encode\u chunked)
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py”,第1225行,在endheaders中
self.\u发送\u输出(消息体,encode\u chunked=encode\u chunked)
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py”,第1004行,在发送输出中
self.send(msg)
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py”,第944行,在send中
self.connect()
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py”,第1399行,在connect中
self.sock=self.\u context.wrap\u套接字(self.sock,
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”,第500行,在wrap_套接字中
返回self.sslsocket\u类。\u创建(
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”,第1040行,在
self.do_握手
文件“/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py”,第1309行,在do_握手中
赛尔夫:握手
ssl.SSLCertVerificationError:[ssl:证书\u验证\u失败]证书验证失败:无法获取本地颁发者证书(\u ssl.c:1108)
在处理上述异常期间,发生了另一个异常:我找到了答案。我转到Python3.8文件夹并安装了一个名为“安装证书”的命令。这修复了我的SSL错误。谢谢。这看起来像是信任GitHub的SSL证书的问题。您是如何安装Python的?我使用的是MAC,Python是预安装的不过,我确实使用brew安装了Python3。(它只是Mac,不是“Mac”。)您是使用预安装的Python运行此代码,还是使用您自己安装的Python运行此代码?看起来是后者。无论您做了什么,您的Python都不信任此证书。但说真的,谢谢您。您将我的注意力转向了SSL证书,这是问题所在!