PicoCTF 2017 – Bash Loop

Another day, another challenge…

Today’s blog post we will solve the “Bash Loop” challenge in the PicoCTF challenge.

Let’s start!

Clicking on the challenge we see:

PicoCTF_Bash_Loop_1

OK… There’s a program we need to execute to find the hidden number. Let’s look at the hints to see what they give us.

PicoCTF_Bash_Loop_2

OK… the hint tells us that we need to use Google to search for “bash loops”.

First let’s navigate to the folder of the program

Copying the location of the program, right clicking on the command line, selecting paste from browser, and pressing enter we have the following:

PicoCTF_Bash_Loop_3

PicoCTF_Bash_Loop_4

We see the bashloop program and the flag.

Executing the bashloop program we see the following:

PicoCTF_Bash_Loop_6

Let’s do a quick Google search and look for bash loops

Going to the following link, and scrolling down to the for loop we see the following:

PicoCTF_Bash_Loop_5

Let’s use this for our challenge.

Going back to the command line we enter the following:

PicoCTF_Bash_Loop_7

Let’s break down the loop…

In the first line we are using a for loop and we’re looping over the range from 0 to 4096 as that is the range of numbers we need to guess over.

The next line we are invoking (calling) the program with the current number in the range (between 0 to 4096). From that we’re grepping (finding) the keyword of flag. The reason we’re doing that is to find the flag. Next line is specifying that we’re ending the loop.

Pressing enter we see that the flag is displayed to us.

Entering this into the input box we acquired 40 points!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s