Bfilter is a proxy server used to block advertisements. It is available under the GPL, cross platform (Windows, Linux, OSX), can be used with any browser, and can be run from a flash drive (think portable). In addition you can import the Adblock Plus (Firefox extension) “blacklist” via a pearl script.
BFilter is a filtering web proxy. It was originally intended for removing banner ads only, but since then its capabilities have been greatly extended. Unlike most of the similar tools, it doesn’t rely on blacklists (although it does support them). The problem with blacklists is that advertisers are always one step ahead. You see an ad slip through, you update your blacklist, and in case it didn’t help, you add a new entry yourself. Once I got tired of that, I decided to write a proxy that would detect ads heuristically, much like modern anti-virus software manages to detect many viruses unknown to it.
Install Bfilter
Bfilter can be run in two ways, as a service (started in /etc/init.d/bfilter) or as a GUI (graphical user interface).
- Ubuntu – bfilter is in the repositories – install either bfilter (service, no gui) or bfilter-gui (gui) but NOT Both !!!
- Other distros (Fedora) you will need to either compile bfilter or use the bfilter-gui which is available as an “Autopackage” (See the Bfilter Downloads page). Run the Autopackage on the command line (does not work when launched from a gui).
- Windows – Obtain it from the Bfilter Downloads page. To run portable, download from here.
Using bfilter
Start bfilter
- As a service (bfilter) – bfilter starts on boot. You can start or stop it manually with
# Ubuntu
sudo /etc/init.d/bfilter start|stop|restart
# Fedora
su -c ‘service bfilter start|stop|restart’ - As a gui -
- Windows – run (double click) the bfilter.exe .
- Linux – You will find it easier to write a (short) script to autostart bfilter-gui when you log in. Save this script in ~/bin/bfilter-gui :
#!/bin/bash
sleep 10
nohup /usr/bin/bfilter-gui > /dev/null &Make it executable:
chmod a+x ~/bin/bfilter-gui
Now add to your autolauncher, go to Settings -> Sessions and Startup
Add an entry:
name: bfilter-gui
command: /home/you/bin/bfilter-gui

Configure your browser
One advantage of bfilter, it will work with any browser. The menus will vary with your browser, and on Windows you may need to edit your network configuration.
-
Friefox -
- Open your options, navigate to the Advanced tab
- Select the “network” tab and hit the settings button.

- In the dialog box, set your proxy to 127.0.0.1 port 8080

- Windows users –
- In your control panel, open your “Internet Options” , select the “connections” tab.

- Hit the “LAN Settings” button and insert your proxy settings 127.0.0.1 port 8080

- In your control panel, open your “Internet Options” , select the “connections” tab.
That is all there is to it, no need to re-boot or re-start your browser.
Power Tweaks
Import the Adblock Plus (Firefox extension) “blacklist”
This is not necessary as bfilter does just fine on it’s own. If you find there are some ads not blocked, you can try to add the Adblock Plus filter list.
See This Link for the original scripts. I modified them (fixed the paths and files, fixed the perl script with dos2unix) and re-posted them below.
Save this first one in /usr/local/bin/adblock2bfilter.pl
And the second one in /usr/local/bin/bfilterUpdateLists.sh
Make them executable :
sudo chmod a+x /usr/local/bin/*
Note: On the origional page there is a link to a windows script, but I used the above scripts on Linux, converted with tofrodos, and saved the urls.local to my flash drive. If you wish here is a link to a urls.local you may use on Windows (Note: the list in that link is unmaintained).
To use the script simply:
sudo /usr/local/bin/bfilterUpdateLists.sh
This will update your list in /etc/bfilter/urls.local
To use the list with the service, simply restart bfilter.
To use the list with bfilter-gui, copy
sudo cp /etc/bfilter/urls.local /home/your_user/.bfilter/urls.local
sudo chown you:you /home/your_user/.bfilter/urls.local
Then quit and restart the bfilter-gui
Use a cache for bfilter
- bfilter-gui uses a cache automatically.
- Linux it is located in ~/.bfilter/cache .
- Windows it is in Program Files\BFilter\Cache
- If you are using bfilter as a service you will need to make a (small) edit to /etc/init.d/bfilter. Using any editor, add “-C /tmp/bfilter” to /etc/init.d/bfilter on the “DAEMON_OPTS” line. It looks like this:
# All one line:
DAEMON_OPTS=”-u nobody -g nogroup -p /var/run/bfilter.pid -C /tmp/bfilter $DAEMON_OPTS”
Use bfilter as a proxy server on your LAN
This is easy to do if you are running bfilter as a service.
Using any editor, open /etc/bfilter/config
Under the [global] section, at the top of the page, edit the “listen_address” line, use your ip address rather then 127.0.0.1
listen_address = 192.168.0.10:8080
You may wish to change the default port and firewall the connection.
Additional options are explained in the configuration file.
The advantage of running bfilter this way is that you then only need to maintain one set of config files for all clients on your LAN.
Assuming your LAN is 192.168.0.0/24 any your bfilter server is 192.168.0.10 , you can firewall the connection with ufw
sudo ufw enable
sudo ufw default deny
sudo ufw allow from 192.168.0.0/24 to 192.168.0.10 port 8080
Haha ok now all you need is an AppArmor profile for the daemon and the fetcher scripts ;-)
But I’m serious! This is a good candidate for confinement.
jdong: done -
http://bodhizazen.net/aa-profiles/bodhizazen/ubuntu-9.04/usr.bin.bfilter
Of if you prefer the gui :
http://bodhizazen.net/aa-profiles/bodhizazen/ubuntu-8.04/usr.bin.bfilter-gui
The following command is not necessary.
sudo chown you:you /home/your_user/.bfilter/urls.local
Because if you copy the urls.local as a regular user, you’ll get a copy under the ownership of the user that issues the cp
cp /etc/bfilter/urls.local /home/your_user/.bfilter/urls.local
You can then write the cp and also add in kill and invoke bfilter-gui commands into one script.
Thanks for your scripts.
No, but it is necessary if you are setting up multiple users (which is why I included the information).
sadly this project seems to be down
cant install it with ubuntu lucid, not in repo and debian packages failed to install due to conflicts with libboost-program, even launchpad branch is outdated
remus: Sad but true, bfilter was removed from the Ubuntu (Lucid) repository.
The bfilter home page is here :
http://bfilter.sourceforge.net/
Use the “autopackage”
http://prdownloads.sourceforge.net/bfilter/bfilter-gui-1.1.4.x86.package?download
The autopackage is gui only.
wget http://prdownloads.sourceforge.net/bfilter/bfilter-gui-1.1.4.x86.package?download
chmod a+x bfilter-gui-1.1.4.x86.package
sudo ./bfilter-gui-1.1.4.x86.package
Answer Y to downloading and installing.
Your other option would be to convert to an alternate proxy, I suggest you consider Privoxy.
Privoxy is in the Ubuntu repos and includes adblocking.