0

I want to try and right some code that will guess the default ip of a router that you are currently connected to. To do this, i would write a bit of javascript code that would type into the google chrome URL bar and attempt to search it. For instance: it would type 192.168.0.0 , then 192.168.0.1, etc... currently my largest problem with this is that i have no idea how i would write code that would locate and type into the url bar, i could do it with any other user input. How would i do this?

1 Answers1

0

URL bar is not part of the window so you couldn't just locate it using javascript as with DOM elements.

To read and write to URL you could use window.location (more to find here: https://developer.mozilla.org/en-US/docs/Web/API/Window/location).

If you change window.location to another address, it will force browser to load new content, in the same way as reloading a page. Remember that loading new page will probably lead to discarding your javascript code if it was loaded from within the website.

Another way is to use iframe and dynamically change its url, like here: dynamically set iframe src

If you want to make tool that iterates through possible addresses, i would recommend writing it as a Chrome extension. More about it and tutorial are available here: https://developer.chrome.com/extensions

Community
  • 1
  • 1
SzybkiSasza
  • 1,591
  • 12
  • 27