Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.34 KB | None | 0 0
  1. #encoding = utf-8
  2. from selenium import webdriver
  3. import sys
  4.  
  5. import time
  6.  
  7. phantomjs_location = 'C:\Program Files (x86)\Python36-32\phantomjs\phantomjs.exe'
  8.  
  9. driver = webdriver.PhantomJS(executable_path=phantomjs_location)
  10. driver.set_window_size(1366,768)
  11. driver.get("http://192.168.1.254/login.lp")
  12. user = driver.find_element_by_name("user")
  13. passwd = driver.find_element_by_name("password")
  14. ok_button = driver.find_element_by_name("ok")
  15. user.send_keys("sumeo")
  16. passwd.send_keys("trttab123")
  17. ok_button.click()
  18.  
  19. ## after login
  20.  
  21. wireless = """
  22. GoAndRemember(arguments[0], arguments[1]);
  23.  
  24. function GoAndRemember(aLink, customArgs)
  25. {
  26.  var l0   = -1;
  27.  var l1   = -1;
  28.  var link = new String(aLink);
  29.  var notFound = true;
  30.  
  31.  if (customArgs && isSpecialPage(aLink))
  32.  {//we have to add that hard-code here,since only special pages need to be escaped twice
  33.     customArgs = escapeTwice(customArgs);
  34.  }
  35.  
  36.  if (link.length == 0)
  37.  {
  38.    // load the page indicated by the state vars
  39.    link = new String(getCurrentLink());
  40.    if(link != "/")
  41.       link += constructArgString(customArgs);
  42.    location.href = link;
  43.  }
  44.  else if (link == "/")
  45.  {
  46.    g_state[BE] = g_cur_mode;
  47.    g_state[L0] = -1;
  48.    g_state[L1] = -1;
  49.    if (customArgs == "no")
  50.      location.href = link+"?be="+g_cur_mode+"&l0=-1&l1=-1";
  51.    else
  52.      location.href = link + constructArgString("");
  53.  }
  54.  else if (link.indexOf("javascript:", 0) != -1)
  55.  {
  56.    // just execute the javascript code
  57.    eval(link.substr(link.indexOf("javascript:")));
  58.  }
  59.  else
  60.  {
  61.    // find the menu item that corresponds with the given link
  62.    for (var i = 0; (i < mtree.length) && notFound; i++) // mode
  63.    {
  64.      for (var j = 0; (j < mtree[i].length) && notFound; j++) // l0
  65.      {
  66.        if (mtree[i][j][1] == link)
  67.        {
  68.          // discard custom arguments
  69.          g_state[ARGS] = "";
  70.          g_state[NAME] = "";
  71.          g_state[TYPE] = "";
  72.          g_state[BE] = i;
  73.          g_state[L1] = -1;
  74.          g_state[L0] = j;
  75.          notFound = false;
  76.        }
  77.        else
  78.        {
  79.          for (var k = 0; (k < mtree[i][j][4].length) && notFound; k++) // l1
  80.          {
  81.            if (mtree[i][j][4][k][1] == link)
  82.            {
  83.              // discard custom arguments when we go to another menu item
  84.              if (g_state[L1] != k)
  85.              {
  86.                g_state[ARGS] = "";
  87.                g_state[NAME] = "";
  88.                g_state[TYPE] = "";
  89.              }
  90.              g_state[BE] = i;
  91.              g_state[L0] = j;
  92.              g_state[L1] = k;
  93.              notFound = false;
  94.            }
  95.            else if (i == 0)
  96.            {
  97.              for (var l = 0; (l < mtree[i][j][4][k][4].length) && notFound; l++)
  98.              {
  99.                var tmp = mtree[i][j][4][k][4][l];
  100.                for (var m = 0; (m < tmp[1].length) && notFound; m++)
  101.                {
  102.                  if (tmp[1][m][1] == link)
  103.                  {
  104.                    // discard custom arguments when we go to another menu item
  105.                    if (g_state[L1] != k)
  106.                    {
  107.                      g_state[ARGS] = "";
  108.                      g_state[NAME] = "";
  109.                      g_state[TYPE] = "";
  110.                    }
  111.                    g_state[BE] = i;
  112.                    g_state[L0] = j;
  113.                    g_state[L1] = k;
  114.                    notFound = false;
  115.                  }
  116.                }
  117.              }
  118.            }
  119.          }
  120.        }
  121.      }
  122.    }
  123.    // note that when the corresponding menu item is not found, we go to the
  124.    // link but with the current state as arguments
  125.    link += constructArgString(customArgs);
  126.    location.href = link;
  127.  }
  128. }"""
  129.  
  130. to_encode = 'name\x3dWLAN\x3a\x20MEO\x2d33BE01'
  131.  
  132. driver.execute_script(wireless, '/cgi/b/_wli_/ov/', 'name=WLAN: MEO-33BE01')
  133. driver.execute_script(wireless, '/cgi/b/_wli_/cfg/', to_encode)
  134.  
  135. print(driver.page_source)
  136.  
  137. #passwd_network = driver.find_element_by_name('41')
  138. password = sys.argv[1]
  139. if (len(password) < 8 or len(password) <= 0):
  140.     sys.stderr("Defaulting to 12345678")
  141.     password = "12345678"
  142.  
  143. #passwd_network.clear()
  144. #passwd_network.send_keys(password)
  145.  
  146. #button_save = driver.find_element_by_name("10")
  147. #button_save.click()
  148. print("SUCCESS")
  149.  
  150. time.sleep(5)
  151. driver.close()
  152. sys.exit(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement