If you have a jailbroken iPhone or iPod Touch, it is quite simple to block many advertisement sites from being displayed either in your Safari browser, or in various apps which may have a small section on the screen reserved for littering annoying and flashing ads. This is done by updating your device’s hosts file as described on the “Blocking Unwanted Parasites with a Hosts File” site.
Your device is just like a tiny computer, running the Linux OS (Darwin). And just like other Linux and UNIX operating systems, it contains a
In order to change this file, you need to ssh from a computer to your iPhone or iPod Touch. This requires sshd to be installed on your devices, which you can easily download and install from Cydia.
For instance say your device’s IP is 192.168.0.22, you log on like this:
$ ssh 192.168.0.22 -l root firstname.lastname@example.org's password: myipod:~ root# cd /etc myipod:/etc root# vim hosts
Snippet of hosts file:
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost #start of lines added by WinHelp2002 # [Misc A - Z] 127.0.0.1 fr.a2dfp.net 127.0.0.1 m.fr.a2dfp.net 127.0.0.1 ad.a8.net 127.0.0.1 asy.a8ww.net 127.0.0.1 abcstats.com 127.0.0.1 a.abv.bg 127.0.0.1 adserver.abv.bg 127.0.0.1 adv.abv.bg 127.0.0.1 bimg.abv.bg . . . 127.0.0.1 www.stickylogic.com 127.0.0.1 www.winadiscount.com #[Dr.Web.Adware.Xbarre] 127.0.0.1 www.winaproduct.com #end of lines added by WinHelp2002
The default root password is “alpine” but with the passwd command you can change it.
Once you are logged on to the device, you can use vim or any other text editor (install via Cydia) to modify the hosts file. You can download one from http://winhelp2002.mvps.org/hosts.htm or make up your own. Then copy/paste it into the hosts file you have open on the device and save it.
Make sure at least the following lines are in the hosts file, otherwise bad things may happen:
127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost