Updated some comments and moved a global variable

This commit is contained in:
2023-06-03 16:55:06 +02:00
parent 6f2ad7a54b
commit f607839e7d
2 changed files with 10 additions and 6 deletions

View File

@@ -12,8 +12,7 @@ colors = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white",
total_processes = 0 total_processes = 0
total_decrypt_attempts = 0 total_decrypt_attempts = 0
update_rate = 0
update_rate = 100000
""" """
Get a color for a process using an array Get a color for a process using an array
@@ -76,9 +75,11 @@ Global function of a child process
""" """
def worldlist_bruteforce_partial(fileToCrack, wordlistPath, total_proc, processNumbar, startPos, endPos): def worldlist_bruteforce_partial(fileToCrack, wordlistPath, total_proc, rate_of_update, processNumbar, startPos, endPos):
global total_processes global total_processes
total_processes = total_proc total_processes = total_proc
global update_rate
update_rate = rate_of_update
# Opens the excel file # Opens the excel file
with open(fileToCrack, 'rb') as file: with open(fileToCrack, 'rb') as file:
@@ -93,7 +94,9 @@ def worldlist_bruteforce_partial(fileToCrack, wordlistPath, total_proc, processN
# Find the right start position in the wordlist for this process # Find the right start position in the wordlist for this process
print_thread(processNumbar, "Started new process [" + str(startPos) + " -> " + str(endPos) + "]") print_thread(processNumbar, "Started new process [" + str(startPos) + " -> " + str(endPos) + "]")
# Sets initial position in the file
wordlistToUse.seek(startPos) wordlistToUse.seek(startPos)
# Move backward until a newline character is found or we reach the beginning of the file # Move backward until a newline character is found or we reach the beginning of the file
position = startPos position = startPos
while position > 0: while position > 0:
@@ -109,7 +112,7 @@ def worldlist_bruteforce_partial(fileToCrack, wordlistPath, total_proc, processN
try: try:
line = wordlistToUse.readline() line = wordlistToUse.readline()
# End the thread if it has arrived to its given endPos # End the process if it has arrived to its given end position
if wordlistToUse.tell() >= endPos: if wordlistToUse.tell() >= endPos:
print_thread(processNumbar, "Thread done at line " + line + " with " + str( print_thread(processNumbar, "Thread done at line " + line + " with " + str(
total_decrypt_attempts) + " attempts.") total_decrypt_attempts) + " attempts.")
@@ -125,7 +128,7 @@ def worldlist_bruteforce_partial(fileToCrack, wordlistPath, total_proc, processN
line = line.rstrip() # Removes line endings line = line.rstrip() # Removes line endings
# Print status every x lines read # Print status every x attempts
if last_update <= total_decrypt_attempts - update_rate: if last_update <= total_decrypt_attempts - update_rate:
calculate_speed(processNumbar, start_time, last_update, line) calculate_speed(processNumbar, start_time, last_update, line)
start_time = time.time() start_time = time.time()

View File

@@ -10,6 +10,7 @@ from child_process import worldlist_bruteforce_partial
fileToCrack = "Base_MPP_Ouest_2013.xls" # The file to crack fileToCrack = "Base_MPP_Ouest_2013.xls" # The file to crack
wordlistPath = "rockyou.txt" # The wordlist to use wordlistPath = "rockyou.txt" # The wordlist to use
num_threads = 16 # Number of processes to launch (should be the same as your number of cpu cores) num_threads = 16 # Number of processes to launch (should be the same as your number of cpu cores)
update_rate = 100000 # Everytime the program needs to remind you what its doing
# =============================== # # =============================== #
@@ -35,7 +36,7 @@ def run_processes():
end_pos = start_pos + chunk_size end_pos = start_pos + chunk_size
process = multiprocessing.Process(target=worldlist_bruteforce_partial, process = multiprocessing.Process(target=worldlist_bruteforce_partial,
args=(fileToCrack, wordlistPath, num_threads, i + 1, start_pos, end_pos)) args=(fileToCrack, wordlistPath, num_threads, update_rate, i + 1, start_pos, end_pos))
process.start() process.start()
processes.append(process) processes.append(process)