forked from netwrix/pingcastle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHealthcheckData.cs
1232 lines (974 loc) · 41.5 KB
/
HealthcheckData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Copyright (c) Ping Castle. All rights reserved.
// https://www.pingcastle.com
//
// Licensed under the Non-Profit OSL. See LICENSE file in the project root for full license information.
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Security.Principal;
using System.Text;
using System.Xml.Serialization;
using PingCastle.Data;
using PingCastle.Rules;
namespace PingCastle.Healthcheck
{
public interface IGPOReference
{
string GPOName { get; set; }
string GPOId { get; set; }
}
[DebuggerDisplay("{Name}")]
public class HealthCheckGroupMemberData
{
public string Name { get; set; }
public bool IsExternal { get; set; }
public string DistinguishedName { get; set; }
public bool IsEnabled { get; set; }
public bool IsActive { get; set; }
public bool IsLocked { get; set; }
public bool DoesPwdNeverExpires { get; set; }
public bool CanBeDelegated { get; set; }
public DateTime LastLogonTimestamp { get; set; }
public DateTime PwdLastSet { get; set; }
public bool SmartCardRequired { get; set; }
public bool IsService { get; set; }
public DateTime Created { get; set; }
public bool IsInProtectedUser { get; set; }
}
[DebuggerDisplay("{GroupName}")]
public class HealthCheckGroupData
{
public HealthCheckGroupData()
{
Level = PingCastleReportDataExportLevel.Full;
}
[IgnoreDataMember]
[XmlIgnore]
public PingCastleReportDataExportLevel Level { get; set; }
public string GroupName { get; set; }
public string DistinguishedName { get; set; }
public int NumberOfMember { get; set; }
public int NumberOfMemberDisabled { get; set; }
public int NumberOfMemberPwdNotRequired { get; set; }
public int NumberOfMemberPwdNeverExpires { get; set; }
public int NumberOfMemberLocked { get; set; }
public int NumberOfMemberInactive { get; set; }
public int NumberOfMemberActive { get; set; }
public int NumberOfMemberEnabled { get; set; }
public int NumberOfMemberCanBeDelegated { get; set; }
public int NumberOfExternalMember { get; set; }
public int NumberOfSmartCardRequired { get; set; }
public int NumberOfServiceAccount { get; set; }
public int NumberOfMemberInProtectedUsers { get; set; }
public bool ShouldSerializeMembers() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthCheckGroupMemberData> Members { get; set; }
}
[DebuggerDisplay("FQDN: {DnsName} SiD: {Sid} NetBIOS: {NetbiosName} Forest: FQDN: {ForestName} SID: {ForestSid} NetBIOS {ForestNetbios}")]
public class HealthCheckTrustDomainInfoData
{
public string DnsName { get; set; }
public string NetbiosName { get; set; }
public string Sid { get; set; }
public DateTime CreationDate { get; set; }
public string ForestName { get; set; }
public string ForestSid { get; set; }
public string ForestNetbios { get; set; }
private DomainKey _domain;
[IgnoreDataMember]
[XmlIgnore]
public DomainKey Domain
{
get
{
if (_domain == null)
{
_domain = DomainKey.Create(DnsName, Sid, NetbiosName);
}
return _domain;
}
set
{
_domain = value;
}
}
private bool _forestSet = false;
private DomainKey _forest;
[IgnoreDataMember]
[XmlIgnore]
public DomainKey Forest
{
get
{
if (!_forestSet)
{
_forestSet = true;
if (String.Equals(DnsName, ForestName, StringComparison.InvariantCultureIgnoreCase))
_forest = Domain;
else
{
_forest = DomainKey.Create(ForestName, ForestSid, ForestNetbios);
}
}
return _forest;
}
set
{
_forest = value;
}
}
}
[DebuggerDisplay("{TrustPartner} {CreationDate}")]
public class HealthCheckTrustData
{
///<summary>
///TrustPartner is garanteed to be in lowercase.
///</summary>
public string TrustPartner { get; set; }
public int TrustAttributes { get; set; }
public int TrustDirection { get; set; }
public int TrustType { get; set; }
public DateTime CreationDate { get; set; }
public bool IsActive { get; set; }
public string SID { get; set; }
public string NetBiosName { get; set; }
public List<HealthCheckTrustDomainInfoData> KnownDomains { get; set; }
private DomainKey _domain;
[IgnoreDataMember]
[XmlIgnore]
public DomainKey Domain
{
get
{
if (_domain == null)
{
_domain = DomainKey.Create(TrustPartner, SID, NetBiosName);
}
return _domain;
}
}
}
[DebuggerDisplay("{GPOName} {UserName}")]
public class GPOInfo : IGPOReference
{
public string GPOName { get; set; }
public string GPOId { get; set; }
public bool IsDisabled { get; set; }
public List<string> AppliedTo { get; set; }
}
[DebuggerDisplay("{GPOName} {UserName}")]
public class GPPPassword : IGPOReference
{
public string UserName { get; set; }
public string Other { get; set; }
public string Password { get; set; }
public DateTime Changed { get; set; }
public string Type { get; set; }
public string GPOName { get; set; }
public string GPOId { get; set; }
}
[DebuggerDisplay("{GPOName} {FileName}")]
public class GPPFileDeployed : IGPOReference
{
public string FileName { get; set; }
public string Type { get; set; }
public string GPOName { get; set; }
public string GPOId { get; set; }
public List<HealthcheckScriptDelegationData> Delegation { get; set; }
}
[DebuggerDisplay("{Property} {Value}")]
public class GPPSecurityPolicyProperty
{
public GPPSecurityPolicyProperty()
{
}
public GPPSecurityPolicyProperty(string property, int value)
{
this.Property = property;
this.Value = value;
}
public string Property { get; set; }
public int Value { get; set; }
}
[DebuggerDisplay("{GPOName}")]
public class GPPSecurityPolicy : IGPOReference
{
public List<GPPSecurityPolicyProperty> Properties { get; set; }
public string GPOName { get; set; }
public string GPOId { get; set; }
}
[DebuggerDisplay("{GPOName} {User} {Privilege}")]
public class GPPRightAssignment : IGPOReference
{
public string User { get; set; }
public string Privilege { get; set; }
public string GPOName { get; set; }
public string GPOId { get; set; }
}
[DebuggerDisplay("{GPOName} {User} {Privilege}")]
public class GPOMembership : IGPOReference
{
public string GPOName { get; set; }
public string GPOId { get; set; }
public string User { get; set; }
public string MemberOf { get; set; }
}
[DebuggerDisplay("{GPOName} {Order} {Server}")]
public class GPOEventForwardingInfo : IGPOReference
{
public string GPOName { get; set; }
public string GPOId { get; set; }
public int Order { get; set; }
public string Server { get; set; }
}
[DebuggerDisplay("{Name}")]
public class HealthcheckAccountDetailData
{
public string DistinguishedName { get; set; }
public string Name { get; set; }
public DateTime LastLogonDate { get; set; }
public DateTime CreationDate { get; set; }
public DateTime PwdLastSet { get; set; }
public bool ShouldSerializeEvent() { return Event != DateTime.MinValue; }
public DateTime Event { get; set; }
}
public class HealthcheckAccountData
{
public HealthcheckAccountData()
{
Level = PingCastleReportDataExportLevel.Full;
}
public void Add(HealthcheckAccountData x)
{
Number += x.Number;
NumberActive += x.NumberActive;
NumberBadPrimaryGroup += x.NumberBadPrimaryGroup;
NumberDesEnabled += x.NumberDesEnabled;
NumberDisabled += x.NumberDisabled;
NumberEnabled += x.NumberEnabled;
NumberInactive += x.NumberInactive;
NumberLocked += x.NumberLocked;
NumberPwdNeverExpires += x.NumberPwdNeverExpires;
NumberPwdNotRequired += x.NumberPwdNotRequired;
NumberReversibleEncryption += x.NumberReversibleEncryption;
NumberSidHistory += x.NumberSidHistory;
NumberTrustedToAuthenticateForDelegation += x.NumberTrustedToAuthenticateForDelegation;
NumberDuplicate += x.NumberDuplicate;
NumberNoPreAuth += x.NumberNoPreAuth;
}
public void SetProxy(HealthcheckAccountData proxy)
{
if (proxy.ListBadPrimaryGroup == null)
proxy.ListBadPrimaryGroup = new List<HealthcheckAccountDetailData>();
ListBadPrimaryGroup = proxy.ListBadPrimaryGroup;
if (proxy.ListDesEnabled == null)
proxy.ListDesEnabled = new List<HealthcheckAccountDetailData>();
ListDesEnabled = proxy.ListDesEnabled;
if (proxy.ListDomainSidHistory == null)
proxy.ListDomainSidHistory = new List<HealthcheckSIDHistoryData>();
ListDomainSidHistory = proxy.ListDomainSidHistory;
if (proxy.ListDuplicate == null)
proxy.ListDuplicate = new List<HealthcheckAccountDetailData>();
ListDuplicate = proxy.ListDuplicate;
if (proxy.ListInactive == null)
proxy.ListInactive = new List<HealthcheckAccountDetailData>();
ListInactive = proxy.ListInactive;
if (proxy.ListLocked == null)
proxy.ListLocked = new List<HealthcheckAccountDetailData>();
ListLocked = proxy.ListLocked;
if (proxy.ListNoPreAuth == null)
proxy.ListNoPreAuth = new List<HealthcheckAccountDetailData>();
ListNoPreAuth = proxy.ListNoPreAuth;
if (proxy.ListPwdNeverExpires == null)
proxy.ListPwdNeverExpires = new List<HealthcheckAccountDetailData>();
ListPwdNeverExpires = proxy.ListPwdNeverExpires;
if (proxy.ListPwdNotRequired == null)
proxy.ListPwdNotRequired = new List<HealthcheckAccountDetailData>();
ListPwdNotRequired = proxy.ListPwdNotRequired;
if (proxy.ListReversibleEncryption == null)
proxy.ListReversibleEncryption = new List<HealthcheckAccountDetailData>();
ListReversibleEncryption = proxy.ListReversibleEncryption;
if (proxy.ListSidHistory == null)
proxy.ListSidHistory = new List<HealthcheckAccountDetailData>();
ListSidHistory = proxy.ListSidHistory;
if (proxy.ListTrustedToAuthenticateForDelegation == null)
proxy.ListTrustedToAuthenticateForDelegation = new List<HealthcheckAccountDetailData>();
ListTrustedToAuthenticateForDelegation = proxy.ListTrustedToAuthenticateForDelegation;
}
public void ClearProxy()
{
ListBadPrimaryGroup = null;
ListDesEnabled = null;
ListDomainSidHistory = null;
ListDuplicate = null;
ListInactive = null;
ListLocked = null;
ListNoPreAuth = null;
ListPwdNeverExpires = null;
ListPwdNotRequired = null;
ListReversibleEncryption = null;
ListSidHistory = null;
ListTrustedToAuthenticateForDelegation = null;
}
[IgnoreDataMember]
[XmlIgnore]
public PingCastleReportDataExportLevel Level { get; set; }
public int Number { get; set; }
public int NumberEnabled { get; set; }
public int NumberDisabled { get; set; }
public int NumberActive { get; set; }
public int NumberInactive { get; set; }
public bool ShouldSerializeListInactive() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListInactive { get; set; }
public int NumberLocked { get; set; }
public bool ShouldSerializeListLocked() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListLocked { get; set; }
public int NumberPwdNeverExpires { get; set; }
public bool ShouldSerializeListPwdNeverExpires() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListPwdNeverExpires { get; set; }
public int NumberSidHistory { get; set; }
public bool ShouldSerializeListSidHistory() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListSidHistory { get; set; }
public bool ShouldSerializeListDomainSidHistory() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public List<HealthcheckSIDHistoryData> ListDomainSidHistory { get; set; }
public int NumberPwdNotRequired { get; set; }
public bool ShouldSerializeListPwdNotRequired() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListPwdNotRequired { get; set; }
public int NumberBadPrimaryGroup { get; set; }
public bool ShouldSerializeListBadPrimaryGroup() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListBadPrimaryGroup { get; set; }
public int NumberDesEnabled { get; set; }
public bool ShouldSerializeListDesEnabled() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListDesEnabled { get; set; }
public int NumberTrustedToAuthenticateForDelegation { get; set; }
public bool ShouldSerializeListTrustedToAuthenticateForDelegation() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListTrustedToAuthenticateForDelegation { get; set; }
public int NumberReversibleEncryption { get; set; }
public bool ShouldSerializeListReversibleEncryption() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListReversibleEncryption { get; set; }
public int NumberDuplicate { get; set; }
public bool ShouldSerializeListDuplicate() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListDuplicate { get; set; }
public int NumberNoPreAuth { get; set; }
public bool ShouldSerializeListNoPreAuth() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListNoPreAuth { get; set; }
}
public class HealthcheckRiskRule : IRuleScore
{
public HealthcheckRiskRule()
{
Level = PingCastleReportDataExportLevel.Full;
}
[IgnoreDataMember]
[XmlIgnore]
public PingCastleReportDataExportLevel Level { get; set; }
public int Points { get; set; }
// we are using a xml serialization trick to be resilient if a new RiskRuleCategory is added in the future
[XmlIgnore]
public RiskRuleCategory Category { get; set; }
[XmlElement("Category")]
public string CategoryAsString
{
get
{
return Category.ToString();
}
set
{
try
{
Category = (RiskRuleCategory)Enum.Parse(typeof(RiskRuleCategory), value);
}
catch
{
Category = RiskRuleCategory.Unknown;
}
}
}
// we are using a xml serialization trick to be resilient if a new RiskModelCategory is added in the future
[XmlIgnore]
public RiskModelCategory Model { get; set; }
[XmlElement("Model")]
public string ModelAsString
{
get
{
return Model.ToString();
}
set
{
try
{
Model = (RiskModelCategory)Enum.Parse(typeof(RiskModelCategory), value);
}
catch
{
Model = RiskModelCategory.Unknown;
}
}
}
public string RiskId { get; set; }
public string Rationale { get; set; }
public bool ShouldSerializeDetails() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<string> Details { get; set; }
}
[DebuggerDisplay("{OperatingSystem}")]
public class HealthcheckOSData
{
public HealthcheckOSData()
{
}
public HealthcheckOSData(string OS)
{
this.OperatingSystem = OS;
}
public string OperatingSystem { get; set; }
public int NumberOfOccurence { get; set; }
public HealthcheckAccountData data { get; set; }
}
[DebuggerDisplay("{LoginScript}")]
public class HealthcheckLoginScriptData
{
public HealthcheckLoginScriptData()
{
}
public HealthcheckLoginScriptData(string script, int numOccurence)
{
this.LoginScript = script;
this.NumberOfOccurence = numOccurence;
}
public string LoginScript { get; set; }
public int NumberOfOccurence { get; set; }
public List<HealthcheckScriptDelegationData> Delegation { get; set; }
}
[DebuggerDisplay("{GPOName} {Action} {CommandLine}")]
public class HealthcheckGPOLoginScriptData : IGPOReference
{
public string GPOName { get; set; }
public string GPOId { get; set; }
public string Action { get; set; }
public string Source { get; set; }
public string CommandLine { get; set; }
public string Parameters { get; set; }
public List<HealthcheckScriptDelegationData> Delegation { get; set; }
}
[DebuggerDisplay("{DistinguishedName} {Account} {Right}")]
public class HealthcheckDelegationData
{
public string DistinguishedName { get; set; }
public string Account { get; set; }
public string SecurityIdentifier { get; set; }
public string Right { get; set; }
}
[DebuggerDisplay("{Account} {Right}")]
public class HealthcheckScriptDelegationData
{
public string Account { get; set; }
public string Right { get; set; }
}
[DebuggerDisplay("{GPOName} {Account} {Right}")]
public class GPODelegationData : IGPOReference
{
public string GPOName { get; set; }
public string GPOId { get; set; }
public string Item { get; set; }
public string Account { get; set; }
public string Right { get; set; }
}
[DebuggerDisplay("{GPOName} {Category} {Value}")]
public class GPOAuditSimpleData : IGPOReference
{
public string GPOName { get; set; }
public string GPOId { get; set; }
public string Category { get; set; }
public int Value { get; set; }
}
[DebuggerDisplay("{GPOName} {SubCategory} {Value}")]
public class GPOAuditAdvancedData : IGPOReference
{
public string GPOName { get; set; }
public string GPOId { get; set; }
public Guid SubCategory { get; set; }
public int Value { get; set; }
}
//public class HealthcheckSiteTopologyData
//{
// public string SiteName { get; set; }
// public List<string> Subnets { get; set; }
//}
[DebuggerDisplay("{new System.Security.Cryptography.X509Certificates.X509Certificate2(Certificate)} Source: {Source}")]
public class HealthcheckCertificateData
{
public string Source { get; set; }
public string Store { get; set; }
public byte[] Certificate { get; set; }
}
[DebuggerDisplay("{DomainSid} {FriendlyName}")]
public class HealthcheckSIDHistoryData
{
public string DomainSid { get; set; }
public string FriendlyName { get; set; }
public string NetBIOSName { get; set; }
public DateTime FirstDate { get; set; }
public DateTime LastDate { get; set; }
public int Count { get; set; }
public bool DangerousSID { get; set; }
private DomainKey _domain;
[IgnoreDataMember]
[XmlIgnore]
public DomainKey Domain
{
get
{
if (_domain == null)
{
_domain = DomainKey.Create(FriendlyName, DomainSid, NetBIOSName);
}
return _domain;
}
}
}
[Flags]
public enum SMBSecurityModeEnum
{
NotTested = 0,
None = 1,
SmbSigningEnabled = 2,
SmbSigningRequired = 4,
}
[DebuggerDisplay("{DCName}")]
public class HealthcheckDomainController
{
public string DCName { get; set; }
public DateTime CreationDate { get; set; }
public DateTime StartupTime { get; set; }
public DateTime LastComputerLogonDate { get; set; }
public string DistinguishedName { get; set; }
public string OperatingSystem { get; set; }
public string OwnerSID { get; set; }
public string OwnerName { get; set; }
public bool HasNullSession { get; set; }
public bool SupportSMB1 { get; set; }
public SMBSecurityModeEnum SMB1SecurityMode { get; set; }
public bool SupportSMB2OrSMB3 { get; set; }
public SMBSecurityModeEnum SMB2SecurityMode { get; set; }
public bool RemoteSpoolerDetected { get; set; }
public List<string> IP { get; set; }
public List<string> FSMO { get; set; }
public List<string> LDAPSProtocols { get; set; }
public DateTime PwdLastSet { get; set; }
public string RegistrationProblem { get; set; }
[DefaultValue(null)]
public List<HealthcheckDomainControllerDelegation> Delegations { get; set; }
[XmlIgnore]
[IgnoreDataMember]
public List<string> msDSRevealedUsers { get; set; }
[XmlIgnore]
[IgnoreDataMember]
public List<string> msDSRevealOnDemandGroup { get; set; }
[XmlIgnore]
[IgnoreDataMember]
public List<string> msDSNeverRevealGroup { get; set; }
public bool RODC { get; set; }
public bool SYSVOLOverwrite { get; set; }
}
[XmlType("delegation")]
public class HealthcheckDomainControllerDelegation
{
[XmlAttribute]
public string Delegate { get; set; }
[XmlAttribute]
public string DelegateSid { get; set; }
[XmlAttribute]
public string DelegationType { get; set; }
}
[DebuggerDisplay("{SiteName}")]
public class HealthcheckSite
{
public string SiteName { get; set; }
public string Description { get; set; }
public string Location { get; set; }
public List<string> Networks { get; set; }
}
public class HealthcheckDnsZones
{
public string name { get; set; }
public bool InsecureUpdate { get; set; }
}
[XmlType("Dist")]
public class HealthcheckPwdDistributionData
{
[XmlAttribute]
public int HigherBound { get; set; }
[XmlAttribute]
public int Value { get; set; }
}
[DebuggerDisplay("{Domain}")]
public class HealthcheckData : IRiskEvaluation, IPingCastleReport
{
public string EngineVersion { get; set; }
public DateTime GenerationDate { get; set; }
public string GetHumanReadableFileName()
{
return "ad_hc_" + DomainFQDN + ".html";
}
public string GetMachineReadableFileName()
{
return "ad_hc_" + DomainFQDN + ".xml";
}
public void SetExportLevel(PingCastleReportDataExportLevel level)
{
Level = level;
}
// this property is used to limit the serialization of some properties
private PingCastleReportDataExportLevel _level;
public PingCastleReportDataExportLevel Level
{
get
{
return _level;
}
set
{
_level = value;
// if the value is changed, propagate it to properties which needs it
if (UserAccountData != null)
{
UserAccountData.Level = value;
}
if (ComputerAccountData != null)
{
ComputerAccountData.Level = value;
}
if (PrivilegedGroups != null)
{
foreach (var group in PrivilegedGroups)
{
group.Level = value;
}
}
if (RiskRules != null)
{
foreach (var rule in RiskRules)
{
rule.Level = value;
}
}
if (ControlPaths != null && ControlPaths.Data != null)
{
foreach (var d in ControlPaths.Data)
{
d.Level = value;
}
}
}
}
public void InitializeReportingData()
{
version = new Version(EngineVersion.Split(' ')[0]);
applicableRules = new List<RuleBase<HealthcheckData>>();
foreach (var rule in RuleSet<HealthcheckData>.Rules)
{
object[] models = rule.GetType().GetCustomAttributes(typeof(RuleIntroducedInAttribute), true);
if (models != null && models.Length != 0)
{
RuleIntroducedInAttribute model = (RuleIntroducedInAttribute)models[0];
if (model.Version <= version)
{
applicableRules.Add(rule);
}
}
else
{
applicableRules.Add(rule);
}
}
if (MaturityLevel == 0)
{
MaturityLevel = 5;
foreach (var rule in RiskRules)
{
var hcrule = RuleSet<HealthcheckData>.GetRuleFromID(rule.RiskId);
if (hcrule == null)
{
continue;
}
int level = hcrule.MaturityLevel;
if (level > 0 && level < MaturityLevel)
MaturityLevel = level;
}
}
}
[IgnoreDataMember]
[XmlIgnore]
public Version version { get; set; }
public int MaturityLevel { get; set; }
[IgnoreDataMember]
[XmlIgnore]
public List<RuleBase<HealthcheckData>> applicableRules {get;set;}
private Dictionary<string, GPOInfo> _GPOInfoDic;
[IgnoreDataMember]
[XmlIgnore]
public Dictionary<string, GPOInfo> GPOInfoDic
{
get
{
if (_GPOInfoDic != null)
return _GPOInfoDic;
_GPOInfoDic = new Dictionary<string, GPOInfo>(StringComparer.OrdinalIgnoreCase);
foreach (var gpo in GPOInfo)
{
if (!_GPOInfoDic.ContainsKey(gpo.GPOId))
{
_GPOInfoDic.Add(gpo.GPOId, gpo);
}
}
return _GPOInfoDic;
}
}
public string DomainFQDN { get; set; }
public string NetBIOSName { get; set; }
public string ForestFQDN { get; set; }
public DateTime DomainCreation { get; set; }
public string DomainSid { get; set; }
public int DomainFunctionalLevel { get; set; }
public int ForestFunctionalLevel { get; set; }
public int SchemaVersion { get; set; }
public int SchemaInternalVersion { get; set; }
public bool IsRecycleBinEnabled { get; set; }
public DateTime SchemaLastChanged { get; set; }
public int NumberOfDC { get; set; }
public int GlobalScore { get; set; }
public int StaleObjectsScore { get; set; }
public int PrivilegiedGroupScore { get; set; }
public int TrustScore { get; set; }
public int AnomalyScore { get; set; }
public bool ShouldSerializeTrusts() { return (int)Level <= (int)PingCastleReportDataExportLevel.Light; }
public List<HealthCheckTrustData> Trusts { get; set; }
public bool ShouldSerializeReachableDomains() { return (int)Level <= (int)PingCastleReportDataExportLevel.Light; }
public List<HealthCheckTrustDomainInfoData> ReachableDomains { get; set; }
public bool ShouldSerializeDomainControllers() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public List<HealthcheckDomainController> DomainControllers { get; set; }
public bool ShouldSerializeSites() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public List<HealthcheckSite> Sites { get; set; }
public bool ShouldSerializePreWindows2000AnonymousAccess() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public bool PreWindows2000AnonymousAccess { get; set; }
public bool ShouldSerializePreWindows2000NoDefault() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public bool PreWindows2000NoDefault { get; set; }
public bool ShouldSerializeDsHeuristicsAnonymousAccess() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public bool DsHeuristicsAnonymousAccess { get; set; }
public bool ShouldSerializeDsHeuristicsAdminSDExMaskModified() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public bool DsHeuristicsAdminSDExMaskModified { get; set; }
public bool ShouldSerializeDsHeuristicsDoListObject() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public bool DsHeuristicsDoListObject { get; set; }
public bool ShouldSerializeDsHeuristicsAllowAnonNSPI() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public bool DsHeuristicsAllowAnonNSPI { get; set; }
public bool ShouldSerializeUsingNTFRSForSYSVOL() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public bool UsingNTFRSForSYSVOL { get; set; }
public bool ShouldSerializeRiskRules() { return (int)Level <= (int)PingCastleReportDataExportLevel.Light; }
public List<HealthcheckRiskRule> RiskRules { get; set; }
[IgnoreDataMember]
[XmlIgnore]
public IList<IRuleScore> AllRiskRules { get { return RiskRules.ConvertAll(x => { return (IRuleScore)x; }); } }
public bool ShouldSerializeUserAccountData() { return (int)Level <= (int)PingCastleReportDataExportLevel.Light; }
public HealthcheckAccountData UserAccountData { get; set; }
public bool ShouldSerializeComputerAccountData() { return (int)Level <= (int)PingCastleReportDataExportLevel.Light; }
public HealthcheckAccountData ComputerAccountData { get; set; }
public bool ShouldSerializeOperatingSystem() { return (int)Level <= (int)PingCastleReportDataExportLevel.Light; }
public List<HealthcheckOSData> OperatingSystem { get; set; }
// DO NOT USE - former data
public bool ShouldSerializeOperatingSystemDC() { return (int)Level <= (int)PingCastleReportDataExportLevel.Light; }
public List<HealthcheckOSData> OperatingSystemDC { get; set; }
public bool ShouldSerializeListComputerPwdNotChanged() { return (int)Level <= (int)PingCastleReportDataExportLevel.Full; }
public List<HealthcheckAccountDetailData> ListComputerPwdNotChanged { get; set; }
public bool ShouldSerializeGPOInfo() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public List<GPOInfo> GPOInfo { get; set; }
public bool ShouldSerializeLoginScript() { return (int)Level <= (int)PingCastleReportDataExportLevel.Normal; }
public List<HealthcheckLoginScriptData> LoginScript { get; set; }