C语言程序被检测为病毒

Sag*_*ari 1 c c++ antivirus turbo-c++ windows-7

#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();
}
Run Code Online (Sandbox Code Playgroud)

我已将此程序保存为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();
}
Run Code Online (Sandbox Code Playgroud)

区别仅在于\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();
}
Run Code Online (Sandbox Code Playgroud)

当我运行这个程序时,它会给出"病毒警告" - 即使它不是病毒.现在,悲剧是当你删除析构函数时,它不会将其检测为病毒.

这是屏幕截图和类似的问题:

C语言 - \n - 创建病毒

替代文字

问题是如何以及为什么?

Ale*_*ler 19

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

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

  • ...也许OP调用他的程序`VIRUS`和`VIRUS2`的事实有助于让反病毒软件认为它发现了病毒......? (5认同)

Ben*_*igt 12

看起来像假阳性.由于现代病毒使用多态来隐藏反病毒程序,因此反病毒程序必须报告部分匹配,显然,使用给定源代码的编译器会产生与该恶意软件的部分匹配.