@@ -18,7 +18,7 @@ class VadYaraScan(interfaces.plugins.PluginInterface):
1818 """Scans all the Virtual Address Descriptor memory maps using yara."""
1919
2020 _required_framework_version = (2 , 4 , 0 )
21- _version = (1 , 0 , 1 )
21+ _version = (1 , 1 , 0 )
2222
2323 @classmethod
2424 def get_requirements (cls ) -> List [interfaces .configuration .RequirementInterface ]:
@@ -32,11 +32,8 @@ def get_requirements(cls) -> List[interfaces.configuration.RequirementInterface]
3232 requirements .PluginRequirement (
3333 name = "pslist" , plugin = pslist .PsList , version = (2 , 0 , 0 )
3434 ),
35- requirements .VersionRequirement (
36- name = "yarascanner" , component = yarascan .YaraScanner , version = (2 , 0 , 0 )
37- ),
3835 requirements .PluginRequirement (
39- name = "yarascan" , plugin = yarascan .YaraScan , version = (1 , 2 , 0 )
36+ name = "yarascan" , plugin = yarascan .YaraScan , version = (1 , 3 , 0 )
4037 ),
4138 requirements .ListRequirement (
4239 name = "pid" ,
@@ -59,6 +56,8 @@ def _generator(self):
5956
6057 filter_func = pslist .PsList .create_pid_filter (self .config .get ("pid" , None ))
6158
59+ sanity_check = 0x1000 * 0x1000 * 0x1000
60+
6261 for task in pslist .PsList .list_processes (
6362 context = self .context ,
6463 layer_name = kernel .layer_name ,
@@ -67,18 +66,34 @@ def _generator(self):
6766 ):
6867 layer_name = task .add_process_layer ()
6968 layer = self .context .layers [layer_name ]
70- for offset , rule_name , name , value in layer .scan (
71- context = self .context ,
72- scanner = yarascan .YaraScanner (rules = rules ),
73- sections = self .get_vad_maps (task ),
74- ):
75- yield 0 , (
76- format_hints .Hex (offset ),
77- task .UniqueProcessId ,
78- rule_name ,
79- name ,
80- value ,
81- )
69+ for start , end in self .get_vad_maps (task ):
70+ size = end - start
71+ if size > sanity_check :
72+ vollog .warn (
73+ f"VAD at 0x{ start :x} over sanity-check size, not scanning"
74+ )
75+ continue
76+
77+ for match in rules .match (data = layer .read (start , end - start , True )):
78+ if yarascan .YaraScan .yara_returns_instances ():
79+ for match_string in match .strings :
80+ for instance in match_string .instances :
81+ yield 0 , (
82+ format_hints .Hex (instance .offset + start ),
83+ task .UniqueProcessId ,
84+ match .rule ,
85+ match_string .identifier ,
86+ instance .matched_data ,
87+ )
88+ else :
89+ for offset , name , value in match .strings :
90+ yield 0 , (
91+ format_hints .Hex (offset + start ),
92+ task .UniqueProcessId ,
93+ match .rule ,
94+ name ,
95+ value ,
96+ )
8297
8398 @staticmethod
8499 def get_vad_maps (
0 commit comments