Advertisement
Guest User

Untitled

a guest
Oct 18th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #without comments
  2.  
  3. $username = "admin"
  4. $password = "public"
  5.  
  6. $ie = New-Object -com InternetExplorer.Application
  7. $ie.visible=$false
  8.  
  9. $ie.navigate("http://192.168.1.1")
  10.  
  11. while($ie.ReadyState -ne 4) {start-sleep -m 100}
  12. $ie.document.getElementById("username").value= "$username"
  13. $ie.document.getElementById("pass").value = "$password"
  14. $ie.document.getElementById("loginform").submit()
  15. start-sleep 20
  16.  
  17. $ie.navigate("http://192.168.1.1/maintenance.html")
  18. $ie.document.getElementById("restartButton").click()
  19.  
  20. # $links = $ie.Document.getElementsByTagName('A')
  21. # $restart = $links | where {$_.innerText -like 'Restart'}
  22. # $restart.click()
  23.  
  24.  
  25. #- - - - - - - - - - - - - - - - - - - - -
  26.  
  27. #WITH COMMENTS
  28.  
  29.  
  30. # define username and password to login to airport
  31. $username = "admin"
  32. $password = "public"
  33.  
  34. # initiate Internet explorer object (think of it as starting an invisible IE browser)
  35. $ie = New-Object -com InternetExplorer.Application
  36. $ie.visible=$false
  37.  
  38. # use invisible browser and go to this URL
  39. $ie.navigate("http://192.168.1.1")
  40.  
  41. # while readystate is not equal to 4, sleep this code 100 milliseconds so it doesnt move on without the page being loaded yet.
  42. # For Reference, here are the ReadyStates
  43. # READYSTATE_UNINITIALIZED = 0
  44. # READYSTATE_LOADING = 1
  45. # READYSTATE_LOADED = 2
  46. # READYSTATE_INTERACTIVE = 3
  47. # READYSTATE_COMPLETE = 4
  48. while($ie.ReadyState -ne 4) {start-sleep -m 100}
  49.  
  50. # grab the element ID of the username box (this will depend on the airports login page.)
  51. # We will have to right click > inspect element in chrome on the login box to get the correct value
  52. $ie.document.getElementById("username").value= "$username"
  53.  
  54. # same shit for password
  55. $ie.document.getElementById("pass").value = "$password"
  56.  
  57. # clicks the login button
  58. $ie.document.getElementById("loginform").submit()
  59.  
  60. # sleeps the code while the login process takes place
  61. start-sleep 20
  62.  
  63. # navigates to the routers maintenance page where the restart button most likely takes place
  64. $ie.navigate("http://192.168.1.1/maintenance.html")
  65.  
  66. # finds and clicks the reset button based on its html ID tag (theoretical that it is called restartButton)
  67. $ie.document.getElementById("restartButton").click()
  68.  
  69.  
  70. # the next 3 lines would be another way to grab the restart button
  71. # $links = $ie.Document.getElementsByTagName('A')
  72. # $restart = $links | where {$_.innerText -like 'Restart'}
  73. # $restart.click()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement