{"id":394,"date":"2024-03-23T19:26:33","date_gmt":"2024-03-23T19:26:33","guid":{"rendered":"https:\/\/jsec-rt.com\/?p=394"},"modified":"2024-07-08T22:53:39","modified_gmt":"2024-07-09T02:53:39","slug":"rt-bt-enumeracion-sobre-active-directory-y-explotacion-de-acls-para-escalar-privilegios-parte-1-2","status":"publish","type":"post","link":"https:\/\/jsec-rt.com\/index.php\/en\/2024\/03\/23\/rt-bt-enumeracion-sobre-active-directory-y-explotacion-de-acls-para-escalar-privilegios-parte-1-2\/","title":{"rendered":"RT\/BT &#8211; Active Directory enumeration and ACL exploitation for privilege escalation &#8211; Part 1"},"content":{"rendered":"\n<p>In this post we will use different tools to analyze an Active Directory environment, both from Linux and Windows.<\/p>\n\n\n\n<p>This post is useful for both Pentesters and Blue Team members, as it identifies possible attack vectors and insecure configurations on a domain. Both to exploit from the attacker&#8217;s side, and to correct and monitor from Blue Team&#8217;s side.<\/p>\n\n\n\n<p>We will use the previously deployed Active Directory to practice, the tools we will use are:<\/p>\n\n\n\n<p><strong>Windows:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Powerview &#8211; https:\/\/github.com\/PowerShellMafia\/PowerSploit\/blob\/dev\/Recon\/PowerView.ps1 (Archived, still useful however).<\/li>\n\n\n\n<li>RSAT Active Directory DLL &#8211; https:\/\/github.com\/samratashok\/ADModule.git (DLL signed by Microsoft to manage an Active Directory environment from Powershell)<\/li>\n\n\n\n<li>SharpHound &#8211; https:\/\/github.com\/BloodHoundAD\/BloodHound\/tree\/master\/Collectors (Bloodhound ingestor tool, automates the process of enumerating the internal domain)<\/li>\n<\/ul>\n\n\n\n<p><strong>Linux:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ldapdomaindump &#8211; https:\/\/github.com\/dirkjanm\/ldapdomaindump.git (Previously used tool, Active Directory enumeration tool)<\/li>\n\n\n\n<li>bloodhound-python &#8211; https:\/\/github.com\/fox-it\/BloodHound.py.git (python based bloodhound ingestor)<\/li>\n<\/ul>\n\n\n\n<p>For both cases, it&#8217;s necessary to have Bloodhound installed correctly, including the Neo4j database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">NEO4J\/BLOODHOUND installation<\/h2>\n\n\n\n<p>Windows installation documentation:<\/p>\n\n\n\n<p><a href=\"https:\/\/bloodhound.readthedocs.io\/en\/latest\/installation\/windows.html\">https:\/\/bloodhound.readthedocs.io\/en\/latest\/installation\/windows.html<\/a><\/p>\n\n\n\n<p>Linux installation documentation:<br><a href=\"https:\/\/bloodhound.readthedocs.io\/en\/latest\/installation\/linux.html\">https:\/\/bloodhound.readthedocs.io\/en\/latest\/installation\/linux.html<\/a><\/p>\n\n\n\n<p>Following the guides, we can start recollecting information with the ingestors and analyzing it through Bloodhound.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">AD CONFIGURATION TO EXPLORE MULTIPLE ATTACK VECTORS THROUGH BLOODHOUND<\/h2>\n\n\n\n<p>We&#8217;re going to add a couple of insecure configurations through the <strong>ADSI Edit <\/strong>option in the DC.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"542\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-1024x542.png\" alt=\"\" class=\"wp-image-150\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-1024x542.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-300x159.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-768x407.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-1536x814.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image.png 1552w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The first time we start the console, we need to connect to our AD by clicking on <strong>Actions > Connect To<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"847\" height=\"596\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-1.png\" alt=\"\" class=\"wp-image-151\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-1.png 847w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-1-300x211.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-1-768x540.png 768w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/figure>\n\n\n\n<p>We can leave the default values for this exercise.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"908\" height=\"724\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-2.png\" alt=\"\" class=\"wp-image-152\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-2.png 908w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-2-300x239.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-2-768x612.png 768w\" sizes=\"auto, (max-width: 908px) 100vw, 908px\" \/><\/figure>\n\n\n\n<p>Once the connection has been established, we expand our main tree until we identify the <strong>CN=Users<\/strong> folder, where we&#8217;ll see our domain groups and users.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"911\" height=\"711\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-3.png\" alt=\"\" class=\"wp-image-153\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-3.png 911w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-3-300x234.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-3-768x599.png 768w\" sizes=\"auto, (max-width: 911px) 100vw, 911px\" \/><\/figure>\n\n\n\n<p>Here we can modify the DACL properties for any domain object, in this scenario, we&#8217;ll give the <strong>hank.scorpio<\/strong> user privileges over the <strong>admin<\/strong> user.<\/p>\n\n\n\n<p>Right click on the <strong>admin<\/strong> user object and we access to <strong>Properties<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"346\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-4.png\" alt=\"\" class=\"wp-image-155\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-4.png 884w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-4-300x117.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-4-768x301.png 768w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/figure>\n\n\n\n<p>We move to the <strong>Security<\/strong> tab and we click on <strong>Add<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"993\" height=\"664\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-5.png\" alt=\"\" class=\"wp-image-156\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-5.png 993w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-5-300x201.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-5-768x514.png 768w\" sizes=\"auto, (max-width: 993px) 100vw, 993px\" \/><\/figure>\n\n\n\n<p>In the new window, we write the desired username and click on <strong>Check Names<\/strong> so the object gets searched for within our Forest.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"844\" height=\"599\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-6.png\" alt=\"\" class=\"wp-image-157\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-6.png 844w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-6-300x213.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-6-768x545.png 768w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><\/figure>\n\n\n\n<p>We click <strong>OK<\/strong> and then define which permissions we want to give the <strong>hank.scorpio<\/strong> over the <strong>admin<\/strong> user, for this post, we&#8217;re going to assign the <strong>Change Password<\/strong> privilege.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1001\" height=\"689\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-7.png\" alt=\"\" class=\"wp-image-158\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-7.png 1001w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-7-300x206.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-7-768x529.png 768w\" sizes=\"auto, (max-width: 1001px) 100vw, 1001px\" \/><\/figure>\n\n\n\n<p>We apply the changes and switch to another user.<\/p>\n\n\n\n<p>Repeating previous steps, we&#8217;re going to give the user <strong>Service_BD<\/strong> privileges over the <strong>Administrators<\/strong> group.<\/p>\n\n\n\n<p>To identify the group, we move into the <strong>CN=Builtin <\/strong>folder on the main tree.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"911\" height=\"643\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-8.png\" alt=\"\" class=\"wp-image-159\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-8.png 911w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-8-300x212.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-8-768x542.png 768w\" sizes=\"auto, (max-width: 911px) 100vw, 911px\" \/><\/figure>\n\n\n\n<p>Modifying the group, we add the <strong>Service_BD<\/strong> user to the list.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1002\" height=\"629\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-9.png\" alt=\"\" class=\"wp-image-160\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-9.png 1002w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-9-300x188.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-9-768x482.png 768w\" sizes=\"auto, (max-width: 1002px) 100vw, 1002px\" \/><\/figure>\n\n\n\n<p>We assign the <strong>Write<\/strong> privilege over the <strong>Administrators<\/strong> group.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"638\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-10-1024x638.png\" alt=\"\" class=\"wp-image-161\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-10-1024x638.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-10-300x187.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-10-768x479.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-10.png 1032w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Then, we can click on <strong>Update Schema Now<\/strong> to make sure the changes were applied.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"809\" height=\"744\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-15.png\" alt=\"\" class=\"wp-image-167\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-15.png 809w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-15-300x276.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-15-768x706.png 768w\" sizes=\"auto, (max-width: 809px) 100vw, 809px\" \/><\/figure>\n\n\n\n<p>With these configurations, we&#8217;ll proceed to extract information regarding possible attack paths using SharpHound\/bloodhound-python.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SHARPHOUND EXECUTION<\/h2>\n\n\n\n<p>Sharphound comes both in exe and PS1, in this case, we&#8217;re going to use the Windows binary.<\/p>\n\n\n\n<p>We&#8217;re going to use the <strong>TECNOLOGIA01<\/strong> host to execute the ingestor since it&#8217;s a domain joined machine.<\/p>\n\n\n\n<p>For simplicity sake, we&#8217;ll disable the antivirus to execute the binary.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"661\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-17-1024x661.png\" alt=\"\" class=\"wp-image-169\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-17-1024x661.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-17-300x194.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-17-768x496.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-17.png 1101w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Since we&#8217;re logged in as a domain user, the CMD window runs under the domain user&#8217;s context, so we don&#8217;t need to specify credentials unless we want to use a different user to run the enumeration tasks. (We&#8217;re going to explore options on how to execute the tool using a non domain joined machine)<\/p>\n\n\n\n<p>We execute Sharphound with the flag &#8220;<strong>-c all&#8221;<\/strong> so it obtains as much information as possible (very noisy).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"631\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-18-1024x631.png\" alt=\"\" class=\"wp-image-170\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-18-1024x631.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-18-300x185.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-18-768x473.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-18.png 1120w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once the extraction finishes, a compressed file is generated, which we can move into the host that has Bloodhound and Neo4j installed.<\/p>\n\n\n\n<p>Using bloodhound-python from Linux is pretty similar, the only notable difference is that we would need to specify the domain controller and the credentials, or establish the domain controller as a DNS server on our Linux host.<\/p>\n\n\n\n<p>We can edit the \/etc\/resolv.conf file to manually add a DNS server.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"231\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-25.png\" alt=\"\" class=\"wp-image-177\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-25.png 652w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-25-300x106.png 300w\" sizes=\"auto, (max-width: 652px) 100vw, 652px\" \/><\/figure>\n\n\n\n<p>Executing bloodhound-python with the mentioned parameters, we start the enumeration process.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"574\" height=\"397\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-26.png\" alt=\"\" class=\"wp-image-178\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-26.png 574w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-26-300x207.png 300w\" sizes=\"auto, (max-width: 574px) 100vw, 574px\" \/><\/figure>\n\n\n\n<p>Once it finishes, we get 4 json files ready to be imported into Bloodhound.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"426\" height=\"71\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-27.png\" alt=\"\" class=\"wp-image-179\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-27.png 426w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-27-300x50.png 300w\" sizes=\"auto, (max-width: 426px) 100vw, 426px\" \/><\/figure>\n\n\n\n<p>We can drag and drop the files into the Bloodhound main window, where the data will start to get uploaded and analyzed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"626\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-19-1024x626.png\" alt=\"\" class=\"wp-image-171\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-19-1024x626.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-19-300x183.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-19-768x469.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-19.png 1401w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once it&#8217;s done, we can use pre-existing queries to find possible attack paths.<\/p>\n\n\n\n<p><strong>Find all Domain Admins<\/strong>.<\/p>\n\n\n\n<p>It identifies members of the <strong>Domain Admins<\/strong> group.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"672\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-20-1024x672.png\" alt=\"\" class=\"wp-image-172\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-20-1024x672.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-20-300x197.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-20-768x504.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-20.png 1293w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>There, we can observe multiple domain admins, including a machine account, indicating that if we get to compromise the <strong>TECNOLOGIA01<\/strong> host and obtain the machine account NTLM hash, we could perform a DCSync attack to compromise the domain.<\/p>\n\n\n\n<p>But this is a group membership problem, since we&#8217;re trying to explore ACL attack paths, we can use a different pre-built query in Bloodhound, <strong>Find Shortest Paths to Domain Admins<\/strong>, where we&#8217;ll see the following result.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"455\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-21-1024x455.png\" alt=\"\" class=\"wp-image-173\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-21-1024x455.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-21-300x133.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-21-768x341.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-21-1536x682.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-21.png 1677w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Analyzing all of this possible paths can be overwhelming, but by doing so, we can identify if there&#8217;s a direct path to compromise a Domain Admin.<\/p>\n\n\n\n<p>We observe that the <strong>PWNED, ADMIN, JSEC, ADMINISTRATOR <\/strong>users and the <strong>TECNOLOGIA01<\/strong> host belong to the Domain Admins group, however, if we focus on the upper part, we can identify a different path.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"583\" height=\"129\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-23.png\" alt=\"\" class=\"wp-image-175\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-23.png 583w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-23-300x66.png 300w\" sizes=\"auto, (max-width: 583px) 100vw, 583px\" \/><\/figure>\n\n\n\n<p>We see that <strong>SERVICE_BD<\/strong> has a <strong>GenericWrite<\/strong> link pointing to the <strong>ADMINISTRATORS<\/strong> group, meaning that by compromising this user, we can modify this group&#8217;s properties.<\/p>\n\n\n\n<p>Simplifying some Active Directory concepts, we can consider the existing users, groups, machines, group policies, organizational units and more as <strong>Objects<\/strong>, each with specific and different properties according to the type of object (a user object will have different properties than a group object), the identified link can be interpreted as a special privilege the <strong>Service_BD<\/strong> has over the <strong>ADMINISTRATORS<\/strong> group, even when the user is not a member of it, so we can use this privilege to add any domain user into this group.<\/p>\n\n\n\n<p>The pre-build query identified this path, but I always recommend to find valuable users and explore their Explicit Object Controllers, since we can identify other possible attack paths.<\/p>\n\n\n\n<p>Going back to Bloodhound, we explore all of the high privilege users, eventually reaching the <strong>admin<\/strong> user where we expand the Explicit Object Controllers property.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"683\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-24-1024x683.png\" alt=\"\" class=\"wp-image-176\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-24-1024x683.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-24-300x200.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-24-768x513.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-24.png 1323w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Here we can find a special privilege granted to the <strong>hank.scorpio<\/strong> user that allows it to forcefully reset the <strong>admin<\/strong> user password.<\/p>\n\n\n\n<p>This is how we can identify a previously unknown attack path, which is why it&#8217;s recommended to carefully analyze Bloodhound results.<\/p>\n\n\n\n<p>Now we can proceed with the exploitation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ACL EXPLOITATION<\/h2>\n\n\n\n<p>We can use Powerview to exploit these misconfigurations, however, the tool is widely known and detected by most Antivirus solutions. We could disable the antivirus to proceed with the exploitation, but personally, I like to use the Microsoft signed Active Directory management DLL over Powerview to maintain a certain level of stealthiness, and since a common scenario during these types of engagements involves access to domain joined hosts where we can&#8217;t simply disable the antivirus, knowing how to use these legitimate tools can be advantageful.<\/p>\n\n\n\n<p>We can download the DLL into the <strong>TECNOLOGIA01<\/strong> host and import it through Powershell.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"458\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-29-1024x458.png\" alt=\"\" class=\"wp-image-181\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-29-1024x458.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-29-300x134.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-29-768x344.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-29.png 1099w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Sometimes we can get an error, but most of the time just importing again will work. We can proceed with the exploitation.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Service_BD user account with writing privilege over Administrators group.<\/h2>\n\n\n\n<p>For this scenario, we&#8217;re going to create a new low privileged user.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1025\" height=\"712\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-30.png\" alt=\"\" class=\"wp-image-182\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-30.png 1025w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-30-300x208.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-30-768x533.png 768w\" sizes=\"auto, (max-width: 1025px) 100vw, 1025px\" \/><\/figure>\n\n\n\n<p>To list the available commands of the imported module, we can use the Get-Command cmdlet.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"816\" height=\"804\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-31.png\" alt=\"\" class=\"wp-image-183\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-31.png 816w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-31-300x296.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-31-768x757.png 768w\" sizes=\"auto, (max-width: 816px) 100vw, 816px\" \/><\/figure>\n\n\n\n<p>To obtain information about the target group, we use the Get-ADGroupMember cmdlet.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"155\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-34.png\" alt=\"\" class=\"wp-image-186\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-34.png 640w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-34-300x73.png 300w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/figure>\n\n\n\n<p>We can see we have 6 members, <strong>legendario.esquilax<\/strong> and <strong>Service_BD <\/strong>are not.<\/p>\n\n\n\n<p>To keep things simple, we&#8217;re going to use the password for the <strong>Service_BD<\/strong> user we found before.<\/p>\n\n\n\n<p>Firstly, we define a credential type object to execute commands under the <strong>Service_BD<\/strong> user context, without the credential object, we would be running commands as <strong>cosme.fulanito<\/strong> user context, which is not useful given that <strong>Service_BD<\/strong> has the privileges we&#8217;ll exploit.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"874\" height=\"182\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-35.png\" alt=\"\" class=\"wp-image-187\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-35.png 874w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-35-300x62.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-35-768x160.png 768w\" sizes=\"auto, (max-width: 874px) 100vw, 874px\" \/><\/figure>\n\n\n\n<p>The <strong>$pass <\/strong>object stores the known password &#8220;P4ssw0rd123&#8221; as a secure string, which is required to use credential objects.<\/p>\n\n\n\n<p>The <strong>$cred<\/strong> object will store logon information for the account we define, in this case, <strong>Service_BD<\/strong> referencing the <strong>$pass<\/strong> object as its password, allowing us to use the object to impersonate the respective user.<\/p>\n\n\n\n<p>To exploit the ACL misconfiguration, we&#8217;ll use the <strong>Add-ADGroupMember<\/strong> cmdlet.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"132\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-36.png\" alt=\"\" class=\"wp-image-188\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-36.png 656w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-36-300x60.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/figure>\n\n\n\n<p>If we execute the command without parameters we&#8217;ll be prompted for the required information, however, we can also use a one-liner to execute the desired task.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"836\" height=\"248\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-37.png\" alt=\"\" class=\"wp-image-190\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-37.png 836w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-37-300x89.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-37-768x228.png 768w\" sizes=\"auto, (max-width: 836px) 100vw, 836px\" \/><\/figure>\n\n\n\n<p>The first line is adding the<strong> legendario.esquilax<\/strong>, defined by the parameter <strong>Members<\/strong>, into the <strong>Administrators<\/strong> group, defined by the <strong>Identity<\/strong> parameter, using the created credential object, defined by the parameter <strong>Credential<\/strong>.<\/p>\n\n\n\n<p>The second line is querying the group members again, this time showing the user we just added to the group, confirming the privilege abuse worked.<\/p>\n\n\n\n<p>We can easily confirm the validity of the user from our Kali host, successfully executing a DCSync and compromising the domain.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"907\" height=\"677\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-38.png\" alt=\"\" class=\"wp-image-191\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-38.png 907w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-38-300x224.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-38-768x573.png 768w\" sizes=\"auto, (max-width: 907px) 100vw, 907px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">HANK.SCORPIO WITH PASSWORD RESET PRIVILEGES OVER THE  ADMIN USER<\/h2>\n\n\n\n<p>The second attack path involves the <strong>hank.scorpio<\/strong> user, given that it can forcefully change the <strong>admin<\/strong> user&#8217;s password. We&#8217;ll be using the Active Directory signed DLL for this task.<\/p>\n\n\n\n<p>Once again, we create the <strong>$pass<\/strong> and <strong>$cred<\/strong> objects in order to impersonate the <strong>hank.scorpio<\/strong> user.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"849\" height=\"191\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-39.png\" alt=\"\" class=\"wp-image-192\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-39.png 849w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-39-300x67.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-39-768x173.png 768w\" sizes=\"auto, (max-width: 849px) 100vw, 849px\" \/><figcaption class=\"wp-element-caption\">La credencial expiro, por lo que la actualice a ese valor.<\/figcaption><\/figure>\n\n\n\n<p>Within our Kali host, we&#8217;ll try to login into the DC with the <strong>admin<\/strong> user and the password <strong>Test1234!!<\/strong>, the attempt fails.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"208\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-41-1024x208.png\" alt=\"\" class=\"wp-image-194\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-41-1024x208.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-41-300x61.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-41-768x156.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-41.png 1253w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To change the user&#8217;s password, we&#8217;ll use the <strong>Set-ADAccountPassword<\/strong> cmdlet, by defining a second secure string object named $<strong>newpass<\/strong> and the desired value.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"753\" height=\"64\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-40.png\" alt=\"\" class=\"wp-image-193\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-40.png 753w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-40-300x25.png 300w\" sizes=\"auto, (max-width: 753px) 100vw, 753px\" \/><\/figure>\n\n\n\n<p>The second line is the password change command, defining the target account through the <strong>Identity<\/strong> parameter, the user context through the <strong>Credential<\/strong> parameter and the new password, defined by the <strong>NewPassword<\/strong> parameter.<\/p>\n\n\n\n<p>Once we execute the command, we don&#8217;t get any errors or output, however, if we try to authenticate to the domain once again with the set password, we obtain administrative access.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"74\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-42-1024x74.png\" alt=\"\" class=\"wp-image-195\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-42-1024x74.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-42-300x22.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-42-768x55.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/07\/image-42.png 1233w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This is the first part of misconfigured or permissive ACL privileges, we&#8217;ll delve further on future posts (Attacks such as Resource Based Constrained Delegation and arbitrary SPN tickets registration for Kerberoasting attacks).<\/p>\n\n\n\n<p>Also, we&#8217;re going to use a non-domain joined host to execute this attacks, through Powershell objects and running proceses under a different user context through <strong>runas<\/strong>.<\/p>\n\n\n\n<p>For Blue Team members, it&#8217;s recommended to search for this type of misconfigurations in your internal infrastructure, analyzing Bloodhound in depth, mostly because these type of attack paths are slightly more complicated to exploit, but are also stealthier.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post we will use different tools to analyze an Active Directory environment, both from Linux and Windows. This post is useful for both Pentesters and Blue Team members, as it identifies possible attack vectors and insecure configurations on a domain. Both to exploit from the attacker&#8217;s side, and <a href=\"https:\/\/jsec-rt.com\/index.php\/en\/2024\/03\/23\/rt-bt-enumeracion-sobre-active-directory-y-explotacion-de-acls-para-escalar-privilegios-parte-1-2\/\" class=\"btn-link\">Continue Reading<i class=\"ion-ios-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,22],"tags":[26,28,30],"class_list":["post-394","post","type-post","status-publish","format-standard","hentry","category-bt-en","category-p-rt-en","tag-bt","tag-english","tag-rt"],"_links":{"self":[{"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/posts\/394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/comments?post=394"}],"version-history":[{"count":3,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/posts\/394\/revisions"}],"predecessor-version":[{"id":424,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/posts\/394\/revisions\/424"}],"wp:attachment":[{"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/media?parent=394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/categories?post=394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/tags?post=394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}