PageRenderTime 48ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/src/pentest/metagoofil/extractors/metadataExtractor.py

https://github.com/sullivanmatt/Raspberry-Pwn
Python | 50 lines | 48 code | 1 blank | 1 comment | 0 complexity | 93aad45dc7818db4671000b6a0139235 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0
  1. #!/usr/bin/env python
  2. import sys, re, os, subprocess
  3. class metaExtractor:
  4. def __init__(self,fname):
  5. self.fname=fname
  6. self.command="extract" #If any error put the full path
  7. self.data=""
  8. self.paths=[]
  9. self.users=[]
  10. def runExtract(self):
  11. comm=self.command+" "+self.fname
  12. try:
  13. process = subprocess.Popen([self.command,self.fname], shell=False, stdout=subprocess.PIPE)
  14. res=process.communicate()
  15. self.data=res[0]
  16. return "ok"
  17. except:
  18. return "error"
  19. def getData(self):
  20. pathre= re.compile('worked on .*')
  21. pathre2= re.compile('template -.*')
  22. for reg in (pathre,pathre2):
  23. path=reg.findall(self.data)
  24. if path !=[]:
  25. for x in path:
  26. try:
  27. temp=x.split('\'')[1]
  28. if self.paths.count(temp) == 0:
  29. self.paths.append(temp)
  30. except:
  31. pass
  32. author= re.compile(': Author \'.*\'')
  33. authors=author.findall(self.data)
  34. if authors !=[]:
  35. for x in authors:
  36. temp=x.split('\'')[1]
  37. temp=temp.replace('\'','')
  38. if self.users.count(temp) == 0:
  39. self.users.append(temp)
  40. def getUsers(self):
  41. return self.users
  42. def getPaths(self):
  43. return self.paths