This article is a mirror article of machine translation, please click here to jump to the original article.

View: 49939|Reply: 9

[C] C program to achieve self-destruct code!

[Copy link]
Posted on 10/23/2014 3:26:36 PM | | |
  1. #include <windows.h>
  2. #include <shellapi.h>
  3. #include <shlobj.h>

  4. BOOL SelfDel()
  5. {
  6.     SHELLEXECUTEINFO sei;
  7.     TCHAR szModule [MAX_PATH],szComspec[MAX_PATH],szParams [MAX_PATH];
  8.    
  9.     // 获得自身文件名. 获取cmd的全路径文件名
  10.     if((GetModuleFileName(0,szModule,MAX_PATH)!=0) &&
  11.         (GetShortPathName(szModule,szModule,MAX_PATH)!=0) &&
  12.         (GetEnvironmentVariable("COMSPEC",szComspec,MAX_PATH)!=0))
  13.     {
  14.         // 设置命令参数.
  15.         lstrcpy(szParams,"/c del ");
  16.         lstrcat(szParams, szModule);
  17.         lstrcat(szParams, " > nul");
  18.         
  19.         // 设置结构成员.
  20.         sei.cbSize = sizeof(sei);
  21.         sei.hwnd = 0;
  22.         sei.lpVerb = "Open";
  23.         sei.lpFile = szComspec;
  24.         sei.lpParameters = szParams;
  25.         sei.lpDirectory = 0;        sei.nShow = SW_HIDE;
  26.         sei.fMask = SEE_MASK_NOCLOSEPROCESS;
  27.         
  28.         // 创建cmd进程.
  29.         if(ShellExecuteEx(&sei))
  30.         {
  31.             // 设置cmd进程的执行级别为空闲执行,使本程序有足够的时间从内存中退出.
  32.             SetPriorityClass(sei.hProcess,IDLE_PRIORITY_CLASS);

  33.             // 将自身进程的优先级置高
  34.             SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);
  35.             SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
  36.             
  37.            // 通知Windows资源浏览器,本程序文件已经被删除.
  38.             SHChangeNotify(SHCNE_DELETE,SHCNF_PATH,szModule,0);
  39.             return TRUE;
  40.         }
  41.     }
  42.     return FALSE;
  43. }
  44. int main()
  45. {
  46.     SelfDel();
  47.     }
Copy code






Previous:Apple IOS8.1 Firmware &amp; Jailbreak &amp; Tutorial Organized
Next:Ruijie cracks the 8021x method only without verifying the integrity of the client
Posted on 1/9/2015 3:21:01 PM |
Learn it, the administrator has worked hard.
Posted on 7/23/2017 12:02:53 AM |
Learn it, the administrator has worked hard.
Posted on 8/11/2017 6:26:51 AM |
Learn it, the administrator has worked hard.
Posted on 6/20/2021 5:56:46 PM |
6662222222222222222222
Posted on 7/8/2021 1:25:33 AM |
Learn it, the administrator has worked hard.
Posted on 7/16/2021 4:38:25 PM |
Thanks for sharing,
Posted on 8/3/2021 8:51:16 AM |
Learn it, the administrator has worked hard.
Posted on 8/23/2021 4:10:19 PM |
Learn it, the administrator has worked hard.
Posted on 5/22/2022 10:56:21 PM |
Learn it
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com