Skip to content

Commit df03d22

Browse files
authored
Merge pull request #1771 from volatilityfoundation/framework/process_traversal_bugfix
Bugfix: Linux/Windows process traversal
2 parents 745e148 + 2e206fe commit df03d22

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

volatility3/framework/plugins/linux/pslist.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PsList(interfaces.plugins.PluginInterface, timeliner.TimeLinerInterface):
3434
"""Lists the processes present in a particular linux memory image."""
3535

3636
_required_framework_version = (2, 13, 0)
37-
_version = (4, 1, 0)
37+
_version = (4, 1, 1)
3838

3939
@classmethod
4040
def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]:
@@ -262,17 +262,27 @@ def list_tasks(
262262
init_task = vmlinux.object_from_symbol(symbol_name="init_task")
263263

264264
# Note that the init_task itself is not yielded, since "ps" also never shows it.
265-
for task in init_task.tasks:
266-
if not task.is_valid():
267-
continue
268-
269-
if filter_func(task):
270-
continue
271-
272-
yield task
273-
274-
if include_threads:
275-
yield from task.get_threads()
265+
seen = set()
266+
for forward in (True, False):
267+
for task in init_task.tasks.to_list(
268+
symbol_type=init_task.vol.type_name,
269+
member="tasks",
270+
forward=forward,
271+
):
272+
if task.vol.offset in seen:
273+
continue
274+
seen.add(task.vol.offset)
275+
276+
if not task.is_valid():
277+
continue
278+
279+
if filter_func(task):
280+
continue
281+
282+
yield task
283+
284+
if include_threads:
285+
yield from task.get_threads()
276286

277287
def run(self):
278288
pids = self.config.get("pid")

volatility3/framework/plugins/windows/pslist.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import logging
77
from typing import Callable, Iterator, List, Optional, Type
88

9-
from volatility3.framework import renderers, interfaces, layers, exceptions, constants
9+
from volatility3.framework import constants, exceptions, interfaces, layers, renderers
1010
from volatility3.framework.configuration import requirements
1111
from volatility3.framework.objects import utility
1212
from volatility3.framework.renderers import format_hints
1313
from volatility3.framework.symbols import intermed
14-
from volatility3.framework.symbols.windows.extensions import pe
1514
from volatility3.framework.symbols.windows import extensions
15+
from volatility3.framework.symbols.windows.extensions import pe
1616
from volatility3.plugins import timeliner
1717

1818
vollog = logging.getLogger(__name__)
@@ -24,7 +24,7 @@ class PsList(interfaces.plugins.PluginInterface, timeliner.TimeLinerInterface):
2424
_required_framework_version = (2, 0, 0)
2525

2626
# 3.0.0 - changed signature for `list_processes`
27-
_version = (3, 0, 0)
27+
_version = (3, 0, 1)
2828
PHYSICAL_DEFAULT = False
2929

3030
@classmethod
@@ -261,9 +261,18 @@ def list_processes(
261261
absolute=True,
262262
)
263263

264-
for proc in eproc.ActiveProcessLinks:
265-
if not filter_func(proc):
266-
yield proc
264+
seen = set()
265+
for forward in (True, False):
266+
for proc in eproc.ActiveProcessLinks.to_list(
267+
symbol_type=eproc.vol.type_name,
268+
member="ActiveProcessLinks",
269+
forward=forward,
270+
):
271+
if proc.vol.offset in seen:
272+
continue
273+
seen.add(proc.vol.offset)
274+
if not filter_func(proc):
275+
yield proc
267276

268277
def _generator(self):
269278
kernel = self.context.modules[self.config["kernel"]]

0 commit comments

Comments
 (0)