#include
#include
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)运行。
我使用的是Windows7,我已经安装了Avira防病毒系统。
当我试图运行上述程序时,它会产生一个蠕虫(DOS/Candy)。我相信这个计划没什么错。
这里有一些特别的东西。执行相同的程序,但有以下区别。这里唯一的区别是
\n
:
#include
#include
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
#include
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<
}
void get()
{
cout<
cout<
}
};
void main()
{
A a1(5,10);
clrscr();
a1.get();
getch();
}
当我运行这个程序时,它会发出“病毒警告”——即使它不是病毒。现在,悲剧是,当你移除了析构函数,它不会把它当作病毒来检测。
以下是屏幕截图和类似问题:
问题是如何,为什么?