Advertisement
opexxx

check_pe.py

Jun 13th, 2014
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import os, sys, pefile
  4.  
  5. def corrupt(path):
  6. try:
  7. pe = pefile.PE(path)
  8. except:
  9. return True
  10. highest = 0
  11. for section in pe.sections:
  12. tmp = section.PointerToRawData + section.SizeOfRawData
  13. if tmp > highest:
  14. highest = tmp
  15. if os.path.getsize(path) < highest:
  16. return True
  17. return False
  18.  
  19. if len(sys.argv) == 2:
  20. for i in os.listdir(sys.argv[1]):
  21. file = sys.argv[1] + '\\' + i
  22. if corrupt(file):
  23. print 'del ' + file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement