Skip to content

Commit 67f8265

Browse files
authored
Merge pull request #1261 from gcmoreira/linux_checkcreds_pointer_verification_improvements
Linux checkcreds pointer verification improvements
2 parents bb6ab45 + 48ae43d commit 67f8265

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

volatility3/framework/plugins/linux/check_creds.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
# which is available at https://www.volatilityfoundation.org/license/vsl-v1.0
33
#
44

5-
import logging
6-
75
from volatility3.framework import interfaces, renderers
6+
from volatility3.framework.renderers import format_hints
87
from volatility3.framework.configuration import requirements
98
from volatility3.plugins.linux import pslist
109

11-
vollog = logging.getLogger(__name__)
12-
1310

1411
class Check_creds(interfaces.plugins.PluginInterface):
1512
"""Checks if any processes are sharing credential structures"""
1613

1714
_required_framework_version = (2, 0, 0)
1815

16+
_version = (2, 0, 0)
17+
1918
@classmethod
2019
def get_requirements(cls):
2120
return [
@@ -46,20 +45,28 @@ def _generator(self):
4645
tasks = pslist.PsList.list_tasks(self.context, vmlinux.name)
4746

4847
for task in tasks:
49-
cred_addr = task.cred.dereference().vol.offset
48+
task_cred_ptr = task.cred
49+
if not (task_cred_ptr and task_cred_ptr.is_readable()):
50+
continue
5051

51-
if cred_addr not in creds:
52-
creds[cred_addr] = []
52+
cred_addr = task_cred_ptr.dereference().vol.offset
5353

54+
creds.setdefault(cred_addr, [])
5455
creds[cred_addr].append(task.pid)
5556

56-
for _, pids in creds.items():
57+
for cred_addr, pids in creds.items():
5758
if len(pids) > 1:
58-
pid_str = ""
59-
for pid in pids:
60-
pid_str = pid_str + f"{pid:d}, "
61-
pid_str = pid_str[:-2]
62-
yield (0, [str(pid_str)])
59+
pid_str = ", ".join([str(pid) for pid in pids])
60+
61+
fields = [
62+
format_hints.Hex(cred_addr),
63+
pid_str,
64+
]
65+
yield (0, fields)
6366

6467
def run(self):
65-
return renderers.TreeGrid([("PIDs", str)], self._generator())
68+
headers = [
69+
("CredVAddr", format_hints.Hex),
70+
("PIDs", str),
71+
]
72+
return renderers.TreeGrid(headers, self._generator())

0 commit comments

Comments
 (0)