Source: http://feeds.feedburner.com/~r/gizmodo/full/~3/415172853/how-to-block-ads-on-your-jailbroken-iphone
It's always a kick in the nuts waiting for a page to load in mobile Safari when you know like half of it is for an ad. Luckily, there's a way to block most of them using this method from James Is Bored. It requires a jailbroken iPhone and bit of voodoo, but it's not overly complicated. Once you've got a jailbroken iPhone, you need to install OpenSSH from Cydia. And that's where the work starts.
After your phone restarts, head to Settings>Wi-Fi and hit the arrow next to your home Wi-Fi server. Write down the IP address you see. Then pop back to general settings and set auto-lock to never. On your computer, download this replacement hosts.php file.
Then, using an FTP client like FileZilla or Cyberduck with SFTP (secure SSH connection over FTP), open an SFTP connection with your iPhone's IP address as the host. U/P is root and alpine. The connection will take a bit, and might fail a few times, but say yes to any prompts and keep trying.
At your iPhone's root, navigate to the /etc folder and move the hosts.php file there somewhere on your computer for safe-keeping (don't lose it!). Then replace it with the one you downloaded and restart your iPhone. Now you'll start seeing glorious blank spots or compressed frames wherever ads used to be. It'll nuke ads at most sites serving them through a third-party server. That wasn't so bad was it? The method will work on iPod touches too. Let us know how it goes. [James Is Bored via Lifehacker]