The Hosts File

    The hosts file is your computer's first resort when it needs to translate a hostname into an IP address. An example of a hostname would be The IP address that this hostname typically resolves to would be We have hostnames so that we don't have to remember difficult strings of numbers (IP addresses). However, computers need to use this IP addresses to connect to each other. (IP addresses for hostnames can be obtained by 'ping'ing the hostname in your command prompt.)
    When you type into your browser, your computer first consults your hosts file to see if you have designated an IP address to go with that name. Most likely, none of us have designated a custom IP address to match with the hostname In this case, your computer doesn't know what "" means, so it goes to your Internet Service Provider, or ISP, and asks your ISP for the IP address of the hostname.
    If you haven't guessed it yet, the hosts file is what matches the hostname "localhost" to the loopback IP address of ""
    On Windows your hosts file is located in C:\WINDOWS\system32\drivers\etc. (I believe the hosts file is in /etc for *nix machines, but I don't know for sure). When you view this folder, you'll see several files with no extensions (minus the .sam file). Look for the file named "hosts" and open it with Notepad to view it. You should see a brief explanation of the hosts file. After that, you'll see the first (and perhaps only) hosts file entry of "".
    Adding a new entry to the hosts file is simple. You just need to make sure you're on a new line, and type the IP address [tab] hostname. Now whenever somebody enters that hostname in the browser on your computer, instead of going to the actual website, they will be redirected to the site with the IP address you entered.
    Get creative! Imagine you catch your computer continuously connecting to, for example, and it is causing annoying popups. A quick treatment would be to use your hosts file to redirect to your own machine ( Now, anytime your computer attempts to connect to the ads server, it will attempt to connect to itself. The connection will time out and fail... no more popups!
    Maybe you're more of the malicious type... set up a webserver on your home computer. On this, create a mock MySpace or Yahoo! webpage that logs a user's information (phishing). Now go to your local library, school, work, wherever! Edit their hosts file to connect to your home IP address when is entered.
    One fallback of using the hosts file is that, it can be bypassed if your victim types in http:// before the hostname. will consult the hosts file first, whereas will go straight to your ISP. But seriously, how many people always type http://?
    The possibilities are endless with this. You just have to try new things!