1
votes

I am trying to play with a hashcracker to use in a secure sandbox account for ethical purposes. I believe my code is correct and I cannot find a reason why it is not executing. Well the code is clearly not correct unless it would run LOL however, I cannot find the bug

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

HERE IS MY ERROR TRACEBACK

Traceback (most recent call last): File "hashcracker.py", line 5, in 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') File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 525, in open response = self._open(req, data) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 542, in _open result = self._call_chain(self.handle_open, protocol, protocol + File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 502, in _call_chain result = func(*args) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1360, in https_open return self.do_open(http.client.HTTPSConnection, req, File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1320, in do_open raise URLError(err) urllib.error.URLError: MBP-00704:SHA1cracker andrewroe$ python3 hashcracker.py Please input the hash to crack.

cbfdac6008f9cab4083784cbd1874f76618d2a97 Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/urllib/request.py", line 1317, in do_open h.request(req.get_method(), req.selector, req.data, headers, File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1230, in request self._send_request(method, url, body, headers, encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1276, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1225, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1004, in _send_output self.send(msg) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 944, in send self.connect() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/http/client.py", line 1399, in connect self.sock = self._context.wrap_socket(self.sock, File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1040, in _create self.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

During handling of the above exception, another exception occurred:

1
This looks like an issue trusting GitHub's SSL certificate. How did you install Python?Chris
I am using a MAC, python was preinstalled. However, I did install Python3 using brew.aroe
(It's just Mac, not "MAC".) Are you running this code with the preinstalled Python, or with the one you installed yourself? It looks like the latter. Whatever you did, your Python doesn't trust the certificate.Chris
But seriously, thank you. You turned my attention to the SSL certificate which was the issue!aroe

1 Answers

1
votes

I found the answer. I went to Python3.8 folder and installed something called, Install Certificates Command. This fixed my SSL error. Thank you.