Files
Python-Excel-Bruteforcer/main.py

73 lines
2.2 KiB
Python

import multiprocessing
import os
import time
from termcolor import cprint
from child_process import worldlist_bruteforce_partial
# ============ Setup ============ #
fileToCrack = "Base_MPP_Ouest_2013.xls" # The file to crack
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)
update_rate = 100000 # Everytime the program needs to remind you what its doing
# =============================== #
"""
Launches and monitors every process
"""
def run_processes():
# Get the wordlist's size in bytes from the OS
wordlistSize = os.path.getsize(wordlistPath)
# Calculate the portion of the file each process will read
chunk_size = wordlistSize // num_threads
# Create and start the processes
processes = []
total_processes = 0
for i in range(num_threads):
total_processes += 1
start_pos = i * chunk_size
end_pos = start_pos + chunk_size
process = multiprocessing.Process(target=worldlist_bruteforce_partial,
args=(fileToCrack, wordlistPath, num_threads, update_rate, i + 1, start_pos, end_pos))
process.start()
processes.append(process)
cprint("[MAINPROCESS] Started " + str(total_processes) + "/" + str(num_threads) + " threads", "red", attrs=["bold"])
# Check if any process has finished early
while True:
still_alive = False
for process in processes:
if process.is_alive():
still_alive = True
else:
if process.exitcode == 111: # It means found
cprint("[MAINPROCESS] Found the code !", "green", attrs=["bold"])
# Kill everything
still_alive = False
for proc in processes:
proc.kill()
break
if not still_alive: # If every process is dead, break the loop
break
time.sleep(1) # Wait for some time
"""
Main function
"""
if __name__ == '__main__':
run_processes()