javascript - how to replace url of webpage with ip adress - Stack Overflow

i am trying to basically replace a webpage's url with its ip address for example, instead ofwww.fa

i am trying to basically replace a webpage's url with its ip address for example, instead of

www.facebook

i want to replace it with

66.220.153.11  

Rationale
i have recently discovered that our school blocks websites based on a particular string patern in the url for example www.facebook is blocked but 66.220.153.11 is not yet they are the same thing.

so i want to learn how to do this using javascript(is this possible?) so i can develop a firefox addon to automatically change the url www.facebook to 66.220.153.11 and beat the censorship.
i am usually a c programmer but i know little javascript. Help me out. Thanks

i am trying to basically replace a webpage's url with its ip address for example, instead of

www.facebook.

i want to replace it with

66.220.153.11  

Rationale
i have recently discovered that our school blocks websites based on a particular string patern in the url for example www.facebook. is blocked but 66.220.153.11 is not yet they are the same thing.

so i want to learn how to do this using javascript(is this possible?) so i can develop a firefox addon to automatically change the url www.facebook. to 66.220.153.11 and beat the censorship.
i am usually a c programmer but i know little javascript. Help me out. Thanks

Share Improve this question asked Oct 19, 2010 at 10:11 Dr DeoDr Deo 4,84811 gold badges46 silver badges76 bronze badges 4
  • 2 +1 Interesting question, but yet they are the same thing. is incorrect: Only if the site is configured to show the site when entering the IP this will work. For the vast majority of sites, it won't. – Pekka Commented Oct 19, 2010 at 10:17
  • 1 @pekka: For the vast majority of sites, it won't . Give us an illustrative example of a website where replacing the url with ip address wont work. Thanks – Dr Deo Commented Oct 19, 2010 at 10:23
  • 2 I have one for you: Facebook :) Try to log in from the page you opened using the IP. Apart from that, every web site that runs on shared hosting is bound not to work (because multiple domains share one IP). However, all major sites do work, as a cursory check shows – Pekka Commented Oct 19, 2010 at 10:28
  • 1 There are good security reasons why websites should not allow access to a browser that fails to supply the correct Host: header. See DNS rebinding and cross-subdomain cookie attacks. – bobince Commented Oct 19, 2010 at 10:42
Add a ment  | 

3 Answers 3

Reset to default 3

(Assuming accessing the site via the IP works)

I don't know in how detailed you expect an answer to be, but here is a general approach:

  • Changing the host
    This is easy. The location object has an attribute hostname. If you have the IP address, you can just assign it to location.hostname. On change, the site will reload (example - of course the target page does not exist).
    In your plugin, you can attach an event handler for the load event to the gBrowser object. Read about Intercepting Page Loads.

  • Getting the IP address
    This is trickier. The only thing that es to my mind is to use some web service that does host name to IP resolution. So you would have to use Ajax with (probably) JSONP for this.

I hope this gives you a start.

This cant't work for the most domains in the world, because the IP points to a server, not to a domain. If there are hosted different domains on the same server(often hundreds of domains are hosted on one server), there is no way to point at the wanted domain without knowledge of the virtualhost-settings(which are usually not public).

You may take a look at this and see, how many domains can depend on a single IP:
http://www.robtex./ip/194.117.254.46.html

Also see, how many domains are hosted on the facebook-IP:
http://www.robtex./ip/66.220.153.11.html

Why don't you use a proxy to bypass the blocks?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745232942a4617761.html

相关推荐

  • javascript - how to replace url of webpage with ip adress - Stack Overflow

    i am trying to basically replace a webpage's url with its ip address for example, instead ofwww.fa

    8小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信