Hosts file filtering
From Wikipedia, the free encyclopedia
Hosts files are a method by which a computer's operating system can translate hostnames into valid IP addresses. It's a legacy mechanism still found in many operating systems. Because a hosts file trumps DNS lookups when it comes to name translation, they can be used for filtering unwanted content.
Contents |
[edit] Ad filtering
One use of the hosts file is ad filtering. This is accomplished by adding a line to the file that maps an ad server's hostname to an address that will not satisfy the browser's request for the ad. Since no additional programs are necessary to do this, hosts file based ad-blocking has a near-zero memory and CPU footprint, as well as requiring no loading time. The hostname for an advertiser may be obtained by right-clicking on the banner or advertisement, then clicking properties from the context menu. This will indicate the full URL, of which the part between the double slash and first single slash represent the hostname.
The two most common addresses used for this purpose are the 'null' address 0.0.0.0 (which may simply be written as a single '0') and the 'loopback' address 127.0.0.1. The distinction between the two is that 0.0.0.0 is an invalid destination address[1], so no connection can be established. If a name is mapped to the loopback address 127.0.0.1, any connections to the "blocked" domain will be mapped to the originating machine. If it is running a Web server, that Web server may attempt to handle the request. The ad-blocking technique may include a local web server that provides substitute images rather than 404 error messages [2], which would require the use of 127.0.0.1.
The following examples use the null address; the 127.0.0.1 would be substituted if the loopback method is to be used.
For example, this hosts file entry would block DoubleClick ads:
0.0.0.0 ad.doubleclick.net
These entries, demonstrating the short form of the null address, would block Google AdSense ads:
0 pagead.googlesyndication.com 0 pagead2.googlesyndication.com 0 adservices.google.com
[edit] Hijacking
The hosts file can also be used in malicious ways by the authors of spyware and viruses. It is similar to ad blocking with the hosts file, but instead of redirecting advertising servers to dummy ones, popular websites are redirected to an advertiser's server. This technique is known as Hijacking. The Qhosts trojan hijacked many search engines such as Google and AltaVista and redirected them to a site specified by the author.
Other malware such as Mydoom.B may just block the user from visiting sites about security and the removal of viruses. These sites included the makers of popular anti-virus software and Microsoft's Windows Update page to make the removal of the software more difficult for novice users.
Prevention of hosts file hijacking requires either routinely logging in with limited 'user' access (so malicious software has no privileges to change the hosts file, or other important things), or real-time monitoring software such as Windows Defender's "Hosts Monitor", which will warn if anything attempts to edit the hosts file. Changing the properties of the hosts file to read-only is mostly ineffective against modern hijacks as well-programmed malicious software can simply change the file's attribute value. Anti-spyware software such as Spybot - Search & Destroy and ZoneAlarm's anti-spyware module have a feature to "lock" the hosts file. This does nothing more than set it to read-only. Another way to do this is set the permissions for the file so everyone can only read from it, although the owner and therefore malicious software running in the context of it can change the permissions in Windows and the root user can ignore the permissions in Unix.
[edit] External links
[edit] More Information
- Blocking ads on the Internet with a list of ad server hostnames and IP addresses.
- Eliminate Web Advertisements The author describes how to combine hosts files with multiple technologies to block advertisements.
- Eric L. Howes contains many good links for security and hosts-file-related stuff.
- HOSTS File Myth The author explains his opinion on why using the hosts file to stop malware is false security.
- SSMedia hosts file and Utilities
[edit] Custom Hosts Files
- MVPS hosts Information on blocking ads using a HOSTS file and a free, comprehensive, updated HOSTS file download
- The Security Now! podcast page on the hosts file
- Andrew Short's Hosts file project comprehensive hosts file.
- Bluetack HOSTS File and Manager A massive hosts file
- Dan Pollock's hosts file Pretty thorough website, lots of comments, lot of work went into this as shown in his credits.
- Hosts-pider The largest public hosts file on the net, with over 100,000 hostnames in the blacklist and counting. - back online in 2 weeks
- Mikes Ad-Blocking hosts file available as a direct download to merge in, or as an installer.
- SCoooBY's fav free apps SCoooBY's AD Blocking Hosts File.
- hpguru's Hosts file
[edit] Applications to Manage hosts files
- Abelhadigital's HostsMan 2.1 is a freeware application that lets you manage your hosts file.
- Aldo's Hosts Manager 1.4 is another hosts file manager alternative, though very slim in options.
- Funkytoad's Hoster 3.1 free application to arrange, and edit your hosts file.
- Mike Meyer's HostsToggle 2.1 an open source hosts file tweaker
- Ray Marron's Hostess 3.0