@@ -14,37 +14,77 @@ namespace PingCastle.Healthcheck.Rules
14
14
[ RuleSTIG ( "V-63577" , "Hardened UNC Paths must be defined to require mutual authentication and integrity for at least the \\ \\ *\\ SYSVOL and \\ \\ *\\ NETLOGON shares." , STIGFramework . Windows10 ) ]
15
15
[ RuleMaturityLevel ( 2 ) ]
16
16
[ RuleMitreAttackTechnique ( MitreAttackTechnique . ManintheMiddleLLMNRNBTNSPoisoningandSMBRelay ) ]
17
- [ RuleIntroducedIn ( 2 , 10 , 1 ) ]
17
+ [ RuleIntroducedIn ( 2 , 10 , 1 ) ]
18
18
public class HeatlcheckRuleAnomalyHardenedPaths : RuleBase < HealthcheckData >
19
19
{
20
20
protected override int ? AnalyzeDataNew ( HealthcheckData healthcheckData )
21
21
{
22
22
if ( healthcheckData . GPOHardenedPath == null )
23
23
return null ;
24
+ bool netlogon = false ;
25
+ bool sysvol = false ;
24
26
foreach ( var policy in healthcheckData . GPOHardenedPath )
25
27
{
26
- if ( policy . RequireIntegrity == false || policy . RequireMutualAuthentication == false )
28
+ if ( string . IsNullOrEmpty ( policy . GPOId ) )
27
29
{
28
- bool anomaly = false ;
29
- if ( policy . Key . IndexOf ( "SYSVOL" , StringComparison . OrdinalIgnoreCase ) > 0 || policy . Key . IndexOf ( "NETLOGON" , StringComparison . OrdinalIgnoreCase ) > 0 )
30
+ continue ;
31
+ }
32
+ if ( healthcheckData . GPOInfoDic == null || ! healthcheckData . GPOInfoDic . ContainsKey ( policy . GPOId ) )
33
+ {
34
+ continue ;
35
+ }
36
+ var refGPO = healthcheckData . GPOInfoDic [ policy . GPOId ] ;
37
+ if ( refGPO . IsDisabled )
38
+ {
39
+ continue ;
40
+ }
41
+ if ( refGPO . AppliedTo == null || refGPO . AppliedTo . Count == 0 )
42
+ {
43
+ continue ;
44
+ }
45
+
46
+ bool anomaly = false ;
47
+ if ( policy . Key . IndexOf ( "SYSVOL" , StringComparison . OrdinalIgnoreCase ) > 0 )
48
+ {
49
+ sysvol = true ;
50
+ if ( policy . RequireIntegrity == false || policy . RequireMutualAuthentication == false )
51
+ {
52
+ anomaly = true ;
53
+ }
54
+ }
55
+ else if ( policy . Key . IndexOf ( "NETLOGON" , StringComparison . OrdinalIgnoreCase ) > 0 )
56
+ {
57
+ netlogon = true ;
58
+ if ( policy . RequireIntegrity == false || policy . RequireMutualAuthentication == false )
30
59
{
31
60
anomaly = true ;
32
61
}
33
- else
62
+ }
63
+ else
64
+ {
65
+ foreach ( var dc in healthcheckData . DomainControllers )
34
66
{
35
- foreach ( var dc in healthcheckData . DomainControllers )
67
+ if ( policy . Key . StartsWith ( " \\ \\ " + dc . DCName + " \\ " , StringComparison . OrdinalIgnoreCase ) && policy . Key . Contains ( "*" ) )
36
68
{
37
- if ( policy . Key . StartsWith ( " \\ \\ " + dc . DCName + " \\ " , StringComparison . OrdinalIgnoreCase ) && policy . Key . Contains ( "*" ) )
69
+ if ( policy . RequireIntegrity == false || policy . RequireMutualAuthentication == false )
38
70
{
39
71
anomaly = true ;
40
72
}
41
73
}
42
74
}
43
- if ( anomaly )
44
- {
45
- AddRawDetail ( policy . GPOName , policy . Key , GetString ( policy . RequireIntegrity ) , GetString ( policy . RequireMutualAuthentication ) , GetString ( policy . RequirePrivacy ) ) ;
46
- }
47
75
}
76
+ if ( anomaly )
77
+ {
78
+ AddRawDetail ( policy . GPOName , policy . Key , GetString ( policy . RequireIntegrity ) , GetString ( policy . RequireMutualAuthentication ) , GetString ( policy . RequirePrivacy ) ) ;
79
+ }
80
+ }
81
+ if ( ! netlogon )
82
+ {
83
+ AddRawDetail ( "No GPO Found" , "NETLOGON" , "Not Set" , "Not Set" , "Not Set" ) ;
84
+ }
85
+ if ( ! sysvol )
86
+ {
87
+ AddRawDetail ( "No GPO Found" , "SYSVOL" , "Not Set" , "Not Set" , "Not Set" ) ;
48
88
}
49
89
return null ;
50
90
}
0 commit comments