Google CTF 2017 Mind Reader Write-up

June 28, 2017 | Views: 3363

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:


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.





Then after a couple of fingerprinting, it turns out that the environment is running some docker, so the main page was opened again and “” 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


And the flag has been captured!


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

You must be logged in to post a comment.

Get more out of Cybrary
Reach an audience of 1,500,000+ IT and cyber professionals, including the world's top companies
Create impact at a scale by reaching a global audience
Build your personal brand
Supplement your income
Access the world's largest talent pool of cyber security professionals, and receive candidates with pre-assessed technical skills
Eliminate the pain and costs of technical vetting
Receive candidate skill profiles highlighting knowledge and technical proficiency
Reach active and passive candidates; and, fill your pipeline with pre-vetted, qualified cyber professionals
Get a Job
Work with a dedicated mentor to help you select the career that's right for you, and get a job at one of the world's top companies.
Receive all the training and assessments you need to prepare for the job
Work with a dedicated Mentor
Get placed through Cybrary for jobs earning average salaries of $116,000/yr

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.

Cybrary On The Go

Get the Cybrary app for Android for online and offline viewing of our lessons.

Get it on Google Play

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?