邪恶八进制信息安全团队技术讨论组's Archiver

EvilOctal 2006-1-12 00:50

[转载]Blocking Unwanted Sites by Using a Simple hosts File

原始连接:[url]http://www.informit.com/guides/printerfriendly.asp?g=security&seqNum=173&rl=1[/url]

Security
Practical Home User Security: Blocking Unwanted Sites by Using a Simple hosts File
Last updated Jan 6, 2006.
It may come as a surprise to you to learn that you don't need to download all sorts of programs to block unwanted websites on your computer. If you are using a Windows-based desktop computer, you already have everything you need to permanently block nasty porn-sites, adverts, malware and spyware-riddled sites. This section looks at these techniques and gets you on the road to owning your internet connection.

What is a hosts file?
A hosts file works in a similar fashion to a street directory. In the back of a street directory a user can look up a street name and then find the information in the directory on locating that street. Your computer’s hosts file does a similar job. When your computer tries to connect to a website, the hosts file is first consulted. If the address is in the hosts file, the computer will go to the address stipulated by the hosts file even if it isn't the proper address.

Hosts files have lots of technical uses for network administrators, but you don't need a computer science degree to learn how to make use of the hosts file. Everyday home users can take advantage of the hosts file to block out internet nasties.

Where is my hosts file?
The answer to this depends on what operating system you are running.

Here are the most common locations for windows hosts files

Windows XP:

C:\WINDOWS\SYSTEM32\DRIVERS\ETCWindows 2000:

C:\WINNT\SYSTEM32\DRIVERS\ETCWin 98/ME:

C:\WINDOWSIf your windows is not installed into C drive or you are having trouble finding the hosts file, you may want to use the windows search function to find the file. The file is simply called HOSTS and will probably be in capital letters. It has no extension at the end. Don't try to open it just yet and don't allocate a program to open it, as this may cause problems later on.

Editing the hosts file
Once you have located your hosts file, it is best to now make a back up copy of it. Right click on your hosts file and choose to copy. Now navigate to your My Documents folder and paste the hosts file in there (right click and choose paste or hit the ctrl and v key at the same time). Rename this hosts file to hosts.backup. Renaming it will help you differentiate between the two later on if you need to use the windows search function to find your hosts file.

Once you have backed up your hosts file securely you, are now free to edit the original copy. To open the original file, right click and choose rename. Rename the file to hosts.txt. Once it has been renamed you can double click on it and it will pop up in MS Notepad. It should look something like this:


Figure 1 A sample hosts file

If it doesn't look like that then don't worry; sometimes they are blank or they have had entries put in them by anti spyware programs and even malicious spyware.

If your hosts file doesn't have the 127.0.0.1 Localhost entry, then you should add it now. This is important as it tells the computer that the IP address 127.0.0.1 always points to your own computer. To add it simply place it at the top of the file and make sure that you do no have any # symbols at the start of the line.

Now underneath the 127.0.0.1 localhost line you can start adding sites that are dodgy or have adverts like this:

127.0.0.1 iads.adroar.com
127.0.0.1 lists.adroar.com
127.0.0.1 advertisingvision.comYou can continue adding sites that you don't want people on your computer to visit until you can't think of any more to add. Once you are done you can simply save the file and rename it back to HOSTS and it will block those sites.

Is there an easier way to do this?
The answer is yes.

It would take a single individual months and months to add the thousands of nasty sites to a hosts list. Luckily someone has spent the time and created a hosts file that contains a good percentage of the unwanted and dodgy websites on the internet and have made this hosts file available to everyone.

You can download this super hosts file here:

[url]http://www.mvps.org/winhelp2002/hosts.txt[/url]

Simply back up and replace your hosts file with this big hosts file. It blocks spyware infected sites, porn sites, adverts and even web hijackers. You can get an easy to install version here

[url]http://www.mvps.org/winhelp2002/hosts.htm[/url]

It comes with an installer file that will install the hosts file for you as well as make a back up copy of your original.

If you notice your computer slows down a bit due to the large size of the hosts file, then you may need to stop your DNS service. The instructions are on the previously mentioned site but please note if your computer is part of a network then I would advise not performing this procedure as it can cause troubles with internet connections.

Locking the hosts file
Once you have modified your hosts file the lasts thing you want is for some malicious spyware to change the settings. To stop this from happening you will need to lock or guard your hosts file using a software protection program. Spyware and trojans have been known to modify the hosts file to block users from accessing anti virus websites etc. It can be very scary for a new computer user when something like this happens.

A simple yet effective program that I have found is ArovaxShield. Arovax shield watches your hosts file and notifies you when software is attempting to modify it. (In a similar way a firewall asks you if you want to allow or disallow access). Ultimately it is your decision to allow or disallow software to modify the hosts file but it is safe to say that not many legitimate programs make changes to the hosts file.

Problems that may occur
Generally speaking, hosts file modification is fairly safe, but sometimes problems do occur. Here is a list of few problems that may pop up and their remedies.

Q) Your favorite website suddenly "doesn’t work."

You need to look through the hosts list to see if it has been blocked. Sometimes websites will use server side spyware such as java applets, and blocking these will occasionally stop the website from functioning. If you can't find the website on the list and it still doesn't work, you can try looking at the source code of the site and seeing if you can see java applets from a different website.

Q) The internet doesn't work at all

A) You may be on a network and have disabled your DNS with the speed fix. Try re-enabling it by reversing the procedure.

Q) My computer has slowed down, but I cant use the speed fix as I am on a network

A) Try trimming your hosts file down a bit or making a custom one yourself. The larger the file the slower your computer will go. A smaller hosts file will make a big difference.

页: [1]
© 1999-2008 EvilOctal Security Team