Skip to content

Instantly share code, notes, and snippets.

@vanhoefm
Created June 21, 2020 01:25
Show Gist options
  • Save vanhoefm/7d6216205d07e123b5951ffecce4ab83 to your computer and use it in GitHub Desktop.
Save vanhoefm/7d6216205d07e123b5951ffecce4ab83 to your computer and use it in GitHub Desktop.
Reset router using Selenium
#!/usr/bin/env python3
from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options
import subprocess, time
def reset_router(browser):
browser.execute_script('javascript:CheckHTMLStatus("System");')
time.sleep(0.13)
browser.execute_script('javascript:SetFactory_Default();')
time.sleep(0.01)
browser.find_element_by_id("Confirm_btn").click()
def main():
# Starting browser
opts = Options()
browser = Firefox(options=opts)
try:
browser.get('https://duckduckgo.com')
except:
pass
# Wait until the router has booted
subprocess.call(["./asroot", "./etisalat_wait.py"])
print("Router is online!")
time.sleep(0.05)
browser.get("http://192.168.0.1/")
print("Loaded management page!")
password = browser.find_element_by_id("admin_Password")
password.send_keys("SuperSecretPassword")
browser.find_element_by_id("logIn_btn").click()
time.sleep(0.01)
reset_router(browser)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment