1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hacking the hosts file in windows

Discussion in 'Windows' started by neo_vi, Dec 5, 2009.

  1. neo_vi

    neo_vi New Member

    Joined:
    Feb 1, 2008
    Messages:
    722
    Likes Received:
    15
    Trophy Points:
    0
    Occupation:
    Software engineer
    Location:
    Earth
    Home Page:

    INTRODUCTION



    Many of us would have used a local webserver for designing websites or for previewing. This is where the 'localhost' comes. We always give http://localhost or http://127.0.0.1 to tell the browser to take the files from the local web server instead of going into the internet. How and where to change that name, if u wanted to make the localhost as .com or .net, whatever.
    Just edit the file named hosts under the location
    'C:\WINDOWS\system32\drivers\etc\hosts' (assuming C: is the drive where u installed windows)
    A default hosts file will look like this

    Code:
    # Copyright (c) 1993-1999 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    # 102.54.94.97 rhino.acme.com # source server
    # 38.25.63.10 x.acme.com # x client host
     
    127.0.0.1 localhost
    
    Change the last line to whatever name u like.
    e.g
    Code:
    127.0.0.1 xyz.com
    
    Use the name xyz.com instead of localhost while using the local webserver.

    This file can also be used to block unwanted sites. U can put the sites here that u don't wish to see.
    e.g
    Code:
    127.0.0.1 dont-see-this.com
    

    How the above line works?



    If you go to a particular URL in the browser the OS will check the hosts file whether any specific address has been mapped to that site.If yes it will load that,if not it will fetch it from the web. If you give the above line in the hosts file, whenever u goto the site 'dont-see-this.com' it will point the browser to the address 127.0.0.1 which is your localhost.
    (The above technique is used in 'spybot search and destroy' when u give the immunize option)
    Happy hacking! :D
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    Same process is used by many virus to block the anti virus sites and that means you cannot update your anti-virus thus preventing the removal of virus
     
  3. pankaj.sea

    pankaj.sea New Member

    Joined:
    Apr 6, 2009
    Messages:
    461
    Likes Received:
    13
    Trophy Points:
    0
    Occupation:
    Web Developer
    Location:
    Kolkata
    Home Page:
    Hi neo_vi
    There was a small mistake in your article, the path of "hosts" file will be
    not
    Thanks...
    ;)
     
    neo_vi likes this.
  4. venami

    venami New Member

    Joined:
    Dec 26, 2008
    Messages:
    195
    Likes Received:
    10
    Trophy Points:
    0
    Occupation:
    Software Professional
    Location:
    India, Tamil Nadu, Cuddalore
    Home Page:
    Nice info neo_vi.

    And in Linux, the same can be done in /etc/hosts file.
     
  5. neo_vi

    neo_vi New Member

    Joined:
    Feb 1, 2008
    Messages:
    722
    Likes Received:
    15
    Trophy Points:
    0
    Occupation:
    Software engineer
    Location:
    Earth
    Home Page:
    Oh. I am sorry. Thanks for letting me know. It happened cos i didn't copy the path, i typed it instead.

    >>> for shabbir,
    can u please make the above change in the article.?
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
  7. technica

    technica New Member

    Joined:
    Dec 15, 2007
    Messages:
    107
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    Good one. I have already used it some times, but with this article I understood how it works.
     
  8. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83

Share This Page