Skip to content

Commit

Permalink
Linux: Differentiate yara/yara-x in vmayarascan
Browse files Browse the repository at this point in the history
  • Loading branch information
ikelos committed Nov 28, 2024
1 parent 3748cb8 commit 126ac9d
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions volatility3/framework/plugins/linux/vmayarascan.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,28 +67,39 @@ def _generator(self):
proc_layer = self.context.layers[proc_layer_name]

for start, end in self.get_vma_maps(task):
for match in rules.match(
data=proc_layer.read(start, end - start, True)
):
if yarascan.YaraScan.yara_returns_instances():
for match_string in match.strings:
for instance in match_string.instances:
data = proc_layer.read(start, end - start, True)
if not yarascan.YaraScan._yara_x:
for match in rules.match(data=data):
if yarascan.YaraScan.yara_returns_instances():
for match_string in match.strings:
for instance in match_string.instances:
yield 0, (
format_hints.Hex(instance.offset + start),
task.UniqueProcessId,
match.rule,
match_string.identifier,
instance.matched_data,
)
else:
for offset, name, value in match.strings:
yield 0, (
format_hints.Hex(offset + start),
task.tgid,
match.rule,
name,
value,
)
else:
for match in rules.scan(data=data).matching_rules:
for match_string in match.patterns:
for instance in match_string.matches:
yield 0, (
format_hints.Hex(instance.offset + start),
task.UniqueProcessId,
match.rule,
match_string.identifier,
instance.matched_data,
)
else:
for offset, name, value in match.strings:
yield 0, (
format_hints.Hex(offset + start),
task.tgid,
match.rule,
name,
value,
)

@staticmethod
def get_vma_maps(
Expand Down

0 comments on commit 126ac9d

Please sign in to comment.