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,6 +16,7 @@ import traceback
16 import logger 16 import logger
17 from consolelogger import ConsoleLogger 17 from consolelogger import ConsoleLogger
18 from filelogger import FileLogger 18 from filelogger import FileLogger
  19 +from hashlib import sha256
19 20
20 def getModules(): 21 def getModules():
21 choiceList = [] 22 choiceList = []
@@ -44,7 +45,26 @@ def prepareModule(moduleName): @@ -44,7 +45,26 @@ def prepareModule(moduleName):
44 except Exception as e: 45 except Exception as e:
45 raise 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 msg = "" 68 msg = ""
49 if(allSuccessful): 69 if(allSuccessful):
50 msg = "All modules finished execution" 70 msg = "All modules finished execution"
@@ -103,7 +123,7 @@ if __name__ == "__main__": @@ -103,7 +123,7 @@ if __name__ == "__main__":
103 #logger.msgLog(traceback.format_exc(), module[0], logger.TYPE_ERROR) 123 #logger.msgLog(traceback.format_exc(), module[0], logger.TYPE_ERROR)
104 ans = showContinueDialog(d,msg) 124 ans = showContinueDialog(d,msg)
105 if ans == "abort": 125 if ans == "abort":
106 - showFinishDialog(False) 126 + finish(False)
107 elif ans == "continue": 127 elif ans == "continue":
108 logger.msgLog("Skipping module " + module[0], "digger", logger.TYPE_INFO) 128 logger.msgLog("Skipping module " + module[0], "digger", logger.TYPE_INFO)
109 break 129 break
@@ -121,7 +141,7 @@ if __name__ == "__main__": @@ -121,7 +141,7 @@ if __name__ == "__main__":
121 #logger.msgLog(traceback.format_exc(), tag logger.TYPE_ERROR) 141 #logger.msgLog(traceback.format_exc(), tag logger.TYPE_ERROR)
122 ans = showContinueDialog(d, msg) 142 ans = showContinueDialog(d, msg)
123 if ans == "abort": 143 if ans == "abort":
124 - showFinishDialog(False) 144 + finish(False)
125 elif ans == "continue": 145 elif ans == "continue":
126 logger.msgLog("Skipping module " + tag, "digger", logger.TYPE_INFO) 146 logger.msgLog("Skipping module " + tag, "digger", logger.TYPE_INFO)
127 break 147 break
@@ -136,4 +156,4 @@ if __name__ == "__main__": @@ -136,4 +156,4 @@ if __name__ == "__main__":
136 #logger.msgLog(traceback.format_exc(), module.name, logger.TYPE_ERROR) 156 #logger.msgLog(traceback.format_exc(), module.name, logger.TYPE_ERROR)
137 157
138 158
139 - showFinishDialog(True) 159 + finish(True)