#include<stdio.h>
#include<conio.h>
union abc
{
int a;
int x;
float g;
};
struct pqr
{
int a;
int x;
float g;
} ;
void main()
{
union abc b;
struct pqr c;
clrscr();
b.a=10;
textbackground(2);
textcolor(6);
cprintf(" A = %d",b.a);
printf("\nUnion = %d",sizeof(b));
printf("\nStructure = %d",sizeof(c));
getch();
}
我已将此程序保存为 virus.cpp。我正在使用 Turbo C 编译器编译此程序并从 Turbo C (Ctrl + F9) 运行。
我使用的是 Windows 7,并且安装了 Avira AntiVir 病毒系统。
当我尝试运行上面的程序时,它创建了一个蠕虫 (DOS/Candy)。我相信程序没有问题。
现在这里有一些特别的东西。执行相同的程序,但有以下区别。这里唯一的区别是 \n
之间的空格:
#include<stdio.h>
#include<conio.h>
union abc
{
int a;
int x;
float g;
};
struct pqr
{
int a;
int x;
float g;
} ;
void main()
{
union abc b;
struct pqr c;
clrscr();
b.a=10;
textbackground(2);
textcolor(6);
cprintf(" A = %d",b.a);
printf("\n Union = %d",sizeof(b));
printf("\n Structure = %d",sizeof(c));
getch();
}
区别仅在于\n和空格。我的问题是,为什么我的简单程序被检测为病毒?
这是另一个代码示例,这次是针对 C++ 的:
#include<iostream.h>
#include<conio.h>
class A
{
int a,b;
public:
A()
{
a=0;b=0;
}
A(int x)
{a=x;
b=0;
}
A(int x,int y)
{
a=x;
b=y;
}
~A()
{
cout<<"All things are deleted.";
}
void get()
{
cout<<"\nA = "<<a;
cout<<"\nB = "<<b;
}
};
void main()
{
A a1(5,10);
clrscr();
a1.get();
getch();
}
当我运行这个程序时,它会发出“病毒警告”——即使它不是病毒。现在,悲剧是当您删除析构函数时,它不会将其检测为病毒。
这是屏幕截图和类似的问题:
C Language - \n - creating virus
问题是如何以及为什么?
最佳答案
病毒扫描器使用启发式和签名来检测漏洞。误报是不可避免的。您的程序似乎触发了启发式。据推测,它的校验和、文件大小或其他特征与已知病毒相匹配。这是因为一个小的改变就足以解决问题。
编辑 调用您的应用程序 Virus.exe 是一个非常不幸的选择,我认为它会快速触发大多数病毒扫描程序(尽管它肯定不是一个完美的名字对于真正的病毒......)。
关于c++ - C语言程序被检测为病毒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2443166/