This type of antivirus program are followed by
many antivirus companies .However there program better then this.This
program is only example of antivirus making using c++.
The main logic followed is the matching of characters(signatures) of infected file from virus database provided by company.
1st) Write VIRUSACTIV on notepad and save it as vdt.dat in TCC. -(this will be your virus database)
2nd) Write VIRUSACTIV on notepad and save it as inf.dat in TCC.-(filename to be search)
3rd) Copy below code and run it.--by this u will learn how antivirus worked.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
void main()
{ clrscr();
ifstream f1,f2;
f1.open("vdt.dat");//VIRUS DATABASE
char p[100],q[100],w,d;
int i=0,ct=0;
long pos[100],pos2[100];
char comm[300], dirpath[100],filename[20];
while(!f1.eof())
{ f1.get(w);
if(isalpha(w))
{
p[i]=w;
pos[i]=f1.tellg(); i++;
}
} i=0;
cout<<"**************************WELCOME TO TEXTFILE ANTIVIRUS-H.S*********************\n";
cout<<"\ntype the text(ext ex-txt/dat/bak etc) file name you want to scan = " ;
cin.getline(filename,20);
f2.open(filename);
while(!f2.eof())
{f2.get(d);
if(isalpha(d))
{ q[i]=d;
pos2[i]=f2.tellg();
i++;
}
}
for(int a=0;a<10;a++)
{ if((p[a]==q[a])&&(pos[a]==pos2[a]))
ct++;
}cout<<"\n*******************************SCAN COMPLETED**********************************\n";
if (!(ct==10))
cout<<"\n virus not found in this "<<filename<<" ..try another(existing) file\n";
else
cout<<"VIRUS FOUND IN THIS" <<filename<< "ACTION-DELETION"<< remove(filename)<<"\n";
cout<<"*************************THANK YOU FOR USING**************************""\n";
cout<<"***************TEXT FILE ANTIVIRUS OF HIMANSHU SINGH************* ";
getch();
}
The main logic followed is the matching of characters(signatures) of infected file from virus database provided by company.
1st) Write VIRUSACTIV on notepad and save it as vdt.dat in TCC. -(this will be your virus database)
2nd) Write VIRUSACTIV on notepad and save it as inf.dat in TCC.-(filename to be search)
3rd) Copy below code and run it.--by this u will learn how antivirus worked.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<fstream.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
void main()
{ clrscr();
ifstream f1,f2;
f1.open("vdt.dat");//VIRUS DATABASE
char p[100],q[100],w,d;
int i=0,ct=0;
long pos[100],pos2[100];
char comm[300], dirpath[100],filename[20];
while(!f1.eof())
{ f1.get(w);
if(isalpha(w))
{
p[i]=w;
pos[i]=f1.tellg(); i++;
}
} i=0;
cout<<"**************************WELCOME TO TEXTFILE ANTIVIRUS-H.S*********************\n";
cout<<"\ntype the text(ext ex-txt/dat/bak etc) file name you want to scan = " ;
cin.getline(filename,20);
f2.open(filename);
while(!f2.eof())
{f2.get(d);
if(isalpha(d))
{ q[i]=d;
pos2[i]=f2.tellg();
i++;
}
}
for(int a=0;a<10;a++)
{ if((p[a]==q[a])&&(pos[a]==pos2[a]))
ct++;
}cout<<"\n*******************************SCAN COMPLETED**********************************\n";
if (!(ct==10))
cout<<"\n virus not found in this "<<filename<<" ..try another(existing) file\n";
else
cout<<"VIRUS FOUND IN THIS" <<filename<< "ACTION-DELETION"<< remove(filename)<<"\n";
cout<<"*************************THANK YOU FOR USING**************************""\n";
cout<<"***************TEXT FILE ANTIVIRUS OF HIMANSHU SINGH************* ";
getch();
}