Skip to content

Commit 44ae4f1

Browse files
authored
Merge pull request #1596 from volatilityfoundation/vma_get_name_fixes
Fix get_name API, fix malfind
2 parents e5e4d30 + ac8eeec commit 44ae4f1

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

volatility3/framework/plugins/linux/elfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def _generator(self, tasks):
177177
name,
178178
format_hints.Hex(vma.vm_start),
179179
format_hints.Hex(vma.vm_end),
180-
path,
180+
path or renderers.NotAvailableValue(),
181181
file_output,
182182
),
183183
)

volatility3/framework/plugins/linux/malfind.py

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

5-
from typing import List
5+
from typing import List, Tuple, Optional
66
import logging
77
from volatility3.framework import interfaces
88
from volatility3.framework import renderers, symbols
@@ -39,7 +39,9 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
3939
),
4040
]
4141

42-
def _list_injections(self, task):
42+
def _list_injections(
43+
self, task
44+
) -> Tuple[interfaces.objects.ObjectInterface, Optional[str], bytes]:
4345
"""Generate memory regions for a process that may contain injected
4446
code."""
4547

@@ -54,12 +56,9 @@ def _list_injections(self, task):
5456
vollog.debug(
5557
f"Injections : processing PID {task.pid} : VMA {vma_name} : {hex(vma.vm_start)}-{hex(vma.vm_end)}"
5658
)
57-
if (
58-
vma.is_suspicious(proc_layer)
59-
and vma.get_name(self.context, task) != "[vdso]"
60-
):
59+
if vma.is_suspicious(proc_layer) and vma_name != "[vdso]":
6160
data = proc_layer.read(vma.vm_start, 64, pad=True)
62-
yield vma, data
61+
yield vma, vma_name, data
6362

6463
def _generator(self, tasks):
6564
# determine if we're on a 32 or 64 bit kernel
@@ -71,7 +70,7 @@ def _generator(self, tasks):
7170
for task in tasks:
7271
process_name = utility.array_to_string(task.comm)
7372

74-
for vma, data in self._list_injections(task):
73+
for vma, vma_name, data in self._list_injections(task):
7574
if is_32bit_arch:
7675
architecture = "intel"
7776
else:
@@ -88,6 +87,7 @@ def _generator(self, tasks):
8887
process_name,
8988
format_hints.Hex(vma.vm_start),
9089
format_hints.Hex(vma.vm_end),
90+
vma_name or renderers.NotAvailableValue(),
9191
vma.get_protection(),
9292
format_hints.HexBytes(data),
9393
disasm,
@@ -103,6 +103,7 @@ def run(self):
103103
("Process", str),
104104
("Start", format_hints.Hex),
105105
("End", format_hints.Hex),
106+
("Path", str),
106107
("Protection", str),
107108
("Hexdump", format_hints.HexBytes),
108109
("Disasm", interfaces.renderers.Disassembly),

volatility3/framework/plugins/linux/proc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def vma_filter_function(x: interfaces.objects.ObjectInterface) -> bool:
246246
major,
247247
minor,
248248
inode_num,
249-
path,
249+
path or renderers.NotAvailableValue(),
250250
file_output,
251251
),
252252
)

volatility3/framework/symbols/linux/extensions/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ def get_page_offset(self) -> int:
11631163
parent_layer = self._context.layers[self.vol.layer_name]
11641164
return self.vm_pgoff << parent_layer.page_shift
11651165

1166-
def get_name(self, context, task):
1166+
def _do_get_name(self, context, task) -> str:
11671167
if self.vm_file != 0:
11681168
fname = linux.LinuxUtilities.path_for_file(context, task, self.vm_file)
11691169
elif self.vm_start <= task.mm.start_brk and self.vm_end >= task.mm.brk:
@@ -1179,6 +1179,12 @@ def get_name(self, context, task):
11791179
fname = "Anonymous Mapping"
11801180
return fname
11811181

1182+
def get_name(self, context, task) -> Optional[str]:
1183+
try:
1184+
return self._do_get_name(context, task)
1185+
except exceptions.InvalidAddressException:
1186+
return None
1187+
11821188
# used by malfind
11831189
def is_suspicious(self, proclayer=None):
11841190
ret = False

0 commit comments

Comments
 (0)