Last active
July 1, 2019 22:14
-
-
Save CaptBoykin/d0677c2ee14912ddf9432799aabf85f3 to your computer and use it in GitHub Desktop.
Bumping my modem
This file contains hidden or 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
from selenium import webdriver | |
from subprocess import Popen, PIPE | |
import sys | |
USERNAME="" | |
PASSWORD="" | |
CHROMEDRIVER_LOCATION="" | |
for i,x in enumerate(sys.argv): | |
if x in ["-u","--user"]: | |
USERNAME=sys.argv[i+1] | |
elif x in ["-p","--passwd"]: | |
PASSWORD=sys.argv[i+1] | |
elif x in ["--location"]: | |
CHROMEDRIVER_LOCATION=sys.argv[i+1] | |
theproc = Popen(["ncat.exe","8.8.8.8","53","-z","-vv"],stdout=PIPE,stderr=PIPE) | |
reply = theproc.communicate()[1].split('\r\n')[4][51:66] | |
if not reply in ["CONNECT SUCCESS"]: | |
browser = webdriver.Chrome(CHROMEDRIVER_LOCATION) | |
url = "http://"+USERNAME+":"+PASSWORD+"@192.168.100.1" | |
browser.get(url) | |
url = "http://192.168.100.1/RouterStatus.asp" | |
browser.get(url) | |
element2 = browser.find_element_by_id("reboot") | |
element2.click() | |
alert = browser.switch_to.alert | |
alert.accept() | |
browser.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment