Step-By-Step Guide to Block Ads on your iPhone

BY Jason

Published 10 Oct 2008

If you find advertisements on websites annoying (including the ones here on iPhone Hacks); then on your computer you can always use browser add-ons like Adblock to prevent page elements such as advertisements from being downloaded and displayed.

However, there was no way to block advertisements in iPhone’s Safari browser. Not any more, as James over at James is Bored has figured out a way to block ads even in your iPhone’s Safari browser.

You can checkout the step-by-step guide to block ads on your jailbroken iPhone after the jump.

Before we can start, please note that you need to jailbreak your iPhone.

It goes without saying that hacking your iPhone is at your own risk, please take a backup of your iPhone.

Please follow the step-by-step guide to block ads on your jailbroken iPhone:

  1. You need to be able to transfer files to your iPhone, so you can either install OpenSSH application using Cydia or use iPhone software like iPhoneBrowser (for Windows).
  2. Then go to Settings -> Wi-Fi, click on arrow next to the Wi-Fi server you are currently using on your iPhone and write down the IP address.
  3. If you are not using iPhone software like iPhoneBrowser to transfer files from your computer to your iPhone and vice versa, then you will need and FTP client with SFTP (secure SSH connection over FTP). Windows users can try FileZilla while Mac users can use Cyderduck.
  4. Download the replacement host file from this link. (Please note that the host file downloaded from this link will also disable Apple’s kill-switch mechanism to deactivate iPhone apps). Note: If you want to use the Categories App, then please remove the 127.0.0.1 mm.admob.com line from the downloaded replacement host file, otherwise mentioned by reader, Zai, it will not work. If you don’t want to disable Apple’s kill-switch mechanism then remove this line as well 127.0.0.1 iphone-services.apple.com from the replacement host file.
  5. Open your FTP client, set it to connect over an SFTP connection, and then put your iPhone’s IP address (the one your had written down in step 2) in the "host" section. The username and password (unless you changed them) are root and alpine, respectively. The connection may take a few minutes at first, and you may be asked to accept a host key; say yes to any prompts. In case the connection fails try again.
  6. Take a backup of the host file on your iPhone before you override the host file. You will find it in /etc folder at your iPhone’s root directory.
  7. After taking the backup, replace the host file on your iPhone with the replacement host file you had downloaded in step 4.
  8. Close your FTP client and restart your iPhone.

After restarting your iPhone, you should start seeing blank spaces or compressed frames instead of advertisements.

If you open the replacement host file using a text editor, you will figure out that the trick behind this iPhone hack similar to the method used by iPhone Expert Zdziarski to block Apple’s kill-switch mechanism to deactivate iPhone apps. You are basically mapping the IP address of most of the ad servers to localhost (127.0.0.1) in the host file.

This hack also seems to block ads in iPhone apps that use any of the ad servers that are mapped to localhost.

You can see the screen shot of the iPhone Hacks website before the Adblock hack below:


iPhone Hacks Before Blocking Ads

And the screen shot of the iPhone Hacks website after the Adblock hack below:


iPhone Hacks After Blocking Ads

If you observe any issues or want to revert the hack, simply copy the backed up host file back to your iPhone’s /etc folder and restart it.

Hope this makes readers who were complaining about the ads on iPhone Hacks happy. As always, let us know how it goes.

[James is Bored via Lifehacker]




Follow this blog

 

Top iPhone Hacks Categories:

Hacks
iPhone Applications
Unlock iPhone
JailBreak iPhone
iPhone Tips & Tricks
iPhone Games
iPhone News