{"id":396,"date":"2024-03-24T01:07:58","date_gmt":"2024-03-24T01:07:58","guid":{"rendered":"https:\/\/jsec-rt.com\/?p=396"},"modified":"2024-07-08T22:53:46","modified_gmt":"2024-07-09T02:53:46","slug":"rt-ntlm-relay-y-coerce-authentication-casos-practicos-2","status":"publish","type":"post","link":"https:\/\/jsec-rt.com\/index.php\/en\/2024\/03\/24\/rt-ntlm-relay-y-coerce-authentication-casos-practicos-2\/","title":{"rendered":"RT &#8211; NTLM Relay and Coerce authentication, practical scenarios"},"content":{"rendered":"\n<p>I have come across many times, in real scenarios, certain configurations in the domain that allow an attacker to gain control over certain computers and servers under the following conditions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>We have the ability to force authentication of a user or server to the attacker&#8217;s computer.<\/li>\n\n\n\n<li>This user or server has administrative privileges over another server or workstation.<\/li>\n\n\n\n<li>SMB message signing is not required.<\/li>\n<\/ul>\n\n\n\n<p>The last two points are not under the attacker&#8217;s control, they are configurations that are already defined in a domain and an attacker without the necessary privileges cannot modify them, however, the first point can be executed by the attacker, through numerous techniques already documented and with their years of antiquity, in this post I will demonstrate how these relay attacks can be performed through different techniques, taking advantage of RPC calls to different services.<\/p>\n\n\n\n<p>One of these scenarios hit quite hard last year, through the Petit Potam vulnerability, which consists of abusing a legitimate functionality of an ADCS (Active Directory Certificate Services) server to request a base64 digital certificate belonging to a domain controller, using this to request a TGT on behalf of the DC, with this ticket you can perform certain actions impersonating the DC, including the recovery of its hash in NTLM format, and then use it in a DCSYNC process and get the rest of the hashes of the internal domain.<\/p>\n\n\n\n<p>Now, in many cases I saw that Petit Potam was referred to as obtaining the digital certificate through the ADCS, which in my opinion, is wrong, since the delivery of the digital certificate is the regular operation of the service. In my opinion and according to my experience, Petit Potam is the vulnerability that allows to force the authentication of a domain computer to the attacker&#8217;s computer, the relay to the ADCS and the rest of the mentioned points are part of the chain of exploitation, but not necessarily of the vulnerability.<\/p>\n\n\n\n<p>There is an abundance of resources on the exploitation of Petit Potam, so I will not explain the vulnerability or the exploitation chain as such, but what I do think is important to explore is Coerce Authentication.<\/p>\n\n\n\n<p>As I mentioned, it is the ability to force a user or computer to authenticate to another, using its machine account.<\/p>\n\n\n\n<p>Explaining this point a little more, in a simplified way, when a computer is associated to the internal domain, a user of this computer is created, which will be used to validate if the computer belongs or not to the internal domain, if the hostname of the computer is SERVER, the user created will be SERVER$.<\/p>\n\n\n\n<p>These users belonging to computers are equally valid to perform queries on the internal domain or authenticate to their respective resources, however, belong to a non-privileged group and their access is quite limited, but they can still be defined as administrator users or privileged by ACLs to other objects in the domain.<\/p>\n\n\n\n<p>In this post, I will show some scenarios that I encountered at work, where computers are administrators of other computers that do not require SMB message signing and capture NetNTLMv1 hashes using Responder from a domain controller, and then use an online service to try to obtain the respective NTLM hash.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lab configuration.<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Machine account users with administrative privilege over other hosts<\/h3>\n\n\n\n<p>In order to simulate a slightly more realistic environment, we&#8217;re going to create a new domain group called, in my case, <strong>equipos_ti<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"982\" height=\"1024\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-982x1024.png\" alt=\"\" class=\"wp-image-260\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-982x1024.png 982w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-288x300.png 288w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-768x801.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image.png 1346w\" sizes=\"auto, (max-width: 982px) 100vw, 982px\" \/><\/figure>\n\n\n\n<p>We&#8217;re going to add two hosts to this group, <strong>SOPORTE01<\/strong> and <strong>TECNOLOGIA01<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"780\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-1-1024x780.png\" alt=\"\" class=\"wp-image-261\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-1-1024x780.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-1-300x229.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-1-768x585.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-1-1536x1170.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-1.png 1722w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>In order to add computers to a group, we need to click on the <strong>Add<\/strong> button after accessing the group properties, on the search window, we need to click on <strong>Object Types<\/strong> and enable the <strong>Computers<\/strong> object.<\/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\/11\/image-2-1024x626.png\" alt=\"\" class=\"wp-image-262\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-2-1024x626.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-2-300x183.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-2-768x469.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-2-1536x939.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-2.png 1590w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once it&#8217;s enabled, we can add the hosts to the group.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"646\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-3-1024x646.png\" alt=\"\" class=\"wp-image-263\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-3-1024x646.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-3-300x189.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-3-768x484.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-3.png 1094w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once completed, we authenticate to the hosts with a local administrator and manually add the machine accounts as local administrator.<\/p>\n\n\n\n<p>Configuration at <strong>SOPORTE01<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"641\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-4-1024x641.png\" alt=\"\" class=\"wp-image-264\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-4-1024x641.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-4-300x188.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-4-768x480.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-4-1536x961.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-4.png 1560w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We add the domain group <strong>equipos_ti<\/strong> and the machine account <strong>ATENCION01$<\/strong> to the local administrators group.<\/p>\n\n\n\n<p>Configuration at <strong>TECNOLOGIA01<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"387\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-5-1024x387.png\" alt=\"\" class=\"wp-image-265\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-5-1024x387.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-5-300x113.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-5-768x290.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-5.png 1260w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We add the <strong>equipos_ti<\/strong> domain group to the local administrators group.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">NetNTLMv1 hash capture from the DC.<\/h3>\n\n\n\n<p>By default, latest Windows Server versions come with a safe configuration, however, older versions may have the vulnerable configuration.<\/p>\n\n\n\n<p>In the domain controller, we run <strong>secpol.msc<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"1003\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-6-1024x1003.png\" alt=\"\" class=\"wp-image-266\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-6-1024x1003.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-6-300x294.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-6-768x752.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-6.png 1448w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We expand the <strong>Local Policies<\/strong> folder, then <strong>Security Options<\/strong> and we find the <strong>Network Security: LAN Manager authentication level<\/strong> option.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"810\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-8-1024x810.png\" alt=\"\" class=\"wp-image-268\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-8-1024x810.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-8-300x237.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-8-768x607.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-8.png 1482w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>By double clicking, we can modify the value to any of these ones<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>Send LM&amp; NTLM responses<\/em><\/li>\n\n\n\n<li><em>Send LM&amp; NTLM \u2013 use NTLMv2 session security if negotiated<\/em><\/li>\n\n\n\n<li><em>SendNTLM responses only<\/em><\/li>\n<\/ul>\n\n\n\n<p>For this lab, I&#8217;ll use the <strong>Send LM&amp; NTLM responses<\/strong> option.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"716\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-9-1024x716.png\" alt=\"\" class=\"wp-image-269\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-9-1024x716.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-9-300x210.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-9-768x537.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-9-1536x1074.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-9.png 1690w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We apply the changes and proceed with the exploitation<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">NetNTLMv1 hash capture<\/h3>\n\n\n\n<p>To capture the hash, we need the domain controller to authenticate to the attacker&#8217;s computer, similar to a case where a computer lists the shared directories of another networked computer.<\/p>\n\n\n\n<p>While listing a computer&#8217;s shared directories is a simple task, you need to have an active session on the target computer.<\/p>\n\n\n\n<p>It is also possible to use the public xp_dirtree or xp_fileexists function from an MSSQL instance, but requires the target server to have this software installed (Future blog post, using tools like PowerUpSQL for lateral movement on domain MSSQL instances).<\/p>\n\n\n\n<p>The above two paths are not applicable in the environment we are evaluating, as we do not have a way to generate an active session on the domain controller or MSSQL installed, so we will use one of the many Coerce tools available.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Printerbug<\/strong><\/li>\n\n\n\n<li>DFSCoerce<\/li>\n\n\n\n<li>ShadowCoerce<\/li>\n\n\n\n<li>PetitPotam<\/li>\n\n\n\n<li>Dementor<\/li>\n\n\n\n<li>Coercer (It uses 9 different Coercion methods, including the previous ones)<\/li>\n\n\n\n<li>Etc.<\/li>\n<\/ul>\n\n\n\n<p>There are multiple tools that, through RPC protocol calls, cause the target computer to authenticate to the attacker&#8217;s computer, this authentication is performed by the user of the domain computer, for this lab, user <strong>DC01$.<\/strong><\/p>\n\n\n\n<p>We will use the Printerbug tool, which uses the SpoolService, related to printing, to force authentication from the target computer to the attacker&#8217;s computer.<\/p>\n\n\n\n<p>To demonstrate the difference after performing the above configuration, run <strong>Responder<\/strong> with the <strong>&#8211;lm<\/strong> flag to force the downgrade in the communication established on the domain controller without making the above change to the local security policy.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"518\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-7-1024x518.png\" alt=\"\" class=\"wp-image-267\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-7-1024x518.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-7-300x152.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-7-768x388.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-7-1536x777.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-7-2048x1036.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>It is observed that the domain controller hash is captured, however, it is of the NetNTLMv2 type, so cracking or performing a brute force attack on it is practically impossible, since the hash represents the password of the user <strong>DC01$<\/strong>, this password is defined by the same domain controller and has an ideal complexity (An approximate example: ^7a1913^0*!@$(@#%)@)61!!$^#@*@!5632472579%#^2871$%3497#@469FVTBang6Q^), and the NetNTLMv2 protocol is complex by itself, so brute forcing won&#8217;t be possible.<\/p>\n\n\n\n<p>The ease of NetNTLMv1 hashes is that there are already Rainbow Tables corresponding to the NTLM hash, so it is much easier to convert a NetNTLMv1 hash to NTLM, due to the initial obsolete protocol.<\/p>\n\n\n\n<p>After performing the respective configuration, the authentication of the domain controller to the attacker&#8217;s machine is forced again, obtaining its NetNTLMv1 hash.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"535\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-10-1024x535.png\" alt=\"\" class=\"wp-image-270\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-10-1024x535.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-10-300x157.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-10-768x402.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-10-1536x803.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-10-2048x1071.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>However, in order to use the <strong>crack.sh<\/strong> online service, we need to configure a Challenge with the value <strong>1122334455667788<\/strong> in <strong>Responder<\/strong>, so we proceed to make the setting in the tool.<\/p>\n\n\n\n<p>Modifying the Responder.conf file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"764\" height=\"1024\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-11-764x1024.png\" alt=\"\" class=\"wp-image-271\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-11-764x1024.png 764w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-11-224x300.png 224w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-11-768x1030.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-11.png 1016w\" sizes=\"auto, (max-width: 764px) 100vw, 764px\" \/><\/figure>\n\n\n\n<p>With the desired challenge configured, we&#8217;ll execute <strong>Responder<\/strong> and <strong>Printerbug<\/strong> once again.<\/p>\n\n\n\n<p>*Note: Since the Domain controller&#8217;s machine account hash was captured previously, its necessary to erase such entry from the Responder database, so the hash can be recaptured (\/usr\/share\/responder\/Responder.db in Kali Linux)<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"539\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-12-1024x539.png\" alt=\"\" class=\"wp-image-272\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-12-1024x539.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-12-300x158.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-12-768x405.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-12-1536x809.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-12-2048x1079.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now, in order to obtain the hash in NTLM format, we can use the online service mentioned above or run a brute force attack on the hash, however, this task requires quite a lot of computational power and time, since computer passwords change every 30 days automatically, often this scenario is not optimal unless we have a powerful cracking station, so the online service is used.<\/p>\n\n\n\n<p>**UPDATE: Sadly, as of March 2024, the online cracking service is still offline, so the only option available is through brute forcing by using the following tool and its guidelines, this guide will be updated with such method:<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/evilmog\/ntlmv1-multi\">https:\/\/github.com\/evilmog\/ntlmv1-multi<\/a><\/p>\n\n\n\n<p>Once the bruteforcing process is finished, we&#8217;ll have the NTLM hash for the domain controller&#8217;s machine account, which we can use to perform a DCSync attack.<\/p>\n\n\n\n<p>Confirming the hash value works for the machine account.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"116\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-17-1024x116.png\" alt=\"\" class=\"wp-image-277\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-17-1024x116.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-17-300x34.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-17-768x87.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-17-1536x175.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-17.png 1636w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>DCSync attack.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"818\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-18-1024x818.png\" alt=\"\" class=\"wp-image-278\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-18-1024x818.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-18-300x240.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-18-768x613.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-18.png 1252w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Machine account users as administrators<\/h3>\n\n\n\n<p>On a common scenario, user or group objects are assigned administrative privileges over other hosts, which can be seen like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"834\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-19-1024x834.png\" alt=\"\" class=\"wp-image-281\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-19-1024x834.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-19-300x244.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-19-768x626.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-19-1536x1251.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-19.png 1736w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We can see that the domain group <strong>equipos_ti<\/strong> has administrative privilege over the hosts <strong>SOPORTE01 <\/strong>and <strong>TECNOLOGIA01<\/strong>.<\/p>\n\n\n\n<p>However, once we explore which objects belong to the group <strong>equipos_ti<\/strong>, we observe that the same hosts observed before belong to it.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"802\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-20-1024x802.png\" alt=\"\" class=\"wp-image-282\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-20-1024x802.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-20-300x235.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-20-768x601.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-20-1536x1203.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-20.png 1734w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Therefore, we can conclude that <strong>SOPORTE01<\/strong> and <strong>TECNOLOGIA01<\/strong> are their own administrators.<\/p>\n\n\n\n<p>If we want to search for these types of scenarios in bloodhound, we can use the following raw query:<\/p>\n\n\n\n<p><em><strong>MATCH p = (c1:Computer)-[r1:AdminTo]->(c2:Computer) RETURN p UNION ALL MATCH p = (c3:Computer)-[r2:MemberOf*1..]->(g:Group)-[r3:AdminTo]->(c4:Computer) RETURN p<\/strong><\/em><\/p>\n\n\n\n<p>By analyzing the result, we can observe an attack path using machine accounts.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"318\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-22-1024x318.png\" alt=\"\" class=\"wp-image-284\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-22-1024x318.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-22-300x93.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-22-768x238.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-22-1536x477.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-22-2048x636.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>If we manage to compromise the machine <strong>ATENCION$<\/strong>, we can use the hash of the machine account to gain administrative access to <strong>SOPORTE01$<\/strong>, then use the hash of the user <strong>SOPORTE01$<\/strong> to gain administrative access to <strong>TECNOLOGIA01$<\/strong> and finally use the hash of the user <strong>TECNOLOGIA01$<\/strong> to gain control of the internal domain, since this user is a member of the domain administrators.<\/p>\n\n\n\n<p>Using the aforementioned tool, Coercer, we can perform a Relay attack.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Access to SOPORTE01 from ATENCION01<\/h4>\n\n\n\n<p>We use <strong>ntlmrelayx<\/strong> to execute the attack.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"874\" height=\"562\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-23.png\" alt=\"\" class=\"wp-image-285\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-23.png 874w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-23-300x193.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-23-768x494.png 768w\" sizes=\"auto, (max-width: 874px) 100vw, 874px\" \/><\/figure>\n\n\n\n<p>In this scenario, the relay main target will be <strong>soporte01.jsec.local<\/strong>, indicating that any authentication attempts done towards the attacker machine will be relayed to the target.<\/p>\n\n\n\n<p>Coercing the authentication from <strong>atencion01.jsec.local<\/strong> towards the attacker machine.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"510\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-24-1024x510.png\" alt=\"\" class=\"wp-image-286\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-24-1024x510.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-24-300x149.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-24-768x383.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-24-1536x765.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-24-2048x1020.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We observed that by using Coercer, multiple ways to force authentication from the target to the attacker&#8217;s machine were validated, succeeding in one of them according to the result obtained in the relay, since it was possible to authenticate to the machine <strong>soporte01.jsec.local<\/strong> as the user <strong>JSEC\\ATENCION01$<\/strong>, subsequently dummying the local user hashes.<\/p>\n\n\n\n<p>We&#8217;ll use the <strong>IEUser<\/strong> local administrator account to dump the LSA secrets through a <strong>Pass the hash<\/strong> attack.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"269\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-27-1024x269.png\" alt=\"\" class=\"wp-image-288\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-27-1024x269.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-27-300x79.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-27-768x201.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-27-1536x403.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-27.png 1754w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>That way, we can obtain the <strong>ATENCION01$<\/strong> NTLM hash, which we can use to access with administrative privilege to the <strong>SOPORTE01<\/strong> host.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"287\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-28-1024x287.png\" alt=\"\" class=\"wp-image-289\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-28-1024x287.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-28-300x84.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-28-768x215.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-28-1536x430.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-28.png 1756w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Once we obtain the <strong>SOPORTE01$<\/strong> NTLM hash, we can access as a local administrator to the <strong>TECNOLOGIA01$<\/strong> host.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"379\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-30-1024x379.png\" alt=\"\" class=\"wp-image-290\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-30-1024x379.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-30-300x111.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-30-768x285.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-30-1536x569.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-30.png 1754w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>FInally, we can use the machine account hash to compromise the domain.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"113\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-31-1024x113.png\" alt=\"\" class=\"wp-image-291\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-31-1024x113.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-31-300x33.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-31-768x85.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-31.png 1486w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>However, if we take a look at the Bloodhound result again, we observe that we don&#8217;t really need to relay the authentication from <strong>ATENCION01<\/strong> towards <strong>SOPORTE01<\/strong>, given that we can Coerce authentication straight from <strong>SOPORTE01<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"493\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-32-1024x493.png\" alt=\"\" class=\"wp-image-292\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-32-1024x493.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-32-300x144.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-32-768x369.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-32-1536x739.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-32-2048x985.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>This way, we get the local user&#8217;s NTLM hashes.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"346\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-33-1024x346.png\" alt=\"\" class=\"wp-image-293\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-33-1024x346.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-33-300x101.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-33-768x259.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-33.png 1078w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>However, if we consider a scenario where <strong>Pass the hash<\/strong> is not possible with local accounts, those hashes will be of no use unless we crack them and obtain physical access to the vulnerable host. So what we can do is to configure the relay to execute a specific command instead of dumping the hashes.<\/p>\n\n\n\n<p>We deploy the relay with the &#8220;<strong>-c&#8221;<\/strong> flag and the desired command.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"446\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-34-1024x446.png\" alt=\"\" class=\"wp-image-294\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-34-1024x446.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-34-300x131.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-34-768x334.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-34-1536x668.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-34-2048x891.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>On the previous image, at the bottom right corner, we have registered an attempt to login into the host with the <strong>demo<\/strong> domain user, where the login is valid, but we don&#8217;t have administrative privilege<\/p>\n\n\n\n<p>Coercing authentication to execute the desired command, we now observe at the bottom right corner that we have a successful administrative login with the same user.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"404\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-35-1024x404.png\" alt=\"\" class=\"wp-image-295\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-35-1024x404.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-35-300x118.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-35-768x303.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-35-1536x606.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-35-2048x808.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Now, we could use the <strong>demo<\/strong> user to dump the LSA secrets, obtain the machine account NTLM hash for the <strong>TECNOLOGIA01<\/strong> host and obtain domain admin privileges.<\/p>\n\n\n\n<p>In case it is a regular computer, without privileges, but with sensitive information and we do not want to raise alerts of user creation or new users in privileged groups, we can use the relay to deploy a SOCKS4 proxy and use the authentication attempt with other tools.<\/p>\n\n\n\n<p>In this case, we will use Printerbug to force a one-time authentication from the target machine to the attacker, instead of 9 times with Coercer.<\/p>\n\n\n\n<p>It is recommended to use IP addresses instead of hostnames to set up the proxy, because when trying to use the proxy with a hostname, it will try to perform hostname resolution through it and will fail, since it only has a route to port 445, not port 53.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"543\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-38-1024x543.png\" alt=\"\" class=\"wp-image-298\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-38-1024x543.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-38-300x159.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-38-768x407.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-38-1536x815.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-38-2048x1086.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To list our active connections, we can run the <strong>socks<\/strong> command.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"734\" height=\"160\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-39.png\" alt=\"\" class=\"wp-image-299\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-39.png 734w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-39-300x65.png 300w\" sizes=\"auto, (max-width: 734px) 100vw, 734px\" \/><\/figure>\n\n\n\n<p>We can see that we have an active session on the computer <strong>192.168.64.212<\/strong> with the user <strong>JSEC\/SOPORTE01$<\/strong> on port 445 with administrator privileges (AdminStatus TRUE).<\/p>\n\n\n\n<p>Now we can use proxychains to use this connection and the privileges of the user <strong>SOPORTE01$<\/strong> to access the <strong>TECNOLOGIA01<\/strong> machine through the SMB protocol.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"662\" src=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-40-1024x662.png\" alt=\"\" class=\"wp-image-300\" srcset=\"https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-40-1024x662.png 1024w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-40-300x194.png 300w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-40-768x496.png 768w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-40-1536x992.png 1536w, https:\/\/jsec-rt.com\/wp-content\/uploads\/2022\/11\/image-40-2048x1323.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>We observe that we have administrative access to the TECNOLOGIA01 equipment, since by SMB we can navigate through the C$ directory, although it is observed in the capture that the password is requested, we can leave it empty, since the session stored in the relay will be used.<\/p>\n\n\n\n<p>This type of attack paths are a bit rare in real scenarios, however, I came across these scenarios multiple times, especially this last one, so I think it is important to document one of the ways to exploit these attack paths.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have come across many times, in real scenarios, certain configurations in the domain that allow an attacker to gain control over certain computers and servers under the following conditions: The last two points are not under the attacker&#8217;s control, they are configurations that are already defined in a domain <a href=\"https:\/\/jsec-rt.com\/index.php\/en\/2024\/03\/24\/rt-ntlm-relay-y-coerce-authentication-casos-practicos-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":[22],"tags":[28,30],"class_list":["post-396","post","type-post","status-publish","format-standard","hentry","category-p-rt-en","tag-english","tag-rt"],"_links":{"self":[{"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/posts\/396","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=396"}],"version-history":[{"count":2,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/posts\/396\/revisions"}],"predecessor-version":[{"id":427,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/posts\/396\/revisions\/427"}],"wp:attachment":[{"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/media?parent=396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/categories?post=396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jsec-rt.com\/index.php\/wp-json\/wp\/v2\/tags?post=396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}