def hasherFromString(s): import hashlib if s == 'sha1': return hashlib.sha1() elif s == 'sha224': return hashlib.sha224() elif s == 'sha256': return hashlib.sha256() elif s == 'sha384': return hashlib.sha384() elif s == 'sha512': return hashlib.sha512() elif s == 'blake2b': return hashlib.blake2b() elif s == 'blake2s': return hashlib.blake2s() elif s == 'md5': return hashlib.md5() elif s == 'sha3_224': return hashlib.sha3_224() elif s == 'sha3_256': return hashlib.sha3_256() elif s == 'sha3_384': return hashlib.sha3_384() elif s == 'sha3_512': return hashlib.sha3_512() elif s == 'shake_128': return hashlib.shake_128() elif s == 'shake_256': return hashlib.shake_256() else: return None
def test_sha3384(self): """ Test SHA3-384 hash. """ if "sha3_384" not in hashlib.algorithms_available: pass else: assert bh.hashlib_hash("tempfile.txt", hashlib.sha3_384()) == "1ae83352968f601e16eff076f5967dd356edce4c4c5629e3939123b7507efbaafd1dabc1e459f8e47f7a05df718e5927"
def calculate_sha3_384(path): """Calculate sha3 384 hash, reading the file in 1MB chunks.""" blocksize = 2**20 with open(path, 'rb') as snap_file: hasher = hashlib.sha3_384() while True: buf = snap_file.read(blocksize) if not buf: break hasher.update(buf) return hasher.hexdigest()
def get_engine(hashtype): """ Get hashlib engine from hash type. :param hashtype: Hash type. :type hashtype: str """ hashengines = {"md5": hashlib.md5(), "sha1": hashlib.sha1(), "sha224": hashlib.sha224(), "sha256": hashlib.sha256(), "sha384": hashlib.sha384(), "sha512": hashlib.sha512()} if utilities.new_enough(6): hashengines.update({"sha3224": hashlib.sha3_224(), "sha3256": hashlib.sha3_256(), "sha3384": hashlib.sha3_384(), "sha3512": hashlib.sha3_512()}) return hashengines[hashtype]
from tkinter import * import hashlib from Crypto.Random import get_random_bytes import pickle S = [get_random_bytes(16) for i in range(0, 3)] D = { 'user1': (S[0], hashlib.sha3_384(b'pass1' + S[0]).digest()), 'user2': (S[1], hashlib.sha3_384(b'pass2' + S[1]).digest()), 'user3': (S[2], hashlib.sha3_384(b'pass3' + S[2]).digest()) } with open("D:/password.pkl", 'wb') as f: pickle.dump(D, f) with open("D:/password.pkl", 'rb') as f: pickle.load(f) root = Tk() l1 = Label(root, text='Login') e1 = Entry(root, width=50) l2 = Label(root, text='Password') e2 = Entry(root, width=50) b1 = Button(text='Log in') b2 = Button(text='Register') l3 = Label(root) l4 = Label(root, text='New password') e4 = Entry(root, width=50) b4 = Button(text='Change password') def login(event): with open("D:/password.pkl", 'rb') as f: D = pickle.load(f) if D[e1.get()][1] == hashlib.sha3_384(
def fpath2hash(fpath, sha_key): """Transform regular expression into hash translated expression. Parameters ---------- fpath : str Final path of the file name. sha_key : str Reference SHA key of the secured hash algorithm. Returns ------- hcode: str Returns the encoded full path in hexadecimal format. """ fpath_encoded = fpath.encode("utf-8") if sha_key == SHAKeys.sha1: # deepcode ignore insecureHash: <because the option is needed> hcode = hlib.sha1(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha224: hcode = hlib.sha224(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha256: hcode = hlib.sha256(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha384: hcode = hlib.sha384(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha512: hcode = hlib.sha512(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.blake2b: hcode = hlib.blake2b(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.blake2s: hcode = hlib.blake2s(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.md5: # deepcode ignore insecureHash: <because the option is needed> hcode = hlib.md5(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha3_224: hcode = hlib.sha3_224(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha3_256: hcode = hlib.sha3_256(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha3_384: hcode = hlib.sha3_384(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.sha3_512: hcode = hlib.sha3_512(fpath_encoded) return hcode.hexdigest() elif sha_key == SHAKeys.shake_128: hcode = hlib.shake_128(fpath_encoded) return hcode.hexdigest(32) elif sha_key == SHAKeys.shake_256: hcode = hlib.shake_256(fpath_encoded) return hcode.hexdigest(32) else: sys.exit(1)
import sha3 # User is offered choice of input (file/string) print("Welcome to hash checker. This program can calculate the hash of a string or file.") question = input("Do you wish to check the hash of a string (S) or file (F)? Enter S or F: ") # If user choses file, accept filename as input, open, read file, compute hashes if question == "F" or question == "f": filename = input("Enter a file name: ") contents = open(filename, 'rb').read() yoursha1 = hashlib.sha1(contents) yoursha256 = hashlib.sha256(contents) yoursha512 = hashlib.sha512(contents) yoursha3224 = hashlib.sha3_224(contents) yoursha3256 = hashlib.sha3_256(contents) yoursha3384 = hashlib.sha3_384(contents) yoursha3512 = hashlib.sha3_512(contents) else: # Prompt user to enter string and compute hashes guess = input("\nPlease enter a string: ") yoursha1 = hashlib.sha1(guess.encode()) yoursha256 = hashlib.sha256(guess.encode()) yoursha512 = hashlib.sha512(guess.encode()) yoursha3224 = hashlib.sha3_224(guess.encode()) yoursha3256 = hashlib.sha3_256(guess.encode()) yoursha3384 = hashlib.sha3_384(guess.encode()) yoursha3512 = hashlib.sha3_512(guess.encode()) # Convert hashes to readable form and print print("\nYour hashes are computed as follows: ") print("\nSHA-1: ", yoursha1.hexdigest())
if args.sha256: print(hashlib.sha256(userinput.encode('utf-8')).hexdigest()) elif args.sha224: print(hashlib.sha224(userinput.encode('utf-8')).hexdigest()) elif args.sha384: print(hashlib.sha384(userinput.encode('utf-8')).hexdigest()) elif args.md5: print(hashlib.md5(userinput.encode('utf-8')).hexdigest()) elif args.sha512: print(hashlib.sha512(userinput.encode('utf-8')).hexdigest()) elif args.sha3_256: print(hashlib.sha3_256(userinput.encode('utf-8')).hexdigest()) elif args.sha3_224: print(hashlib.sha3_224(userinput.encode('utf-8')).hexdigest()) elif args.sha3_384: print(hashlib.sha3_384(userinput.encode('utf-8')).hexdigest()) elif args.sha3_512: print(hashlib.sha3_512(userinput.encode('utf-8')).hexdigest()) elif args.all: print("MD5: " + hashlib.md5(userinput.encode('utf-8')).hexdigest()) print("Sha256: " + hashlib.sha256(userinput.encode('utf-8')).hexdigest()) print("Sha224: " + hashlib.sha224(userinput.encode('utf-8')).hexdigest()) print("Sha384: " + hashlib.sha384(userinput.encode('utf-8')).hexdigest()) print("Sha512: " + hashlib.sha512(userinput.encode('utf-8')).hexdigest()) print("Sha3_256: " + hashlib.sha3_256(userinput.encode('utf-8')).hexdigest()) print("Sha3_224: " + hashlib.sha3_224(userinput.encode('utf-8')).hexdigest()) print("Sha3_384: " + hashlib.sha3_384(userinput.encode('utf-8')).hexdigest()) print("Sha3_512: " + hashlib.sha3_512(userinput.encode('utf-8')).hexdigest()) else: print("Error: type must be specified in the initial program execution. Try python hasher.py --help")
def sha3_384(self, text, salt=''): return hashlib.sha3_384((text + salt).encode('UTF-8')).hexdigest()
elif alg == 'sha224': hs = hashlib.sha224(block_str.encode()).hexdigest() elif alg == 'sha256': hs = hashlib.sha256(block_str.encode()).hexdigest() elif alg == 'sha384': hs = hashlib.sha384(block_str.encode()).hexdigest() elif alg == 'sha512': hs = hashlib.sha512(block_str.encode()).hexdigest() elif alg == 'MD5': hs = hashlib.md5(block_str.encode()).hexdigest() elif alg == 'SHA3-224': hs = hashlib.sha3_224(block_str.encode()).hexdigest() elif alg == 'SHA3-256': hs = hashlib.sha3_256(block_str.encode()).hexdigest() elif alg == 'sha3-384': hs = hashlib.sha3_384(block_str.encode()).hexdigest() elif alg == 'SHA3-512': hs = hashlib.sha3_512(block_str.encode()).hexdigest() if hs[:cz] == '0'*cz: block['hash'] = hs break nonce += 1 answer = f'\nAnswer: {json.dumps(block, separators=(",", ":"), indent=4)}' with open(f'{os.path.dirname(__file__)}/Tasks.txt', 'a', encoding='UTF') as f: f.write('Задание 2\n') f.write(text_of_task) f.write('\n\n\n')
def sha3_384(self, msg, **kwargs): self.bot.say(hashlib.sha3_384(msg.encode()).hexdigest())
def sha3_384(str): message = hashlib.sha3_384(str.encode()) #encoding return message.hexdigest() #result in hexadecimal format
print(" [", i + 1, "]", algos[i]) for i in range(9, len(algos)): print("[", i + 1, "]", algos[i]) alo = int(input("\nEnter choice: ")) if alo > 0 and alo < 15: inp = input("Enter Plain text: ") else: print( "Enter the number left of the respective algorithm from the displayed output." ) if alo == 1: print("Encrypted Text: ", hashlib.sha256(inp.encode()).hexdigest()) elif alo == 2: print("Encrypted Text: ", hashlib.sha3_384(inp.encode()).hexdigest()) elif alo == 3: print("Encrypted Text: ", hashlib.sha224(inp.encode()).hexdigest()) elif alo == 4: print("Encrypted Text: ", hashlib.sha3_512(inp.encode()).hexdigest()) elif alo == 5: print("Encrypted Text: ", hashlib.sha1(inp.encode()).hexdigest()) elif alo == 6: print("Encrypted Text: ", hashlib.shake_256(inp.encode()).hexdigest()) elif alo == 7: print("Encrypted Text: ", hashlib.shake_128(inp.encode()).hexdigest()) elif alo == 8: print("Encrypted Text: ", hashlib.md5(inp.encode()).hexdigest()) elif alo == 9: print("Encrypted Text: ", hashlib.sha3_224(inp.encode()).hexdigest()) elif alo == 10:
def encodeSha3_384(): x = file y = hashlib.sha3_384(x.encode()).hexdigest() print(Cre + Cg + '>>>> ' + Cre + y) save('sha3_384', y, 'Anas.encodeSha3_384()')
import hashlib # Список хэш функций HASH_FUNCTIONS = [ lambda string: hashlib.blake2s(string.encode(encoding='UTF-8')), lambda string: hashlib.sha3_512(string.encode(encoding='UTF-8')), lambda string: hashlib.sha3_256(string.encode(encoding='UTF-8')), lambda string: hashlib.shake_128(string.encode(encoding='UTF-8')), lambda string: hashlib.sha224(string.encode(encoding='UTF-8')), lambda string: hashlib.sha3_384(string.encode(encoding='UTF-8')), lambda string: hashlib.sha3_224(string.encode(encoding='UTF-8')), lambda string: hashlib.md5(string.encode(encoding='UTF-8')), lambda string: hashlib.sha384(string.encode(encoding='UTF-8')), lambda string: hashlib.sha1(string.encode(encoding='UTF-8')), lambda string: hashlib.shake_256(string.encode(encoding='UTF-8')), lambda string: hashlib.sha512(string.encode(encoding='UTF-8')), lambda string: hashlib.sha256(string.encode(encoding='UTF-8')), lambda string: hashlib.blake2b(string.encode(encoding='UTF-8')), ] class Analyzer: @staticmethod def shingles(words: list, shingles_len=3): """ Алгоритм разделения текста на шинглы Получаем слова, составляющие шинглы и собирем шинглы """ return [ ''.join(words[i:i + shingles_len]) for i in range(len(words) - shingles_len + 1)
def encodeSha3_384(self): x = input(Cy + "enter your text here : " + Cre) y = hashlib.sha3_384(x.encode()).hexdigest() print(Cre + Cg + '>>>> ' + Cre + y) save('sha3_384', y, 'Anas.encodeSha3_384()')
def crack(): try: os.system('figlet cracking') except: pass print(Clr + '#############################################################\n') print(Cg + '\"q\" to go back') wordlist = input(Cy + "enter your wordlist here : " + Cre) if wordlist == 'q': start() exit() elif wordlist == '': print(Clg + '[●] thanks for using my tool') exit() try: wordlist = open(wordlist, "r").read() except: print(Clr + 'Error, file not found') exit() hash = input(Cy + "enter your hash here : " + Cre) try: h128 = int( input( "shake_128 needs a key , enter a number for \"shake_128\" : ")) h256 = int( input( "shake_256 needs a key , enter a number for \"shake_256\" : ")) except: print('Error, please enter a number') exit() default = 10 if hash == 'q': exit() wordlist = wordlist.split() Stime = time.time() counter = 1 for i in wordlist: hashedmd5 = hashlib.md5(i.encode()).hexdigest() hashedsha1 = hashlib.sha1(i.encode()).hexdigest() hashedsha224 = hashlib.sha224(i.encode()).hexdigest() hashedsha512 = hashlib.sha512(i.encode()).hexdigest() hashedsha384 = hashlib.sha384(i.encode()).hexdigest() hashedsha256 = hashlib.sha256(i.encode()).hexdigest() hashedblake2b = hashlib.blake2b(i.encode()).hexdigest() hashedblake2s = hashlib.blake2s(i.encode()).hexdigest() hashedsha3_224 = hashlib.sha3_224(i.encode()).hexdigest() hashedsha3_256 = hashlib.sha3_256(i.encode()).hexdigest() hashedsha3_384 = hashlib.sha3_384(i.encode()).hexdigest() hashedsha3_512 = hashlib.sha3_512(i.encode()).hexdigest() hashedshake_256 = hashlib.shake_256(i.encode()).hexdigest(h128) hashedshake_128 = hashlib.shake_128(i.encode()).hexdigest(h256) time.sleep(0.1) counter = str(counter) print(Cg + counter + Cr + ' : trying >>> ' + Clr + i) counter = int(counter) counter += 1 counter = str(counter) if hashedmd5 == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'md5' + Cre) break else: if hashedblake2s == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'blake2s' + Cre) break else: if hashedblake2b == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'blake2b' + Cre) break else: if hashedsha1 == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha1' + Cre) break else: if hashedsha224 == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha224' + Cre) break else: if hashedsha256 == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha256' + Cre) break else: if hashedsha512 == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha512' + Cre) break else: if hashedsha384 == hash: print(Clg + '\n[+] Target has been found \n') print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha384' + Cre) break else: if hashedsha3_256 == hash: print( Clg + '\n[+] Target has been found \n' ) print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha3_256' + Cre) break else: if hashedsha3_224 == hash: print( Clg + '\n[+] Target has been found \n' ) print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha3_224' + Cre) break else: if hashedsha3_384 == hash: print( Clg + '\n[+] Target has been found \n' ) print(hash + Clr + ' ===> ' + Clg + i) print(Cy + '\nthe type is : ' + Cp + 'sha3_384' + Cre) break else: if hashedsha3_512 == hash: print( Clg + '\n[+] Target has been found \n' ) print(hash + Clr + ' ===> ' + Clg + i) print( Cy + '\nthe type is : ' + Cp + 'sha3_512' + Cre) break else: if hashedshake_128 == hash: print( Clg + '\n[+] Target has been found \n' ) print(hash + Clr + ' ===> ' + Clg + i) print( Cy + '\nthe type is : ' + Cp + 'shake_128' + Cre) break else: if hashedshake_256 == hash: print( Clg + '\n[+] Target has been found \n' ) print( hash + Clr + ' ===> ' + Clg + i) print( Cy + '\nthe type is : ' + Cp + 'shake_256' + Cre) break Etime = time.time() Ttime = Stime - Etime Ttime = int(Ttime) Ttime = str(Ttime) print(Cy + '\nfinished') print(Clg + 'Elapsed time ' + Cre + '-' + Cre + Ttime + 's')
elif alg == 'sha256': hs = hashlib.sha256(word.encode()).hexdigest() elif alg == 'sha384': hs = hashlib.sha384(word.encode()).hexdigest() elif alg == 'sha512': hs = hashlib.sha512(word.encode()).hexdigest() if salg == 'SHA3-224': new_word = hs + str(value) f_hs = hashlib.sha3_224(new_word.encode()).hexdigest() elif salg == 'SHA3-256': new_word = hs + str(value) f_hs = hashlib.sha3_256(new_word.encode()).hexdigest() elif salg == 'SHA3-384': new_word = hs + str(value) f_hs = hashlib.sha3_384(new_word.encode()).hexdigest() elif salg == 'SHA3-512': new_word = hs + str(value) f_hs = hashlib.sha3_512(new_word.encode()).hexdigest() text_of_task = f'Известно исходное слово - "{word}".\nДанное слово было преобразовано с помощью алгоритма хэширования {alg}.\nЗатем полученный результат преобразовали в строку и прибавили к нему {x_long} число x (конкатенация строк).\nПосле этого был сгенерирован хэш с помощью одного из алгоритмов семейства SHA3.\nБыло получено следующее значение "{f_hs}" (Хэш для удобства приведен в файле «Модуль1/Task4/Task4-hash»).\nУчастникам необходимо:\n- определеить значение хэша исходного слова по заданному алгоритму\n- определелить второй алгоритм хэширования\n- определеить минимальное число x.' answer = f'\nAnswer:\n{hs}\n{salg}\n{value}' with open(f'{os.path.dirname(__file__)}/Module1/Task4/Task4-hash', 'w') as f: f.write(f_hs) with open(f'{os.path.dirname(__file__)}/Tasks.txt', 'a', encoding='UTF') as f: f.write('Задание 4\n') f.write(text_of_task) f.write('\n\n\n')
def update_event(self, inp=-1): self.set_output_val(0, hashlib.sha3_384(self.input(0)))
def generate_sha3_384(text, salt=0): m = sha3_384() text += addSalt(salt) m.update(text) return m.hexdigest()
def main(): # Provide decription of the program parser = argparse.ArgumentParser( description= 'Enrypt all the files in the given directory with the provided key; program encrypts directories by default' ) op_mode = parser.add_mutually_exclusive_group() # Optional flag for individual file mode of operation; if not included, program uses directory mode op_mode.add_argument( '-d', '--dirmode', help='Use to encrypt an entire directory as opposed to a single file', action='store_true') op_mode.add_argument( '-f', '--filemode', help='Use to encrypt a single file as opposed to an entire directory', action='store_true') # Positional arguments for specifying target directory/file and key to be used in the keystream parser.add_argument( 'target', help= 'The directory that you want to encrypt; If file mode is used this becomes a file' ) parser.add_argument('key', help='The key to be used in the encryption process') # Parse arguments and initialize variables args = parser.parse_args() target = args.target key = args.key # Hash key to create keystream to be used in XOR cipher keystream = sha3_384() keystream.update(key.encode()) # Filemode operation explicitly provided if args.filemode: # Verify that target is actually a file and exists if not isfile(target): raise SystemExit("ERROR: The provided argument for target: " + target + " is not a file or doesn't exist") # Verify that the file is not in the current working directory abs_filepath = os.path.realpath(target) dir_path = os.path.dirname(abs_filepath) if dir_path == os.getcwd(): raise SystemExit( 'ERROR: The file is in the same directory as the current working directory' ) # Only one file to apply the cipher to cipher_file(target, keystream.digest()) # Otherwise dirmode is explicitly provided or excluded (default program mode is dirmode) else: # Verify that target is actually a directory and exists if not isdir(target): raise SystemExit("ERROR: The provided argument for target: " + target + " is not a directory or doesn't exist") # Verify that target is not the current working directory abs_filepath = os.path.realpath(target) if abs_filepath == os.getcwd(): raise SystemExit( 'ERROR: The file is in the same directory as the current working directory' ) # Iterate through all the files in the directory tree (depth-first) for (root, directories, files) in walk(target, topdown=False): # Get all files in the current directory file_list = [join(root, f) for f in files] for filepath in file_list: cipher_file(filepath, keystream.digest())
def h10(self, nGram): return int(hashlib.sha3_384(nGram.encode()).hexdigest(), 16)
print("\n") pass_hash = input(Fore.CYAN+"ENTER sha3_384 HASH: ") wordlist = input("ENTER NAME OF THE FILE: ") try: pass_file = open (wordlist, "r") except: cprint("CANNOT FIND THE FILE!! YOUR FILE SHOULD BE IN THE SAME DIRECTORY THAT YOU ARE RUNNING THIS PYTHON SCRIPT",'red') quit() for word in pass_file: enc_wrd = word.encode('utf-8') digest = hashlib.sha3_384(enc_wrd.strip()).hexdigest() if digest == pass_hash: print("Your Password is",) cprint(word) flag = 1 break if flag ==0: cprint("password not found );") if selection == 14: cprint("sha3_512 is now selected") print("\n")
print("SHA384 : " + result.hexdigest()) if parsed_args.sha512: result = hashlib.sha512(parsed_args.word.encode()) print("SHA512 : " + result.hexdigest()) if parsed_args.sha3_224: result = hashlib.sha3_224(parsed_args.word.encode()) print("SHA3_224 : " + result.hexdigest()) if parsed_args.sha3_256: result = hashlib.sha3_256(parsed_args.word.encode()) print("SHA3_256 : " + result.hexdigest()) if parsed_args.sha3_384: result = hashlib.sha3_384(parsed_args.word.encode()) print("SHA3_384 : " + result.hexdigest()) if parsed_args.sha3_512: result = hashlib.sha3_512(parsed_args.word.encode()) print("SHA3_512 : " + result.hexdigest()) if parsed_args.blake2s: result = hashlib.blake2s(parsed_args.word.encode()) print("BLAKE2S : " + result.hexdigest()) if parsed_args.blake2b: result = hashlib.blake2b(parsed_args.word.encode()) print("BLAKE2B : " + result.hexdigest()) if parsed_args.all:
sys.exit() else: print('mot this :', files, '-->', password) if you_went == 8: x = 0 file = open(input('enter name file :'), 'r') xx = file.readlines() the_hash = input('enter your hash :') while x == 0: for files in xx: attack = sha3_384(files.encode()).hexdigest() password = attack if the_hash == password: print(files, " ---GOOD-ATTACK---> ", the_hash) print(''' DONE !! INSTA = D_5TR ''') sys.exit() else: print('mot this :', files, '-->', password) if you_went == 9: x = 0
def readNormal(): with open(wordlist, "r", encoding="ISO-8859-1") as FileObj: for line in FileObj: passwd1 = line.replace("\n", "") if hash_type == 0: #MD5 passwd_hash = hashlib.md5(passwd1.encode()).hexdigest() elif hash_type == 1: #MD4 passwd_hash = MD4.new(passwd1.encode()).hexdigest() elif hash_type == 2: #MD2 passwd_hash = MD2.new(passwd1.encode()).hexdigest() elif hash_type == 3: #SHA1 passwd_hash = hashlib.sha1(passwd1.encode()).hexdigest() elif hash_type == 4: #SHA-224 passwd_hash = hashlib.sha224(passwd1.encode()).hexdigest() elif hash_type == 5: #SHA-256 passwd_hash = hashlib.sha256(passwd1.encode()).hexdigest() elif hash_type == 6: #SHA-384 passwd_hash = hashlib.sha384(passwd1.encode()).hexdigest() elif hash_type == 7: #SHA-512 passwd_hash = hashlib.sha512(passwd1.encode()).hexdigest() elif hash_type == 8: #SHA3-224 passwd_hash = hashlib.sha3_224(passwd1.encode()).hexdigest() elif hash_type == 9: #SHA3-256 passwd_hash = hashlib.sha3_256(passwd1.encode()).hexdigest() elif hash_type == 10: #SHA3-384 passwd_hash = hashlib.sha3_384(passwd1.encode()).hexdigest() elif hash_type == 11: #SHA3-512 passwd_hash = hashlib.sha3_512(passwd1.encode()).hexdigest() elif hash_type == 12: #BLAKE2s256 passwd_hash = hashlib.new('blake2s256', passwd1.encode()).hexdigest() elif hash_type == 13: #BLAKE2b512 passwd_hash = hashlib.new('blake2b512', passwd1.encode()).hexdigest() elif hash_type == 14: #NTLM passwd_hash = hashlib.new('md4', passwd1.encode('utf-16le')).hexdigest() elif hash_type == 15: #Whirlpool passwd_hash = hashlib.new('whirlpool', passwd1.encode()).hexdigest() elif hash_type == 16: #SM3 passwd_hash = hashlib.new('sm3', passwd1.encode()).hexdigest() elif hash_type == 17: #RIPEMD-160 passwd_hash = hashlib.new('ripemd160', passwd1.encode()).hexdigest() else: print(color.RED + "[-] Invalid hash type...Exiting!" + color.END) sys.exit() if verbose == True: print(color.BLACK + "Trying {}" .format(str(repr(passwd1))) + color.END) if user_hash == passwd_hash: print(color.GREEN + "[+] Hash cracked! Results: " + color.RED + str(line) + color.END) endTime = time.time() deltaTime = endTime - startTime sys.stdout.write("\033[F") print(color.GREEN + "[+] Cracking finished in " + color.RED + str(format(deltaTime, ".3f")) + color.END + color.GREEN + "s" + color.END) if output == True: output_text = "\nDate: {0}\nHash: {1}\nCracked hash: {2}\nCracking time: {3}\nWordlist: {4}" .format(str(today.strftime("%d/%m/%Y")), str(user_hash), str(line).replace("\n", ""), format(deltaTime, ".3f"), str(wordlist)) print(output_text, file=open("results.txt", "a")) print(color.ORANGE + "Results saved successfully in ./results.txt!" + color.END) if output_json == True: results = { "Date": str(today.strftime("%d/%m/%Y")), "hash": str(user_hash), "crackedHash": str(line).replace("\n", ""), "crackingTime": format(deltaTime, ".3f"), "wordlist": str(wordlist) } results_json = json.dumps(results, indent=2) print(results_json, file=open("results.json", "a")) print(color.ORANGE + "Results saved successfully in ./results.json!" + color.END) sys.exit() print(color.RED + "[-] Hash not found! Maybe another wordlist would help." + color.END) sys.exit()
import p import file_info public_file_block = "" md5_hash = hashlib.md5() sha1_hash = hashlib.sha1() sha224_hash = hashlib.sha224() sha256_hash = hashlib.sha256() sha384_hash = hashlib.sha384() sha512_hash = hashlib.sha512() blake2b_hash = hashlib.blake2b() blake2s_hash = hashlib.blake2s() sha3_224_hash = hashlib.sha3_224() sha3_256_hash = hashlib.sha3_256() sha3_384_hash = hashlib.sha3_384() sha3_512_hash = hashlib.sha3_512() class check_file_block(threading.Thread): def __init__(self, file_name, block_size=8910720 * 2): threading.Thread.__init__(self) self.file_name = file_name self.block_size = block_size def run(self): file_name = self.file_name block_size = self.block_size file = open(file_name, mode="rb") checking_size = 0 file_size = os.path.getsize(file_name)
def generate_hash(text): return hashlib.sha3_384(text).hexdigest()
c.update(cadena.encode('utf-8')) if algoritmo == "sha1": c = hashlib.sha1() c.update(cadena.encode('utf-8')) if algoritmo == "sha224": c = hashlib.sha224() c.update(cadena.encode('utf-8')) if algoritmo == "sha256": c = hashlib.sha256() c.update(cadena.encode('utf-8')) if algoritmo == "sha384": c = hashlib.sha384() c.update(cadena.encode('utf-8')) if algoritmo == "sha3_224": c = hashlib.sha3_224() c.update(cadena.encode('utf-8')) if algoritmo == "sha3_256": c = hashlib.sha3_256() c.update(cadena.encode('utf-8')) if algoritmo == "sha3_384": c = hashlib.sha3_384() c.update(cadena.encode('utf-8')) if algoritmo == "sha3_512": c = hashlib.sha3_512() c.update(cadena.encode('utf-8')) if algoritmo == "sha512": c = hashlib.sha512() c.update(cadena.encode('utf-8')) print('Tu texto cifrado es:', (c.hexdigest()))
def register(event): SOLD = get_random_bytes(16) D[e1.get()] = (SOLD, hashlib.sha3_384(bytes(e2.get(), 'ASCII') + SOLD).digest()) with open("D:/password.pkl", 'wb') as f: pickle.dump(D, f)
# ch17_6.py import hashlib data = hashlib.sha3_384() # 建立data物件 data.update(b'Ming-Chi Institute of Technology') # 更新data物件內容 print('Hash Value = ', data.hexdigest()) print(type(data)) # 列出data資料型態 print(type(data.hexdigest())) # 列出雜湊碼資料型態
time.sleep(3) break else: linum += 1 except IndexError: print('\nHash uncrackable with SHA384') sha384 = 0 time.sleep(3) break print('Trying SHA3-384') time.sleep(0.5) print('Begin cracking') linum = 0 while True: try: com_hash2 = hashlib.sha3_384(wl[linum][:len(wl[linum]) - 1]).hexdigest() word2 = wl[linum][:len(wl[linum]) - 1] print('Comparing: ' + str(input_hash) + ' - ' + str(com_hash2) + ' ( ' + str(word2)[1:] + ' )') if com_hash2 == input_hash: print('\nHash successfully cracked') sha3_384 = 1 time.sleep(3) break else: linum += 1 except IndexError: print('\nHash uncrackable with SHA256') sha3_384 = 0 time.sleep(3) break
buf = afile.read(BLOCKSIZE) print("SHA-512 of",get_filename,":\n",hasher512.hexdigest(),"\n") #Calculate SHA3-256: BLOCKSIZE = 65536 hasher3_256 = hashlib.sha3_256() with open(get_filename, 'rb') as afile: buf = afile.read(BLOCKSIZE) while len(buf) > 0: hasher3_256.update(buf) buf = afile.read(BLOCKSIZE) print("SHA3-256 of",get_filename,":\n",hasher3_256.hexdigest(),"\n") #Calculate SHA3-384: BLOCKSIZE = 65536 hasher3_384 = hashlib.sha3_384() with open(get_filename, 'rb') as afile: buf = afile.read(BLOCKSIZE) while len(buf) > 0: hasher3_384.update(buf) buf = afile.read(BLOCKSIZE) print("SHA3-384 of",get_filename,":\n",hasher3_384.hexdigest(),"\n") #Calculate SHA3-512: BLOCKSIZE = 65536 hasher3_512 = hashlib.sha3_512() with open(get_filename, 'rb') as afile: buf = afile.read(BLOCKSIZE) while len(buf) > 0: hasher3_512.update(buf) buf = afile.read(BLOCKSIZE)
print('=' * 70) hash = input('Enter the hash to crack:~# ') wordlist = input('Enter the path of wordlist:~# ') c = 0 try: wordlist = open(wordlist, 'r') quit() except: print('File not found') for paswd in wordlist: hash_obj_1 = hb.shake_128(paswd.strip().encode('utf-8')).hexdigest(1) hash_obj_2 = hb.sha384(paswd.strip().encode('utf-8')).hexdigest() hash_obj_3 = hb.sha256(paswd.strip().encode('utf-8')).hexdigest() hash_obj_4 = hb.sha3_384(paswd.strip().encode('utf-8')).hexdigest() hash_obj_5 = hb.blake2b(paswd.strip().encode('utf-8')).hexdigest() hash_obj_6 = hb.sha224(paswd.strip().encode('utf-8')).hexdigest() hash_obj_7 = hb.sha3_224(paswd.strip().encode('utf-8')).hexdigest() hash_obj_8 = hb.blake2s(paswd.strip().encode('utf-8')).hexdigest() hash_obj_9 = hb.sha3_256(paswd.strip().encode('utf-8')).hexdigest() hash_obj_10 = hb.sha3_512(paswd.strip().encode('utf-8')).hexdigest() hash_obj_11 = hb.sha1(paswd.strip().encode('utf-8')).hexdigest() hash_obj_12 = hb.sha512(paswd.strip().encode('utf-8')).hexdigest() hash_obj_13 = hb.shake_256(paswd.strip().encode('utf-8')).hexdigest(1) hash_obj_14 = hb.md5(paswd.strip().encode('utf-8')).hexdigest() if hash == hash_obj_1 or hash == hash_obj_2 or hash == hash_obj_3 or hash == hash_obj_4 or hash == hash_obj_5 or hash == hash_obj_6 or hash == hash_obj_7 or hash == hash_obj_8 or hash == hash_obj_9 or hash == hash_obj_10 or hash == hash_obj_11 or hash == hash_obj_12 or hash == hash_obj_13 or hash == hash_obj_14: system('clear') print('Password found --------> ' + paswd) c = c + 1 else:
import hashlib import os word = 'FutureSkills2021' hs_w = hashlib.sha3_384(word.encode()).hexdigest() x = 1000 print(hs_w) while True: w = hs_w + (str(x)) hs = hashlib.sha3_256(w.encode()).hexdigest() if hs == 'f595a6a6bc28fb4c0af5474d31771c3a0b3fbcef045efa24b5604c7ea3ee7ed5': print('sha3_256') print(x) break if x > 10000: print('Too many x') break x += 1
import hashlib s = "this is a string with no line terminators" # hexdigest() returns a string object of double length, containing only hexadecimal digits # md5() may be blocked if using a FIPS-compliant build of Python s_md5 = hashlib.md5(s.encode('utf-8')).hexdigest() s_sha1 = hashlib.sha1(s.encode('utf-8')).hexdigest() s_sha224 = hashlib.sha224(s.encode('utf-8')).hexdigest() s_sha256 = hashlib.sha256(s.encode('utf-8')).hexdigest() s_sha384 = hashlib.sha384(s.encode('utf-8')).hexdigest() s_sha512 = hashlib.sha512(s.encode('utf-8')).hexdigest() s_sha3_224 = hashlib.sha3_224(s.encode('utf-8')).hexdigest() s_sha3_256 = hashlib.sha3_256(s.encode('utf-8')).hexdigest() s_sha3_384 = hashlib.sha3_384(s.encode('utf-8')).hexdigest() s_sha3_512 = hashlib.sha3_512(s.encode('utf-8')).hexdigest() print() print("md5", "(" + str(len(s_md5)) + " bytes)", s_md5) print("sha1", "(" + str(len(s_sha1)) + " bytes)", s_sha1) print("sha224", "(" + str(len(s_sha224)) + " bytes)", s_sha224) print("sha256", "(" + str(len(s_sha256)) + " bytes)", s_sha256) print("sha384", "(" + str(len(s_sha384)) + " bytes)", s_sha384) print("sha512", "(" + str(len(s_sha512)) + " bytes)", s_sha512) print() print("sha3_224", "(" + str(len(s_sha3_224)) + " bytes)", s_sha3_224) print("sha3_256", "(" + str(len(s_sha3_256)) + " bytes)", s_sha3_256) print("sha3_384", "(" + str(len(s_sha3_384)) + " bytes)", s_sha3_384) print("sha3_512", "(" + str(len(s_sha3_512)) + " bytes)", s_sha3_512) print()