I'm trying to create a password cracker using brute force(I'm testing it on a really simple html login page I created), the program worked but would take too long to get the password right, so I had the idea to run the cracking function once for each starting digit, from zero through nine, using multiprocessing.I want to stop all processes when one of them gets to login, but could only stop the one that figures the password out so far.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import multiprocessing
import sys
import signal
password = ''
currentUrl = ""
def toNumber(num1, num2, num3, num4, num5, num6, num7, num8):
password = str(num1) + str(num2) + str(num3) + str(num4) + str(num5) + str(num6) + \
str(num7) + str(num8)
return (password)
def crack(startWith):
wb = webdriver.Chrome('./chromedriver')
wb.get("http://127.0.0.1:5500/index.html")
inputEmail = wb.find_element_by_id('email')
inputPassword = wb.find_element_by_id('password')
submitbtn = wb.find_element_by_class_name('login-btn')
inputEmail.send_keys("My personal email")
for first in range(startWith, 10):
for second in range(0, 10):
for third in range(0, 10):
for fourth in range(0, 10):
for fifth in range(0, 10):
for sixth in range(0, 10):
for seventh in range(0, 10):
for eighth in range(0, 10):
password = toNumber(
first, second, third, fourth, fifth, sixth, seventh, eighth)
inputPassword.send_keys(password)
submitbtn.click()
inputPassword.send_keys(
Keys.CONTROL + "a")
inputPassword.send_keys(Keys.BACKSPACE)
print(password)
if(wb.current_url != "http://127.0.0.1:5500/index.html"):
sys.exit()
start = time.time()
pool = multiprocessing.Pool()
pool.map(crack, range(0, 10))
end = time.time()
print("Time elapsed: " + end - start)