5,594,518 Members 32,549 Now Online
XDA Developers Android and Mobile Development Forum

Block Ads on Surface! :D

Tip us?
 
C-Lang
Old
(Last edited by C-Lang; 31st January 2014 at 10:03 AM.)
#1  
Senior Member - OP
Thanks Meter 36
Posts: 152
Join Date: Nov 2012
Location: Redlands, CA
Prompt Block Ads on Surface! :D

Ok, so disclaimer: this isn't the same as Ad Block, some ads will slip through, and there will probably be IE error messages popping up.

However, if you despise adverts and are ready to give feedback, this does block many ads.
So, what we're doing is editing Windows' built-in hosts file to block these addresses at the source.

First, download the hosts file attached here.
Then, browse to "C:\Windows\System32\drivers\etc" and rename "hosts" to "hosts.old"
Then copy and paste the file you downloaded into the folder, making sure there is no file extension (go to View>show/hide file extensions)

Next, open CMD as admin (start>cmd>right click>run as admin)
Type "net stop dnscache" and hit enter.
After a couple minutes that'll finish.
Type "sc config dnscache start= disabled"

Reboot your Surface (or other device)

You're now (mostly) ad-free! Let me know what you think, and what effects this has on page load speed. (negligible to me, but I'm on a high-speed, slow connections would most benefit.)
Attached Files
File Type: zip Hostsfile.zip - [Click for QR Code] (2.46 MB, 113 views)
The Following User Says Thank You to C-Lang For This Useful Post: [ Click to Expand ]
 
GoodDayToDie
Old
(Last edited by GoodDayToDie; 31st January 2014 at 02:13 PM.)
#2  
Recognized Developer
Thanks Meter 2463
Posts: 5,280
Join Date: Jan 2011
Location: Seattle
HOSTS-file ad blocking is nothing new, but it is a nice trick. However, there are a few problems with the way you suggested doing this:

1) the HOSTS file on Win8 and WRT is protected by Windows Defender, and attempts to modify the mapping for a number of known domains (some of which, annoyingly, are advertising domains) will fail. You will want to add \Windows\System32\drivers\etc\HOSTS to the Excluded Files in Defender.

2) Neither disabling DNS caching nor restarting are needed. Just run the following command: "ipconfig /flushdns" (no quotes). This will wipe the current DNS cache. Disabling the caching entirely will actually degrade performance, as your browser (for example) will need to do a DNS lookup every single time it wants to open a connection to a server, which could be dozens of times per click. Windows will use the HOSTS file just fine while the DNS cache is active. I'm not even *sure* you need to flush it, but it won't hurt.

By the way, for web browsing, a somewhat "nicer" approach to ad-blocking is to use the built-in IE feature of Tracking Protection Lists. You can "get a Tracking Protection List online" and then add EasyList (who also make the most popular block list for AdBlock Plus/AdBlock Edge). Most people don't realize that IE effectively has a built-in ad blocker, and has for a few releases now... Of course, that won't help with ads outside of the browser.
Win8/Windows RT projects:
List of desktop apps for hacked RT devices

WP8 projects:
Native Access WebServer and Libraries
WP8 Interop Unlocks
Storage Cleanup tool

WP7 projects:
XapHandler, Root Webserver, OEM Marketplace XAPs, Bookmarklets collection (Find On Page), Interop-unlock hacks.


Do not private message me with questions that should have been posted on the forum! Not only are you wasting your time - I'm not going to bother writing an answer to such a question for only one person - but I will probably block you from PMing me in the future as well.
The Following User Says Thank You to GoodDayToDie For This Useful Post: [ Click to Expand ]
 
C-Lang
Old
#3  
Senior Member - OP
Thanks Meter 36
Posts: 152
Join Date: Nov 2012
Location: Redlands, CA
Quote:
Originally Posted by GoodDayToDie View Post
HOSTS-file ad blocking is nothing new, but it is a nice trick. However, there are a few problems with the way you suggested doing this:

1) the HOSTS file on Win8 and WRT is protected by Windows Defender, and attempts to modify the mapping for a number of known domains (some of which, annoyingly, are advertising domains) will fail. You will want to add \Windows\System32\drivers\etc\HOSTS to the Excluded Files in Defender.

2) Neither disabling DNS caching nor restarting are needed. Just run the following command: "ipconfig /flushdns" (no quotes). This will wipe the current DNS cache. Disabling the caching entirely will actually degrade performance, as your browser (for example) will need to do a DNS lookup every single time it wants to open a connection to a server, which could be dozens of times per click. Windows will use the HOSTS file just fine while the DNS cache is active. I'm not even *sure* you need to flush it, but it won't hurt.

By the way, for web browsing, a somewhat "nicer" approach to ad-blocking is to use the built-in IE feature of Tracking Protection Lists. You can "get a Tracking Protection List online" and then add EasyList (who also make the most popular block list for AdBlock Plus/AdBlock Edge). Most people don't realize that IE effectively has a built-in ad blocker, and has for a few releases now... Of course, that won't help with ads outside of the browser.
Ah, very interesting. Thanks for the feedback.
The Following User Says Thank You to C-Lang For This Useful Post: [ Click to Expand ]
 
nazoraios
Old
#4  
Junior Member
Thanks Meter 5
Posts: 23
Join Date: Jun 2013
Good tip...

I used the same method as I do on the desktop, I go to :
http://winhelp2002.mvps.org/hosts.htm

Scroll down to folder icon and where it says download, tap and hold or right click and save to local disk.
Then extract and right click or tap and hold the mvps.bat file and run as admin and your done.

It makes a backup of your original hosts file as HOST.MVP.

I have never noticed windows defender 'undoing' this unless it just removes a few entries within it.
The Following 2 Users Say Thank You to nazoraios For This Useful Post: [ Click to Expand ]
 
waraukaeru
Old
#5  
waraukaeru's Avatar
Junior Member
Thanks Meter 1
Posts: 24
Join Date: Mar 2012
Quote:
Originally Posted by nazoraios View Post
Good tip...

I used the same method as I do on the desktop, I go to :
http://winhelp2002.mvps.org/hosts.htm

Scroll down to folder icon and where it says download, tap and hold or right click and save to local disk.
Then extract and right click or tap and hold the mvps.bat file and run as admin and your done.

It makes a backup of your original hosts file as HOST.MVP.

I have never noticed windows defender 'undoing' this unless it just removes a few entries within it.
In MVPS's specific instructions for Windows 8 they tell you to make an exception in Windows Defender because it will block it.
 
nazoraios
Old
#6  
Junior Member
Thanks Meter 5
Posts: 23
Join Date: Jun 2013
Quote:
Originally Posted by waraukaeru View Post
In MVPS's specific instructions for Windows 8 they tell you to make an exception in Windows Defender because it will block it.
Yes.. interesting. My ad blocking worked fine but i bet they did unblock a series of domains that they deem 'necessary' for windows8.

Thanks for the windows defender tip... i'll have to start using that as well.
 
waraukaeru
Old
(Last edited by waraukaeru; 4th February 2014 at 08:42 AM.)
#7  
waraukaeru's Avatar
Junior Member
Thanks Meter 1
Posts: 24
Join Date: Mar 2012
Hey, I have a couple questions for all of you awesome ad-blocking folk. I'm using the MVPS hosts file on my Surface 2 and it seems to be blocking some of the ad content for me when I have tracking protection turned off or when tracking protection is ineffective. So, I assume it is set up properly. When you find an unblocked ad, (for instance, my ad blocking efforts seem effective against the images on Facebook but not the text ads) what is your process for determining the domain/host for the ad and blocking it? Do you always go and edit your hosts file, or do you add the domain to you restricted list in Internet Explorer? Or add it to your custom Tracking Protection list?

My other question is: have any of you have determined the common hosts for the banner ads in Windows Store apps? I noticed the MVPS hosts file doesn't seem to be blocking these hosts.
 
nazoraios
Old
#8  
Junior Member
Thanks Meter 5
Posts: 23
Join Date: Jun 2013
Well since your talking about a web page I would say download fiddler (on an x86 box) and run it in the background while you use your web page. It acts as a proxy so all requests go through it. Then once you find the domains you can add them to HOSTS file.

If you x86 box is Windows 8/8.1 it's a little trickier, you need to use fiddler's 'Windows 8 Config' button to add exceptions to the apps your trying to monitor. I think if you are running IE11 (in protected mode only?) you need to add exceptions for win_ie_ac_??? entries. To monitor apps you can try enabling them all or find your app.

If your talking about on device (RT) you might try running netstat -f in the background but that may only work with desktop IE not running in Enhanced Protected Mode.... if its too much data to read you could redirect to a file to skim through later like netstat -f > temp.txt

Quote:
Originally Posted by waraukaeru View Post
Hey, I have a couple questions for all of you awesome ad-blocking folk. I'm using the MVPS hosts file on my Surface 2 and it seems to be blocking some of the ad content for me when I have tracking protection turned off or when tracking protection is ineffective. So, I assume it is set up properly. When you find an unblocked ad, (for instance, my ad blocking efforts seem effective against the images on Facebook but not the text ads) what is your process for determining the domain/host for the ad and blocking it? Do you always go and edit your hosts file, or do you add the domain to you restricted list in Internet Explorer? Or add it to your custom Tracking Protection list?

My other question is: have any of you have determined the common hosts for the banner ads in Windows Store apps? I noticed the MVPS hosts file doesn't seem to be blocking these hosts.
 
waraukaeru
Old
#9  
waraukaeru's Avatar
Junior Member
Thanks Meter 1
Posts: 24
Join Date: Mar 2012
Quote:
Originally Posted by nazoraios View Post
Well since your talking about a web page I would say download fiddler (on an x86 box) and run it in the background while you use your web page. It acts as a proxy so all requests go through it. Then once you find the domains you can add them to HOSTS file.

If you x86 box is Windows 8/8.1 it's a little trickier, you need to use fiddler's 'Windows 8 Config' button to add exceptions to the apps your trying to monitor. I think if you are running IE11 (in protected mode only?) you need to add exceptions for win_ie_ac_??? entries. To monitor apps you can try enabling them all or find your app.

If your talking about on device (RT) you might try running netstat -f in the background but that may only work with desktop IE not running in Enhanced Protected Mode.... if its too much data to read you could redirect to a file to skim through later like netstat -f > temp.txt
Those are some great ideas; I'm going to try them out. They're all fairly labor intensive... I wonder... do you go to those lengths to block ads? It matters that much to me. Looking at how much work that will be though, I am missing the ease of using Adblock Plus and Ghostery plugins in Firefox.
 
nazoraios
Old
#10  
Junior Member
Thanks Meter 5
Posts: 23
Join Date: Jun 2013
I usually go through those measures to determine which domains to 'unblock' so that I can get a site working with my ad blocking.

I forgot the most obvious method for web stuff, hit F12 in IE, go to network tab, start capturing traffic, load page you want to minitor, and examine results.


Quote:
Originally Posted by waraukaeru View Post
Those are some great ideas; I'm going to try them out. They're all fairly labor intensive... I wonder... do you go to those lengths to block ads? It matters that much to me. Looking at how much work that will be though, I am missing the ease of using Adblock Plus and Ghostery plugins in Firefox.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes