<?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 Anirban Chakraborty on Medium]]></title>
        <description><![CDATA[Stories by Anirban Chakraborty on Medium]]></description>
        <link>https://medium.com/@anir08?source=rss-2c3fce898a79------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Sq4sF9JDM3uFX4QLjSV_VQ.png</url>
            <title>Stories by Anirban Chakraborty on Medium</title>
            <link>https://medium.com/@anir08?source=rss-2c3fce898a79------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 09:25:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anir08/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[VulnHub CyberSploit 1 Write-up]]></title>
            <link>https://anir08.medium.com/vulnhub-cybersploit-1-write-up-6eaff5e3b54f?source=rss-2c3fce898a79------2</link>
            <guid isPermaLink="false">https://medium.com/p/6eaff5e3b54f</guid>
            <category><![CDATA[vulnhub]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Anirban Chakraborty]]></dc:creator>
            <pubDate>Sun, 01 Nov 2020 16:20:25 GMT</pubDate>
            <atom:updated>2020-11-01T16:27:17.858Z</atom:updated>
            <content:encoded><![CDATA[<p>みなさん、こんにちは!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtbtQGrUielBoKOJmYfuaA.jpeg" /><figcaption>Can you break the glass?</figcaption></figure><p>I decided to take a break from Hack the box and make my trip to Off-Sec Proving Grounds. Now Off-Sec proving grounds is nothing special, it just has VulnHub machines hosted. One thing is that it is convenient that you don’t have to download and install VMs which in my case is a pain (I have low storage lel). Cyber Sploit was perhaps one of the most easiest boxes I have ever done. I rooted the box in a little under 15 minutes so it was a indeed a nice warm up.</p><h4>Abstract</h4><p>One thing which I did not like about the box is that it is too CTFy like. I actually hate boxes like these to be honest. What’s the point if you don’t learn anything? Well you do learn something here if you pay more attaention and play with it after completiting it though. It starts with website recon, I find a weird base64 encoded string in robots.txt directory. looking at the source of the home directory we also get a username. SSHing into the box using those credentials was successful. An Overlayfs exploit exists on the box due to the outdated kernel. We exploit that to get the root shell.</p><h4>Enumeration</h4><p>As always we start with the nmap scan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Crsf5rq8VEEn5jpy22Sz0w.png" /></figure><p>Only two ports are open; Port 22 running SSH and port 80 running a webservice.</p><p>Visiting the webservice, we see:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ibzp5Y_1uowS31nDXDMnvg.png" /></figure><p>Nothing to special comes up until we examine the source of the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*uOBKqqRvkIiboF8CrIkKBw.png" /></figure><p>A username is hidden from the view by HTML comments. Now I search for a password.</p><p>As a habit, before starting a directory bruteforcing tool, I tend to test some common words like robots.txt, dev and so on.</p><p>Here robots.txt worked and we see a weird base64 encrypted string.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*i3gbsTug7zsGSPYLR19qzA.png" /></figure><p>Decrypting it, we get:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lLx76qDXe-YOHhDakxL_5g.png" /></figure><p>We get a string “cybersploit{youtube.com/c/cybersploit}”. At first glance it looks like a YouTube channel link but this can be a password.</p><h4>Exploitation</h4><p>Not really an exploitation but using the creds obtained earlier — itsskv::cybersploit{youtube.com/c/cybersploit} I ssh in successfully. Honestly did not expect it to be that easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*mH_JyugE8pcukjgJBfLFEQ.png" /></figure><h4>Escalation</h4><p>There are a couple of things to enumerate first before we go to some advanced or custom made technique. First thing I tried is, obviously to see what version of Linux Kernel its running by doing <em>uname -a</em></p><p>It returned saying that it was running a 3.13.0–32-generic Kernel. Searching for a Kernel exploit landed me to some interesting places. This is where things get interesting.</p><p><strong>Some Words about Overlayfs Kernel Exploit:</strong></p><p>An Overlayfs is basically a file system.</p><p>Here is what <a href="https://www.kernel.org/doc/Documentation/filesystems/overlayfs.txt">kernel.org</a> had to say:</p><pre>An overlay filesystem combines two filesystems - an &#39;upper&#39; filesystem<br>and a &#39;lower&#39; filesystem.  When a name exists in both filesystems, the<br>object in the &#39;upper&#39; filesystem is visible while the object in the<br>&#39;lower&#39; filesystem is either hidden or, in the case of directories,<br>merged with the &#39;upper&#39; object.<br><br>It would be more correct to refer to an upper and lower &#39;directory<br>tree&#39; rather than &#39;filesystem&#39; as it is quite possible for both<br>directory trees to be in the same filesystem and there is no<br>requirement that the root of a filesystem be given for either upper or<br>lower.<br><br>The lower filesystem can be any filesystem supported by Linux and does<br>not need to be writable.  The lower filesystem can even be another<br>overlayfs.  The upper filesystem will normally be writable and if it<br>is it must support the creation of trusted.* extended attributes, and<br>must provide valid d_type in readdir responses, so NFS is not suitable.<br><br>A read-only overlay of two read-only filesystems may use any<br>filesystem type.</pre><p>So now that we know what the thing is, lets deep dive into the exploit.</p><p>I found a Git Hub repo which contains tons of Kernel Exploits and tried to understand the actual exploit. The exploit uses another property of namespaces that has always seemed like something of a bug: the /proc filesystem provides a route for processes outside of a namespace to “see” inside it. In this case, the overlayfs mounted inside the namespace can be accessed from outside of it by using information on the mounts inside the namespace via /proc/PID/cwd.</p><p>Here is my breakdown of the code:</p><p>The <a href="http://www.halfdog.net/Security/2015/UserNamespaceOverlayfsSetuidWriteExec/UserNamespaceOverlayfsSetuidWriteExec.c">exploit [C program]</a> works like this:</p><ul><li>New mount and user namespaces are created for the process.</li><li>That process then mounts an overlayfs atop /bin using temporary directories for the overlayfs “upperdir” and “workdir” directories. A writable overlayfs must have both of these directories; upperdir holds the files/directories that have been changed, while workdir is used as a work space to enable atomic overlayfs operations.</li><li>The process inside the namespaces changes its working directory to the overlayfs, thus making it visible outside of the namespaces by way of /proc/PID/cwd.</li><li>The process changes the su binary (in /bin) to be world-writable, but does not change the owner. That results in a new file being created in the upper overlay directory.</li><li>A process outside of the namespaces writes anything it wants to that file without changing the setuid bit (more on that coming).</li><li>The outer process then runs that su with root privileges.</li></ul><p>Pretty Awesome right!!</p><p>Lets get back to the box and get root now.</p><p>Transfer the binary to the box using python module SimpleHTTPServer. Then just execute it: <strong><em>STARBURST STREAM !!!!!!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*V60i_TJW6D2O71LfLiy2qQ.png" /><figcaption>1337root</figcaption></figure><h4>Conclusion</h4><p>Although box was of CTF type, I learnt something new about an exciting Kernel Exploit which is cool. I would like to write my own kernel exploit one day! Anyways, good warm up box, best for beginners.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6eaff5e3b54f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Sense Write-up]]></title>
            <link>https://anir08.medium.com/htb-sense-write-up-5960b6a01f68?source=rss-2c3fce898a79------2</link>
            <guid isPermaLink="false">https://medium.com/p/5960b6a01f68</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[information-security]]></category>
            <dc:creator><![CDATA[Anirban Chakraborty]]></dc:creator>
            <pubDate>Wed, 14 Oct 2020 20:17:11 GMT</pubDate>
            <atom:updated>2020-10-14T20:24:39.259Z</atom:updated>
            <content:encoded><![CDATA[<p>みなさん、こんにちは!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*IXMCJw22zxFti8wPS4_IoA.jpeg" /><figcaption>Illusions or firewall, we’ll break ’em all!!</figcaption></figure><p>This a notes like write-up I am posting about the HTB boxes I managed to compromise by myself. Preparing for “a certain” course, these kind of boxes are really helpful in getting experience. Lets jump in!</p><h4><strong>Abstract</strong></h4><p>This box is all about deep website enumeration and finding the correct CVE. We start off by having very little information about any of the services running in the box, gradually enumerating almost everything and piecing together vital piece of information we finally get a foothold. Funny thing is, the foothold itself is root so no need for lateral-movement and privilege escalation (yeet!)</p><h4>Enumeration</h4><p>As always, we start with an nmap scan:</p><p>nmap -sV -sC -T4 10.10.10.60</p><p>Which returned the following for top responding ports, usually ports within 1 to 1000.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*_SBcVI7eudfYcxRQo-NKkw.png" /></figure><p>It showed only two ports open — actually just one since the port 80 is supported by ssl on 443 so visiting port 80 will actually redirect to port 443. Port 80 is running PF Sense on lighttpd version 1.4.35.</p><p>Lets run a full scan to see if we get other ports to respond. I do not put the -sC flag since it will make the scan incredibly slow. I just want nmap to knock all ports, I’ll enum each of them individually.</p><p>nmap -vvv -p- 10.10.10.60</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*2CLhn6StmvlsKFztTAvyyg.png" /></figure><p>Seems like no other ports are open other than these two (actually one).</p><p>Visiting the website, we are visited with a login page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*zZhSgdRKleSH22YNiszN2w.png" /></figure><p>Pretty basic, nothing fancy. First thing obviously is to try default credentials, so I googled <a href="https://docs.netgate.com/pfsense/en/latest/usermanager/defaults.html">pf sense default creds</a> which returned this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*h3INgq-6yji4vfSiIG0rDg.png" /></figure><p>Which obviously did not work. After that I tried SQLi but that did not work at all. Next I used wfuzz to brute-force all directories, normally I’d use gobuster but for some strange reason it refused to work.</p><p>Here is a snap from when wfuzz was finding all the directories but every one of them retrned 404 not found. It was obvious that we need to get ourselves authenticated before we can visit any of these:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*rcN-4l_2TOFpwrQohXuwPg.png" /></figure><p>I tried to find some kind of vulnerability in the website itself using the nmap script <a href="https://nmap.org/nsedoc/categories/vuln.html">vuln</a> which basically automates and tries all possible vulnerability scripts against the site, but that didn’t find anything.</p><p>The next thing to try is to test for directory-traversal vulnerability. Apparently there is a <a href="https://www.exploit-db.com/exploits/39038">directory traversal vulnerability in the pf sense firewall site </a>but unfortunately it did not match the version (we didn’t know the version yet). i tried almost all poking I know of but nothing happened. Now I started looking for any important files that might be left by the webdev in the web home directory. The most important thing now is to look for creds.</p><p>I ran wfuzz again, this time adding a .txt extension to it</p><p>Finally some direction!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*MR_7o97RSYcwYv_DvsA-2A.png" /></figure><p>We find two very interesting files, visiting them gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/669/1*oqzJ81LT5v5pNjiqnP3JEw.png" /><figcaption>changelog.txt</figcaption></figure><p>and…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*3xmTsc0hk0W2F88C6F4nGQ.png" /><figcaption>system-users.txt</figcaption></figure><p>Firstly, the security changelog points that one out of three vulnerabilities is still not patched. Secondly we get a user named “Rohit” who has “Company default” password which is pfsense. I tried with Rohit::pfsense but it didn’t work, I tried rohit::pfsense and this time it did. I logged in as “Rohit”.</p><p>Upon logging in, there was a very vital piece of information at the very top!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/365/1*bdsN8s3FOlzpGJfbATkt4A.png" /></figure><p>The system was running a 2.1.3-RELEASE (amd64) PF Sense firewall.</p><p>I immediately searched google and found a multiple vulnerabilities on the said version. The one that looked most promising was the <a href="https://www.exploit-db.com/exploits/43560">Remote Code Execution.</a></p><p>I found a metasploit module which could be used to exploit it and I tried it first that way — it’s too easy so I am not writing about that… you basically put some commands and boom it gives you root. You can find that <a href="https://www.rapid7.com/db/modules/exploit/unix/http/pfsense_graph_injection_exec">here</a>, no fun at all. Lets try to understand the exploit code and try to exploit it manually!</p><h4>Exploitation</h4><p>Lets try to understand what causes a RCE in the application. I found an amazing explanation <a href="https://spencerdodd.github.io/2018/01/14/pfsense-arbitrary-code-execution/">here</a>, I’ll explain it here too.</p><p>The vulnerability arises due to lack of blacklisting improper and dangerous characters in the status_rrd_graph_img.php</p><blockquote>/* this is used for temp name */<br>if ($_GET[&#39;graph&#39;]) {<br> $curgraph = str_replace(array(&quot;&lt;&quot;, &quot;&gt;&quot;, &quot;;&quot;, &quot;&amp;&quot;, &quot;&#39;&quot;, &#39;&quot;&#39;), &quot;&quot;, htmlspecialchars_decode($_GET[&#39;graph&#39;], ENT_QUOTES | ENT_HTML401));<br>} else {<br> $curgraph = &quot;custom&quot;;<br>}</blockquote><p>In the str_replace array, blacklists certain characters but misses the “|” symbol (the pipe symbol) which allows RCE.</p><p><a href="https://www.exploit-db.com/exploits/43560">This python script</a> sends a reverse shell payload encoded to exploit that vulnerability after authenticating the user. This exploit only works for non root users only.</p><p>Let’s examine it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aktwXT-fEfJBlnmAt_U6kg.png" /><figcaption>43560.py</figcaption></figure><p>It navigates to the vulnerable php script then sends a *NIX command (in this case a reverse shell) using printf and pipes (“|”) the output to sh (the command shell) which then gets executed. Careful, this payload is carefully encoded in firstly hex then octal values. Such are the pains while exploiting web vulnerabilities.</p><p>I ran the script, opening netcat on other window, waiting for connections “<em>STARBURST STREAM</em>!!”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B8H_AJ4-NkC00R84xNTcbg.png" /></figure><p>We got a connection back.</p><h4>Escalation</h4><p>It is obvious from the ‘#’ symbol that we already have root access:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*2fRC6KUmVrr6b_kM3_2U0w.png" /><figcaption>1337root1337</figcaption></figure><h4>Conclusion</h4><p>This box was rather smooth sailing but the amount of brute-forcing the website to find files was huge. This teaches that you should leave no stone unturned while doing an enumeration. Overall a very fun box which helped me construct my thinking power while tackling a box a lot. Was kinda funny that there was no Priv-Esc part. That’s why this box has more root owns than user owns on HTB lol!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5960b6a01f68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB — Valentine Write-up]]></title>
            <link>https://anir08.medium.com/htb-valentine-write-up-250805d36424?source=rss-2c3fce898a79------2</link>
            <guid isPermaLink="false">https://medium.com/p/250805d36424</guid>
            <category><![CDATA[hackthebox]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[heartbleed-bug]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Anirban Chakraborty]]></dc:creator>
            <pubDate>Wed, 07 Oct 2020 07:34:45 GMT</pubDate>
            <atom:updated>2020-10-14T18:50:30.791Z</atom:updated>
            <content:encoded><![CDATA[<h3>HTB Valentine Write-up</h3><p>みなさん、こんにちは!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3PAkmi7JJ6W1sErfoK8E6w.jpeg" /></figure><p>So, I managed to solve the retired Valentine box from Hack the Box and decided to write a write-up about. You can always return to your write up if you forget something, its like a notes taking! Lets begin!</p><h4>Abstract</h4><p>The box teaches us how to detect and exploit the “Heartbleed” vulnerability which is a serious vulnerability in the popular OpenSSL cryptographic software library. This weakness allows stealing the information protected, under normal conditions, by the SSL/TLS encryption used to secure the Internet. More on that on <a href="https://heartbleed.com/">this site</a>. We get a weired looking hex string which actually is the id_rsa private key, converting it to ASCII and giving it necessary permissions, we try to login as user “hype” but get a password prompt on the private key. Exploiting the heartbleed vulnerability gives us sensitive password of the id_rsa. We log in successfully. After logging in, we see root is running tmux process on a definite binary. Simply exploiting that suid vulnerability gives us root.</p><h4>Enumeration</h4><p>As always we start with an nmap scan.</p><p>I first do a detailed scan :</p><p><em>nmap -v -sV -sC -T4 10.10.10.79</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*VW1x29fHETigkQJNwvaLHQ.png" /></figure><p>Nmap returned port 22, 80 and 443 open.</p><p>Then I ran a full port scan but this time without the default scripts. I did this because running default scripts and a full port scan would be very very slow. We can simply see what ports are open then use nmap to enumerate each port individually. You can find more such tricks <a href="http://nmap.org/">here</a>.</p><p>Here is the result of full port scan:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*IMLIC8dbSxmPP6TxJPklQQ.png" /></figure><p>Looks like no other ports are open.</p><p>Port 80:</p><p>It says Apache is running on port 80 so lets go visit it. Also lets check if its php or not. This can be done by just typing &lt;website.name&gt;/html.php. If it return valid response then it is running php. This is a vital piece of information.</p><p>Also while we manually look at the website, lets brute force directories</p><p>Personally I prefer <em>gobuster</em> for directories and <em>wfuzz</em> for special files</p><p>Visiting the website we got this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4HOIq6N5HMsLTRxJ_hhb_g.png" /></figure><p>I attempted path traversal vulnerability but to no avail.</p><p>Moving on to gobuster and wfuzz:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*31kDEuJ_eNsfHx6VMKnmrQ.png" /></figure><p>A wild ‘dev’ appeared!!!!</p><p>Lets go on to that directory!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*UJrg_lMNqZjFTCsNHdlS9g.png" /></figure><p>Honestly, notes.txt did not make much sense. But hype_key did!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xoy1Vz46WfxRkRDxfJtbnA.png" /></figure><p>we get a weird hex encoded string here. I had a big hunch that this is going to be an RSA private key. I converted first 7 characters and yes, it was the RSA file! Lets omit those spaces and use <a href="https://gchq.github.io/CyberChef/">this</a> to convert it to the RSA file!</p><p>Here is the original private key!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*Qv0kdiCcrzSq914qafVFYw.png" /></figure><p>Lets try to login with it on the box using ssh. (remember to do chmod 600)</p><p>ssh -i id_rsa hype@10.10.10.79</p><p>But it asked for the rsa key password!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*uKxYkO0OoF6nM8j90h5e_Q.png" /></figure><p>This is weird! I did not set any password for it! I tried to open the file and sure enough it wanted password. Then I realised that the user “hype” set up the password. So although you have the id_rsa key you won’t be able to login until you have the passphrase.</p><p>Port 443</p><p>Nmap retunrned the following for port 443:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/1*zaBB2-3qc-GGaLBcP7Rs8g.png" /></figure><p>Its running SSL. So lets just enumerate it with the nmap heartbleed script</p><p>nmap -v — script ssl-heartbleed 10.10.10.79 -p 443</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*SLoBM7rEBQ9WFQXsWSbwzg.png" /></figure><p>SSL on port 443 is vulnerable to heartbleed vulnerability. So lets exploit it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rRF6snAOJ3VNh2NPIQP3wA.png" /></figure><p>lets use that python script to see if we can have access to sensitive data behind the SSL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*GqDRNBNyNBzVwxqYgdvXZQ.png" /></figure><p>Running the script we get a base64 string.</p><p>Decoding it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*8QKCTfQvhnFIUljd0Le5jA.png" /></figure><p>Looks like we have he password.</p><p>Testing it against the id_rsa worked so lets go ahead and login via ssh</p><h4>Exploitation</h4><p>Login via ssh:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*xvnJPuv-OuCzANzJGtqCxg.png" /></figure><p>Cool, we are inside!</p><h4>Escalation</h4><p>Firstly lets look for SUID binaries;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/1*JZnpxKfq-cq2uHoNIVqKcQ.png" /></figure><p>Nothing that interesting. Lets check running processes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*AGd6AfPyQuF2y9zyDE_kWg.png" /></figure><p>An interesting process is being run as root :</p><p>it seems tmux is running on /.dev/dev_sess. Theoretically if we just issue this command we will get root within the tmux</p><p>First lets see if we can use tmux within the box:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*C7ZmT1_psspOPxvGLwVtfw.png" /></figure><p>Looks like it is so lets issue the command:</p><p><strong><em>STARBURST STREAM!!!!</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*-P6KrC6e6ycVAnGnJ2xnRw.png" /></figure><p>Nice! We are root on tmux!</p><h4>Conclusion</h4><p>According to TJ Null this was an OSCP type box which is actually perfect for learning and trying out different things without getting into too many technical difficulties.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=250805d36424" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[College CTF: Reversing Challenge]]></title>
            <link>https://anir08.medium.com/college-ctf-reversing-challenge-17f090dfe5dc?source=rss-2c3fce898a79------2</link>
            <guid isPermaLink="false">https://medium.com/p/17f090dfe5dc</guid>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[information-security]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Anirban Chakraborty]]></dc:creator>
            <pubDate>Tue, 01 Sep 2020 00:09:07 GMT</pubDate>
            <atom:updated>2020-09-08T15:31:43.636Z</atom:updated>
            <content:encoded><![CDATA[<p>みなさん、こんにちは!</p><p>A week back, one of my seniors published a series of three CTF challenges from Cryptography, Reversing and Forensics. This write up focuses on the Reversing challenge.</p><h4>First look at the Binary</h4><p>I always like to perform some easy tests on the binary which can be a easy win or at least give insight to what’s going on inside without having to delve in deeper for now.</p><p>I ran <a href="https://www.geeksforgeeks.org/file-command-in-linux-with-examples/"><em>file</em></a> command to see the information about the binary, it displayed the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*nLK8Dk8lcrQS1Jf8km1-6w.png" /></figure><p>One thing I noticed is that the Binary is “not stripped” which means we can debug it easily and disassemble the functions easily in a debugger, in other words it’s not obfuscated in here.</p><blockquote><em>Want to read this story later? Save it in </em><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=blog&amp;utm_campaign=noteworthy&amp;utm_content=eid7"><em>Journal</em></a><em>.</em></blockquote><p>The next commands I run are the basic , <a href="https://www.man7.org/linux/man-pages/man1/ltrace.1.html"><em>ltrace</em></a>, <a href="https://man7.org/linux/man-pages/man1/strace.1.html"><em>strace</em></a> and <a href="https://r2wiki.readthedocs.io/en/latest/tools/rabin2/"><em>rabin2 -z</em></a> :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n0kQ20BkHjvYZMMUEq7xqg.png" /><figcaption>ltrace output</figcaption></figure><p>It is now obvious from the ltrace output that the binary is written in C++ language because a binary written in C language would never produce an output like this. Notice the “<em>_ZNSt7__cxx</em>” which actually is a function indication in C++.</p><p>Running rabin2 -z sure returned a interesting result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*906I0fnXIviRZImoxithXg.png" /></figure><p>We are greeted with some very interesting strings and a string mocking us with “…RUNNING STRINGS HUH???…”. Also a notice a Base64 type of string in there. I immediately try to decode it had unreadable characters so, nope it’ll not be that easy win. Omoshiroi!!</p><h4>Taking apart the Binary</h4><p>“Now its time to bust you open!” — Accelerator (A certain scientific accelerator)</p><p>I opened the binary in IDA here’s how I made a roadmap myself:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*qubwZVaQgHeBUIQ6Wpk_dg.png" /><figcaption>IDA disassembler showing all the entry points</figcaption></figure><p>Neglecting all the compiler-generated functions, we see two interesting functions, “base64encode” and “base64decode” and one super interesting function “flagfunk()”. Obviously our area of interest would be “flagfunk()”.</p><p>One thing that is actually pretty comfortable in C and C++ binaries is that any outgoing functions always start from main so lets inspect main and see if we can sketch a tree, as to where the program flow is directing too. In this way we can ignore unimportant functions and focus on fishing out the flag.</p><p>Upon inspecting main, I found:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*vgO5tEcN-QZ-Ldb9Z5lRXg.png" /><figcaption>ASCII encoded strings</figcaption></figure><p>The welcoming message that we found while running the binary is actually encoded in the form of ASCII making it somewhat hard to actually spot input and output. This is a form of obfuscation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/961/1*MHCYEc7y9z368K7rOLuudA.png" /><figcaption>An outgoing reference to b64encode</figcaption></figure><p>This is by far the most interesting part of main()!! The program takes the input via “cin” (first red box) then immediately displays, “I ate everything” (second red box). Then it sends the string as an argument to “b64encode” ( third red box). B64encode function returns a b64encoded string of the input and then it is printed out on the screen via “cout” (the last “lea” to the cout). Upon running the actual binary with dummy inputs fetches the same result. Other than this call to b64encode, there is no other call to any other function in the binary.</p><p>At this point, it’s better to think of patching or jumping to any uncalled functions which contain the flag. We found a strange base64 string in the strings too and there is a base64 decode function too! But decoding that base64 string online didn’t do anything good. So it maybe is possible that the algorithm of base64decode has been altered specifically for this string. That is however unlikely since I didn’t find any unusual things in the said function.</p><p>So the main function is pretty much useless. I pay a visit to the “<em>func(void)</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*oNy3jXImOei6TaRVaTFJsA.png" /><figcaption>The overly-confusing function</figcaption></figure><p>After spending a lot of time analyzing the “func()” function I realized it was a trap. Under certain command line argument conditions it can be called from main to display certain messages. We’ll get to that later but other than that it does not do anything with the flag or the base64 string I found earlier in the strings dump.</p><p>With all these out of the way, I went to the promising “flagfunk()” function and yes it had exactly what I wanted it to have! It calls the base64decode function and it loads into address the base64 string we found earlier. It’s all coming together!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/1*GrmKwMcZwQiEHaFAl5WBuA.png" /><figcaption>The strange b64 string is loaded in the rdx register</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*RUTksLz7CJ5An6hcRkN8TQ.png" /><figcaption>The base64decode function is called soon after the base64 string is sent as an argument</figcaption></figure><p>Since now it is clear that:</p><ol><li>flagfunk() is calling the decode function with the string as an argument.</li><li>The decoded string is being returned to the flagfunk() function</li><li>Some sort of operation is being done on the decoded string to generate a flag. So at this point, it seemed feasible to just call the flagfunk() function!</li></ol><p>I did that but…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*r_l3HVoOyJgXfiDYDP5xGw.png" /></figure><p>I break at main, run the program and then used the gdb command jump to directly control the RIP to flagfunk() but this is what I got. Just before the supposed flag is to be printed, it waited until the user exited the program.</p><h4>Dynamic Analysis!</h4><p>The binary is a non stripped version so, we have two options: either analyze and recreate your own version of flagfunk() to generate the flag or we can simply run dynamic analysis and see the flag being generated! I chose the second option since it is easier!</p><p>We have to choose to place our breakpoints very carefully since it would determine which position of the flag generation we are at:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*EIjXa3k79EsMawFxzW4MBw.png" /><figcaption>break * flagfunk+675</figcaption></figure><p>I chose the marked break-point since the program doesn’t seem to be doing anything special after that.</p><p>There is however a little trick: Simply jumping to the flagfunk() won’t do and we won’t be able to get to our desired vantage point to observe things. We need to place a break-point so that the execution gets halted at that point.</p><p>The whole point of breakpoints is actually issuing an interrupt (\xCC).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*bMOhXH4KMxF7YTrRFIUHQQ.png" /><figcaption>All set!</figcaption></figure><p>Now we just need to run and when it halts at main+1 execute a jump instruction to flagfunk().</p><p>Here I go! <strong><em>STARBURST STREAM</em></strong> !!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i_xBdeLINSS2wyCmthfB3w.png" /><figcaption>The flag is already visible!</figcaption></figure><p>The flag is already visible but hey, its cut in way so to view full simply use <em>x/10s $r8</em> which basically prints the next 10 addresses referred by the register R8</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AfPU7jnZufdheg19_hA_AA.png" /><figcaption>Flag!</figcaption></figure><p>Got it!: The whole string is</p><p>“Good job! So here is the flag… FSec{1_g0t_Th1s_b3caus3_1_kN0W_H0w_t0_r3V3RS3_3LF_ef3_d04cad63d0aac} … we see potential in this. wanna join college-level CTF Team? Fill this form and provide the above flag we will recognize you next time. <a href="https://forms.gle/HiN6UGg8GusQjgXc7">https://forms.gle/HiN6UGg8GusQjgXc7</a> Cheers.”</p><h4>flagfunk()</h4><p>So, we got the flag noice! But what magic went in flagfunk() that an unreadable string got suddenly converted into a readable flag?</p><p>Here I think is really what’s going on:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1012/1*6xLp7jPT7L7j6PMT6uYSFA.png" /><figcaption>flagfunk analysis</figcaption></figure><p>A strange hex string “0xd0e0a0d” into the memory and a lot of loops were operating here. So I think maybe the decoded string was formatted and ANDed and XORed with this string.</p><h4>Playing with input</h4><p>It’s time to talk about the func() function. I realized that certain inputs can trigger the call to this function from main.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ydkNxnjTnINr1iYvtknfKw.png" /><figcaption>funny outputs</figcaption></figure><p>So we see, func() function is called under certain circumstances from main.</p><h4>Conclusion</h4><p>Interesting binary! It reminded me that sometimes things have an easy workaround too!</p><p>📝 Save this story in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://usejournal.com/newsletter/noteworthy-in-tech/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=17f090dfe5dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTB Stratosphere Write-Up]]></title>
            <link>https://anir08.medium.com/htb-stratosphere-write-up-497d7ccb1cba?source=rss-2c3fce898a79------2</link>
            <guid isPermaLink="false">https://medium.com/p/497d7ccb1cba</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[hackthebox]]></category>
            <dc:creator><![CDATA[Anirban Chakraborty]]></dc:creator>
            <pubDate>Fri, 29 May 2020 19:02:17 GMT</pubDate>
            <atom:updated>2020-05-29T19:02:17.790Z</atom:updated>
            <content:encoded><![CDATA[<p>皆さんこんにちは！</p><h3>Introduction</h3><p>The box was pretty fun with some rabbit holes which can really frustrate someone (personal experience) once the vulnerability has been exposed things do not go easy from there as the boxes itself has many protections in it. I am going to show you how I owned this box. So basically the “http” running Apache Tomcat was vulnerable to Apache struts vulnerability, leveraging that we get credential information of a user, ssh in and then do a DLL Injection Privilege Escalation to get root.</p><h3>Initial Enumeration</h3><p>The first enumeration is starting an nmap scan and brute forcing website directories. For this specific purpose I created a Automation tool called “AutoRecon” which I use here, but you can always do this manually.</p><p><strong>nmap flags are</strong><em> : nmap -v -sV -sC 10.10.10.64 -oA nmap/scanResults</em></p><p>Nmap returned the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*X0dAWK1RrhOp4dKOLAQVjw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*ZTlcJOv3Wk89GAgOzzvZBw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AetElaLQBQqvQiPCey0wlw.png" /></figure><p>It shows 3 ports are open which are 22,80 and 8080, I did a full port scan but did not find anything different. Everything seems to be normal, nothing much to do here.</p><p>Visiting the website, we are greeted with this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J9zeLjGB9mS6xxB2oayMEg.png" /><figcaption>Stratosphere</figcaption></figure><p>Pretty dandy if you ask me &gt;_&lt; !! Let’s start the directory brute forcing then!</p><p><strong>gobuster flags are</strong> : <em>gobuster dir -u </em><a href="http://10.10.10.64/"><em>http://10.10.10.64/</em></a><em> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*gXHhsg7qkCM-EdIYhhXAjg.png" /><figcaption>Gobuster scan</figcaption></figure><p><em>Hmm?? Omoshiroi!! This is starting to get interesting now! We get two directories but the status is 302 (which means “moved permanently”)</em></p><p>Without further ado lets search em’ up!</p><p>A search to <a href="http://10.10.10.64/manager">http://10.10.10.64/manager</a> returned the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/898/1*oi0sz_FkzG0C3WOrPMzpdQ.png" /><figcaption>Login on the http://10.10.10.64/manager</figcaption></figure><p>It’s asking for credentials but we don’t have any, still I tried some basic combinations like <em>“admin::admin”, “admin::password”</em> and such but to no luck :( .</p><p>A search to <a href="http://10.10.10.64/Monitoring">http://10.10.10.64/Monitoring</a> actually redirected me to <a href="http://10.10.10.64/Monitoring/example/Welcome.action">http://10.10.10.64/Monitoring/example/Welcome.action</a> and this is what greeted me.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R6kTgonJx-nJxnnlJWeAkA.png" /><figcaption>http://10.10.10.64/Monitoring/example/Welcome.action</figcaption></figure><p>Clicking on both the links showed this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*pNxtWHsO3IMAy_UhUHDHkg.png" /><figcaption>Under Construction!</figcaption></figure><p>At this point I did some more directory brute forcing and used all the wordlists but I didn’t have a clue as to what to do now. I though that if <a href="http://10.10.10.64/manager"><em>http://10.10.10.64/manager</em></a><em> </em>requires a login and <a href="http://10.10.10.64/Monitoring/example/Welcome.action"><em>http://10.10.10.64/Monitoring/example/Welcome.action</em></a> is a site under construction then why bother with the later website? Something is definitley <strong>fishy in the second url.</strong> My mistake was that I was searching for credentials to log in to the first one and lost a lot of time. Then I noticed something strange in the second website.</p><h3>Apache Struts Vulnerability</h3><p>I noticed that the urls of the second website were kind of strange, I’ve never seen them before.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*V70_6fulecRIWf_IEEiUOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/372/1*f844kQt6jTB6MBQx3aXKkw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*LIctenQPgW15UGLLtIzJ4A.png" /></figure><p>Precisely! They were all ending with “.action” and after searching I found the gold-mine I was looking for.</p><p>From <a href="https://www.tutorialspoint.com/struts_2/struts_actions.htm">https://www.tutorialspoint.com/struts_2/struts_actions.htm</a> , “<strong>Actions</strong> are the core of the Struts2 framework, as they are for any MVC (Model View Controller) framework. Each URL is mapped to a specific action, which provides the processing logic which is necessary to service the request from the user.</p><p>But the action also serves in two other important capacities. Firstly, the action plays an important role in the transfer of data from the request through to the view, whether its a JSP or other type of result. Secondly, the action must assist the framework in determining which result should render the view that will be returned in the response to the request.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B9Cquex5ByLwdVyrXJMOXw.png" /><figcaption>*crack</figcaption></figure><p>From Wikipedia:</p><p>“Struts 2 has a history of critical security bugs, many tied to its use of <a href="https://en.wikipedia.org/wiki/OGNL">OGNL</a> technology, some vulnerabilities can lead to <a href="https://en.wikipedia.org/wiki/Arbitrary_code_execution">arbitrary code execution</a>. In October 2017, it was reported that failure by <a href="https://en.wikipedia.org/wiki/Equifax">Equifax</a> to address a Struts 2 vulnerability advised in March 2017 was later exploited in the <a href="https://en.wikipedia.org/wiki/Data_breach">data breach</a> that was disclosed by Equifax in September 2017.”</p><h3>Exploitation</h3><p>So, if RCE is possible then we should be able to get a Reverse Shell and subsequently own the box, I found an exploit via searchsploit (<a href="https://www.exploit-db.com/exploits/41570">https://www.exploit-db.com/exploits/41570</a>) but there was a trouble. My first plan was to play around the RCE then use reverse shell commands to get me a shell via netcat but that required multiple line commands and this exploit only allowed single argument commands like “ls”, “whoami” and so on. I tried to change this but only ended up complicating things. No doubt this is what I wanted (all the single argument commands worked) but the exploit needs to be modified a bit. I searched “CVE 2017–5638 git-hub” and I got across this beautiful repo <a href="https://github.com/mazen160/struts-pwn"><strong>https://github.com/mazen160/struts-pwn</strong></a>. This exploit had exactly what I wanted I can run multiple commands at once (“I’m great at things like this *&gt;_&lt;).</p><p>After reading it’s documentation I ran it as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lzlu8HIwji3F1TpfaGpv3g.png" /></figure><p>It worked and we see the id of Tomcat showing up. Now, after all this, I am still after those credentials so that we can login to that site and I know any user on this box should be on the home folder, so here I go!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_g8hrtFt-oefJ6FCd1ZKJg.png" /></figure><p>using multiple commands I fished out the user “richard” !!</p><p><strong><em>python struts-pwn.py -u </em></strong><a href="http://10.10.10.64/Monitoring/example/Welcome.action"><strong><em>http://10.10.10.64/Monitoring/example/Welcome.action</em></strong></a><strong><em> -c ‘cd ../../../home &amp;&amp; ls -la’</em></strong></p><p>But the trouble is, I don’t know “richard” ‘s password so I can’t ssh in as user in the box. Need more enumeration.</p><p>Looking at tomcat directory I found a directory called “db_connect”. A text file containing Database credentials.</p><h3>Retrieving credentials from Database</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hxsagiyFa6b_lYPUq6Nndw.png" /></figure><p><strong><em>python struts-pwn.py -u </em></strong><a href="http://10.10.10.64/Monitoring/example/Welcome.action"><strong><em>http://10.10.10.64/Monitoring/example/Welcome.action</em></strong></a><strong><em> -c ‘cat db_connect’</em></strong></p><p>Caution: First credentials are Rabbit Hole! I learned it the hard way T_T</p><p>I tried to login to mysql using the credentials given here using my own machine but it seems like Stratosphere was blocking connections. The only way is to use the RCE to access it. Again remember, we don’t have reverse shell so it should be a one-liner command. We know we are using database name: “users” so “SELECT * from &lt;tableName&gt; should work!</p><p>This was according to me the hardest part! After many hit and trials, and searching I finally got it to work. This article helped me very much <a href="https://medium.com/bugbountywriteup/alternatives-to-extract-tables-and-columns-from-mysql-and-mariadb-813171d3c8bc">https://medium.com/bugbountywriteup/alternatives-to-extract-tables-and-columns-from-mysql-and-mariadb-813171d3c8bc</a> ! But how many tables are there? I ran the following to know.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m7ZGv4gES63aP_KiOljZAA.png" /></figure><p><strong><em>python struts-pwn.py -u </em></strong><a href="http://10.10.10.64/Monitoring/example/Welcome.action"><strong><em>http://10.10.10.64/Monitoring/example/Welcome.action</em></strong></a><strong><em> -c ‘mysql -u admin -padmin -e “use users; show tables”’</em></strong></p><p>Immediately it informed me that the table name is “accounts” ! UwU !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Hb9Ylt0VK4WKqF4IDiz6A.png" /><figcaption>richard should secure his account asap</figcaption></figure><p><strong><em>python struts-pwn.py -u </em></strong><a href="http://10.10.10.64/Monitoring/example/Welcome.action"><strong><em>http://10.10.10.64/Monitoring/example/Welcome.action</em></strong></a><strong><em> -c ‘mysql -u admin -padmin -e “use users; SELECT * from accounts”’</em></strong></p><p>aaanddd… we got richard’s password!! Who would have know it was here!!! OwO</p><p>Lets SSH in !!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XrMorFR-5AekYv2ixU6TFg.png" /></figure><p>Everything’s fine! user.txt is done! Now Priv Esc!</p><h3><strong>Privilege Escalation — DLL Injection</strong></h3><p>HTB has taught me many things, and one of them is abusing sudo to get an escalation. So that’s what I do! <strong><em>sudo -l</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_a4v_koAKw4GfTi1HL0NQ.png" /></figure><p>This sure returned interesting results! So richard can run two things without password, first is the test.py in its home directory and other, it can also use python version to do the same ( /usr/bin/python*). So it is now pretty obvious that if we somehow hijack test.py and force it run system commands, we are pretty much done with. And yes it was that easy!</p><p>Taking a look at test.py</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aJurtID8UdHLcDiHSV5kSQ.png" /></figure><p>It’s asking us to crack some hashes, after which it will run the “os.system(‘/root/success.py’)” command, it has cleverly shielded the import os module inside the “question” function, the last boss lives up-to its name!</p><p>Now obviously it does not wants us to win this little cracking game (yes, I tried). The first three hashes seems easy and hashcat will do its job perfectly but the last one is intentionally there to stop us. Here comes DLL Injection!!!</p><p>DLL Injection means instead of linking the libraries from the disc, if a same name python script is present in the same folder it links it. Here hashlib is the very good attack target for DLL Injection. Once the original hashlib.py from the <em>/usr/lib/python2.7/hashlib.py</em> is not linked anymore and it is linked with our own custom made hashlib.py in the home folder, the whole cracking game would crumble! Let’s do it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*RibZwfVvQIAabxNPSheNAA.png" /><figcaption>the original hashlib.py in the /usr/lib/python2.7 directory</figcaption></figure><p><strong><em>Lets create our own hashlib.py which will be actually linked instead of the original one and execute the bash command! echo ‘import os; os.system(“/bin/bash”)’ &gt; hashlib.py</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*ZrtN6ZI9aK3P4F4m6HhBWA.png" /><figcaption>custom made hashlib.py (exploit) in /home/richard</figcaption></figure><p>Time for the final attack! <strong>STARBURST STREAM!</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*_adHjem9axm1AylbX0FR1w.png" /></figure><p>YESS!! WE ARE ROOT!! root.txt can be obviously obtained from the root directory!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*xZxJpdxhRfINJj9MwFSztg.png" /></figure><h3>Conclusion</h3><p>In the end, I enjoyed this box I was so frustrated in the beginning and I ignored what’s in front of me for so long just goes to show how well these are made! There were many Rabbit Holes in this one! After finishing the box I tested DLL Injection on my home Kali Machine too and yes it was vulnerable but since I am the only user so that should not be a problem but it can be a problem in a multi-user environment. This was my first Blog post I hope you enjoyed it! I plan to post more security related stuff, write-ups, exploits, cves and the like, so please look forward to it. Any suggestion or improvements in my steps are greatly welcomed!</p><p><strong><em>Stay Cool!</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=497d7ccb1cba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>