|
2 | 2 | # which is available at https://www.volatilityfoundation.org/license/vsl-v1.0 |
3 | 3 | # |
4 | 4 |
|
5 | | -import logging |
6 | | - |
7 | 5 | from volatility3.framework import interfaces, renderers |
| 6 | +from volatility3.framework.renderers import format_hints |
8 | 7 | from volatility3.framework.configuration import requirements |
9 | 8 | from volatility3.plugins.linux import pslist |
10 | 9 |
|
11 | | -vollog = logging.getLogger(__name__) |
12 | | - |
13 | 10 |
|
14 | 11 | class Check_creds(interfaces.plugins.PluginInterface): |
15 | 12 | """Checks if any processes are sharing credential structures""" |
16 | 13 |
|
17 | 14 | _required_framework_version = (2, 0, 0) |
18 | 15 |
|
| 16 | + _version = (2, 0, 0) |
| 17 | + |
19 | 18 | @classmethod |
20 | 19 | def get_requirements(cls): |
21 | 20 | return [ |
@@ -46,20 +45,28 @@ def _generator(self): |
46 | 45 | tasks = pslist.PsList.list_tasks(self.context, vmlinux.name) |
47 | 46 |
|
48 | 47 | 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 |
50 | 51 |
|
51 | | - if cred_addr not in creds: |
52 | | - creds[cred_addr] = [] |
| 52 | + cred_addr = task_cred_ptr.dereference().vol.offset |
53 | 53 |
|
| 54 | + creds.setdefault(cred_addr, []) |
54 | 55 | creds[cred_addr].append(task.pid) |
55 | 56 |
|
56 | | - for _, pids in creds.items(): |
| 57 | + for cred_addr, pids in creds.items(): |
57 | 58 | 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) |
63 | 66 |
|
64 | 67 | 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