Binary Search

Challenge Overview

Want to play a game? As you use more of the shell, you might

be interested in how they work! Binary search is a classic

algorithm used to quickly find an item in a sorted list. Can you

find the flag? You'll have 1000 possibilities and only 10

guesses.

Cyber security often has a huge amount of data to look

through - from logs, vulnerability reports, and forensics.

Practicing the fundamentals manually might help you in the

future when you have to write your own tools!

You can download the challenge files here:

ssh -p 53039 ctf-player@atlas.picoctf.net

Using the password 6dd28e9b. Accept the fingerprint with yes,

and ls once connected to begin. Remember, in a shell,

passwords are hidden!

Solution

SSH into the challenge based on the instructions in the description.

Welcome to the Binary Search Game!

I'm thinking of a number between 1 and 1000.

The first guess is going to always be 500 because it is the middle of 1 and 1000.

For each guess after 500 the known lower bound is taken and the known higher bound is taken and divided by two for the next guess.

Example Sequence:

Enter your guess: 500

Lower! Try again.

(1 + 500) / 2 = 250.5

Enter your guess: 251

Lower! Try again.

(1 + 250) / 2 = 125.5

Enter your guess: 125

Lower! Try again.

(1 + 125) / 2 = 63

Enter your guess: 63

Lower! Try again.

(1 + 63) / 2 = 32

Enter your guess: 32

Higher! Try again.

(32 + 63) / 2 = 47.5

Enter your guess: 47

Lower! Try again.

(32 + 47) / 2 = 39.5

Enter your guess: 39

Lower! Try again.

(32 + 39) / 2 = 35.5

Enter your guess: 36

Higher! Try again.

(36 + 39) / 2 = 37.5

Enter your guess: 38

Congratulations! You guessed the correct number: 38

Flag: picoCTF{g00d_gu355_de95...}