Skip to content

Commit

Permalink
v2.3 update license, readme, refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
proplayer919 committed Mar 30, 2024
1 parent 8bfcb8b commit 2a82ff4
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 121 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Digital Open Technologies License (DOTL) Version 1.0

Copyright (c) 2023 proplayer919 (github), fifly-llc (github), fifly.org, proplayer919.dev
Copyright (c) 2023 proplayer919 (github), fifly-llc (github), fifly.org, proplayer919.dev, and open-source contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hashcrack
# Hashcrack v2.3

Hashcrack is a simple, fast, and free hash bruteforcer for all different hashing algorithms.

Expand Down
187 changes: 68 additions & 119 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from colorama import Style
import bcrypt

title_text = "HASHCRACK v2.2"
title_text = "HASHCRACK v2.3"

args = sys.argv

Expand Down Expand Up @@ -54,100 +54,67 @@ def number_to_text(number):


def crack_hash(hash_value, print_current=False, hash_algorithm="sha256"):
if not print_current:
print_to_screen(
combine_strings(
title_text + "\n",
"Cracking hash: " + hash_value,
"Hash Algorithm: " + hash_algorithm,
)
)

hasher = globals()["calculate_hash_" + hash_algorithm] or calculate_hash_sha256

start_time = time()
result = None
tried_hashes = []
attempts = 0

def batch_worker():
nonlocal attempts
nonlocal result
nonlocal tried_hashes
nonlocal print_current
nonlocal hasher

while True:
with lock:
batch_start = next(hash_generator)
batch_end = min(batch_start + batch_size, max_attempts)

for i in range(batch_start, batch_end):
if not result == None:
return

if i in tried_hashes:
continue

tried_hashes.append(i)

attempts += 1
current_try = number_to_text(i)

current_try_hashed = hasher(current_try)

if print_current:
print_to_screen(
combine_strings(
title_text + "\n",
"Cracking hash: " + hash_value,
"Currently trying: " + current_try,
"Currently trying (hashed): " + current_try_hashed,
"Time elapsed: "
+ str(round(time() - start_time, 2))
+ " seconds",
"Attempts: " + str(attempts),
"Speed: "
+ str(round(attempts / round(time() - start_time + 0.1, 2)))
+ " hashes / second",
)
)

if hash_value == current_try_hashed:
cracked = current_try
result = cracked
return

num_threads = 6
max_attempts = 94 ** 6
batch_size = max_attempts // num_threads
hash_generator = iter(range(max_attempts))
lock = threading.Lock()

threads = []
for _ in range(num_threads):
thread = threading.Thread(target=batch_worker)
threads.append(thread)
thread.start()

for thread in threads:
thread.join()

if not result == None:
cracked = result

print_to_screen(
combine_strings(
title_text + "\n",
"Cracked hash: " + hash_value,
"Cracked: " + cracked,
"Time elapsed: " + str(round(time() - start_time, 3)) + " seconds",
"Attempts: " + str(attempts),
"Speed: "
+ str(round(attempts / (time() - start_time + 0.1), 2))
+ " hashes / second",
)
)
try:
print_to_screen(combine_strings(title_text + "\n", "Cracking hash: " + hash_value, "Hash Algorithm: " + hash_algorithm))

hasher = globals().get("calculate_hash_" + hash_algorithm, calculate_hash_sha256)

start_time = time()
result = None
tried_hashes = []
attempts = 0

def batch_worker():
nonlocal attempts, result, tried_hashes, hasher

while True:
with lock:
batch_start = next(hash_generator)
batch_end = min(batch_start + batch_size, max_attempts)

for i in range(batch_start, batch_end):
if result is not None:
return

if i in tried_hashes:
continue

tried_hashes.append(i)

attempts += 1
current_try = number_to_text(i)

current_try_hashed = hasher(current_try)

if print_current:
print_to_screen(combine_strings(title_text + "\n", "Cracking hash: " + hash_value, "Currently trying: " + current_try, "Currently trying (hashed): " + current_try_hashed, "Time elapsed: " + str(round(time() - start_time, 2)) + " seconds", "Attempts: " + str(attempts), "Speed: " + str(round(attempts / round(time() - start_time + 0.1, 2))) + " hashes / second"))

if hash_value == current_try_hashed:
cracked = current_try
result = cracked
return

num_threads = 6
max_attempts = 94 ** 6
batch_size = max_attempts // num_threads
hash_generator = iter(range(max_attempts))
lock = threading.Lock()

threads = []
for _ in range(num_threads):
thread = threading.Thread(target=batch_worker)
threads.append(thread)
thread.start()

for thread in threads:
thread.join()

if result is not None:
cracked = result

print_to_screen(combine_strings(title_text + "\n", "Cracked hash: " + hash_value, "Cracked: " + cracked, "Time elapsed: " + str(round(time() - start_time, 3)) + " seconds", "Attempts: " + str(attempts), "Speed: " + str(round(attempts / (time() - start_time + 0.1), 2)) + " hashes / second"))
except Exception as e:
print_to_screen(f"Error: {str(e)}")


formattedArgs = []
Expand All @@ -166,44 +133,26 @@ def batch_worker():
continue

for arg in formattedArgs:
if arg[0] == "-c" or arg[0] == "--crack":
if arg[0] in ("-c", "--crack"):
hash_value = arg[1]
mode = "c"
elif arg[0] == "-h" or arg[0] == "--hash":
elif arg[0] in ("-h", "--hash"):
hash_text = arg[1]
mode = "h"

if arg[0] == "-a" or arg[0] == "--algorithm":
if arg[0] in ("-a", "--algorithm"):
hash_algorithm = arg[1]
else:
hash_algorithm = "sha256"

if arg[0] == "-si" or arg[0] == "--show-info":
if arg[0] in ("-si", "--show-info"):
show_info = True
else:
show_info = False

if mode == "c":
crack_hash(hash_value, show_info, hash_algorithm)
elif mode == "h":
print_to_screen(
combine_strings(
title_text + "\n",
"Text to hash: " + hash_text,
"Hash: " + globals()["calculate_hash_" + hash_algorithm](hash_text),
"Hash algorithm: " + hash_algorithm + "\n",
)
)
print_to_screen(combine_strings(title_text + "\n", "Text to hash: " + hash_text, "Hash: " + globals().get("calculate_hash_" + hash_algorithm, calculate_hash_sha256)(hash_text), "Hash algorithm: " + hash_algorithm + "\n"))
else:
print_to_screen(
combine_strings(
title_text + " Usage\n",
"<program> [-c or --crack] <hash> [-a or --algorithm] <hash algorithm> [-si or --show-info]",
"'-c / --crack' - Crack hash",
"'-a / --algorithm' - Hash algorithm (sha256, md5, sha1, bcrypt)",
"'-si / --show-info' - Show current information (dynamically updating - slows down a lot)\n",
"<program> [-h or --hash] <text to hash> [-a or --algorithm] <hash algorithm>",
"'-h / --hash' - Hash text",
"'-a / --algorithm' - Hash algorithm (sha256, md5, sha1, bcrypt)",
)
)
print_to_screen(combine_strings(title_text + " Usage\n", "<program> [-c or --crack] <hash> [-a or --algorithm] <hash algorithm> [-si or --show-info]", "'-c / --crack' - Crack hash", "'-a / --algorithm' - Hash algorithm (sha256, md5, sha1, bcrypt)", "'-si / --show-info' - Show current information (dynamically updating - slows down a lot)\n", "<program> [-h or --hash] <text to hash> [-a or --algorithm] <hash algorithm>", "'-h / --hash' - Hash text", "'-a / --algorithm' - Hash algorithm (sha256, md5, sha1, bcrypt)"))

0 comments on commit 2a82ff4

Please sign in to comment.