Commit 47b49017a163ae1dc8bb51434a44dc75d43acde3

Authored by Imanol-Mikel Barba Sabariego
1 parent 00dcf762

Fixed errors

digger.py
@@ -38,7 +38,7 @@ def getModules(): @@ -38,7 +38,7 @@ def getModules():
38 del module 38 del module
39 sys.modules.pop(modname) 39 sys.modules.pop(modname)
40 except Exception as e: 40 except Exception as e:
41 - print("Exception raised while importing " + modname) 41 + logger.msgLog("Exception raised while importing " + modname + ": " + str(e),"digger",logger.TYPE_ERROR)
42 return choiceList 42 return choiceList
43 43
44 def prepareModule(moduleName): 44 def prepareModule(moduleName):
@@ -124,14 +124,13 @@ if __name__ == "__main__": @@ -124,14 +124,13 @@ if __name__ == "__main__":
124 locale.setlocale(locale.LC_ALL, '') 124 locale.setlocale(locale.LC_ALL, '')
125 d = Dialog(dialog="dialog",autowidgetsize=True) 125 d = Dialog(dialog="dialog",autowidgetsize=True)
126 d.set_background_title("Gravedigger") 126 d.set_background_title("Gravedigger")
127 -  
128 - moduleList = getModules()  
129 code,value = d.inputbox("Input computer's name") 127 code,value = d.inputbox("Input computer's name")
130 if code == d.OK: 128 if code == d.OK:
131 tomb._MACHINE_NAME= value 129 tomb._MACHINE_NAME= value
132 logger.logSystems.append(ConsoleLogger()) 130 logger.logSystems.append(ConsoleLogger())
133 logger.logSystems.append(FileLogger(tomb.getPath() + "log.txt")) 131 logger.logSystems.append(FileLogger(tomb.getPath() + "log.txt"))
134 logger.msgLog("Beginning excavation of tomb: " + tomb.getPath(),"digger",logger.TYPE_INFO) 132 logger.msgLog("Beginning excavation of tomb: " + tomb.getPath(),"digger",logger.TYPE_INFO)
  133 + moduleList = getModules()
135 d.set_background_title("Gravedigger - " + value) 134 d.set_background_title("Gravedigger - " + value)
136 code, tags = d.checklist("Select modules to execute", 135 code, tags = d.checklist("Select modules to execute",
137 choices=moduleList + [("all","Execute all modules",False)], 136 choices=moduleList + [("all","Execute all modules",False)],
findfile.py
@@ -5,10 +5,10 @@ def find_pattern_all(pattern, path, casesensitive): @@ -5,10 +5,10 @@ def find_pattern_all(pattern, path, casesensitive):
5 result = [] 5 result = []
6 for root, dirs, files in os.walk(path): 6 for root, dirs, files in os.walk(path):
7 for name in files: 7 for name in files:
8 - if sensitive: 8 + if casesensitive:
9 if fnmatch.fnmatchcase(name,pattern): 9 if fnmatch.fnmatchcase(name,pattern):
10 result.append(os.path.join(root, name)) 10 result.append(os.path.join(root, name))
11 - else: 11 + else:
12 if fnmatch.fnmatch(name.lower(), pattern.lower()): 12 if fnmatch.fnmatch(name.lower(), pattern.lower()):
13 result.append(os.path.join(root, name)) 13 result.append(os.path.join(root, name))
14 return result 14 return result
@@ -16,10 +16,10 @@ def find_pattern_all(pattern, path, casesensitive): @@ -16,10 +16,10 @@ def find_pattern_all(pattern, path, casesensitive):
16 def find_pattern(pattern, path, casesensitive): 16 def find_pattern(pattern, path, casesensitive):
17 for root, dirs, files in os.walk(path): 17 for root, dirs, files in os.walk(path):
18 for name in files: 18 for name in files:
19 - if sensitive: 19 + if casesensitive:
20 if fnmatch.fnmatchcase(name,pattern): 20 if fnmatch.fnmatchcase(name,pattern):
21 return os.path.join(root, name) 21 return os.path.join(root, name)
22 - else: 22 + else:
23 if fnmatch.fnmatch(name.lower(), pattern.lower()): 23 if fnmatch.fnmatch(name.lower(), pattern.lower()):
24 return os.path.join(root, name) 24 return os.path.join(root, name)
25 return None 25 return None
modules/globeimposter2.py
@@ -36,9 +36,10 @@ class RegistryModule(Module): @@ -36,9 +36,10 @@ class RegistryModule(Module):
36 profiles = winver.getUserProfiles(mntpoint) 36 profiles = winver.getUserProfiles(mntpoint)
37 for profile in profiles: 37 for profile in profiles:
38 hkcu = profile + "/NTUSER.DAT" 38 hkcu = profile + "/NTUSER.DAT"
39 - value = regquery.queryValue(hkcu,"""Software\Microsoft\Windows\CurrentVersion\RunOnce""","CertificatesCheck")  
40 - if(value != None):  
41 - logger.msgLog("FOUND Globeimposter 2.0 value in RunOnce: " + value,"globeimposter2",logger.TYPE_WARNING) 39 + if(os.path.isfile(hkcu)):
  40 + value = regquery.queryValue(hkcu,"""Software\Microsoft\Windows\CurrentVersion\RunOnce""","CertificatesCheck")
  41 + if(value != None):
  42 + logger.msgLog("FOUND Globeimposter 2.0 value in RunOnce: " + value,"globeimposter2",logger.TYPE_WARNING)
42 #VSS 43 #VSS
43 44
44 for vol in self.vars['ntfsvol'].value: 45 for vol in self.vars['ntfsvol'].value:
@@ -48,9 +49,9 @@ class RegistryModule(Module): @@ -48,9 +49,9 @@ class RegistryModule(Module):
48 except: 49 except:
49 raise 50 raise
50 mntpoint += mntid 51 mntpoint += mntid
51 - result = find_pattern("*.725",mntpoint,False)  
52 - if(result != None): 52 + result = findfile.find_pattern("*.725",mntpoint,False)
  53 + if(result != None):
53 logger.msgLog("FOUND at least one file with 725 extension: " + result,"globeimposter2",logger.TYPE_WARNING) 54 logger.msgLog("FOUND at least one file with 725 extension: " + result,"globeimposter2",logger.TYPE_WARNING)
54 - result = find("RECOVER-FILES.html",mntpoint) 55 + result = findfile.find("RECOVER-FILES.html",mntpoint)
55 if(result != None): 56 if(result != None):
56 logger.msgLog("FOUND ransom letter: " + result,"globeimposter2",logger.TYPE_WARNING) 57 logger.msgLog("FOUND ransom letter: " + result,"globeimposter2",logger.TYPE_WARNING)
regquery.py
1 from Registry import Registry 1 from Registry import Registry
2 2
3 -def queryValue(hive,keyPath,valueName): 3 +def queryValue(hive,key,valueName):
4 reg = Registry.Registry(hive) 4 reg = Registry.Registry(hive)
5 - key = reg.open(keyPath) 5 + key = reg.open(key)
6 try: 6 try:
7 value = str(key.value(valueName).value) 7 value = str(key.value(valueName).value)
8 - except Registry.RegistryValueNotFoundException: 8 + except Registry.RegistryParse.RegistryStructureDoesNotExist:
9 value = None 9 value = None
10 return value 10 return value
11 11
12 def getValues(hive,key): 12 def getValues(hive,key):
13 valueList = [] 13 valueList = []
14 reg = Registry.Registry(hive) 14 reg = Registry.Registry(hive)
15 - key = reg.open(keyPath)  
16 - for value in key.values():  
17 - valueList.append(value.value_name) 15 + key = reg.open(key)
  16 + for value in key.values():
  17 + valueList.append(value.value)
18 return valueList 18 return valueList
19 19
20 def getSubkeys(hive,key): 20 def getSubkeys(hive,key):
21 subkeyList = [] 21 subkeyList = []
22 reg = Registry.Registry(hive) 22 reg = Registry.Registry(hive)
23 - key = reg.open(keyPath) 23 + key = reg.open(key)
24 for subkey in key.subkeys(): 24 for subkey in key.subkeys():
25 subkeyList.append(subkey.name) 25 subkeyList.append(subkey.name)
26 return subkeyList 26 return subkeyList
winver.py
@@ -52,11 +52,11 @@ def getWindowsVersion(path): @@ -52,11 +52,11 @@ def getWindowsVersion(path):
52 return _WIN_9x 52 return _WIN_9x
53 53
54 def getWindowsDirectory(path): 54 def getWindowsDirectory(path):
55 - if DETECTED_WINDOWS_PATH[path] is None:  
56 - result = find_pattern("explorer.exe",path,False) 55 + if path not in DETECTED_WINDOWS_PATH:
  56 + result = findfile.find_pattern("explorer.exe",path,False)
57 #result,code = runProcess(["find",path,"-xdev","-iname","explorer.exe","-print","-quit"]) 57 #result,code = runProcess(["find",path,"-xdev","-iname","explorer.exe","-print","-quit"])
58 #if(result.decode("utf-8") == ""): 58 #if(result.decode("utf-8") == ""):
59 - if(len(result) == 0): 59 + if result is None:
60 return None 60 return None
61 #matches = result.decode("utf-8").splitlines() 61 #matches = result.decode("utf-8").splitlines()
62 #WARNING: ONLY CONSIDERING FIRST MATCH 62 #WARNING: ONLY CONSIDERING FIRST MATCH