Binary Search
Understanding the challenge
We can download the files for the challenge using wget [file link].
Letโs then use unzip [file] to unzip the zip file.
We are given a zip file with 3 folders and a .sh (shell script) file.
Navigating to the file using cd [folder]/, we can then read the file using cat [file] so that we may begin understanding how this file works.
We see that the program first chooses a random number between 1 and 1000,
target=$(( (RANDOM % 1000) + 1 ))
it then reads the inputted guess, and if the guess is valid (only contains numbers between 0 and 9),
if ! [[ "$guess" =~ ^[0-9]+$ ]]; then
checks if the guess is higher or lower than the target number. It then prints a corresponding message to keep the playerโs guesses on the right track.
if (( guess < target )); then
echo "Higher! Try again."
elif (( guess > target )); then
echo "Lower! Try again."
Understanding this, letโs attempt the challenge.
Method
We use the ssh command to connect to the provided port and address, inputting the provided password when prompted.
We can then begin guessing the number.
Upon guessing the right number, we get the flag.
Related Writeups
n0s4n1ty 1
A developer has added profile picture upload functionality to a website. However, the implementation is flawed, and it p ...
Cookie Monster Secret Recipe
Cookie Monster has hidden his top-secret cookie recipe somewhere on his website. As an aspiring cookie detective, your m ...
head-dump
Welcome to the challenge! In this challenge, you will explore a web application and find an endpoint that exposes a file ...