Address feedback from ikelos

This commit is contained in:
Andrew Case
2022-04-28 15:42:10 +00:00
parent 338fcdd0ab
commit b43d61ca03
+24 -6
View File
@@ -4,6 +4,7 @@
from typing import Optional
from volatility3.framework.configuration import requirements
from volatility3.framework import symbols, exceptions, renderers, interfaces
from volatility3.framework.objects import utility
from volatility3.plugins.linux import pslist
@@ -11,6 +12,19 @@ from volatility3.plugins.linux import pslist
class PsAux(pslist.PsList):
""" Lists processes with their command line arguments """
@classmethod
def get_requirements(cls):
# Since we're calling the plugin, make sure we have the plugin's requirements
return [
requirements.ModuleRequirement(name = 'kernel', description = 'Linux kernel',
architectures = ["Intel32", "Intel64"]),
requirements.PluginRequirement(name = 'pslist', plugin = pslist.PsList, version = (2, 0, 0)),
requirements.ListRequirement(name = 'pid',
description = 'Filter on specific process IDs',
element_type = int,
optional = True)
]
def _get_command_line_args(self, task: interfaces.objects.ObjectInterface,
name: str) -> Optional[str]:
"""
@@ -41,7 +55,7 @@ class PsAux(pslist.PsList):
# get the size of the arguments with sanity checking
size_to_read = task.mm.arg_end - task.mm.arg_start
if size_to_read < 1 or size_to_read > 4096:
if not (0 < size_to_read <= 4096):
return renderers.UnreadableValue()
# attempt to read it all as partial values are invalid and misleading
@@ -65,13 +79,11 @@ class PsAux(pslist.PsList):
return args
def _generator(self):
def _generator(self, tasks):
""" Generates a listing of processes along with command line arguments """
vmlinux = self.context.modules[self.config['kernel']]
# walk the process list and report the arguments
for task in self.list_tasks(self.context, vmlinux.name):
for task in tasks:
pid = task.pid
try:
@@ -86,5 +98,11 @@ class PsAux(pslist.PsList):
yield (0, (pid, ppid, name, args))
def run(self):
return renderers.TreeGrid([("PID", int), ("PPID", int), ("COMM", str), ("ARGS", str)], self._generator())
filter_func = pslist.PsList.create_pid_filter(self.config.get('pid', None))
return renderers.TreeGrid([("PID", int), ("PPID", int), ("COMM", str), ("ARGS", str)],
self._generator(
pslist.PsList.list_tasks(self.context,
self.config['kernel'],
filter_func = filter_func)))