Blocking Advertisements in your Web
Browser
Updated March 15, 2009
This article will detail the processes necessary to block
web-based advertising on a single home computer. I will specifically
detail ad-blocking though a hosts file, using Firefox, using Opera,
using Internet Explorer, and also a generic method that should work for
any Windows user.
Why is blocking
ads so important?
At the moment, because of how advertising on the internet normally
works, it is entirely possible for a bad guy to attack your computer
with some seriously nasty malware on an entirely legitimate site, just
because that site carries a specially formed advertisement.
Secondly, viewing ads makes web pages take longer to load and often
creates an obnoxious user experience on an otherwise useful web site.
Many web sites do rely on advertising to generate the money they need
to operate. I am not going to deny that. However, the value of any
particular viewer on such a web site is very, very small. Pennies,
perhaps, or fractions of a cent. Most people ignore advertising anyway,
just like most people change channels during TV commercials and/or fast
forward past them on a DVR. Given the current danger posed to home
computers by internet advertising, I think ad-blocking is an ethical
and responsible choice, no matter what certain deluded individuals
think.
How does
advertising work on the internet?
On most internet sites, the sites themselves do not host advertising.
Instead, in much the same way as newspapers, certain spaces on a web
site are made available as placeholders for advertising. These spaces
are sold to advertising networks. The networks are paid by advertisers
to place an image and link leading to a site of their choosing, and the
network pays the originating web site not just for use of the space,
but also an extra amount if its users click through to any particular
ad.
The ads that the advertising networks might be random ones, or they
might be specifically targeted, depending on the site in question and
if the visitor to that site has been on other web sites that use the
same advertising network.
For example, a visitor to CNN.com who has not visited any other web
site since the last time they cleared their browser cookies might get a
generic ad for Netflix from one of CNN's advertising partners. Later,
after that user has visited other sites that are also served by the
same advertising network, say, a couple of web sites about professional
golf and a high profile online comic strip, the advertising network
will have more specific information about that user and on his next
visit to CNN, instead of a generic ad for Netflix, he gets an ad for
Calloway's new titanium driver.
This is not entirely bad by any means. Advertisers want to show people
ads they might actually click on, and if someone is actually looking at
ads, it's probably better if the ads are at least interesting.
Advertising networks track users through the use of Cookies. A cookie,
in web browsing, is essentially a placeholder for information that can
be retained between visits to any particular web site. Any web site a
person visits can set a cookie, and since the advertising spaces on
many different web pages report back to the same few web sites, those
web sites have some ability to uniquely identify users and track where
they are going on the internet, at least among their customer sites.
The problem with advertising comes from the fact that the site
hosting the ad doesn't have all that much input or control over the ads
that are shown on their site. They can say "We don't want ads from
certain types of advertisers" and that's really about it. At
the same time, many advertising networks use automated
systems to allow advertisers to quickly update the ads they want to
rotate through the network. The result of this is a situation in which
one bad egg can craft an advertisement that exploits security holes in
web browsers or plug-ins to force users to download Malware. Which is
exactly the last thing that anyone wants.
Hosts File: The First Line of Defense
The entire Internet is based on a set of network protocols commonly
called TCP/IP. Fundamental to the operation of Internet
Protocol are a series of systems for translating human-friendly Host
Names into a set of numbers called an IP Address that a computer can
actually contact online.
On most computers, the process of converting a host name to an IP
Address is handled through a system called DNS (Domain Name Service),
in which a computer contacts a particular server and asks it to look up
the Address for a particular host name. The DNS Server, if it doesn't
know, will ask the server it's configured to talk to and so on until
one server along the way can return an answer that is eventually passed
back to the computer that asked for that information.
Many years ago, when the internet was a simpler place, DNS did not
exist. Instead, technical users on the internet used a single file that
just contained a list of all the IP Addresses on the internet, and what
computer name was associated with that address. As you might imagine,
this single-file system grew a bit unwieldy as the number of computers
on the internet increased, but the single-file lookup system is still a
fundamental part of TCP/IP Networking and (this is the important part)
every computer with TCP/IP configured will look at that file before
attempting to do a DNS lookup of name to address information.
Why is that a big deal?
That means that if we stick bogus information in the lookup file, a
computer will try to visit the bogus address, and when no data is
returned, no data is shown on a computer screen. This is a fast,
seamless way to prevent a computer from visiting specific sites on the
internet!
The file in question is always named hosts, and it is located in a
specific place for all computers using specific operating systems
Windows 95, 98, ME: c:\windows\hosts
Windows NT/2000/XP/Vista/Windows 7 :
c:\windows\system32\drivers\etc\hosts
Linux (all versions)/UNIX/*BSD: /etc/hosts
OS X: /private/etc/hosts
On most modern operating systems, some kind of administrator-level
authority is needed to modify this file. This is particularly tricky on
Windows Vista and Windows 7, as most users in a default setup will not
have rights to modify a file in that particular folder even if they are
already running with Administrator-level permissions.
Many
other people on the internet have written of the usefulness of this
trick for removing ads. Some of those same people
even maintain a frequently-updated collection of advertising internet
sites to specifically block.
My personal
favorite is the Hosts file from MVPS.org.
Another possible source for an ad-blocking hosts file is
pgl.yoyo.org.
Choose "hosts in hosts file format" and click the "Go" button to get a
file that can be saved to the hosts file location for your computer.
Generally speaking, the process for "installing" a hosts file is to
saving the plain text file either directly to its location for your
operating system (e.g. c:\windows\system32\drivers\etc), or to save the
file to some other location and then copy the file using some
additional techniques to properly deal with your operating system's
security measures.
Windows Vista and Windows 7 both require access by the actual, named
Administrator account to make changes inside C:\Windows or
C:\Program Files directories. This account is prevented from actually
logging on by default. For Vista or 7 users, the easiest thing to do is
download the Hosts file to your desktop or possibly your Downloads
folder, then invoke Windows Explorer as an Administrator.
This means finding Windows Explorer on your start menu, right clicking
and choosing Run as Administrator from the context list.
Within Windows Explorer, find the Hosts file that you saved to your
Desktop or Downloads folder or where ever you saved it, right click,
Move. Then, in Windows Explorer, expand the listing for your C: drive,
then the Windows folder, then the System32 folder, then the Drivers
folder, then the Etc folder. Highlight the Etc folder on the left
(folder listing) side of Windows Explorer. Right click and choose
Paste. You will be asked you really want to do this action. Possibly
several times, depending on UAC settings.
MVPS.org has other suggestions for getting an updated hosts file where
it needs to be on Vista.
One final note: Windows Users with a recent version of Spybot Search
and Destroy should be aware that Spybot has a feature to prevent
changes to the hosts file as well. Spybot users may need to do the
following prior to updating their hosts file:
Launch Spybot.
Click the Mode menu. Choose Advanced Mode.
Click the Tools button on the left side of the screen.
Click IE Tweaks.
If the box labeled Lock Hosts File is checked, you may need to un-check
it before updating your hosts file.
You will of course want to turn Spybot's protection back on after
updating your hosts file.
Hosts file ad-blocking works for every computer connected to the
internet, for every web browser and for every application. By itself,
it solves a lot of problems.
Ad Blocking in Internet Explorer
First things first: If you are using Internet Explorer version 6, stop
it. Right now. IE version 7 has been out for several years now. Web
designers are aware of it. They've been writing and updating their web
sites to work with Internet Explorer version 7 for a while now.
And, the truth is, IE6 is awful at displaying web pages. It was the
standard web browser for years and years for many, many people, but it
also does not behave like any other browser on the internet, leaving
web designers with a choice between coding for IE6 and coding
for the way everything else works.
There are some businesses that use internal web sites that work only
with IE version 6. Businesses can do whatever they want. Hopefully, you
have enough control over your computer to move to IE version 7.
IE7 adds support for tabs and persistent search, two of the things that
all decent web browsers support, but which IE6 does not (and, QED, IE6
is not a decent web browser). You should get it.
You should also get IEPro.
IEPro is a small plug-in for Internet Explorer 7 (and soon to be
available for IE8) that includes an Ad-blocking component as well as a
real-time spell-checker, two of the features I miss terribly when some
horrible thing requires that I use IE for some reason.
IEPro's Ad-blocking features seem to update when the program does,
including the default list of sites that are blocked.
In
theory, all recent versions of Internet Explorer support Restricted
Sites, sites that IE will not visit or attempt to download from.
Microsoft
has a lovely explanation of IE's Security Zones.
Many Anti-Malware programs actually DO make use of Restricted Sites to
protect IE users from themselves, but I was not able to find a pre-made
method for importing restricted sites for a home computer.
My general recommendation is and always has been to avoid using
Internet Explorer whenever possible.
Ad Blocking in Mozilla Firefox
Out of all the browsers on the internet, none have more options for
preventing internet advertising from reaching a computer than Firefox.
These tools are generally not included with the browser, but rather are
packaged as add-ons to the main Firefox package.
Add-ons are generally written by volunteer programmers. There is a dim
chance that installing a Firefox Add-on from an untrusted source could
harm your computer somehow, so by default, Firefox only allows two
Internet sites to download add-ons without question, and you still have
to confirm your desire to install an add-on more than once.
Firefox's main add-ons site can be reached by visiting
addons.mozilla.org
in Firefox.
On the Addons site, search for Adblock within All Add-Ons. There are a
number of different Ad-blocking plug-ins, but at the moment the best of
those is
Adblock
Plus by Wladimir Palant.
Click the Add to Firefox button. This will bring up a window labeled
Software Installation. The Install button will only enable five seconds
after the window is displayed. In theory, this gives the user a chance
to read the detailed information about the add-on and choose whether or
not to install it.
Click the Install button. Adblock Plus will download and modify your
Firefox installation, though it will not operate until Firefox is
restarted.
Upon restarting Firefox after Adblock Plus installation, you will be
presented with a list of servers from which an updated list of servers
to block advertising might be drawn. The lists are regional and
specific to US, European and Asian sources. At the moment, users in the
United States should choose to receive updates from EasyList. Click the
button for EasyList and choose Subscribe. This will continuously update
Adblock with new servers to block.
Advanced Adblock Plus users can also specify other servers and images
to block. The updates from Easylist do not impact user-created filters.
Adblock appears on Firefox's main window as an octagonal button with
the letters ABP in the middle. In rare cases, it is necessary to
disable Adblock Plus for a web page to operate properly. In those
cases, clicking the down arrow button immediately to the right of the
ABP icon gives users the option to temporarily disable it on
a specific web page, a specific web site, or to turn it on or off
permanently.
Adblock Plus does most of the heavy lifting in removing ads from
Firefox, but it's not the only tool available to Firefox users.
CustomizeGoogle
is another project with ad-blocking implications. Google's
Advertising mostly takes the form of fairly innocuous text-based ads
that might appear just before the first "official" search result or on
the right side of familiar Google search pages.
Some people find the idea of sending so much information about their
personal behavior back to a company that makes its value by capturing
and searching through millions of billions of scraps of information
slightly bothersome.
With CustomizeGoogle installed, users have the ability to alter the
behavior of specific Google Services. After installing CustomizeGoogle
and restarting Firefox, click Firefox's Tools Menu, then on Add-Ons.
Highlight CustomizeGoogle and click the Options button.
On the left side of the screen there is a listing of a number of
different Google services. Clicking each one of those service names in
turn should show a "Remove Ads" option for that service, if that
service supports Advertising from Google.
CustomizeGoogle has many other useful features besides blocking
Google's Advertising system, but they are beyond the scope of this
document.
Those
who are curious can visit the project's own home page for more
information.
Are you REALLY militant about preventing advertising content from
reaching your PC? Do you not mind high levels of
inconvenience in exchange for unparalleled safety in web browsing?
Firefox has an add-on that's just for you!
The Add-On is called
NoScript!,
and it essentially removes the ability for most interactive web content
to run through your web browser. This means anything that would
normally be downloaded to your computer and run on your PC: Java,
javascript (despite the names the two things are totally different),
Flash, Shockwave, Silverlight, Acrobat, Quicktime, Windows Media, Real
Media et al. With NoScript installed, those things
will not run on your PC until you specifically OK them.
The good news is, NoScript prevents an unbelievable number of possible
security issues on your PC, including vulnerabilities that no one is
aware of.... like the recent exploits that involved banner ads forcing
un-updated versions of Adobe Reader to install malicious software.
The bad news? Almost every modern web site worth visiting uses at least
some javascript, and with javascript turned off,
parts of huge numbers
of web sites won't work. NoScript Users can white-list certain sites as
safe to run code, but almost nothing is white-listed by default and so
many sites don't work properly with NoScript turned on that users will
invariably spend most of their time with Noscript not running.
Users who are more interested in NoScript's protection can visit its
ironically ad-laden
web
site to learn more.
Ad Blocking In Opera
Opera is another browsing option for many internet users.
It is available for Windows, Linux and many mobile phones that offer
web access. It's not my favorite web browser in the world,
but
some people do use it instead of Firefox.
Opera is built
from the same code that underlies Google Chrome and Apple Safari.
Unlike those other browsers, the people who make Opera include a tool
for content blocking by default. Unlike Firefox's AdBlock Plus add-on,
Opera's Content Filter does NOT support automatic updating.
The
easiest way to mass-block content in Opera is to add the data from any
one of several sites that maintain ad-blocking lists in Opera's format.
The most complete list at the time of this writing seems to be
Fanboy's
Adblock List (which is also available as a
subscribable
list for Adblock Plus).
Opera
keeps its Ad-blocking list in a file that is stored per-user account.
An Opera user can get the location of the file for his or her computer
by clicking
this link.
Users might also be able to use their operating system's file search
tool to look for a file named "urlfilter.ini"
In
any case, the existing urlfilter.ini file can probably be copeid over
with one downloaded from the internet, or the information contained in
the downloaded file can be cut and pasted into the existing file. Opera
must be closed for changes in the file to be saved.
Large urlfilter.ini files supposedly degrade Opera performance.
Opera
also supports individual item blocking. Users can click on
something they object to, and from the right click (context-click) menu
choose "Block Content." This brings up the Content Blocking toolbar, in
which page elements can be selectively chosen and blocked. As items are
selected, the Content Blocker will model the page without those items.
Users can chose "Done" on the toolbar to accept changes or
"Cancel" to reverse them.
Ad Blocking in Safari and Google Chrome
and other browsers
Neither Apple Safari nor Google Chrome directly offer a tool for
blocking advertisements. Many of the techniques available to Firefox
and Opera users are actually hostile to Google's business model (Google
is the largest provider of Internet advertising).
Safari
users on OS X can install a clone of Firefox's Adblock Plus.
It uses the same subscription lists and works in much the same way. The
developers working on the project have stated that they have no
interest in making Safari Adblock available for Windows users.
At
the moment, Google Chrome has no Ad Blocking add-on. Extensions are a
recently announced feature for future versions of the browser.
Presumably someone will make an Ad-blocking extension.
Windows,
OS X or Linux users of any web browser can choose to install and
configure their browser of choice with Privoxy,
a free tool that routes requests and downloads of web data through an
external filtering program. This is a very flexible approach to
filtering all sorts of content, rather than just advertisements, but it
is slightly more difficult to set up as well.
Privoxy
has a lengthy user manual.
Here are some instructions for configuring Privoxy with certain
Operating Systems and Web Browsers:
OS X with
Safari
Chrome
on Windows
Firefox
on Windows