How to Develop Computer Virus using C?


Computer virus is simply is a malware program which when executed causes some harmful activity on the computer by infecting it. Such virus may be responsible for stealing hard disc space, accessing private data, corrupting information etc. depending up on the type of the malware.

Creating a computer virus is easy, and in this post, I am going to take you through how to develop computer virus using C programming language. Please, use the programs presented here for study purpose only.

To create computer virus using C, you need a good knowledge of C language, and a tricky mind to understand how the virus will infect your computer. The virus programs presented in this post are all different, and each of them infect your computer differently as they have different functions.

The source code which when executed creates a copy of itself in all the other files that are present in the same directory. These virus generally tend to form a network, and easily spread all over the computer.

CAUTION: The source code to develop computer virus presented here are for study purpose only. I suggest you to understand and analyze these programs, but not run them in your computer. Some of these may delete files in your computer, while other may change your computer’s configurations or even remove your system completely.

1. Develop Computer Virus using C to Destroy Files:

How to Develop Computer Virus using C

The source code of this virus is written and compiled in Turbo C. Before going through the source code of the virus, I would like to put forward the algorithm for this virus. It works following the major four steps given below.

  1. First of all, the virus is supposed to look for the files in the current directory. If there are more than one files, it loads the first file which is considered as target file.
  2. Now the copy of the virus is loaded into memory.
  3. After that, the target file is opened and the virus is copied from the memory. After copping the code in the target file, the target file is closed.
  4. Finally, the next file to be infected is loaded and step-3 is repeated.

How to Test this Virus?

Testing this virus normally may infect your computer. So, in order to test this virus program, you are recommended to follow the following steps:

  • Make a new empty folder in your computer.
  • Then, copy some executable files or any kind of files in that folder.
  • Run the application or .exe file of the virus. Within a few seconds, all the other files in that folder get infected.
  • After that, each file in that folder is a virus which can be used to re-infect.

2. Create Computer Virus using C to Restart Computer:

This virus is so simple to create. The only thing you need to know is how to approach the setting menu of your computer. The source code is short. The first line is to reach the setting menu of your system and the second line to shut it down.

It is not so harmful to test this virus on your computer. Save and close all the important programs and run .exe file of this program; it will restart your system. The source code has been compiled in Code::Blocks  using GCC compiler.

If you want to develop this computer virus using C source code compiled in Turbo C, run the .exe file of the code below after compiling it in Turbo C. It will restart your computer after some time.

 3. Develop Computer Virus using C to Jam Hard Disk:

The virus has can jam your hard disk, so do not run it. The source code is such that it will make a self growing file in your computer which grows to a few MB, and may continue infinitely. Here’s the code for this virus.

I hope this tutorial on “How to Develop Computer Virus using C” was useful to you. Again, the source codes here are for academic purpose only. Do not misuse them by spreading to any computer. We can’t be held responsible for that.

Your queries, feedbacks and suggestions regarding this tutorial can be mentioned in the comments section. Also, if you have a different computer virus C source code, share it in the comments.



Please enter your comment!
Please enter your name here