The Tech Diary of an IT support geek

  • Home
  • Android
  • iOS
  • Mobile
  • PC
  • Tips
  • Contact US
Home » How to Create a Program to Block Websites?

How to Create a Program to Block Websites?

Most of us are familiar with the virus that used to block Orkut and Youtube websites. If you are curious about creating such a virus on your own, here is how it can be done.

As usual I am using my favorite programming language ‘C’ to create this website blocking virus. I will give a brief introduction about this virus before I jump into the technical jargon.

This virus has been exclusively created in ‘C’. So, anyone with a basic knowledge of ‘C’ will be able to understand the working of this virus program. When this program is executed, it will block all those websites that are listed in the source code. In the following example, the sites that are listed in the source code are Google, Yahoo and Youtube. When you download the source code of this program, you have a choice to include your own list of sites that you want this virus to block.

I have just removed the source code of this program from this post as it is lengthy and makes the post look messy. You can still download the source code of this virus program from the following link:

Download Block_Site.rar [download id=”240″]

How Virus Program Works?

The Windows operating system maintains a special file called HOSTS which can be used to block any given hostname or domain name (website) by adding new entries onto it. This program works by modifying the HOSTS file by adding new entries of those sites that are intended to be blocked. The HOSTS file is located at:

%windir%system32driversetc (Usually: C:windowssystem32driversetc)

ALSO READ
How To Externally Get Data Off An Old Hard Drive,?

So, when you execute this program, all it does is add the entries of the list of those sites (mentioned in the source code) to this HOSTS file. Once this is done, the site will be blocked from your computer. So, none of the browsers would be able to load those sites on your computer.

For more information on HOSTS file, I recommend reading my other post on How to use HOSTS file to block websites.

Now, as far as the technical part of this program is concerned, people who have a working knowledge of ‘C’ should be easily able to understand the working of this virus program. However, for those who are new to ‘C’ programming, here is the algorithm of this program:

  • Determine the Root drive. ie: Find the drive (C:, D:, E: or F:) on which the Windows is installed.
  • Navigate to: %windir%system32driversetc
  • Open/Load the HOSTS file.
  • Copy a list of those websites that are mentioned in the ARRAY to the END of the file.
  • Save the file and Exit.

How to Compile the Source Code?

For a step-by-step compilation guide, refer my post: How to compile C Programs?

Testing the Virus:

  1. To test, run the compiled module. It will block the sites that are listed in the source code.
  2. Once you run the file block_Site.exe, restart your browser program. Then, type the URL of the blocked site and you’ll see the browser showing error “Page cannot displayed“.
  3. To remove the virus type the following command in the Run.

    %windir%system32driversetc

  4. There, open the file named “hosts” using the notepad. At the bottom of the opened file you’ll see something like this:

    127.0.0.1 google.com

  5. Delete all such entries which contain the names of blocked sites.

NOTE: You can also change the ICON of the virus to make it look like a legitimate program. This method is described in the post: How to Change the ICON of an EXE file?

  • Facebook
  • Twitter
  • LinkedIn
  • WhatsApp
  • Reddit

Related

Posted by Obasi Miracle on this date: Leave a Comment Tagged With: Computer
Shortlink:

Sign Up in Seconds

Join us to get latest posts (ONLY) delivered to your inbox. No Spam, We Promise!

About Obasi Miracle

I am a dedicated web developer with interest in blogging and app development. I have lots of buddies and always ready to connect with like-minded pals - See more about me.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Next PostBlock or Redirect Unwanted Websites Using HOSTS File?
Previous PostHow to Change the ICON of an EXECUTABLE file?

RSS Inside: 3rd Planet Techies

  • Lasta Fasting App Review: Can It Help You Reach Your Health Goals?
  • How To Create Amazing Websites with WordPress Elementor Themes
  • How to Save Snapchat Videos in HD: A Complete Guide
  • 4 Unbeatable Reasons To Invest In Digital Signage

Sign Up in Seconds

Join us to get latest posts (ONLY) delivered to your inbox. No Spam, We Promise!


Recent Posts

  • Full List Of Cars With An S Logo [3ptechies]
  • Factors to Consider When Searching for the Best Mobile Phone Plans
  • Do Battery Savers Work? Can They Really Extend Battery Life?
  • Why Does Phone Keep Turning Off Itself and 9 Ways to Fix It

Looking For?

mtn cheat for android, how to transfer data on etisalat, how to share data on airtel, How to share data on etisalat, mtn free browsing cheat for android phones, how to transfer mb on etisalat, mtn mb cheat for android, mtn free browsing on android, how to transfer data on airtel, latest mtn cheat for android, mtn free browsing cheat codes with unlimited data downloads, how to share airtel data, mtn cheat code for android, best airtel tariff plan for browsing, 2go for windows phone, sharemobile ro, how to transfer etisalat data, mtn cheats for android, etisalat data transfer, airtel data share
© 2022. The Tech Diary of an IT support geek. Privacy Policy