EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff

Training Missions

Read Me First New
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom

Knowledge Bank

Discussion Forums
Enigma Chat New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Enigma Zine
Downloads
Tools New

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Hakipedia: An open collaborative for all your information security needs.

The Urinal

Click Here To Vote For EG!

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site.

enigma group

enigma group

enigma group

enigma group

Enigma Group's Code Bank


Self Deleting executable code

By: Evil1  -  Date Submitted: 2008-05-23 07:50:44

  1. #include <windows.h>
  2. #include <shlobj.h>
  3.  
  4. BOOL SelfDelete()
  5. {
  6. SHELLEXECUTEINFO sei;
  7.  
  8. TCHAR szModule [MAX_PATH],
  9. szComspec[MAX_PATH],
  10. szParams [MAX_PATH];
  11.  
  12. // get file path names:
  13. if((GetModuleFileName(0,szModule,MAX_PATH)!=0) &&
  14. (GetShortPathName(szModule,szModule,MAX_PATH)!=0) &&
  15. (GetEnvironmentVariable("COMSPEC",szComspec,MAX_PATH)!=0))
  16. {
  17. // set command shell parameters
  18. lstrcpy(szParams,"/c del ");
  19. lstrcat(szParams, szModule);
  20. lstrcat(szParams, " > nul");
  21.  
  22. // set struct members
  23. sei.cbSize = sizeof(sei);
  24. sei.hwnd = 0;
  25. sei.lpVerb = "Open";
  26. sei.lpFile = szComspec;
  27. sei.lpParameters = szParams;
  28. sei.lpDirectory = 0;
  29. sei.nShow = SW_HIDE;
  30. sei.fMask = SEE_MASK_NOCLOSEPROCESS;
  31.  
  32. // increase resource allocation to program
  33. SetPriorityClass(GetCurrentProcess(),
  34. REALTIME_PRIORITY_CLASS);
  35. SetThreadPriority(GetCurrentThread(),
  36. THREAD_PRIORITY_TIME_CRITICAL);
  37.  
  38. // invoke command shell
  39. if(ShellExecuteEx(&sei))
  40. {
  41. // suppress command shell process until program exits
  42. SetPriorityClass(sei.hProcess,IDLE_PRIORITY_CLASS);
  43. SetProcessPriorityBoost(sei.hProcess,TRUE);
  44.  
  45. // notify explorer shell of deletion
  46. SHChangeNotify(SHCNE_DELETE,SHCNF_PATH,szModule,0); // dur, take this out
  47. return TRUE;
  48. }
  49. else // if error, normalize allocation
  50. {
  51. SetPriorityClass(GetCurrentProcess(),
  52. NORMAL_PRIORITY_CLASS);
  53. SetThreadPriority(GetCurrentThread(),
  54. THREAD_PRIORITY_NORMAL);
  55. }
  56. }
  57. return FALSE;
  58. }
Return to c category list

Who's Online

483 Guests, 101 Users
Ios, ckryptix, viper0i0, Diznablo, rabbidmind, asapong, Nasrudin, CollapsingWalls, mehtaparag, bitstrike, jnony, C, Nicid1, Nusquam-Redono-Sapientia, bazcrown, saifulfaizan, The End, Ultraminor, psychomarine, st3alth, themastersinner, pgmrlink, login, lionaneesh, ishkur88, mahraja, Mac, chekifr, gandalf88, Vap0r, t0ast, tantrum6226, BnE, Distorted, Psiber_Syn, Ausome1, invas10n, oldgoat, freedaysbecumei, BinaryShinigami, Rex_Mundi, Red_beard, Strobeflux, s0m3nak3dguy, Descent, teehee, machupicchu, Genetix, Anandarl, NotMyOwn, thegamerdude, Godzila, popo12341234, RedEvolution, velocity_b, myne17, teto111, aVoid, Central-Gsm, 1101, JackalReborn, InjectioN, h4lted, c0re, DisPater, markt4death, splatta, Jackowacko, saint556, Pyron2312, Azerion, howsens, white.hat.gone.bad, vazzilly, pwunkz, Inverted, QuarterCask, Infernoe11, deskata, cr4ck3rj4ck, Blizer, jasonmax, j0sh, gwenwavor, N4g4c3N, spizeyboy, Network X, Uino59, Jae Cee, ianFDK, saykov, medhaavee, zofy, demonkiller410, Stumble, SaMTHG, kishore, Raze, helasraizam, Venom1019, Jakabo