@@ -194,10 +194,10 @@ def init_checks(self):
194194 ConfigCheck ('Powershell Execution Policy == "Restricted"' , 'Checks if the Powershell execution policy is set to "Restricted"' , checker_args = [[self , ("HKLM\\ SOFTWARE\\ Microsoft\\ PowerShell\\ 1\\ ShellIds\\ Microsoft.Powershell" , "ExecutionPolicy" , "Restricted\x00 " ), ("HKCU\\ SOFTWARE\\ Microsoft\\ PowerShell\\ 1\\ ShellIds\\ Microsoft.Powershell" , "ExecutionPolicy" , "Restricted\x00 " )]], checker_kwargs = [{"options" : {"KOIfMissing" : False , "lastWins" : True }}]),
195195 ConfigCheck ("Defender service running" , "Checks if defender service is enabled" , checkers = [self .check_defender_service ]),
196196 ConfigCheck ("Defender Tamper Protection enabled" , "Check if Defender Tamper Protection is enabled" , checker_args = [[self , ("HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Features" , "TamperProtection" , 5 )]]),
197- ConfigCheck ("Defender RealTime Monitoring enabled" , "Check if Defender RealTime Monitoring is enabled" , checkers = [ self . check_single_registry_with_policy ], checker_args = [ ("HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableRealtimeMonitoring" , 0 , True ) ]),
198- ConfigCheck ("Defender IOAV Protection enabled" , "Check if Defender IOAV Protection is enabled" , checkers = [ self . check_single_registry_with_policy ], checker_args = [ ("HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableIOAVProtection" , 0 , True ) ]),
199- ConfigCheck ("Defender Behaviour Monitoring enabled" , "Check if Defender Behaviour Monitoring is enabled" , checkers = [ self . check_single_registry_with_policy ], checker_args = [ ("HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableBehaviourMonitoring" , 0 , True ) ]),
200- ConfigCheck ("Defender Script Scanning enabled" , "Check if Defender Script Scanning is enabled" , checkers = [ self . check_single_registry_with_policy ], checker_args = [ ("HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableScriptScanning" , 0 , True ) ]),
197+ ConfigCheck ("Defender RealTime Monitoring enabled" , "Check if Defender RealTime Monitoring is enabled" , checker_args = [[ self , ("HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableRealtimeMonitoring" , 0 ), ( " HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableRealtimeMonitoring" , 0 )]], checker_kwargs = [{ "options" : { "lastWins" : True , "stopOnOK" : True }} ]),
198+ ConfigCheck ("Defender IOAV Protection enabled" , "Check if Defender IOAV Protection is enabled" , checker_args = [[ self , ("HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableIOAVProtection" , 0 ), ( " HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableIOAVProtection" , 0 )]], checker_kwargs = [{ "options" : { "lastWins" : True , "stopOnOK" : True }} ]),
199+ ConfigCheck ("Defender Behaviour Monitoring enabled" , "Check if Defender Behaviour Monitoring is enabled" , checker_args = [[ self , ("HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableBehaviourMonitoring" , 0 ), ( " HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableBehaviourMonitoring" , 0 )]], checker_kwargs = [{ "options" : { "lastWins" : True , "stopOnOK" : True }} ]),
200+ ConfigCheck ("Defender Script Scanning enabled" , "Check if Defender Script Scanning is enabled" , checker_args = [[ self , ("HKLM\\ Software\\ Policies \\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableScriptScanning" , 0 ), ( " HKLM\\ Software\\ Microsoft\\ Windows Defender\\ Real-Time Protection" , "DisableScriptScanning" , 0 )]], checker_kwargs = [{ "options" : { "lastWins" : True , "stopOnOK" : True }} ]),
201201 ConfigCheck ("Defender path exlusion path" , "Checks Defender path exlusion" , checkers = [self .check_defender_exclusion ], checker_args = [("HKLM\\ SOFTWARE\\ Policies\\ Microsoft\\ Windows Defender\\ Exclusions\\ Paths" , "HKLM\\ SOFTWARE\\ Microsoft\\ Windows Defender\\ Exclusions\\ Paths" )]),
202202 ConfigCheck ("Defender extension exlusion" , "Checks Defender extension exlusion" , checkers = [self .check_defender_exclusion ], checker_args = [("HKLM\\ SOFTWARE\\ Policies\\ Microsoft\\ Windows Defender\\ Exclusions\\ Extensions" , "HKLM\\ SOFTWARE\\ Microsoft\\ Windows Defender\\ Exclusions\\ Extensions" )])
203203 ]
@@ -337,37 +337,6 @@ def check_registry(self, *specs, options=None, stop_on_error=False):
337337
338338 return ok , reasons
339339
340-
341- def check_single_registry_with_policy (self , * spec , options = None ):
342- """
343- Perform checks that only require to compare values in the registry with expected values, according to the spec
344- The spec may be either a 5-tuple: (key name, policy key name, value name, expected value, default result), or a 6-tuple (key name, policy key name, value name, expected value, default result, operation), where operation is a function that implements a comparison operator
345- """
346- try :
347- if len (spec ) == 5 :
348- (key , policy_key , value_name , expected_value , default_result ) = spec
349- op = operator .eq
350- elif len (spec ) == 6 :
351- (key , policy_key , value_name , expected_value , default_result , op ) = spec
352- else :
353- ok = False
354- reasons = ["Check could not be performed (invalid specification provided)" ]
355- return ok , reasons
356- except Exception as e :
357- ok , reasons = self .module .log .error (f"Check could not be performed. Details: spec={ spec } , dce={ self .dce } , error: { e } " )
358- return ok , reasons
359-
360- ok , reasons_p = self .check_registry ((policy_key , value_name , expected_value , op ), stop_on_error = True )
361- reasons = [f"Policy: [{ ', ' .join (reasons_p )} ]" ]
362- if ok is not None :
363- return ok , reasons
364- ok , reasons_k = self .check_registry ((key , value_name , expected_value , op ), stop_on_error = True )
365- reasons .append (f"Specific: [{ ', ' .join (reasons_k )} ]" )
366- if ok is not None :
367- return ok , reasons
368-
369- return default_result , reasons
370-
371340 def check_laps (self ):
372341 reasons = []
373342 success = False
0 commit comments