Windows - add missing add_process_layer exception handling in a few plugins

This commit is contained in:
atcuno
2019-10-17 11:47:19 -04:00
parent e0097ac9c1
commit 3df5e9957e
9 changed files with 43 additions and 13 deletions
@@ -31,8 +31,10 @@ class CmdLine(interfaces.plugins.PluginInterface):
for proc in procs: for proc in procs:
process_name = utility.array_to_string(proc.ImageFileName) process_name = utility.array_to_string(proc.ImageFileName)
# TODO: what kind of exceptions could this raise and what should we do? try:
proc_layer_name = proc.add_process_layer() proc_layer_name = proc.add_process_layer()
except exceptions.InvalidAddressException:
continue
try: try:
peb = self._context.object(self.config["nt_symbols"] + constants.BANG + "_PEB", peb = self._context.object(self.config["nt_symbols"] + constants.BANG + "_PEB",
@@ -53,8 +53,11 @@ class DllDump(interfaces.plugins.PluginInterface):
for proc in procs: for proc in procs:
process_name = utility.array_to_string(proc.ImageFileName) process_name = utility.array_to_string(proc.ImageFileName)
# TODO: what kind of exceptions could this raise and what should we do?
proc_layer_name = proc.add_process_layer() try:
proc_layer_name = proc.add_process_layer()
except exceptions.InvalidAddressException:
continue
for vad in vadinfo.VadInfo.list_vads(proc, filter_func = filter_func): for vad in vadinfo.VadInfo.list_vads(proc, filter_func = filter_func):
@@ -73,8 +73,11 @@ class Malfind(interfaces.plugins.PluginInterface):
Returns: Returns:
An iterable of VAD instances and the first 64 bytes of data containing in that region An iterable of VAD instances and the first 64 bytes of data containing in that region
""" """
try:
proc_layer_name = proc.add_process_layer()
except exceptions.InvalidAddressException:
return
proc_layer_name = proc.add_process_layer()
proc_layer = context.layers[proc_layer_name] proc_layer = context.layers[proc_layer_name]
for vad in proc.get_vad_root().traverse(): for vad in proc.get_vad_root().traverse():
@@ -60,7 +60,10 @@ class ModDump(interfaces.plugins.PluginInterface):
layer_name = layer_name, layer_name = layer_name,
symbol_table = symbol_table, symbol_table = symbol_table,
filter_func = filter_func): filter_func = filter_func):
proc_layer_name = proc.add_process_layer() try:
proc_layer_name = proc.add_process_layer()
except exceptions.InvalidAddressException:
continue
try: try:
# create the session space object in the process' own layer. # create the session space object in the process' own layer.
@@ -42,8 +42,11 @@ class ProcDump(interfaces.plugins.PluginInterface):
for proc in procs: for proc in procs:
process_name = utility.array_to_string(proc.ImageFileName) process_name = utility.array_to_string(proc.ImageFileName)
# TODO: what kind of exceptions could this raise and what should we do?
proc_layer_name = proc.add_process_layer() try:
proc_layer_name = proc.add_process_layer()
except exceptions.InvalidAddressException:
continue
try: try:
peb = self._context.object(self.config["nt_symbols"] + constants.BANG + "_PEB", peb = self._context.object(self.config["nt_symbols"] + constants.BANG + "_PEB",
@@ -95,7 +95,11 @@ class Strings(interfaces.plugins.PluginInterface):
for process in pslist.PsList.list_processes(self.context, self.config['primary'], for process in pslist.PsList.list_processes(self.context, self.config['primary'],
self.config['nt_symbols']): self.config['nt_symbols']):
proc_layer_name = process.add_process_layer() try:
proc_layer_name = process.add_process_layer()
except exceptions.InvalidAddressException:
continue
proc_layer = self.context.layers[proc_layer_name] proc_layer = self.context.layers[proc_layer_name]
if isinstance(proc_layer, linear.LinearlyMappedLayer): if isinstance(proc_layer, linear.LinearlyMappedLayer):
for mapval in proc_layer.mapping(0x0, proc_layer.maximum_address, ignore_errors = True): for mapval in proc_layer.mapping(0x0, proc_layer.maximum_address, ignore_errors = True):
@@ -131,7 +131,11 @@ class SvcScan(interfaces.plugins.PluginInterface):
symbol_table = self.config['nt_symbols'], symbol_table = self.config['nt_symbols'],
filter_func = filter_func): filter_func = filter_func):
proc_layer_name = task.add_process_layer() try:
proc_layer_name = task.add_process_layer()
except exceptions.InvalidAddressException:
continue
layer = self.context.layers[proc_layer_name] layer = self.context.layers[proc_layer_name]
for offset in layer.scan(context = self.context, for offset in layer.scan(context = self.context,
@@ -47,8 +47,11 @@ class VadDump(interfaces.plugins.PluginInterface):
for proc in procs: for proc in procs:
process_name = utility.array_to_string(proc.ImageFileName) process_name = utility.array_to_string(proc.ImageFileName)
# TODO: what kind of exceptions could this raise and what should we do? try:
proc_layer_name = proc.add_process_layer() proc_layer_name = proc.add_process_layer()
except exceptions.InvalidAddressException:
continue
proc_layer = self.context.layers[proc_layer_name] proc_layer = self.context.layers[proc_layer_name]
for vad in vadinfo.VadInfo.list_vads(proc, filter_func = filter_func): for vad in vadinfo.VadInfo.list_vads(proc, filter_func = filter_func):
@@ -58,6 +61,7 @@ class VadDump(interfaces.plugins.PluginInterface):
offset = vad.get_start() offset = vad.get_start()
out_of_range = vad.get_start() + vad.get_end() out_of_range = vad.get_start() + vad.get_end()
print("walking from {:x} to {:x} | {:x}".format(offset, out_of_range, out_of_range-offset))
while offset < out_of_range: while offset < out_of_range:
to_read = min(chunk_size, out_of_range - offset) to_read = min(chunk_size, out_of_range - offset)
data = proc_layer.read(offset, to_read, pad = True) data = proc_layer.read(offset, to_read, pad = True)
@@ -123,7 +123,11 @@ class VerInfo(interfaces.plugins.PluginInterface):
# now go through the process and dll lists # now go through the process and dll lists
for proc in procs: for proc in procs:
proc_layer_name = proc.add_process_layer() try:
proc_layer_name = proc.add_process_layer()
except exceptions.InvalidAddressException:
continue
for entry in proc.load_order_modules(): for entry in proc.load_order_modules():
try: try: