Skip to content

Commit 319b35e

Browse files
committed
PingCastle 2.10.1.1
1 parent f645973 commit 319b35e

File tree

8 files changed

+197
-113
lines changed

8 files changed

+197
-113
lines changed

Healthcheck/HealthcheckAnalyzer.cs

Lines changed: 132 additions & 99 deletions
Large diffs are not rendered by default.

Healthcheck/Rules/HeatlcheckRulePrivilegedDNSAdmin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
namespace PingCastle.Healthcheck.Rules
1111
{
1212
[RuleModel("P-DNSAdmin", RiskRuleCategory.PrivilegedAccounts, RiskModelCategory.ACLCheck)]
13-
[RuleComputation(RuleComputationType.TriggerOnPresence, 5)]
13+
[RuleComputation(RuleComputationType.TriggerOnPresence, 0)]
1414
[RuleIntroducedIn(2, 9)]
15-
[RuleDurANSSI(1, "dnsadmins", "DnsAdmins group members")]
15+
[RuleDurANSSI(4, "dnsadmins", "DnsAdmins group members")]
1616
[RuleMitreAttackMitigation(MitreAttackMitigation.PrivilegedAccountManagement)]
1717
public class HeatlcheckRulePrivilegedDNSAdmin : RuleBase<HealthcheckData>
1818
{

Healthcheck/Rules/RuleDescription.resx

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,17 @@ To change it you can edit the owner of an object using &lt;a href="https://docs.
248248
<value>The purpose is to ensure that every account having an SID History is part of an active migration.</value>
249249
</data>
250250
<data name="T_SIDHistoryUnknownDomain_Solution" xml:space="preserve">
251-
<value>Each security descriptor of the domain (including file shares for example) should be reviewed to be rewritten with the new SID of the account. Then the SID History attribute should be removed. Please note that once the SID History has been removed, it cannot be added back again without doing a real migration. Hopefully hacking tools such as mimikatz can be used to undo a deletion with for example the lsadump::dcshadow attack.</value>
251+
<value>Each security descriptor of the domain (including file shares for example) should be reviewed to be rewritten with the new SID of the account. Then the SID History attribute should be removed.
252+
253+
Please note that once the SID History has been removed, it cannot be added back again without doing a real migration. Hopefully hacking tools such as mimikatz can be used to undo a deletion with for example the lsadump::dcshadow attack.
254+
255+
To remove the SIDHistory from a user account, run:
256+
&lt;i&gt;Get-ADUser USERNAME -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
257+
For a group, run:
258+
&lt;i&gt;Get-ADGroup GROUPNAME -properties sidhistory | foreach {Set-ADGroup $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
259+
For all users in a OU:
260+
&lt;i&gt;Get-ADUser -SearchBase "OU=Accounts,DC=mydomain,DC=com" -Filter {sidhistory -like '*'} -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
261+
</value>
252262
</data>
253263
<data name="T_SIDHistoryUnknownDomain_Rationale" xml:space="preserve">
254264
<value>{count} unknown domain(s) used in SIDHistory</value>
@@ -260,7 +270,15 @@ To change it you can edit the owner of an object using &lt;a href="https://docs.
260270
<value>The purpose is to ensure that accounts are not linked for more privileged accounts in the same domain</value>
261271
</data>
262272
<data name="T_SIDHistorySameDomain_Solution" xml:space="preserve">
263-
<value>It is not possible to have this occurrence except if a user from domain A has been migrated to domain B and then migrated again to domain A. This should be strongly investigated as it may be linked to a compromise of the domain.</value>
273+
<value>It is not possible to have this occurrence except if a user from domain A has been migrated to domain B and then migrated again to domain A. This should be strongly investigated as it may be linked to a compromise of the domain.
274+
275+
To remove the SIDHistory from a user account, run:
276+
&lt;i&gt;Get-ADUser USERNAME -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
277+
For a group, run:
278+
&lt;i&gt;Get-ADGroup GROUPNAME -properties sidhistory | foreach {Set-ADGroup $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
279+
For all users in a OU:
280+
&lt;i&gt;Get-ADUser -SearchBase "OU=Accounts,DC=mydomain,DC=com" -Filter {sidhistory -like '*'} -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
281+
</value>
264282
</data>
265283
<data name="T_SIDHistorySameDomain_Rationale" xml:space="preserve">
266284
<value>Account(s) with SID History matching the domain = {count}</value>
@@ -883,7 +901,17 @@ Do not apply /quarantine on a forest trust: you will break the transitivity of t
883901
</data>
884902
<data name="S_SIDHistory_Solution" xml:space="preserve">
885903
<value>To solve the security issue, you should remove all the SIDHistory attributes. To do so, you can list the objects having an SIDHistory attribute using the command: &lt;i&gt;get-ADObject -ldapfilter "(sidhistory=*)" -properties sidhistory&lt;/i&gt;.
886-
Each security descriptor of the domain (including file shares for example) should be reviewed to be rewritten with the new SID of the account. Then, the attribute can be removed of these accounts using the migration tool or a PowerShell snippet &lt;i&gt;Remove-SIDHistory&lt;/i&gt; once the migration is completed. Please note that once the SID History has been removed, it cannot be added back again without doing a real migration. Hopefully hacking tools such as mimikatz can be used to undo a deletion with for example the lsadump::dcshadow attack.</value>
904+
Each security descriptor of the domain (including file shares for example) should be reviewed to be rewritten with the new SID of the account. Then, the attribute can be removed of these accounts using the migration tool or a PowerShell snippet &lt;i&gt;Remove-SIDHistory&lt;/i&gt; once the migration is completed.
905+
906+
Please note that once the SID History has been removed, it cannot be added back again without doing a real migration. Hopefully hacking tools such as mimikatz can be used to undo a deletion with for example the lsadump::dcshadow attack.
907+
908+
To remove the SIDHistory from a user account, run:
909+
&lt;i&gt;Get-ADUser USERNAME -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
910+
For a group, run:
911+
&lt;i&gt;Get-ADGroup GROUPNAME -properties sidhistory | foreach {Set-ADGroup $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
912+
For all users in a OU:
913+
&lt;i&gt;Get-ADUser -SearchBase "OU=Accounts,DC=mydomain,DC=com" -Filter {sidhistory -like '*'} -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
914+
</value>
887915
</data>
888916
<data name="S_SIDHistory_Rationale" xml:space="preserve">
889917
<value>{count} domain(s) used in SIDHistory</value>
@@ -1980,7 +2008,7 @@ SeManageVolumePrivilege can be used to reset the security descriptor on the C vo
19802008
<data name="T_SIDFiltering_ReportLocation" xml:space="preserve">
19812009
<value>The detail can be found in &lt;a href="#discovereddomains"&gt;Trusts section&lt;/a&gt;</value>
19822010
</data>
1983-
<data name="T_SIDHistorySameDomain" xml:space="preserve">
2011+
<data name="T_SIDHistorySameDomain_ReportLocation" xml:space="preserve">
19842012
<value>The SIDHistory detail can be found in &lt;a href="#useraccountanalysis"&gt;User information&lt;/a&gt; and &lt;a href="#computeraccountanalysis"&gt;Computer information&lt;/a&gt; and a quick summary in &lt;a href="#sidhistory"&gt;SID History&lt;/a&gt;</value>
19852013
</data>
19862014
<data name="T_SIDHistoryUnknownDomain_ReportLocation" xml:space="preserve">
@@ -3179,6 +3207,13 @@ Please note that at the time of writing, Microsoft supports it until Windows 202
31793207
<data name="T_SIDHistoryDangerous_Solution" xml:space="preserve">
31803208
<value>
31813209
Identify the account, computer or group having these dangerous SID set in SID History, then clean it up by editing directly the SIDHistory attribute of the underlying AD object.
3210+
3211+
To remove the SIDHistory from a user account, run:
3212+
&lt;i&gt;Get-ADUser USERNAME -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
3213+
For a group, run:
3214+
&lt;i&gt;Get-ADGroup GROUPNAME -properties sidhistory | foreach {Set-ADGroup $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
3215+
For all users in a OU:
3216+
&lt;i&gt;Get-ADUser -SearchBase "OU=Accounts,DC=mydomain,DC=com" -Filter {sidhistory -like '*'} -properties sidhistory | foreach {Set-ADUser $_ -remove @{sidhistory=$_.sidhistory.value}}&lt;/i&gt;
31823217
</value>
31833218
</data>
31843219
<data name="T_SIDHistoryDangerous_TechnicalExplanation" xml:space="preserve">
@@ -3554,7 +3589,13 @@ https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-dnsp/007efcd2-29
35543589
<value>The detail can be found in &lt;a href="#admingroups"&gt;Admin Groups&lt;/a&gt;</value>
35553590
</data>
35563591
<data name="P_DNSAdmin_Solution" xml:space="preserve">
3557-
<value>You should remove the members of the DNS admin group and do a proper delegation to the specific DNS Zones.
3592+
<value>Rule update:
3593+
The Path Tuesday of October 2021 fixed this vulnerability and assigned it the identifier CVE-2021-40469.
3594+
If the patch has been applied, there is no additional mitigation to perform.
3595+
3596+
This rule is transformed into an informative rule in PingCastle 2.10.1 and will be removed in future version of PingCastle.
3597+
3598+
You should remove the members of the DNS admin group and do a proper delegation to the specific DNS Zones.
35583599

35593600
First, grant only "Read Property", "List", "List object" and "Read permssions" to CN=MicrosoftDNS,CN=System to enable access to the RPC service.
35603601

Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@
2828
// Numéro de build
2929
// Révision
3030
//
31-
[assembly: AssemblyVersion("2.10.1.0")]
32-
[assembly: AssemblyFileVersion("2.10.1.0")]
31+
[assembly: AssemblyVersion("2.10.1.1")]
32+
[assembly: AssemblyFileVersion("2.10.1.1")]

RPC/nativemethods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class NativeMethods
2222

2323
[DllImport("Rpcrt4.dll", EntryPoint = "NdrClientCall2", CallingConvention = CallingConvention.Cdecl,
2424
CharSet = CharSet.Unicode, SetLastError = false)]
25-
internal static extern IntPtr NdrClientCall2x64(IntPtr pMIDL_STUB_DESC, IntPtr formatString, IntPtr intptrServer, int flag, ref PingCastle.RPC.nrpc.NETLOGON_TRUSTED_DOMAIN_ARRAY output);
25+
internal static extern IntPtr NdrClientCall2x64(IntPtr pMIDL_STUB_DESC, IntPtr formatString, IntPtr intptrServer, int flag, ref PingCastle.RPC.nrpc2.NETLOGON_TRUSTED_DOMAIN_ARRAY output);
2626

2727
[DllImport("Rpcrt4.dll", EntryPoint = "NdrClientCall2", CallingConvention = CallingConvention.Cdecl,
2828
CharSet = CharSet.Unicode, SetLastError = false)]

RPC/nrpc.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public enum TrustedDomainFlag
3838
DS_DOMAIN_DIRECT_INBOUND = 32,
3939
}
4040

41-
public class nrpc : rpcapi
41+
public class nrpc2 : rpcapi
4242
{
4343

4444
private static byte[] MIDL_ProcFormatStringx86 = new byte[] {
@@ -90,7 +90,7 @@ private struct DS_DOMAIN_TRUSTSW
9090
}
9191

9292
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
93-
public nrpc(bool WillUseNullSession = true)
93+
public nrpc2(bool WillUseNullSession = true)
9494
{
9595
Guid interfaceId = new Guid(magic(8) + "-" + magic(4) + "-ABCD-EF00-01234567CFFB");
9696
if (IntPtr.Size == 8)
@@ -105,7 +105,7 @@ public nrpc(bool WillUseNullSession = true)
105105
}
106106

107107
[SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
108-
~nrpc()
108+
~nrpc2()
109109
{
110110
freeStub();
111111
}

Scanners/nullsessionTrustScanner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Program.DisplayState QueryForAdditionalParameterInInteractiveMode()
4040
public void Export(string filename)
4141
{
4242
DisplayAdvancement("Starting");
43-
nrpc session = new nrpc(); ;
43+
nrpc2 session = new nrpc2(); ;
4444
DisplayAdvancement("Trusts obtained via null session");
4545
List<TrustedDomain> domains;
4646
int res = session.DsrEnumerateDomainTrusts(Server, 0x3F, out domains);

Tasks.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ public bool GenerateFakeReport()
234234
{
235235
var enduserReportGenerator = PingCastleFactory.GetEndUserReportGenerator<HealthcheckData>();
236236
enduserReportGenerator.GenerateReportFile(pingCastleReport, License, pingCastleReport.GetHumanReadableFileName());
237+
DisplayAdvancement("Export level is " + ExportLevel);
238+
if (ExportLevel != PingCastleReportDataExportLevel.Full)
239+
{
240+
DisplayAdvancement("Personal data will NOT be included in the .xml file (add --level Full to add it)");
241+
}
237242
pingCastleReport.SetExportLevel(ExportLevel);
238243
DataHelper<HealthcheckData>.SaveAsXml(pingCastleReport, pingCastleReport.GetMachineReadableFileName(), EncryptReport);
239244

@@ -413,6 +418,11 @@ T PerformTheAnalysis<T>(string server) where T : IPingCastleReport
413418
var enduserReportGenerator = PingCastleFactory.GetEndUserReportGenerator<T>();
414419
htmlreports[domain] = enduserReportGenerator.GenerateReportFile(pingCastleReport, License, pingCastleReport.GetHumanReadableFileName());
415420
DisplayAdvancement("Generating xml file for consolidation report" + (EncryptReport ? " (encrypted)" : ""));
421+
DisplayAdvancement("Export level is " + ExportLevel);
422+
if (ExportLevel != PingCastleReportDataExportLevel.Full)
423+
{
424+
DisplayAdvancement("Personal data will NOT be included in the .xml file (add --level Full to add it)");
425+
}
416426
pingCastleReport.SetExportLevel(ExportLevel);
417427
xmlreports[domain] = DataHelper<T>.SaveAsXml(pingCastleReport, pingCastleReport.GetMachineReadableFileName(), EncryptReport);
418428
DisplayAdvancement("Done");

0 commit comments

Comments
 (0)