提取出了病毒的特征码但怎么也匹配不出来,查了很多资料也没有解决
附上代码原文:
int a;
int b;
int c;
char *id1 = "11110100011110100010110000000000";
char *id2 =“1110100000000000000000000101101110000001111010111101010000000111";
char *fnasb(char *fn)
{
char *path_name = (char *)malloc(30);
strcpy(path_name, "C:\");
strcat(path_name, fn);
cout << path_name;
system("pause");
return path_name;
}
int main(void)
{
long ch;
FILE *fp;
char filename[32];
unsigned char list[6000];
unsigned char *flag = list;
memset(list, 0, 6000);
memset(filename, 0, 32);
printf("enter the file name:");
scanf("%s", filename);
fp = fopen(fnasb(filename), "rb+");
if (fp == NULL)
{
printf("Fail to open file\n");
system("pause");
exit(1);
}
ch = fread(list, 1, sizeof(list), fp);
printf("ch is %d\n", ch);
for (int i = 0; i < 6000; i++)
{
cout << list[i];
//printf("%c",list[i]);
b = memcmp(list, id1 ,32);
c = memcmp(list, id2, 64);
cout << b << endl;
cout << c << endl;
if (b==1||c==1)
{
a++;
}
flag++;
}
cout << a;
if (a == 2)
{
printf("it is a virus!");
}
else {
printf("it is not a virus!");
}
fclose(fp);
system("pause");
free(fnasb(filename));
return 0;
}