Commit a72e372865515d4e97b35d3a67201404d439c165

Authored by Imanol-Mikel Barba Sabariego
1 parent 1d2034c1

Implemented hashing all recovered artifacts

Showing 1 changed file with 24 additions and 4 deletions
digger.py
... ... @@ -16,6 +16,7 @@ import traceback
16 16 import logger
17 17 from consolelogger import ConsoleLogger
18 18 from filelogger import FileLogger
  19 +from hashlib import sha256
19 20  
20 21 def getModules():
21 22 choiceList = []
... ... @@ -44,7 +45,26 @@ def prepareModule(moduleName):
44 45 except Exception as e:
45 46 raise
46 47  
47   -def showFinishDialog(allSuccessful):
  48 +def sha256sum(file):
  49 + f = open(file, 'rb')
  50 + result = sha256(f.read()).hexdigest()
  51 + f.close()
  52 + return result
  53 +
  54 +def bagAndTag():
  55 + tombPath = tomb.getPath()
  56 + hashes = open(tombPath + "hashes.txt",'a+')
  57 +
  58 + for root, dirnames, filenames in os.walk(tombPath):
  59 + for dir in dirnames:
  60 + print(dir)
  61 + for subroot, subdirnames, subfilenames in os.walk(tombPath + dir):
  62 + print(subfilenames)
  63 + for filename in subfilenames:
  64 + hashes.write(sha256sum(subroot + "/" + filename) + " " + subroot + "/" + filename + "\n")
  65 +
  66 +def finish(allSuccessful):
  67 + bagAndTag()
48 68 msg = ""
49 69 if(allSuccessful):
50 70 msg = "All modules finished execution"
... ... @@ -103,7 +123,7 @@ if __name__ == "__main__":
103 123 #logger.msgLog(traceback.format_exc(), module[0], logger.TYPE_ERROR)
104 124 ans = showContinueDialog(d,msg)
105 125 if ans == "abort":
106   - showFinishDialog(False)
  126 + finish(False)
107 127 elif ans == "continue":
108 128 logger.msgLog("Skipping module " + module[0], "digger", logger.TYPE_INFO)
109 129 break
... ... @@ -121,7 +141,7 @@ if __name__ == "__main__":
121 141 #logger.msgLog(traceback.format_exc(), tag logger.TYPE_ERROR)
122 142 ans = showContinueDialog(d, msg)
123 143 if ans == "abort":
124   - showFinishDialog(False)
  144 + finish(False)
125 145 elif ans == "continue":
126 146 logger.msgLog("Skipping module " + tag, "digger", logger.TYPE_INFO)
127 147 break
... ... @@ -136,4 +156,4 @@ if __name__ == "__main__":
136 156 #logger.msgLog(traceback.format_exc(), module.name, logger.TYPE_ERROR)
137 157  
138 158  
139   - showFinishDialog(True)
  159 + finish(True)
... ...