Advertisement
Jarno

EMET all exes

Nov 9th, 2011
1,369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.93 KB | None | 0 0
  1. print """Simple tool to enable Micrsoft EMET for all executables in system
  2. This tool creates a bat file which will call emet_conf with suitable
  3. parameters for all exes in c:\
  4.  
  5. Note that some programs might have problems with EMET memory hardenings
  6. I have added special options for programs I found out causing problems
  7. in my system.
  8.  
  9. If you find out any additional ones, add them to custom settings
  10. and feel free to tell me.
  11.  
  12. Use this program at your own risk, and review the bat file
  13. before running it
  14.  
  15. Created by Jarno Niemela
  16. Twitter:@jarnomn
  17.  
  18. Usage:
  19. 1. Install EMET http://www.microsoft.com/download/en/details.aspx?id=1677
  20. 2. run emet_all.py as admin
  21. 3. run_this_as_admin.bat
  22.  
  23.  
  24. Yes, I know emet_conf has XML import, but that aborts if even
  25. single exe has some problems"""
  26.  
  27. import os
  28. import os.path
  29.  
  30.  
  31. output=file('run_this_as_admin.bat','w')
  32.  
  33. custom_settings=dict()
  34. custom_settings['dropbox.exe']="+DEP +SEHOP +NullPage +HeapSpray -EAF +MandatoryASLR +BottomUpRand"
  35. custom_settings['sdiagnhost.exe']="+DEP +SEHOP +NullPage +HeapSpray -EAF +MandatoryASLR +BottomUpRand"
  36.  
  37. skip_dirs=['temp','recycle','downloads','installer']
  38.  
  39.  
  40. if os.path.exists("""c:\Program Files (x86)\EMET\emet_conf.exe"""):
  41.     emet_dir="""c:\Program Files (x86)\EMET\emet_conf.exe"""
  42. elif os.path.exists("""c:\Program Files (x86)\EMET\emet_conf.exe"""):
  43.     emet_dir="""c:\Program Files\EMET\emet_conf.exe"""
  44. else:
  45.     emet_dir="DEFINE YOUR EMET LOCATION"
  46.  
  47. output.write("".join(['"',emet_dir,'"',' --delete_all \n']))
  48.  
  49. for root,dirs,files in os.walk ('c:\\'):
  50.     for name in files:
  51.         name=name.lower()
  52.         root=root.lower()
  53.         if name.endswith('exe') and not any(x in root for x in skip_dirs ):
  54.             if name in custom_settings:
  55.                 output.write("".join(['"',emet_dir,'"',' --set "%s'%os.path.join(root,name),'" ',custom_settings[name]]))
  56.             else:
  57.                 output.write("".join(['"',emet_dir,'"',' --set "%s'%os.path.join(root,name),'"']))
  58.             output.write('\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement