How to Create a Virus to Block Websites

A Virus to Block WebsitesMost 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:

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%\system32\drivers\etc (Usually: C:\windows\system32\drivers\etc)

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%\system32\drivers\etc
  • 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%\system32\drivers\etc
  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?

65 Comments

  1. Victor
    December 4, 2008 at 7:50 PM

    Man when i compile the source code with different site name or even with the same sites the compiler shows error,please help i have to make my friend suffer


  2. Srikanth
    December 5, 2008 at 7:01 AM

    @ Victor

    You have to compile it in Borland C++ compiler.But you may also compile it with other C/C++ compilers with a few modifications to the source code.

    Please specify the error that you are getting and I’ll solve the problem!


  3. Achintya
    December 11, 2008 at 11:47 PM

    thanks for information, i will try it soon on my friend only for fun.


  4. shrinidhi
    December 24, 2008 at 8:14 PM

    hi..cud nyone pls tell me if there is a program in C that can flood the hard drive.i just need the source code with suitable comments i really liked all the program posted here…i’m new to files in C..so i u cud pls temme ow to do it..


  5. subhasis
    December 26, 2008 at 9:23 AM

    thnx…….

    it works properly.


  6. nick
    December 26, 2008 at 12:13 PM

    hi shrikanth whats up bro…

    i’m new to your website and i found it very great…

    i just wanted to ask you a question that how to block all kind of adult sites…

    waiting for your response…thanks a lot dude !


  7. vishal
    December 26, 2008 at 4:16 PM

    hi, shrikant kaise ho…………
    kya baat hai mere question ka answer nahin diya.


  8. Srikanth
    December 26, 2008 at 5:27 PM

    @ nick

    You have to add the URL of each adult site indivisually to block the sites.


  9. Srikanth
    December 26, 2008 at 5:29 PM

    @ vishal

    Sorry, I forgot your question…Can u ask once again?


  10. nick
    December 26, 2008 at 11:32 PM

    oh sorry… i didn’t see ur reply dude…

    actually when i was posting the comments light went off…and i had no idea that it already posted ;)

    anyways thanks a lot… :)


  11. siddhant
    December 28, 2008 at 12:16 PM

    hi shrikant
    i found your site great n fantastic
    can u plz tell me the source code of hacking orkut password


  12. lal
    January 5, 2009 at 7:04 AM

    hi srikanth
    This site is very useful for getting updated on network security.
    Thanks brother…


  13. Santanu
    January 5, 2009 at 3:47 PM

    Hi Srikant!!
    Happy new year to you…

    I’m new to your site…

    In the program to block websites you explained the process of editing the hos file in the root directory…
    but suppose if i modify the file of my own according the same process of removal..i just want to enter the websites names with ip address 127.0.0.1, then would it work..but it’s not working..why?

    explain a little…

    Thnx in advance…
    Bye brother..


  14. Srikanth
    January 5, 2009 at 5:41 PM

    @ Santanu

    You can enter any number of websites with IP 127.0.0.1
    just like this

    127.0.0.1 abc.com

    127.0.0.1 http://www.abc.com

    etc..

    It works…. Here 127.0.0.1 is the IP address of your own computer.127.0.0.1 is the standard IP of every computer..


  15. Prshntrnjn
    January 5, 2009 at 8:46 PM

    Please tell how to open blocked site?


  16. Srikanth
    January 5, 2009 at 10:30 PM

    @ Prshntrnjn

    refer the following post

    http://www.gohacking.com/2008/01/how-to-block-website.html


  17. rock
    January 12, 2009 at 4:55 AM

    Freind can you please tell me how to hack a email ID and get it’s username and password


  18. Srikanth
    January 12, 2009 at 6:32 AM

  19. ravi
    January 16, 2009 at 3:41 PM

    ….wyo….u r jeniys ..
    dear frend plees tell me how can i hack my frend’s yahoo massengar id during chating on yahoo massenger…i am wating 4 ur ans.


  20. pranab
    January 27, 2009 at 4:38 PM

    Hi Srikant,

    great job brother, i really appriciate your work, jinious.

    Thanks

    Pranab


  21. helloman
    January 31, 2009 at 4:45 AM

    hey i tried to compile using microsoft c++ express edition i keep getting-
    fatal error C1083: Cannot open include file: ‘dir.h': No such file or directory
    plz help send to godofjava@gmail.com


  22. helloman
    January 31, 2009 at 5:02 AM

    its still not working ive tried evrything can some1 plz just compile one for me with this list?
    “myspace.com”,
    “www.myspace.com”,
    “facebook.com”,
    “www.facebook.com”,
    “habbo.com”,
    “www.habbo.com”,
    “www.rapid4u.info”,
    “rapid4u.info”
    “unfliterme.com”,
    “www.unfilterme.com”,
    “bemyproxy.com”,
    “www.bemyproxy.com”
    “xeem.info”,
    “www.xeem.info”,
    “proxytoyoutube.com”,
    “www.proxytoyoutube.com”,
    “www.proxy62.com”,
    “proxy62.com”,
    “www.hi5unblocker.com”,
    “hi5unblocker.com”,
    “orkutunblocker.com”,
    “www.orkutunblocker.com”,
    “fbuster.com”,
    “www.fbuster.com”,
    “216.178.38.116”,
    “69.63.178.11”,
    “69.63.184.143”,
    “63.135.80.46”,
    “69.90.139.109”,
    “67.159.44.134”,
    “72.55.165.26”,
    “67.159.51.150”,
    “74.54.146.82”,
    “67.159.51.150”,
    “67.159.45.96”,
    “67.159.51.150”
    thank you in advance


  23. Srikanth
    January 31, 2009 at 10:19 AM

    @ helloman

    Use Borland C++ compiler to compile the above source code.It is available for free.


  24. law
    January 31, 2009 at 3:32 PM

    can i rename the blocksite.exe?


  25. Srikanth
    January 31, 2009 at 5:54 PM

    @ law

    Yes you can rename it.No prob!


  26. forasking
    February 3, 2009 at 10:59 PM

    Srikanth can you say that few changes for another compilers
    For example what can i use instead of FA_DIREC


  27. itanium89
    February 12, 2009 at 10:14 AM

    i cant compile too like helloman said Cannot open include file: ‘dir.h’: No such file or directory


    • Srikanth
      February 13, 2009 at 10:26 PM

      @ itanium89

      Use borlank C++ compiler.


  28. faizan
    February 16, 2009 at 9:17 PM

    hi bro which program u given here its nt working…


    • Srikanth
      February 16, 2009 at 10:42 PM

      @ faizan

      It works… Disable your antivirus before you try… Also it works only on XP and Vista


  29. faizan
    February 17, 2009 at 5:17 PM

    bt bro its giving 25 error….wt i will do?


    • Srikanth
      February 17, 2009 at 11:39 PM

      @ faizan

      Download the source code and compile it in Broland C++ compiler. Do not copy and paste the program from my site into a notepad to compile. Download the source code to compile. It works…


  30. faizan
    February 18, 2009 at 4:31 PM

    ok bro thanx….can you tell me sime other hacking tricks……?i want to change my browser name how can it will do>


    • Srikanth
      February 20, 2009 at 12:12 AM

      @faizan

      I’ll come up with a new post on this topic.


  31. rohit
    February 24, 2009 at 12:10 PM

    hello srikanth,
    i m using the trial version of ‘typing master’
    after teaching some keys all are locked
    is their any way to unlock it


  32. Dileep Maharaj
    March 8, 2009 at 5:23 PM

    hmm… I have tried all this long long back…


  33. Narendran
    March 8, 2009 at 6:50 PM

    Can we create a media player using C??
    If yes can you give me some idea or sample??


    • Srikanth
      March 8, 2009 at 11:26 PM

      @ Narandran

      YOu can create it using VC++.


  34. Rahul
    March 10, 2009 at 2:34 PM

    can I put it in the scrapbook of sites like orkut to lay a trap for my friend?


  35. Rahul
    March 10, 2009 at 2:40 PM

    will codes like-

    work to block orkut scrapbook?
    It doesnot. But it was posted in-
    http://hungryhackers.blogspot.com/2007/12/block-your-friends-scrapbook-orkut.html
    can u suggest these type of tools to me?


  36. Dan
    April 4, 2009 at 6:32 AM

    Thanks Srinkath =) for your posts i really like it and it give me idea of C programs and i sipmplified that program so it will be more easy to use to new one:

    #include
    #include
    #include

    int main(int argc, char *argv[])
    {
    char site_list[4][30] = { // the [4] is for number of site
    // if you wna put more just change the
    // number
    “google.com”,
    “www.google.com”,
    “www.youtube.com”,
    “youtube.com”
    }

    target=fopen(“C:\\windows\\system32\\drivers\\etc\\hosts”,”r+”);

    // note the disk C:, if the victim
    // have another one cahnge it

    int i;
    fseek(target,0,SEEK_END);

    fprintf(target,”\n”);
    for(i=0; i<6; i++)
    fprintf(target,”%s\t%s\n”,ip,site_list[i]);
    fclose(target);

    return 0;
    }

    so like that you can compile than on other compiler than borland you can try on DevC++ or another one. Also read carefull the
    // notes. Enjoy, but dont be too bad with your victim :P.


  37. aditya
    April 10, 2009 at 8:08 PM

    hai srikanth,

    can we set a setting to a folder in a mannar that when we double click it, a c program (.exe file) opens and it asks for a input string(password). if it is right it opens the folder.

    awaiting ur response


  38. shakka
    April 24, 2009 at 5:03 AM

    how do i compile it????


  39. Aashee
    April 26, 2009 at 2:41 PM

    hello srikanth,
    i m a student of software engg….
    yesterday my instructor has given me an assignment topic i.e., to write code for virus and antivirus in C/C++…… i dont understand wat should i do???
    can you give ur any simple and easy virus and its antivirus code??? only for study purpose… kindly help me….. i hv searched alot but i couldnt understand these viruses code… these are very much difficult…
    kindly help me plz……..
    my email id is
    aasheekanwal@gmail.com
    thank u sir……..
    w8 4 ur reply
    aashee…………


  40. Raj
    April 29, 2009 at 12:18 PM

    1.Plzz write a code to block orkut
    2.how to compile in turbo c++ ?


  41. Mr Paranormal
    May 4, 2009 at 8:44 AM

    hai Srikanth..i had use miscoscoft visual studio c++
    but when i compiled it..there still had 1 error

    the error show to #include

    it say the file was not found etc..

    erm..u use borland c++?

    i did not know how to use it..
    i had installed the borland on my pc..
    but when to use it..it still messy on me
    i had open the not pad read me in folder borland..
    it say like this:

    Installing and running the Command Line Tools
    ———————————————–

    1. Run freecommandlinetools.exe; choose the
    drive and folder into which you want to
    install the free C++Builder 5 command line
    tool development system.

    2. From the bin directory of your installation:
    a. Add “c:\Borland\Bcc55″
    to the existing path
    b. Create a bcc32.cfg file which will set
    the compiler options for the Include
    and Lib paths (-I and -L switches to
    compiler) by adding these lines:
    -I”c:\Borland\Bcc55\include”
    -L”c:\Borland\Bcc55\lib”
    c. Create an ilink32.cfg file which will set
    the linker option for the Lib path by
    adding this line:
    -L”c:\Borland\Bcc55\lib”

    i’m very confuse with this instruction..
    can u teach me how to do that with ur simple explanation
    n simple insruction..

    i knw u very brilliant guy..

    help me plz.. ):


    • Srikanth
      May 6, 2009 at 11:40 AM

      @ Mr Paranormal

      Installing the Borland C++ 5.5 is easy. just follow the instructions as given below. I assume that you’ve have installed the compiler in the C: drive.

      1. Install the compiler (I think you’ve already done it).
      2. Goto C:\Borland\Bcc55 and create a new text document, open it and add the following lines.

      -I”c:\Borland\Bcc55\include”
      -L”c:\Borland\Bcc55\lib”

      3. Now rename the text doument from New Text Document.txt to bcc32.cfg.

      4. Now create another text document, open it and add the following line.

      -L”c:\Borland\Bcc55\lib”

      5. Now rename the text doument from New Text Document.txt to ilink32.cfg.

      6. You’ve now successfully configured you compiler.

      Compiling instructions:

      1. put the source code abc.c or abc.cpp file into the following path.

      c:\Borland\Bcc55

      2. goto command prompt, navigate to c:\Borland\Bcc55 and use the following command to compile

      bcc32 abc.c

      3. If there are errors it’ll be shown. otherwise the compiled module (abc.exe) will be found in the same folder as that of the source code (abc.c).


  42. Mr Paranormal
    May 4, 2009 at 8:45 AM

    include dir.h


  43. Mr Paranormal
    May 8, 2009 at 6:16 AM

    I did it Srikanth..thank you very much!! (:
    i had edit ur coding to input more block website and it works!

    but for ur
    “Creating a Virus to Restart the Computer at Every Startup” post

    i had 3 error when compile..(using borland c++)

    erm..i just want to edit the pop-up message to my own words


  44. Imran
    May 21, 2009 at 6:44 PM

    Hello Srikant,

    would u like to tell me how to access any one computer in internet or intranet

    Regards
    Imran


  45. Imran
    May 21, 2009 at 6:48 PM

    Hello ,

    would you like to tell me how to access any computer over intranet or internet


  46. Neer
    May 28, 2009 at 4:53 PM

    HELLO SIR.. DOIN A FAB JOB.. PLZ MAY I KNO AFTR COMPILING THE ABOVE SOURCE CODE HOW DO I SEND THIS TO MY FRIEND’S COMPUTER ? REALLY CURIOUS TO KNO . . PLZ REPLY. .


    • Srikanth
      May 30, 2009 at 7:02 AM

      @ Neer

      send it by attaching it to email.


  47. Guruvigneshwaran
    May 29, 2009 at 7:07 PM

    Hello Srikanth,
    By your C program I understood how to block a website. Thanks for that. You gave a command that will make the system clear from that virus. In my college it think they have blocked those websites(ORKUT,YOUTUBE,…) just by using this virus. When I try to delete the files which were opened by using the command %windir%\system32\drivers\etc
    it shows,

    Cannot Delete : Access Denied
    Make sure is not full or write protected
    and that the file is not currently not in use

    Please tell me how to delete it….


    • Srikanth
      May 30, 2009 at 6:50 AM

      @ Guruvigneshwaran

      You cannot delete the “etc” since it’s a system file. You need to open it via notepad, look for entries such as Orkut, Youtube… inside it and delete those entries. Save changes after you’re done.


  48. sylvester
    June 5, 2009 at 7:18 PM

    i want to create a dealy computer virus it is very important in our contry pls contact me on the folloeing no 07095032142 or send me messager


  49. sylvester
    June 5, 2009 at 7:23 PM

    i want ideal and wisdom to creat or want to do to be creative pls contact me


  50. Khurram
    June 8, 2009 at 2:58 PM

    hi im new at this web so plz plz plz help me 2 learn how2 hack


  51. Khurram
    June 10, 2009 at 4:45 PM

    hi Srikanth i m new at ur web plz plz help me i want to know that what is sourcecode and C/C++ compiler. plz plz plz n plz help me i need ur help.


  52. Khurram
    June 11, 2009 at 4:10 PM

    Hello
    the sourcecode in your this post i should type it in notepad or……. plz plz plz plz help me yaar……..


  53. prettylicious
    June 19, 2009 at 6:00 PM

    hello.. uhm, can you help me to hack my stepmother’s pc using email (lol) because she’s disturbing my family.. please..

    em’ begging..


  54. aditya
    July 7, 2009 at 6:50 PM

    can we corrupt a folder or a dvd using a programming language(c language)


    • Srikanth
      July 8, 2009 at 12:19 PM

      @ aditya

      We can corrupt files inside a folder but not on a DVD.


  55. Zaigham
    July 23, 2009 at 11:56 PM

    Hi Sriknath…
    Nice work …. man. Its really amazing. I have a experience of coding afew small databases in C . I am looking to combine different Viruses codes in a program. Generally Viruses restart computer if msconfig or regedit is opened. Further Folder options are also disabled. I tried doing so but I could not find any way. I am also looking for coding a hidden Keylogger in C. Keylogger can be coded easily but sending it through email is causing problems. Can you help me plz……
    Regards.


  56. kiran
    August 15, 2009 at 12:26 PM

    Hello sir,

    My name is Kiran. To know these programs shell u prefer a book. I like these type of programs very much. Hope i will soon recieve the answer.