0
how I change this code to use a txt file instead of URL
from urllib.request import urlopen, hashlib sha1hash = input("Please input the hash to crack.\n>") 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'): hashedGuess = hashlib.sha1(bytes(guess, 'utf-8')).hexdigest() 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, we'll get them next time.")
2 Respostas
+ 9
NS7 ,
instead of using the python *path* module, we can use the python module *pathlib*, that offers object-oriented filesystem paths.
https://docs.python.org/3/library/pathlib.html#module-pathlib
> for reading from a txt file, we also need to use the built-in function *open()* .
https://www.sololearn.com/learn/Python/2445/?ref=app
https://www.sololearn.com/learn/Python/2447/?ref=app
https://www.sololearn.com/learn/Python/2446/?ref=app
https://www.sololearn.com/learn/Python/2448/?ref=app
+ 3
You would need to use a path if the txt file on your machine. Check out the os library for using paths:
https://docs.python.org/3/library/os.path.html