The most easy way to block advertisements and other malware sites is to point those site to ip address 127.0.0.1 or 0.0.0.0 (zero version is not supported by all systems) in your hosts file.
There are sites which provides the list of the sites names which are responsible to displaying the ads or spreading the malware so, download the list of those sites and put it into your hosts file and restart your system.
For Windows 9x and ME place this file at “C:\Windows\hosts”
For NT, Win2K and XP use “C:\windows\system32\drivers\etc\hosts” or Linux, /etc/hosts”.
This is an easy and effective way to protect you from many types of spy-ware, reduces bandwidth use, blocks certain pop-up traps, prevents user tracking by way of “web bugs” embedded in Spam, provides partial protection to browsers from certain web-based exploits and blocks most advertising you would otherwise be subjected to on the Internet.
One of the advantages from this modification is that your web surfing experience would be significantly faster because your browser does not have to wait for the annoying advertisement to load.