In [1]:
# Code attribution: Yiyin Shen, Tyler Caraza-Harter
# Imports
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
import time
import itertools
In [2]:
# Get the button and input and output fields
service = Service(executable_path="chromedriver-win64/chromedriver.exe")
driver = webdriver.Chrome(service=service)
url = "https://pages.cs.wisc.edu/~yw/CS320F23T19.html"
driver.get(url)
input = driver.find_element("id", "answer_3")
button = driver.find_element("id", "button_2")
output = driver.find_element("id", "out_3")
In [3]:
# Try all passwords
passwords = list(itertools.permutations(range(0, 10), 4)) # This takes too long
start = ""
passwords = list(itertools.permutations(range(0, 10), 2)) # Guess the last two digits
start = "84"
for password in passwords:
keys = start + "".join(list(map(str, password)))
input.send_keys(keys)
button.click()
time.sleep(0.01)
if not output.text.startswith("I"):
print(keys + ": " + output.text)
input.clear()
8493: Correct!
In [4]:
# Remember to quit when it's done
driver.quit()