@nguyenthehien/

Cpluzpluz

C++

No description

fork
loading
Files
  • main.cpp
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
*/

#include <dirent.h>
#include <string.h>
#include <fstream>

#include <condition_variable>

#include <stdio.h>

#include <stdlib.h>

#include <iostream>

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;

ifstream fin;

cout<<“Enter 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<<“Scan Complete.!! Thank You for using our anti virus”;

getch();

}[/cpp]