After a couple of hours of tinkering around with the new Rad Studio XE from the guys at Embarcadero, I finally came up with this “Facebook Blocker” tool. Initially designed as an instrument to play an April Fool’s prank on a couple of Facebook addicts, I suddenly realised that it could prove useful to a lot of people that would rather keep their “underlings” away from whatever guys are lurking on Facebook.

IMG ACB5F6 D297B7 F81C4C 72ED42 7165DA 8AC39A

To keep the story short, this utility can block Facebook with only one click and the block will stay there regardless of whether the tool is still open or not. I have achieved this by modifying the hosts file to send all the requests to facebook.com and www.facebook.com to 127.0.0.1. When the entry has been added to the hosts file, an “ipconfig /flushdns” command will be issued and the block will be effective immediately.

Well, if your antivirus happens to pop up like crazy with virus warnings and stuff, rest assured you’re safe. The warnings are caused by an external file trying to modify the hosts file, an approach that is also used by viruses to hijack your traffic. If you don’t want to go past that step, I don’t blame you, but I can also throw in the source code of the app, if that makes you feel safer.

Some final words before getting ready to cross Facebook off your list of allowed websites: since I was too lazy to write elevation code, if you happen to run Vista or Windows 7 with UAC turned on, make sure that you run this application as administrator (right-click on it, then select “Run as administrator”), because it won’t be able to edit the hosts file otherwise.

Last, if you have any questions about the tool, feel free to drop me some lines via the contact form below.