<?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 Gonçalo Carvalho on Medium]]></title>
        <description><![CDATA[Stories by Gonçalo Carvalho on Medium]]></description>
        <link>https://medium.com/@attempto?source=rss-a8962e3c02f4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hq11wCpMTE90QVoorRtnMg.png</url>
            <title>Stories by Gonçalo Carvalho on Medium</title>
            <link>https://medium.com/@attempto?source=rss-a8962e3c02f4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 15 Apr 2026 23:39:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@attempto/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[Brute-Force MongoDB SCRAM Authentication]]></title>
            <link>https://medium.com/@attempto/brute-force-mongodb-scram-authentication-20acb4599f74?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/20acb4599f74</guid>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Sat, 13 Aug 2022 14:56:42 GMT</pubDate>
            <atom:updated>2022-08-13T14:57:07.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Rw2mGewrCRlAocTdL_2JOQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@rubaitulazad?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Rubaitul Azad</a> on <a href="https://unsplash.com/s/photos/mongodb?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>This is the explanation for a script to brute-force MongoDB SCRAM authentication when all the required parameters are known or can be obtained (from a .pcap file for example).</p><p>It can be useful for Boot2Root challenges.</p><p>The authentication protocol is described here <a href="https://www.mongodb.com/blog/post/improved-password-based-authentication-mongodb-30-scram-explained-part-1">https://www.mongodb.com/blog/post/improved-password-based-authentication-mongodb-30-scram-explained-part-1</a>.</p><p>From the script perspective, all the parameters are known except the password which is the target.</p><p>The objective is then to simulate the authentication protocol until such point the client proof is generated and then compare to what we already have.</p><p>The simulation of the protocol is made using <a href="https://github.com/tlocke/scramp">https://github.com/tlocke/scramp</a> which greatly simplifies the code.</p><p>The computation of the client proof is,</p><pre>def get_client_proof(username, password, client_nonce, combined_nonce, salt, iteration_count):<br>    client = ScramClient(MECHANISMS, username, password, c_nonce = client_nonce)<br>    client_first = client.get_client_first()<br>    client.set_server_first(f&#39;r={combined_nonce},s={salt},i={iteration_count}&#39;)<br>    return client.get_client_final().split(&#39;,&#39;)[2]</pre><p>The full script can be found at <a href="https://github.com/glslang/mongo_scram_brute">https://github.com/glslang/mongo_scram_brute</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20acb4599f74" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shakabrah (PGPlay) Writeup]]></title>
            <link>https://medium.com/@attempto/shakabrah-pgplay-walkthrough-80ef7d5d50f?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/80ef7d5d50f</guid>
            <category><![CDATA[oscp]]></category>
            <category><![CDATA[oscp-preparation]]></category>
            <category><![CDATA[offensive-security]]></category>
            <category><![CDATA[shakabrah]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Tue, 10 Aug 2021 09:23:29 GMT</pubDate>
            <atom:updated>2021-09-04T12:34:05.986Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VJmTSHlBcYUThRz_lNazaw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@rayhennessy?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ray Hennessy</a> on <a href="https://unsplash.com/@rayhennessy?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Shakabrah is a warm-up box in Offensive Security’s PG Play platform.</p><h3><strong>Recon</strong></h3><p>Nmap found two open ports, SSH (22) and HTTP (80).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*opGxmMF6FAgaetzXISgSsA.png" /></figure><h3><strong>HTTP Port 80</strong></h3><p>We’re allowed to run a ping command (connection tester) remote commands through the web interface. By simply clicking on go we get,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*qwGlPQdNrQdpWoezog0rpw.png" /></figure><p>From here we can attempt to gain RCE by exploring what the interface allows us to do. Rather than trying to fuzz what commands we can run, even though this is a good exercise on its own, we can simply explore it manually. In particular does it allow to chain commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*kfiIi4A15kzVfCrkaEMNQw.png" /></figure><p>And in our python http handler,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*7740Zz3PX46If1IDgCQ7yw.png" /></figure><p>This being the case we can simply try to get RCE by running a python reverse shell.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcU4WOlxTaCNtHfCyOiYVA.png" /></figure><p>We get our shell back and we now have access as www-data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*lQVulgFLx81FAKPrLpX0ow.png" /></figure><p>The reverse shell I used is from <a href="https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#python">https://github.com/swisskyrepo/PayloadsAllTheThings/blob/master/Methodology%20and%20Resources/Reverse%20Shell%20Cheatsheet.md#python</a>.</p><p>A topic that comes up frequently on PG Play/Practice is why only some ports work for reverse shells. In general, one should try ports that nmap identified as open since they’re likely to also allow for outbound connections.</p><p>Also don’t forget to try python3 if python alone doesn’t appear to work.</p><h3><strong>Privilege Escalation</strong></h3><p>Enumeration of SUID binaries shows us that vim.basic is SUID as root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*uZ9M4rjfRMZm_CWjIAqa3g.png" /></figure><p>From <a href="https://gtfobins.github.io/gtfobins/vim/">https://gtfobins.github.io/gtfobins/vim/</a> we get several possible ways of getting a root shell.</p><p>Importantly, we also find from vim.basic -version that it has python3 support. With these two pieces of information we get a shell with a EUID of root.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/577/1*wAGvFtzJZNo3kz6kObqZwg.png" /></figure><h3><strong>Conclusion</strong></h3><p>Shakabrah is a fairly easy Play machine with a PWK lab feel to it suitable for beginners.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80ef7d5d50f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: TWCTF2019 easy_crack_me with Z3, Ghidra and pwntools]]></title>
            <link>https://medium.com/@attempto/ctf-writeup-twctf2019-easy-crack-me-with-z3-ghidra-and-pwn-3ff5bc732e97?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ff5bc732e97</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Sat, 16 May 2020 20:59:34 GMT</pubDate>
            <atom:updated>2020-05-21T19:40:43.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbKqs2OqN-61gsDRrGWPAw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@sxoxm?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sven Mieke</a> on <a href="https://unsplash.com/t/business-work?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>The challenge is a small reverse engineering problem.<br>The program will print <strong>‘Correct’ </strong>when run with the right flag passed to it<br>as the 1st argument.</p><p>Loading the binary in Ghidra, and inspecting the decompilation window, the<br>structure of it can be roughly subdivided in 5 parts.</p><p><strong>1.</strong> Checking the size of the argument and if the flag starts with <strong>TWCTF{</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*XpdVj5HaOVlJ-48yGE-Mgg.png" /></figure><p><strong>2.</strong> Two nested loops doing some basic operations (addition, xor, shifts) followed by 4 memcmp with fixed memory address arrays</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*H_4qUAJRbOXMri2kkekp9A.png" /></figure><p>the second nested loop,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*n7re2HL7JzfGigc0h8DMKA.png" /></figure><p><strong>3.</strong> A single loop assigning constants followed by a memcmp with a fixed memory address array</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*fEiE7yijRAlCrFkSTkdGEA.png" /></figure><p><strong>4.</strong> A loop doing a reduction of fixed locations of the input and checking against a constant</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*6K4WIpWa_0W7keNZdtgAbA.png" /></figure><p><strong>5.</strong> A series of checks against fixed locations of the input</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/1*qqZfRKvU6IRtKyZpJQ-Vow.png" /></figure><p>From the above we can develop our exploit script as follows,</p><p><strong>1.</strong> Use pwn to read the fixed memory addresses to compare against</p><p><strong>2.</strong> Develop our Z3 model based on the expected size of the flag</p><p><strong>3.</strong> Transcribe the loops from Ghidra and add the constraints to our Z3 model</p><p><strong>4.</strong> For all possible satisfiable answers, run the executable with our current flag candidate</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f552b031a93e21b49ffe3890f1ad4c16/href">https://medium.com/media/f552b031a93e21b49ffe3890f1ad4c16/href</a></iframe><p>For simplicity, we’re going to create a bit vector using 4 bytes for each of the possible characters of the flag. This is done in line 29.<br>Lines 32–68 simply use the code decompiled by Ghidra to run the same operations as the binary and set up the constraints<br>that mimic the memcmp calls, the reduction and the if statements.</p><p>With our model built and after checking it’s satisfiable we loop until a solution is found.</p><p>The most interesting part in this section is line 87 which ensures our previous candidate attempt is no longer tried.</p><p>The solution is printed after a few secs of running the script.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ff5bc732e97" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: 0x00sec CTF Exercise 07]]></title>
            <link>https://medium.com/@attempto/ctf-writeup-0x00sec-ctf-exercise-07-4f2537afc0ea?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f2537afc0ea</guid>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Tue, 05 May 2020 21:15:58 GMT</pubDate>
            <atom:updated>2020-05-05T21:15:58.051Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S440tkQqZFkmx69z9OGA-g.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@robertbye?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Robert Bye</a> on <a href="https://unsplash.com/t/architecture?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The 0x00sec CTF exercises (<a href="https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044">https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044</a>) are a welcome addition to the CTF scene allowing for a short 10–30 minute solve.</p><p>In this post I share my thought process and describe a possible walk-through leading to the flag.</p><h3>The Challenge</h3><p>The exercise can be found by following the link from <a href="https://ctf.0x00sec.org/">https://ctf.0x00sec.org/</a>.</p><p>This one is a crypto challenge and we’re given two hints; decode and use <strong>XOR</strong> to get the flag.</p><p>The decode part is easy. From previous challenges we can now recognize it’s base64 encoded.</p><p>We now need to use <strong>XOR</strong> to obtain the flag. But with what? We need a key and we’re not given any hints about it. But, we know,</p><blockquote><em>The flag must start with</em> flag{.</blockquote><blockquote>ciphertext <strong><em>XOR</em></strong> key = flag{…</blockquote><blockquote>ciphertext <strong><em>XOR</em></strong> <em>flag{</em> = key…</blockquote><p>With the above we’re now ready to write some python that implements the above,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/638cb3c449fa0af32e6f318e48188067/href">https://medium.com/media/638cb3c449fa0af32e6f318e48188067/href</a></iframe><p>The code above implements our algorithm and prints the flag. It also makes the assumption that the key size is the same length as <em>flag{</em>. This is reasonable since we’re not given the key size from the challenge.</p><h3>Conclusion</h3><p>In this post I shared a possible walk-through of 0x00sec CTF exercise 07.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f2537afc0ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: 0x00sec CTF Exercise 06]]></title>
            <link>https://medium.com/@attempto/ctf-walkthrough-0x00sec-ctf-exercise-06-568178d57ff3?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/568178d57ff3</guid>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 21:30:28 GMT</pubDate>
            <atom:updated>2020-05-05T20:45:47.165Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAf7aMHMWEUzAbTotkWcFw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@davidclode?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">David Clode</a> on <a href="https://unsplash.com/t/textures-patterns?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The 0x00sec CTF exercises (<a href="https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044">https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044</a>) are a welcome addition to the CTF scene allowing for a short 10–30 minute solve.</p><p>In this post I share my thought process and describe a possible walk-through leading to the flag.</p><h3>The Challenge</h3><p>The exercise can be found by following the link from <a href="https://ctf.0x00sec.org/">https://ctf.0x00sec.org/</a>.</p><p>In this exercise we are greeted with a page that simply checks our IP against a whitelist and denies access.</p><p>Since we cannot interact with the page it’d appear all we can do is change the headers of the request.</p><p>What would be an IP that is whitelisted? We can simply try 127.0.0.1. And what would be a good header? It is <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For">X-Forwarded-For</a>.</p><p>We can try it with the following command,</p><p><em>curl -H “X-Forwarded-For: 127.0.0.1” -X GET “</em><a href="https://exercise-6.0x00sec.dev/"><em>https://exercise-6.0x00sec.dev/</em></a><em>&quot;</em></p><p>The response contains the flag.</p><h3>Conclusion</h3><p>In this post I shared a possible walk-through of 0x00sec CTF exercise 06.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=568178d57ff3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: 0x00sec CTF Exercise 05]]></title>
            <link>https://medium.com/@attempto/ctf-walkthrough-0x00sec-ctf-exercise-05-6ff787354e3f?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ff787354e3f</guid>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Wed, 22 Apr 2020 21:16:29 GMT</pubDate>
            <atom:updated>2020-05-05T20:46:50.768Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TZJYPIwiH4OZvlbhrCAqbQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@micheile?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Micheile Henderson</a> on <a href="https://unsplash.com/t/food-drink?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The 0x00sec CTF exercises (<a href="https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044">https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044</a>) are a welcome addition to the CTF scene allowing for a short 10–30 minute solve.</p><p>In this post I share my thought process and describe a possible walk-through leading to the flag.</p><h3>The Challenge</h3><p>The exercise can be found by following the link from <a href="https://ctf.0x00sec.org/">https://ctf.0x00sec.org/</a>.</p><p>In this exercise we are greeted with a page containing a single login button.</p><p>Right clicking and selecting view page source we can see two interesting comments, “Stop relying on Base64” and “backup pass in /etc/passwd”.</p><p>Further examining the source we see two parameters being passed into the form. The ‘p’ parameter is Base64 encoded and it’s the one we need to change in order to access <em>/etc/passwd</em>.</p><p>Following the above reasoning, what would be a good parameter? There’s a few things we could try but ultimately it’s <em>file:///etc/passwd</em>.</p><p>We can use a little bit of python to automate the request and get our flag,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc23ed6649cfa8bb30aed0153d6d4d69/href">https://medium.com/media/bc23ed6649cfa8bb30aed0153d6d4d69/href</a></iframe><p>The response contains the flag.</p><h3>Conclusion</h3><p>In this post I shared a possible walk-through of 0x00sec CTF exercise 05.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ff787354e3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: 0x00sec CTF Exercise 04]]></title>
            <link>https://medium.com/@attempto/ctf-walkthrough-0x00sec-ctf-exercise-04-5e8085f0934?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e8085f0934</guid>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Sun, 19 Apr 2020 20:22:49 GMT</pubDate>
            <atom:updated>2020-05-05T20:47:51.715Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GXUur8DzSxuMA5HE_bL-mQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@wildspot?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Aurélien — Wild Spot</a> on <a href="https://unsplash.com/s/photos/serenity?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The 0x00sec CTF exercises (<a href="https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044">https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044</a>) are a welcome addition to the CTF scene allowing for a short 10–30 minute solve.</p><p>In this post I share my thought process and describe a possible walk-through leading to the flag.</p><h3>The Challenge</h3><p>The exercise can be found by following the link from <a href="https://ctf.0x00sec.org/">https://ctf.0x00sec.org/</a>.</p><p>In this exercise we are greeted with a form allowing for username and password and the objective is to get the flag.</p><p>Right clicking and selecting view page source we can see an interesting comment, “Restrict debug log access”.</p><p>From the hint above it seems we can access the debug log. But how? The obvious url to try is simply <a href="https://exercise-4.0x00sec.dev/debug.log">https://exercise-4.0x00sec.dev/debug.log</a>.</p><p>Does it work? Yes it does! The log contains a lot of header information but in particular we’re interested in the cookie for the PHP session ids. Our next idea is to simply iterate through the session ids and attempt to get the flag from the server reply.</p><p>There’s a lot of them so we’re going to automate it with a little bit of python,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/877ced5293b6707cc338642d790fd356/href">https://medium.com/media/877ced5293b6707cc338642d790fd356/href</a></iframe><p>Our python script requests the <em>debug.log</em> and then iterates over the session ids. It stops when the flag is found in the reply.</p><p>There are many ways on how we could improve the script but is not necessary for this particular exercise.</p><h3>Conclusion</h3><p>In this post I shared a possible walk-through of 0x00sec CTF exercise 04.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e8085f0934" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: 0x00sec CTF Exercise 03]]></title>
            <link>https://medium.com/@attempto/ctf-walkthrough-0x00sec-ctf-exercise-03-f51f415ceea6?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f51f415ceea6</guid>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[ctf]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Sun, 08 Mar 2020 14:37:41 GMT</pubDate>
            <atom:updated>2020-05-05T20:48:55.098Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5pL1rFnQwTlP992x6hHfLw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@lanceanderson?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Lance Anderson</a> on <a href="https://unsplash.com/s/photos/manga?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The 0x00sec CTF exercises (<a href="https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044">https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044</a>) are a welcome addition to the CTF scene allowing for a short 10–30 minute solve.</p><p>In this post I share my thought process and describe a possible walk-through leading to the flag.</p><h3>The Challenge</h3><p>The exercise can be found by following the link from <a href="https://ctf.0x00sec.org/">https://ctf.0x00sec.org/</a>.</p><p>In this exercise we are greeted with a form allowing for username and password and the objective is to get the flag. We can simply try the combination of <em>admin/admin </em>but this time we’re greeted with detailed user data for the user.</p><p>Right clicking and selecting view page source we can see an interesting comment, “<em>Implement secure object references</em>”.</p><p>Looking at the URL we can see <a href="https://exercise-3.0x00sec.dev/index.php?user_id=5">https://exercise-3.0x00sec.dev/index.php?user_id=5</a>.</p><p>From the above it appears we can simply enumerate the <em>user_id </em>and we’ll be able to find our flag. As it turns out this is the case, so we can simply start at 0 and continue until we have our flag.</p><h3>Conclusion</h3><p>In this post I shared a possible walk-through of 0x00sec CTF exercise 03.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f51f415ceea6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: 0x00sec CTF Exercise 02]]></title>
            <link>https://medium.com/@attempto/ctf-walkthrough-0x00sec-ctf-exercise-02-cab258f21187?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cab258f21187</guid>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[web-exploitation]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Sun, 23 Feb 2020 12:31:51 GMT</pubDate>
            <atom:updated>2020-05-05T20:49:54.629Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWyUs6MRAN87scS_bPpkuQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@hackernoon?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Hacker Noon</a> on <a href="https://unsplash.com/s/photos/hacker?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The 0x00sec CTF exercises (<a href="https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044">https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044</a>) are a welcome addition to the CTF scene allowing for a short 10–30 minute solve.</p><p>In this post I share my thought process and describe a possible walk-through leading to the flag.</p><h3>The Challenge</h3><p>The exercise can be found by following the link from <a href="https://ctf.0x00sec.org/">https://ctf.0x00sec.org/</a>.</p><p>In this exercise we are greeted with a form allowing for username and password and the objective is to get the flag. We can simply try the combination of <em>admin/admin </em>and will get incorrect password.</p><p>Right clicking and selecting view page source we can see an interesting comment, “<em>Implement secure sessions</em>”.</p><p>Toggle developer tools on your browser and inspect the POST request. The session cookie is of the form <em>PHPSESSID=YXV0aGVudGljYXRlZD10cnVlCg%3D%3D</em>.</p><p>The session id is url encoded and in base64. Therefore we need a little bit of python to help us,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6c45aa9654a0caeaca55ac0d3dac08a3/href">https://medium.com/media/6c45aa9654a0caeaca55ac0d3dac08a3/href</a></iframe><p>From the gist we can see that the session cookie is simply “<em>authenticated=false</em>”. We simply encode “<em>authenticated=true</em>” and do request using our new session id cookie,</p><p><em>curl -X POST -v -H ‘Cookie:PHPSESSID=YXV0aGVudGljYXRlZD10cnVlCg%3D%3D’ </em><a href="https://exercise-2.0x00sec.dev/?user=admin\&amp;password=admin."><em>https://exercise-2.0x00sec.dev/?user=admin\&amp;password=admin</em>.</a></p><p>The response reveals the flag.</p><h3>Conclusion</h3><p>In this post I shared a possible walk-through of 0x00sec CTF exercise 02. This exercise was a simple one but that is the point. They’re small brain teasers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cab258f21187" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF Writeup: 0x00sec CTF Exercise 01]]></title>
            <link>https://medium.com/@attempto/ctf-walkthrough-0x00sec-ctf-exercise-01-4a0e0293ccf6?source=rss-a8962e3c02f4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a0e0293ccf6</guid>
            <category><![CDATA[web-exploitation]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[capture-the-flag]]></category>
            <dc:creator><![CDATA[Gonçalo Carvalho]]></dc:creator>
            <pubDate>Sun, 23 Feb 2020 11:52:30 GMT</pubDate>
            <atom:updated>2020-05-05T20:52:06.290Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rqVSn50aqn8F1ufpUrqndQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@seefromthesky?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Ishan @seefromthesky</a> on <a href="https://unsplash.com/s/photos/skyline?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>The 0x00sec CTF exercises (<a href="https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044">https://0x00sec.org/t/introducing-bi-monthly-0x00sec-ctf-exercises/19044</a>) are a welcome addition to the CTF scene allowing for a short 10–30 minute solve.</p><p>In this post I share my thought process and describe a possible walk-through leading to the flag.</p><h3>The Challenge</h3><p>The exercise can be found by following the link from <a href="https://ctf.0x00sec.org/">https://ctf.0x00sec.org/</a>.</p><p>In this exercise we are greeted with a form allowing for username and password and the objective is to get the flag. We can simply try the combination of <em>admin/admin </em>and will get incorrect password.</p><p>Right clicking and selecting view page source we can see an interesting comment “<em>Remove the git directory after publishing</em>”. If the developer forgot to remove the .git directory then it’s possible to reconstruct the source code for the form.</p><p>Recall that a .git directory contains all the information associated with a repository and it is possible to find the SHA commit for current master by following <em>.git/refs/heads/master</em>.</p><p>This allows us to find the current HEAD master commit simply by going to <a href="https://exercise-1.0x00sec.dev/.git/refs/heads/master">https://exercise-1.0x00sec.dev/.git/refs/heads/master</a>. The result we get is <em>05480569507a37df7731115a5888f91b145c189d</em>.</p><p>Since we now know the commit SHA of master’s HEAD we can browse the <em>.git/objects</em> directory for it. The <em>.git/objects</em> directory contains sub-directories corresponding to the first two hex digits of the SHA with the object filename being the remaining digits.</p><p>We can now get our HEAD commit by browsing to <a href="https://exercise-1.0x00sec.dev/.git/objects/05/480569507a37df7731115a5888f91b145c189d">https://exercise-1.0x00sec.dev/.git/objects/05/480569507a37df7731115a5888f91b145c189d</a> and download the object file.</p><p>The object files are compressed using zlib so a little bit of python is required to view its contents,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/75e63011f982425e8f8e56b6bee0f6d9/href">https://medium.com/media/75e63011f982425e8f8e56b6bee0f6d9/href</a></iframe><p>After decompress we get,</p><p><em>commit 212tree b63be1fb236a6be035cd8573a585a356d47285fa<br>parent c13f81bf0a2f2c0e64a97a316bf3df3ccccea25a<br>author pry &lt;pry@Ghostbook-Air.home&gt; 1581195325 +0000<br>committer pry &lt;pry@Ghostbook-Air.home&gt; 1581195325 +0000</em></p><p>We can now follow the same process and download the object for the tree <em>b63be1fb236a6be035cd8573a585a356d47285fa</em>. Decompressing the tree object and piping to the Linux utility <em>hd</em>, we get,</p><p><em>00000000 74 72 65 65 20 37 33 00 31 30 30 36 34 34 20 69 |tree 73.100644 i|<br>00000010 6e 64 65 78 2e 70 68 70 00 49 0d f3 ef e4 5d 6c |ndex.php.I….]l|<br>00000020 c6 73 21 19 32 04 f1 64 9a 57 a3 6c 83 31 30 30 |.s!.2..d.W.l.100|<br>00000030 37 35 35 20 73 74 61 72 74 2e 73 68 00 bc ad c6 |755 start.sh….|<br>00000040 66 0a b5 4f a5 51 90 bc aa a5 e9 1d f0 8b 34 92 |f..O.Q……..4.|<br>00000050 5f |_|<br>00000051</em></p><p>We’re interested in <em>index.php</em> and we can find its SHA from the above after the last character <em>p</em> and the null terminator. The SHA is <em>490df3efe45d6cc67321193204f1649a57a36c83</em>. Repeating the same process of downloading and decompressing this object we find the source code for <em>index.php. </em>Inspecting the source code we learn that the user is <em>admin</em> and the SHA256 for the password is <em>e83176eaefcc1ae8c4a23dbc73ebcf122f26cfb9ba5c7cf4763e96c1c38a6c6c</em>.</p><p>All that is left to do is to go to <a href="https://crackstation.net/">https://crackstation.net/</a> and see if is a known one. As it turns out it is and we get our password.</p><p>Going back to the main exercise page we simply type our combination of user and password, and get the flag.</p><h3>Conclusion</h3><p>In this post I shared a possible walk-through of 0x00sec CTF exercise 01 and although some of these steps are manual, a lot of the work could be automated, something I’ll share in a later post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a0e0293ccf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>