1
#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 语言 - \n - 制造病毒

替代文字

问题是如何,为什么?

4

4 回答 4

19

病毒扫描程序使用启发式和签名来检测漏洞。误报是不可避免的。您的程序似乎触发了启发式。据推测,它的校验和、文件大小或其他特征与已知病毒相匹配。这是因为一个小的改变就足以解决问题。

编辑调用您的应用程序Virus.exe是一个非常不幸的选择,我认为它会迅速触发大多数病毒扫描程序(尽管它肯定不是真正病毒的完美名称......)。

于 2010-03-14T18:17:12.643 回答
13

看起来像一个假阳性。因为现代病毒使用多态性来隐藏反病毒程序,所以反病毒程序甚至必须报告部分匹配,显然你的编译器与给定的源代码会产生与该恶意软件的部分匹配。

于 2010-03-14T18:18:27.673 回答
3

我认为你在某个地方有一个真正的病毒,它可能已经修改了标准库:D 或者只是防病毒软件检测到可执行文件中的模式。

于 2010-03-14T18:17:44.400 回答
3

请参阅http://www.viruslist.com/en/viruses/encyclopedia?virusid=1857

我的猜测是 Antivir 扫描 DOS/Candy 包含的文本字符串,并且由于第二段代码中的那个与它正在寻找的那个一样,Antivir 将编译的可执行文件检测为病毒。

于 2010-03-14T18:17:45.117 回答