Google CTF 2017 Mind Reader Write-up

June 28, 2017 | Views: 3484

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATIONAlready a Member Login Here

MindReader was supposedly one of the easiest challenges at GoogleCTF and it’s after some guessing. So let’s start! First heading the challenge page we see a box with “read” button.

First thing comes to mind is to try to test for “XSS” so a couple of XSS attempts were tested among them the following:

<script>alert(test)</script>

Unluckily the response was not as expected. Command injections techniques were also tried with a couple of “ls”, “cmd”, but also with no luck. Now the next step is to try directory traversal and it turns out that the host is vulnerable. The following traversals were tried but also with no luck.

../.././../etc/passwd

../../../../etc/shadow

../../../../etc/resolv.conf

../../../etc/hosts

Then after a couple of fingerprinting, it turns out that the environment is running some docker, so the main page was opened again and “main.py” was typed and the main script has shown up.

The script above uses “flask” framework and uses the function “index()” to run the tasks of reading the values entered in the challenge box. Line 6 tells us that there’s an environment variable which is asserted before running the function and Google presented us a hint that this environment variable is the actual FLAG. And giving the host is vulnerable to directory traversal, so the environment variable must be accessed in that way. Trying every combination using /proc/self/environ but it seems that we do not have access permissions.

A good knowledge of Linux systems comes into play, /proc/self/fd has symlinks to /dev/fd and this means that in Linux there are relations between environment variables and file descriptors to allow us to access environment from file descriptors or from /dev/fd that starts from 0,1,2 and so on.

So trying /dev/fd/0 nothing but trying /dev/fd/8 gives us this.

Coupled with directory traversal

/dev/fd/../environ

And the flag has been captured!

 

Share with Friends
FacebookTwitterLinkedInEmail
Use Cybytes and
Tip the Author!
Join
Share with Friends
FacebookTwitterLinkedInEmail
Ready to share your knowledge and expertise?
Comment on This

You must be logged in to post a comment.

Our Revolution

We believe Cyber Security training should be free, for everyone, FOREVER. Everyone, everywhere, deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is a free community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

Support Cybrary

Donate Here to Get This Month's Donor Badge

 
Skip to toolbar

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel