#! /usr/bin/env python3 # Printing banner print(""" ████████████████████████████████████████████████████████████ █─▄▄▄─█▄─▄▄▀█▄─█─▄█▄─▄▄─█─▄─▄─█─▄▄─███─▄▄▄▄█████▄─▄▄─█▄─█─▄█ █─███▀██─▄─▄██▄─▄███─▄▄▄███─███─██─███▄▄▄▄─█░░███─▄▄▄██▄─▄██ ▀▄▄▄▄▄▀▄▄▀▄▄▀▀▄▄▄▀▀▄▄▄▀▀▀▀▄▄▄▀▀▄▄▄▄▀▀▀▄▄▄▄▄▀▄▄▀▀▄▄▄▀▀▀▀▄▄▄▀▀ Developed by Zishan Ahamed Thandar. https://zishanadthandar.github.io Crypto S.py version beta 0.1 """) # Importing modules import os, sys, base64, base45, base58 # Choosing hash input type hasht=input("Hash Text or Hash file in text? \n(1) Hash Text \n(2) Hash Text form file\n:: ") # Reading hash if hasht=="1": hashtext=input("Paste Hash:\n") elif hasht=="2": hashfile=input("Hash file location:\n") if os.path.exists(hashfile): with open(hashfile, 'r') as file: hashtext = file.read() else: print("File does not exist.") sys.exit() else: print("Kuchh to garbar hai Daya!") sys.exit() # Adding Keys Keys=['cipher', 'cryptii'] print("\nWe already have " + str(Keys) + ".\n") # Get comma-separated input from the user morekeyinput = input("If you want to add keys, add as comma separated values. Example: Tiger, Crypto, CTF\n:: ") # Split the input string by commas and add the values to a list if morekeyinput!="": morekeys = morekeyinput.split(','); Keys.extend(morekeys) print("\nNow keys are " + str(Keys) + ".\n") # Total number of rotation rotloopnum=input("How many loop you want to check?\n::") # Grep Flag Match grepflag=input("Flag Format (Prefix) to check match.\nExample: If flag is ZCTF{Zishan_Flag} type ZCTF.\n::") if grepflag!="": flagstring=grepflag else: flagstring="flag" declist=[] def bindec(hashtd, dlist): hashtd = str(hashtd).replace(" ", "") hashtd = str(hashtd).replace(",", "") if hashtd.isnumeric(): try: binary_chunks = [hashtd[i:i+8] for i in range(0, len(hashtd), 8)] # Convert each binary chunk to its decimal equivalent and then to a character decoded = ''.join([chr(int(chunk, 2)) for chunk in binary_chunks]) print("Binary [Base2]: " + decoded + "\n") dlist.append(decoded) except: pass def octaldec(hashtd, dlist): hashtd = str(hashtd).replace(" ", "") hashtd = str(hashtd).replace(",", "") if hashtd.isnumeric(): try: octal_chunks = ' '.join([hashtd[i:i+3] for i in range(0, len(hashtd), 3)]) decoded = "" for octal_char in octal_chunks.split(" "): decoded += chr(int(octal_char, 8)) print("Octal [Base8]: " + decoded + "\n") dlist.append(decoded) except: pass def decidec(hashtd, dlist): hashtd = str(hashtd).replace(",", " ") try: decoded="" for i in hashtd.split(" "): decoded+=chr(int(i)) print("Decimal [Base10]: " + decoded + "\n") dlist.append(decoded) except: pass def hexdec(hashtd, dlist): try: decbytes = bytes.fromhex(hashtd) decoded = decbytes.decode('utf-8') print("Hexadecimal [Base16]: " + decoded + "\n") dlist.append(decoded) except: pass def b32dec(hashtd, dlist): try: decoded = base64.b32decode(hashtd).decode('utf-8') print("Base32: " + decoded + "\n") dlist.append(decoded) except: pass def b45dec(hashtd, dlist): try: decoded = base45.b45decode(hashtd).decode('utf-8') print("Base45: " + decoded + "\n") dlist.append(decoded) except: pass def b58dec(hashtd, dlist): try: decoded = base58.b58decode(hashtd).decode('utf-8') print("Base58: " + decoded + "\n") dlist.append(decoded) except: pass def b62dec(hashtd, dlist): aln = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" try: decoded1 = sum([(62**i) * aln.index(char) for i, char in enumerate(hashtd[::-1])]) decoded = decoded1.to_bytes((decoded1.bit_length() + 7) // 8, byteorder='big').decode('utf-8') print("Base62: " + decoded + "\n") dlist.append(decoded) except: pass def b64dec(hashtd, dlist): try: decoded = base64.b64decode(hashtd).decode('utf-8') print("Base64: " + decoded + "\n") dlist.append(decoded) except: pass def b85dec(hashtd, dlist): try: decoded = base64.a85decode(hashtd.encode()).decode('utf-8') print("Base85: " + decoded + "\n") dlist.append(decoded) except: pass def allrot(hashtd, dlist): for shift in range(1, 26): decoded = ''.join([chr(((ord(char) - ord('a' if char.islower() else 'A') - shift) % 26) + ord('a' if char.islower() else 'A')) if char.isalpha() else char for char in hashtd]) dlist.append(decoded) print(f"ROT{shift:02}: {decoded}") def hashloop(hashlt, dlist): bindec(hashlt, dlist) octaldec(hashlt, dlist) decidec(hashlt, dlist) hexdec(hashlt, dlist) b32dec(hashlt, dlist) b45dec(hashlt, dlist) b58dec(hashlt, dlist) b62dec(hashlt, dlist) b64dec(hashlt, dlist) b85dec(hashlt, dlist) allrot(hashlt, dlist) if rotloopnum.isnumeric(): rloopnum=int(rotloopnum) else: rloopnum=1 abcd=[] for i in range(rloopnum): abcd.append([]) print("\n") for i in range(rloopnum): print("Loop[",str(i),"]::\n") if i==0: hashloop(hashtext, abcd[0]) else: for j in abcd[i-1]: hashloop(j, abcd[i]) #for i in range(rloopnum): # print("Loop[",str(i),"]::",abcd[i], "\n") #print(abcd) prflag = [s for sublist in abcd for s in sublist if flagstring.lower() in s.lower()] if prflag!="": print("\nFlag Matches: ", prflag) else: print("Flag not found.")