March 29, 2011

In this post I’m going to show you how to block any websites in computer..

DISCLAIMER: THIS POST IS EDUCATIONAL PURPOSE ONLY. DON’T FLAME ME FOR MISUSE OF THE CODE, AND USE IT ON YOUR OWN RISK.
There are many reasons why you need to know how to block a website. Some of the most common reasons are you have been targeted by spammers who use adware and popup to attack your PC. Other reasons may be to prevent user from having access to certain site.

Save the code as block_site.c and open it and compile it by Ctrl+F9. It will create a exe.
Now right click on that exe and open it with run as administrator.
Now the program will ask to enter the web site name to be block.
Enter the site name like www.site.com and press enter program will say www.site.com is blocked.

Code Analysis:
There is manual way of doing this trick
Go to C:\Windows\System32\Drivers\Etc and find the file “hosts”. Open hosts file in Notepad.
In hosts file go at the end and add the sites you want to block
Example :127.0.0.1 www.site.com
Save the file and exitHosts file description
Restart your browser and try to open the site, changes will take place immediately.
This is what we are doing with above c program..

To unblock site:
To unblock sites follow the manual way and open the hosts file in notepad and delete last lines
That 127.0.0.1 www.site.com and save.

You might cannot modify the hosts file because of windows file permission issue, thenRight click on hosts files > properties > security > and to change permissions click edit then select user and check full control box and save now again open the hosts file and modify.

Note:the reason we are running program exe in run as administrator mode is because the windows file permission issue. Normal user doesn’t have full access to the system files that we can’t write anything into the file.

Hope you like the post, express your feelings about post by comments... :)