Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizations #1

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 46 additions & 39 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,76 +1,83 @@
import hashlib
import itertools
import sys
import threading
import time
from datetime import datetime
import sys
import timeit
import datetime
from colorama import Fore, Back


class style:
class Style:
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'


done = False

# Headers

print(Fore.RED + '░░░██╗░██╗  ░██╗░░██╗░█████╗░░██████╗██╗░░██╗' + Fore.BLUE + '  ░█████╗░██████╗░░█████╗░░█████╗░██╗░░██╗███████╗██████╗░')
print(Fore.RED + '██████████╗  ██║░░██║██╔══██╗██╔════╝██║░░██║' + Fore.BLUE + '  ██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║░██╔╝██╔════╝██╔══██╗')
print(Fore.RED + '╚═██╔═██╔═╝  ███████║███████║╚█████╗░███████║' + Fore.BLUE + '  ██║░░╚═╝██████╔╝███████║██║░░╚═╝█████═╝░█████╗░░██████╔╝')
print(Fore.RED + '██████████╗  ██╔══██║██╔══██║░╚═══██╗██╔══██║' + Fore.BLUE + '  ██║░░██╗██╔══██╗██╔══██║██║░░██╗██╔═██╗░██╔══╝░░██╔══██╗')
print(Fore.RED + '╚██╔═██╔══╝  ██║░░██║██║░░██║██████╔╝██║░░██║' + Fore.BLUE + '  ╚█████╔╝██║░░██║██║░░██║╚█████╔╝██║░╚██╗███████╗██║░░██║')
print(Fore.RED + '░╚═╝░╚═╝░░░  ╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝░░╚═╝' + Fore.BLUE + '  ░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝' + Fore.RESET)
print('')
print(Fore.RED + ' SHA256 Hash' + Fore.MAGENTA + ' Cracker Written ' + Fore.BLUE + 'by' + ' concatenate' + Fore.RESET)
print('')
def cracked(don): # Cadence
don = True
print(f"{Fore.LIGHTWHITE_EX}\r> {Style.BOLD}{Fore.LIGHTMAGENTA_EX}--Decryption complete!--{Style.END}")
return don


def print_end(crack, time1): # Coda
time2 = timeit.default_timer()
print(Fore.LIGHTGREEN_EX + "\nINPUT".ljust(11, ' ') + Fore.LIGHTWHITE_EX + ': ' + Fore.LIGHTYELLOW_EX + Back.BLACK + sha256hash + Back.RESET)
if crack:
time2 -= 2
print(Fore.LIGHTRED_EX + "STATUS".ljust(10, ' ') + Fore.LIGHTWHITE_EX + ': ' + Fore.LIGHTRED_EX + Back.BLACK + "CRACK SUCCESS" + Back.RESET)
print(Fore.LIGHTBLUE_EX + "VERDICT".ljust(10, ' ') + Fore.LIGHTWHITE_EX + ': ' + Back.RED + Fore.LIGHTWHITE_EX + f"'{guess.decode('UTF-8')}' is your password. Try something stronger!" + Back.RESET)
else:
print(Fore.LIGHTRED_EX + "STATUS".ljust(10, ' ') + Fore.LIGHTWHITE_EX + ': ' + Fore.LIGHTGREEN_EX + Back.BLACK + "CRACK FAIL" + Back.RESET)
print(Fore.LIGHTBLUE_EX + "VERDICT".ljust(10, ' ') + Fore.LIGHTWHITE_EX + ': ' + Back.GREEN + Fore.LIGHTWHITE_EX + "I couldn't crack your hash, you have a strong password!" + Back.RESET)
print(f"{Fore.WHITE}\nDecryption runtime: {time2 - time1:5.3f}s")


# Headers
print(f'{Fore.LIGHTGREEN_EX}░░░██╗░██╗{Fore.LIGHTRED_EX}  ░██╗░░██╗░█████╗░░██████╗██╗░░██╗{Fore.LIGHTBLUE_EX}  ░█████╗░██████╗░░█████╗░░█████╗░██╗░░██╗███████╗██████╗░')
print(f'{Fore.LIGHTGREEN_EX}██████████╗{Fore.LIGHTRED_EX}  ██║░░██║██╔══██╗██╔════╝██║░░██║{Fore.LIGHTBLUE_EX}  ██╔══██╗██╔══██╗██╔══██╗██╔══██╗██║░██╔╝██╔════╝██╔══██╗')
print(f'{Fore.LIGHTGREEN_EX}╚═██╔═██╔═╝{Fore.LIGHTRED_EX}  ███████║███████║╚█████╗░███████║{Fore.LIGHTBLUE_EX}  ██║░░╚═╝██████╔╝███████║██║░░╚═╝█████═╝░█████╗░░██████╔╝')
print(f'{Fore.LIGHTGREEN_EX}██████████╗{Fore.LIGHTRED_EX}  ██╔══██║██╔══██║░╚═══██╗██╔══██║{Fore.LIGHTBLUE_EX}  ██║░░██╗██╔══██╗██╔══██║██║░░██╗██╔═██╗░██╔══╝░░██╔══██╗')
print(f'{Fore.LIGHTGREEN_EX}╚██╔═██╔══╝{Fore.LIGHTRED_EX}  ██║░░██║██║░░██║██████╔╝██║░░██║{Fore.LIGHTBLUE_EX}  ╚█████╔╝██║░░██║██║░░██║╚█████╔╝██║░╚██╗███████╗██║░░██║')
print(f'{Fore.LIGHTGREEN_EX}░╚═╝░╚═╝░░░{Fore.LIGHTRED_EX}  ╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░╚═╝░░╚═╝{Fore.LIGHTBLUE_EX}  ░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝\n')
print(Fore.GREEN + 'SHA256'.rjust(45, ' ') + Fore.RED + ' Hash' + Fore.BLUE + ' Cracker\n' + Fore.MAGENTA + 'Written by: c0ncatenate'.rjust(60, ' '))
print(Fore.WHITE + 'For the purposes of decrypting encrypted text, via Secure Hash Algorithm 256'.rjust(88, '_').ljust(99, '_'), end='\n\n')

# Get a hash input from the user
sha256hash = input(Fore.LIGHTWHITE_EX + "[i] " + Fore.LIGHTBLUE_EX + "Put in your password hash here\n > " + Fore.RESET)
print('')
current_time = datetime.now().strftime("%H:%M:%S")
print(Fore.LIGHTWHITE_EX + "[i] " + Fore.LIGHTMAGENTA_EX + "Cracking started: " + Fore.LIGHTWHITE_EX + current_time + '\n' + Fore.RESET)
sha256hash = input(f'{Fore.LIGHTWHITE_EX}> {Fore.LIGHTYELLOW_EX}Encrypted Password: ')
current_time = datetime.datetime.now().strftime("%H:%M:%S %m/%d/%Y")
print(f"\n{Fore.BLACK}{Back.LIGHTWHITE_EX}Decryption initiated @ {current_time}{Back.RESET}\n")
time_start = timeit.default_timer()


# here is the animation
# Animated loading
def animate():
for c in itertools.cycle(['...', '..', '.']):
for c in itertools.cycle(['--', '<>', '[]', '<>']):
if done:
break
sys.stdout.write(style.BOLD + Fore.LIGHTRED_EX + '\rCracking' + c + Fore.RESET + style.END)
sys.stdout.write(f'{Fore.LIGHTWHITE_EX}\r> {Style.BOLD}{Fore.LIGHTCYAN_EX}{c}Decrypting{c}{Style.END}')
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write('\r')
time.sleep(0.2)


t = threading.Thread(target=animate)
t.start()

wordlist = bytes(open("10-million-password-list-top-1000000.txt").read(), encoding='utf-8')
wordlist = bytes(open("milwordlist.txt").read(), encoding='utf-8')

# Hash the passwords in the wordlist
for guess in wordlist.split():
hashed = hashlib.sha256(guess).hexdigest()

# Compare the hashes and give an output
if hashed == sha256hash:
time.sleep(1)
done = True
print(Fore.LIGHTWHITE_EX + "\n\nYour hash :", Fore.LIGHTYELLOW_EX + sha256hash + Fore.RESET)
print(Fore.LIGHTWHITE_EX + "STATUS : " + Fore.LIGHTGREEN_EX + "CRACKED")
print(Fore.LIGHTWHITE_EX + "GUESS : " + Back.GREEN + Fore.LIGHTWHITE_EX + guess.decode(
'UTF-8') + Back.RESET)
print(Fore.LIGHTMAGENTA_EX + "\nCracking ended: " + Fore.LIGHTWHITE_EX + current_time + Fore.RESET)
time.sleep(2)
done = cracked(done)
print_end(True, time_start)
quit()

# Output if the hashes don't match
elif hashed != sha256hash:
pass
done = True
print(Fore.LIGHTWHITE_EX + "\n\nYour hash :", Fore.MAGENTA + sha256hash + Fore.RESET)
print(Fore.LIGHTWHITE_EX + "STATUS : " + Fore.LIGHTRED_EX + "UNCRACKED")
print(
Fore.LIGHTWHITE_EX + "GUESS : " + Back.RED + Fore.LIGHTWHITE_EX + "I couldn't crack your hash, you have a strong password! :)" + Back.RESET)
print(Fore.LIGHTMAGENTA_EX + "\nCracking ended: " + Fore.LIGHTWHITE_EX + current_time + Fore.RESET)
done = cracked(done)
print_end(False, time_start)