From a72e372865515d4e97b35d3a67201404d439c165 Mon Sep 17 00:00:00 2001 From: Imanol-Mikel Barba Sabariego Date: Mon, 31 Oct 2016 12:08:38 +0100 Subject: [PATCH] Implemented hashing all recovered artifacts --- digger.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/digger.py b/digger.py index 3d49649..75b0699 100644 --- a/digger.py +++ b/digger.py @@ -16,6 +16,7 @@ import traceback import logger from consolelogger import ConsoleLogger from filelogger import FileLogger +from hashlib import sha256 def getModules(): choiceList = [] @@ -44,7 +45,26 @@ def prepareModule(moduleName): except Exception as e: raise -def showFinishDialog(allSuccessful): +def sha256sum(file): + f = open(file, 'rb') + result = sha256(f.read()).hexdigest() + f.close() + return result + +def bagAndTag(): + tombPath = tomb.getPath() + hashes = open(tombPath + "hashes.txt",'a+') + + for root, dirnames, filenames in os.walk(tombPath): + for dir in dirnames: + print(dir) + for subroot, subdirnames, subfilenames in os.walk(tombPath + dir): + print(subfilenames) + for filename in subfilenames: + hashes.write(sha256sum(subroot + "/" + filename) + " " + subroot + "/" + filename + "\n") + +def finish(allSuccessful): + bagAndTag() msg = "" if(allSuccessful): msg = "All modules finished execution" @@ -103,7 +123,7 @@ if __name__ == "__main__": #logger.msgLog(traceback.format_exc(), module[0], logger.TYPE_ERROR) ans = showContinueDialog(d,msg) if ans == "abort": - showFinishDialog(False) + finish(False) elif ans == "continue": logger.msgLog("Skipping module " + module[0], "digger", logger.TYPE_INFO) break @@ -121,7 +141,7 @@ if __name__ == "__main__": #logger.msgLog(traceback.format_exc(), tag logger.TYPE_ERROR) ans = showContinueDialog(d, msg) if ans == "abort": - showFinishDialog(False) + finish(False) elif ans == "continue": logger.msgLog("Skipping module " + tag, "digger", logger.TYPE_INFO) break @@ -136,4 +156,4 @@ if __name__ == "__main__": #logger.msgLog(traceback.format_exc(), module.name, logger.TYPE_ERROR) - showFinishDialog(True) + finish(True) -- libgit2 0.22.2