C++写病毒

我想用C++来写一个病毒,但不懂用,打开C++\文件\新建\??下一步是什么?有哪位大侠能告诉我

这里有个郑绍辉2004年写的类似病毒的程序,你可作参考!

/*
*此程序是一具自我复制程序,它将以自己为模板,复制许多不同名字的程序,
*这此复制的程序同样都有自我复制的能力类似于病毒,但有不是病毒,因为
*没有破坏性,程序中也没有具有破坏性的代码
*
*程序在turboc2.0中编绎通过
*
*编程:郑绍辉 2004.3.1
*
*/

#include <stdio.h>
#include <conio.h>
#include <string.h>

#define OK 1
#define ERROR 0
typedef int Bool;

void getPrefixName(int idx, char *name){
/*根据数据idx生成一个文件名前缀,仅4个字节, *
* 用它作为一个可执行文件的文件名的前4个字符,*
* 并保存于name中 */
int temp;
int cnt = 0;
while ( cnt < 4){
name[cnt++] = idx % 26 + 97;
idx /= 26;
}/*while*/
name[4] = '\0';
}/*getName*/

void getFullName(char *prefix, int idx, char *fullname){
/*产生一个可执行文件的全名,这个文件名由前缀*
*prefix和一个数字idx组成,并保存于fullname中*/
int cnt = 4,temp;
strcpy(fullname,prefix);
while( idx > 0 ){
fullname[cnt++] = idx % 10 + 48;
idx /= 10;
}
fullname[cnt] = '\0';
strcat(fullname,".exe");
}/*getFullName*/

Bool writeFile(char *filename,unsigned char *buffer,long size){
/*把buffer中内容放入文件名为filename的文件中*/
FILE *fp;
long count = 0;
fp = fopen(filename,"wb");
if (fp == NULL) return ERROR;
while(count < size)
fputc(buffer[count++],fp);
fclose(fp);
return OK;
}

Bool readFile(char *filename,unsigned char *buffer,long *size){
/*把文件名为filename的文件中的内容放在buffer中*/
FILE *fp;
long count = 0;
fp = fopen(filename,"rb");
if (fp == NULL) return ERROR;
cprintf("wait a moment please, this program is reading soure file...");
while(!feof(fp)){/*当文件未结束时*/
buffer[count++] = fgetc(fp);
}/*while*/
*size = count;
fclose(fp);
return OK;
}/*readFile*/

void showInfo(void){
textbackground(LIGHTBLUE);
clrscr();
window(15,1,65,7);
textbackground(CYAN);
clrscr();
window(17,2,63,6);
textbackground(BLACK);
textcolor(RED);
clrscr();
cprintf(" <Breeding> \n\r Author:FancyBoy fancyboy1983@tom.com.cn");
textcolor(LIGHTBLUE);
cprintf("\n\r This file will breed many files, these breeded file have the same function.");
cprintf("\n\r The following are the breeding file list:");
window(5,9,75,24);
textbackground(BROWN);
textcolor(YELLOW);
clrscr();
}/*showinfo*/

void main(int argc,char *argv[]){

char prefixname[5];
char filename[50];
char buffer[30000];
int count = 0,prefix;
long fsize;
FILE *fp;

(void)argc;
showInfo();
srand(time(NULL));
prefix = rand();
getPrefixName(prefix,prefixname);
if (readFile(argv[0],buffer,&fsize) == ERROR){
cprintf("Sorry,can't read file %s.",argv[0]);
exit(0);
}

while(count++ < 10000){/*产生10000个文件后就退出*/
getFullName(prefixname,count,filename);/*获得一个文件名作为将要产生的文件的名称*/
if (writeFile(filename,buffer,fsize) == ERROR)/*如果写文件错误*/
printf("\n\rCan't create file %s.",filename);
cprintf("%s, ",filename);
}

}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2007-03-12
新建一个EXE标准程序,然后编辑源代码,也可在网上找,最后生成可执行程序!
第2个回答  2007-03-12
刷分
第3个回答  2007-03-12
先学习简单的应用,一步登天不行的~

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网