Skip to main content

antivirus coding in cpp

//antivirus program by akshay

#include <dirent.h>
#include <string.h>
#include <fstream.h>
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#include <graphics.h>
int scan_this(char *file_name)
{
char *pattern, *line_in_file;
char file_ch, ch;
int val, val2, flag;
ifstream fin3, fin4;
fin3.open(file_name); // incase the file is not accesible
if(!fin3) return 0;
else // file is accessible | 100% it is a file.
{ //Opening Virus Database File
fin4.open("db.txt"); // this is our character pattern file
for(;;)
{
fin4>>pattern;
if(!strcmp(pattern,"<-"))
{
fin4>>pattern;
if(!strcmpi(pattern,"End"))return -1;
else if(!strcmpi(pattern," virus"))
{
if(flag) return 1;
else continue;
}
}
else if(!strcmpi(pattern,"LINE"))
{
fin4>>val; // got the line number
// skipping initial lines to reach the line number
for(int i=0;i<val-1;i++)
{
fin3.getline(line_in_file, 300);
}
fin4>>val; // got the character number
fin4>>file_ch; // got the character
//skipping initial character to reach the character
for(i=0;i<val-1;i++)
{
fin3.get(ch);
}
if(file_ch == ch) flag = 1; // matched.
else flag =0;
fin3.seekg(0); // set to start
}
}
}
}

void main()
{
char comm[300], dirpath[100], file_name[200];
char ask;
int response;
int g=DETECT,gm;
initgraph(&g,&gm,"akshay");
settextstyle(1,0,4);
outtextxy(120,100,"!!........Antivirus........!!");
outtextxy(120,150,"  !!....BY Akshay....!!");
setcolor(GREEN);
outtextxy(20,350,"cprogrammingbyakshay.blogspot.in");
ifstream fin;
cout<<" \n\tEnter Directory you want to scan: ";
cin>>dirpath;
strcpy(comm, "dir ");
strcat(comm, "dirpath /b /s >tmp.$$$");
system(comm);
fin.open("tmp.$$$");
while(!fin.eof())
{
fin.getline(file_name, 200);
response = scan_this(file_name);
if(response == 1)
{
cout<<"<–!! Caution.! A Virus has been Detected..!";
cout<<"\n"<<file_name;
cout<<"\nPress Enter Key to Delete it.";
ask= getch();
if(ask == 13)
{
remove(file_name); // delete the virus
}
}
}
fin.close();
cout<<"\n \tScan Complete.!! Thank You for using our antivirus";
getch();
}

Comments

  1. It would be better if explanation is made for each code.

    ReplyDelete

Post a Comment

Popular posts from this blog

Balloon Shooting game in cpp

Balloon Shooting Game is a simple game using c and cpp features. You can easily learn and is easy to run because this game works in TURBOC compiler. The main features are included is  GRAPHICS and DOS commands. Basic commands used in this game : initgraph : initgraph is used to initialising of graphics mode in the program.                   ex. initgraph(&gm,&gd,"akshay"); here gm uses Graphics detect mode and gd points to graphics features to be used in program ans last is a string it may be any string like c://tc/bin etc.. setbkcolor : sets the current background color.    for ex. if you want to set background color to blue, you can call   setbkcolor(BLUE); or setbkcolor(1); getimage : saves a bit image of the specified region into memory. putimage : outputs a bit image onto the screen. settextstyle : sets the current text characteristics.     Declaration : settextstyle(int font, int direction, int charsize); outtextxy : displays a string a

Minesweeper Game in C

Minesweeper Game in C language. This game is like a windows minesweeper game and I am giving you all the code for this game. You can easily understand the code if you are not a beginner. For beginners this code will quite hard to understand. Because in this code it contains mouse pointing function, graphics function, and so many other codes which makes it so hard to play and is a mind game. So play and enjoy it.   Click here for code Click for code

Make your own paint application in c and cpp

Paint application using simple turboc complier. Hello friends now make your own paint application or mini project in your simple c and cpp compiler. click to show the code for paint program