Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #encoding = utf-8
- from selenium import webdriver
- import sys
- import time
- phantomjs_location = 'C:\Program Files (x86)\Python36-32\phantomjs\phantomjs.exe'
- driver = webdriver.PhantomJS(executable_path=phantomjs_location)
- driver.set_window_size(1366,768)
- driver.get("http://192.168.1.254/login.lp")
- user = driver.find_element_by_name("user")
- passwd = driver.find_element_by_name("password")
- ok_button = driver.find_element_by_name("ok")
- user.send_keys("sumeo")
- passwd.send_keys("trttab123")
- ok_button.click()
- ## after login
- wireless = """
- GoAndRemember(arguments[0], arguments[1]);
- function GoAndRemember(aLink, customArgs)
- {
- var l0 = -1;
- var l1 = -1;
- var link = new String(aLink);
- var notFound = true;
- if (customArgs && isSpecialPage(aLink))
- {//we have to add that hard-code here,since only special pages need to be escaped twice
- customArgs = escapeTwice(customArgs);
- }
- if (link.length == 0)
- {
- // load the page indicated by the state vars
- link = new String(getCurrentLink());
- if(link != "/")
- link += constructArgString(customArgs);
- location.href = link;
- }
- else if (link == "/")
- {
- g_state[BE] = g_cur_mode;
- g_state[L0] = -1;
- g_state[L1] = -1;
- if (customArgs == "no")
- location.href = link+"?be="+g_cur_mode+"&l0=-1&l1=-1";
- else
- location.href = link + constructArgString("");
- }
- else if (link.indexOf("javascript:", 0) != -1)
- {
- // just execute the javascript code
- eval(link.substr(link.indexOf("javascript:")));
- }
- else
- {
- // find the menu item that corresponds with the given link
- for (var i = 0; (i < mtree.length) && notFound; i++) // mode
- {
- for (var j = 0; (j < mtree[i].length) && notFound; j++) // l0
- {
- if (mtree[i][j][1] == link)
- {
- // discard custom arguments
- g_state[ARGS] = "";
- g_state[NAME] = "";
- g_state[TYPE] = "";
- g_state[BE] = i;
- g_state[L1] = -1;
- g_state[L0] = j;
- notFound = false;
- }
- else
- {
- for (var k = 0; (k < mtree[i][j][4].length) && notFound; k++) // l1
- {
- if (mtree[i][j][4][k][1] == link)
- {
- // discard custom arguments when we go to another menu item
- if (g_state[L1] != k)
- {
- g_state[ARGS] = "";
- g_state[NAME] = "";
- g_state[TYPE] = "";
- }
- g_state[BE] = i;
- g_state[L0] = j;
- g_state[L1] = k;
- notFound = false;
- }
- else if (i == 0)
- {
- for (var l = 0; (l < mtree[i][j][4][k][4].length) && notFound; l++)
- {
- var tmp = mtree[i][j][4][k][4][l];
- for (var m = 0; (m < tmp[1].length) && notFound; m++)
- {
- if (tmp[1][m][1] == link)
- {
- // discard custom arguments when we go to another menu item
- if (g_state[L1] != k)
- {
- g_state[ARGS] = "";
- g_state[NAME] = "";
- g_state[TYPE] = "";
- }
- g_state[BE] = i;
- g_state[L0] = j;
- g_state[L1] = k;
- notFound = false;
- }
- }
- }
- }
- }
- }
- }
- }
- // note that when the corresponding menu item is not found, we go to the
- // link but with the current state as arguments
- link += constructArgString(customArgs);
- location.href = link;
- }
- }"""
- to_encode = 'name\x3dWLAN\x3a\x20MEO\x2d33BE01'
- driver.execute_script(wireless, '/cgi/b/_wli_/ov/', 'name=WLAN: MEO-33BE01')
- driver.execute_script(wireless, '/cgi/b/_wli_/cfg/', to_encode)
- print(driver.page_source)
- #passwd_network = driver.find_element_by_name('41')
- password = sys.argv[1]
- if (len(password) < 8 or len(password) <= 0):
- sys.stderr("Defaulting to 12345678")
- password = "12345678"
- #passwd_network.clear()
- #passwd_network.send_keys(password)
- #button_save = driver.find_element_by_name("10")
- #button_save.click()
- print("SUCCESS")
- time.sleep(5)
- driver.close()
- sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement