You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rizzlehash/Main.py

88 lines
2.5 KiB

#!/usr/bin/python3
# -*- coding: utf-8 -*-
import multiprocessing
import sys
import time
import locale
from ProcessBruteForce import *
nbProcess = 4
verbose = False
class App():
def __init__(self):
## La liste contenant nos object Processe
self.processes = list()
self.queue = multiprocessing.Queue()
self.infoQueue = multiprocessing.Queue()
self.found = False
self.appTime = time.time()
global nbProcess
global verbose
for i in range(0,nbProcess):
p=ProcessBrurteForce(self.queue, i,nbProcess , "azerty","",6,verbose)
self.processes.append(p)
def run(self):
for proc in self.processes:
proc.start()
procAlive=True
totalMotParSecondes =0
while procAlive:
totalMotParSecondes =0
procAlive =False
for proc in self.processes:
#proc.join()
resultat = self.queue.get()
if resultat[0]== 0 :
if resultat[1] == True :
#print("RESULT: %s" % resultat[2])
self.displayResult(resultat[2])
for proc in self.processes:
proc.terminate()
sys.exit()
elif resultat[0] == 1:
WordsSeconds = round(resultat[1]/resultat[2])
totalMotParSecondes = totalMotParSecondes + WordsSeconds
locale.setlocale(locale.LC_ALL, 'french_france')
WordsSeconds = locale.format('%d', WordsSeconds, grouping=True)
print(resultat[4]+" : " + '{:>30}'.format(WordsSeconds) + " Mots/s \tMot actuel : " + resultat[3])
else:
print("/!\ useCase" + resultat[0] +"non traité")
#on verifie qu'il y a encore des process en cours (il n'y ap aps de do while en python
if proc.is_alive():
procAlive =True
if verbose:
locale.setlocale(locale.LC_ALL, 'french_france')
totalMotParSecondes = locale.format('%d', totalMotParSecondes, grouping=True)
print("Mots Par Secondes : " +'{:>30}'.format(totalMotParSecondes)+ " Mots/s")
return None
def displayResult(self,passTrouve):
if(time.time() - self.appTime) > 60 :
seconds = time.time() - self.appTime
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
d ,h = divmod(h, 24)
if d != 0:
print("Found ! : " + passTrouve +" en " + "%d:%02d:%02d:%02d" % (d,h, m, s))
elif h != 0 :
print("Found ! : " + passTrouve +" en " + "%d:%02d:%02d" % (h, m, s))
else:
print("Found ! : " + passTrouve +" en " + "%d:%02d" % (m, s))
else:
print("Found ! : " + passTrouve +" en " + str(time.time() - self.appTime) + " secondes")
#si le fichier est lancé seul
if __name__ == '__main__' :
application = App()
application.run()
sys.exit()