def Passcrack(): #First, get the hash from the user to get the sha1 hash to crack sha1hash = input("Enter SHA1 Hash:.\nSSTF>") #Second, we'll open a file full of password guesses 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') #Third, we'll take a guess from the list of passwords we opened, and split it by line for guess in LIST_OF_COMMON_PASSWORDS.split('\n'): #Fourth, we'll hash the guess we took from the password list so we can compare it to the hash the user gave us hashedGuess = hashlib.sha1(bytes(guess, 'utf-8')).hexdigest() #Fifth, we'll compare the hash the user gave us to the hashed version of the password guess and determine if they are equal if hashedGuess == sha1hash: #Sixth, we'll tell the program what to do if the password guess matches, which is to print the current guess and quit the program. #We'll also tell the program what to do if the password guess don't match, which is to return to step 3 to get a new password from the list print("The password is ", str(guess)) quit() elif hashedGuess != sha1hash: print(str(guess),", Nope.") #In the seventh and final step, we'll tell the program what to do if we get all the way through the password list without finding a match. print("Password not in list.")
def getWord(self, word : str): if(self.verbose): print(word+"\n") if(self.hashNumber == passwordCracker.SHA1): return hashlib.sha1(bytes(word, 'utf-8')).hexdigest() if(self.hashNumber == passwordCracker.MD5): return hashlib.md5(bytes(word, 'utf-8')).hexdigest() return word
def sha1_hash(sha1_hashed_string): hash_object = hashlib.sha1(sha1_hashed_string.encode()) print(hash_object.hexdigest()) back2menu = input('\nDo you want to choose another option: y/n\n') if back2menu == 'y': return else: quit()
def guess2(y, z): concat = y mainHash = z count = 1 for x in array: saltHash = concat + x hashedGuess = hashlib.sha1(bytes(saltHash, 'utf-8')).hexdigest() if hashedGuess == mainHash: print("\tNumber of Attempts: " + count) print("\tMatch Word: " + y + x + "\n") break count += 1 return x
def guess1(x): # Count the number tries it takes to crack the password count = 1 for x in array: hashedGuess = hashlib.sha1(bytes(x, 'utf-8')).hexdigest() #Compare with the given hash value if hashedGuess == hashsha1: print("Found Hash") print("Number of tries:", count) print("The password is ", x) break count += 1 return x
def decrypt(ch): #manual bruteforce if ch==1: guess_str=pa.password("Enter a password guess:") cmp_result=convertToHash(guess_str) print("SHA1 hash of guess is:") print(cmp_result) if cmp_result==result: print("\nHash Match") print("\nPassword Found") print("\nPassword is: ",guess_str) else: print("\nNo hash matches found...") print("\nPassword not found") #pre-generated list bruteforce if ch==2: try: #creates a file which contains the list of all the common passwords and appends the data with open(fileurl,"x") as f: 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'): f=open(fileurl,"a") f.write(guess) f.write("\n") f.close() print("File created") except(FileExistsError): print("File already exists") print("Fetching data from password list...\n") #opening the password file and comparing the hashes guess_pass=open(fileurl,"r").read().split("\n") for guess in guess_pass: hashedGuess = hashlib.sha1(bytes(guess, 'utf-8')).hexdigest() if hashedGuess == result: pa.alert(guess,"Password is","Done") print("Encoding to image\n") convertToSteg() setup() sys.exit("Completed") elif hashedGuess != result: print("Password guess ",str(guess)," does not match, trying next...") pa.alert("Bruteforce failed... Password not in Database, adding to list") savepassword() convertToSteg() setup()
def sha1_crack(sha1_string): plist = str( urlopen( 'https://raw.githubusercontent.com/cryptshoe/mastersofcyber/main/wordlist.txt' ).read(), 'utf-8') for guess in plist.split('\n'): hashedGuess = hashlib.sha1(bytes(guess, 'utf-8')).hexdigest() if hashedGuess == sha1_string: print("\nCongratulations!! The password is ", str(guess)) back2menu = input('\nDo you want to choose another option: y/n\n') if back2menu == 'y': return else: quit() elif hashedGuess != sha1_string: print("Password guess ", str(guess), " does not match, trying next...") print("Password not in list. Please try another") back2menu = input('\nDo you want to choose another option: y/n\n') if back2menu == 'y': return else: quit()
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') # guess from the list of passwords we opened, and split it by line for guess in LIST_OF_COMMON_PASSWORDS.split('\n'): #checking if the password is in the list so we can compare it to the hash the user gave us hashedGuess = hashlib.sha1(bytes(guess, 'utf-8')).hexdigest() # compare the hash the user gave us to the hashed version of the password guess and determine if they are equal if hashedGuess == sha1hash: #Sixth, we'll tell the program what to do if the password guess matches, which is to print the current guess and quit the program. #We'll also tell the program what to do if the password guess don't match, which is to return to step 3 to get a new password from the list print("The password is ", str(guess)) quit() elif hashedGuess != sha1hash: print("Password guess ", str(guess), " does not match, trying next...") #In the seventh and final step, we'll tell the program what to do if we get all the way through the password list without finding a match. print("Password not in database, we'll get them next time.")
def crack(self, option): self.wopt = option if (self.wopt == 1): wordlist = str(input(bc.BC + ' Online Wordlist: ' + bc.GC)) if (wordlist != '' or wordlist != ' '): try: passwords = str(urlopen(wordlist).read(), 'utf-8') except Exception: os.system('clear') print(banner) print(eBan + bc.RC + ' ERROR: ' + bc.BC + 'Failed to open ' + bc.RC + wordlist) from brutoNova import brutoNova brutoNova() else: os.system('clear') print(banner) print(eBan + bc.RC + ' ERROR: ' + bc.BC + 'Wordlist value cannot be empty\n') from brutoNova import brutoNova brutoNova() else: wordlist = str(input(bc.BC + ' Local Wordlist: ' + bc.GC)) if (wordlist != '' or wordlist != ' '): try: passwords = open(wordlist).read() except Exception: os.system('clear') print(banner) print(eBan + bc.RC + ' ERROR: ' + bc.BC + 'Failed to open ' + bc.RC + wordlist) from brutoNova import brutoNova brutoNova() else: os.system('clear') print(banner) print(eBan + bc.RC + ' ERROR: ' + bc.BC + 'Wordlist value cannot be empty\n') from brutoNova import brutoNova brutoNova() os.system('clear') print(banner) print(bc.BC + ' SHA1: ' + bc.GC + self.sha1) print(bc.BC + ' Wordlist: ' + bc.GC + wordlist + '\n') match = '' for passwd in passwords.split('\n'): if (passwd != ''): pw = hashlib.sha1(bytes(passwd, 'utf-8')).hexdigest() if (self.sha1 == pw): print(sBan + ' Found a Match: ' + bc.GC + passwd) input(bc.BC + '\n Press Enter to Continue...') os.system('clear') print(banner) from brutoNova import brutoNova brutoNova() elif (self.sha1 != pw): print(eBan + ' No Match: ' + bc.RC + passwd) else: continue input(bc.BC + '\n Press Enter to Continue...') os.system('clear') print(banner) from brutoNova import brutoNova brutoNova()
#!/usr/bin/python3 #Condensed python code for sha1 hash cracker - using ternary operator. Example: <expression1> if <condition> else <expression2> from urllib.request import urlopen, hashlib origin = input("Input SHA1 hash to crack\n>") for password in str( urlopen( 'https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-10000.txt' ).read(), 'utf-8').split('\n'): [print("The password is ", str(password)), quit()] if (hashlib.sha1(bytes( password, 'utf-8')).hexdigest()) == origin else print( "Password not in database, we'll get them next time." ) if password == "" else print("Password guess ", str(password), " does not match, trying next...")
from urllib.request import urlopen, hashlib import itertools import sys salt = "bluefire2" password = "******" sha1hash = hashlib.sha1(bytes(salt + password, 'utf-8')).hexdigest() for i in range(4, 8): print("Sprawdzamy hasło dla długości: %d" % i) sys.stdout.flush() for j in map( ''.join, itertools.product('abcdefghijklmnopqrstuvwxyz0123456789', repeat=i)): hashedGuess = hashlib.sha1(bytes(salt + j, 'utf-8')).hexdigest() if hashedGuess == sha1hash: print("The password is ", str(j)) quit() print("Password not in database, we'll get them next time.")
def convertToHash(word): converted_hash=hashlib.sha1(word.encode()).hexdigest() #converting string to sha1 return converted_hash
#Condensed python code for sha1 hash cracker - using ternary operator. Example: <expression1> if <condition> else <expression2> from urllib.request import urlopen, hashlib; origin = input("Input SHA1 hash to crack\n>") for password in str(urlopen('https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-10000.txt').read(), 'utf-8').split('\n'): [print("The password is ", str(password)), quit()] if (hashlib.sha1(bytes(password, 'utf-8')).hexdigest()) == origin else print("Password not in database, we'll get them next time.") if password == "" else print("Password guess ", str(password), " does not match, trying next...")
def get_sha1(word): return hashlib.sha1(bytes(word, 'utf-8')).hexdigest()
from urllib.request import urlopen, hashlib sha1_hash = input("Please enter a hash to crack: ") list = ["polony", "test", "poop", "lice"] for l in list: setpass = bytes(l, 'utf-8') hash_objectsha1 = hashlib.sha1(setpass) guess_pw_sha1 = hash_objectsha1.hexdigest() hash_object_md5 = hashlib.md5(setpass) guess_pw_md5 = hash_object_md5.hexdigest() if guess_pw_sha1 == sha1_hash: print(guess_pw_sha1) print("\n The password is:") print(setpass) if guess_pw_md5 == sha1_hash: print(guess_pw_md5) print("\n The password is:") print(setpass)
from urllib.request import urlopen, hashlib sha1hash = input("> Please insert the SHA-1 hash here.\n>") common_passwords_list_url = input( "> Please, also, provide the URL of the word list that you would like me to check.\n>" ) common_passwords_list = urlopen(common_passwords_list_url).read() common_passwords_list = str(common_passwords_list, 'utf-8') #common_passwords_list = str(urlopen('https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/Common-Credentials/10-million-password-list-top-10000.txt').read(), 'utf-8') for word in common_passwords_list.split('\n'): hashed_word = hashlib.sha1(bytes(word, 'utf-8')).hexdigest() if hashed_word == sha1hash: print(">We found the word. The password is ", str(word)) quit() elif hashed_word != sha1hash: print("> The word ", str(word), "does not match this sha-1 hash, trying the next one...") print( "The word for the SHA-1 hash that you have inserted does not correspond toany word on the current database." )