Description
This program requires some tricky input. It is not a compiled binary - it is a short Python script (input.py). Read the script, see exactly what it reads and what it compares your input against, then feed it the values it wants.
Setup
Download the Python script and read it.
wget https://mercury.picoctf.net/static/.../input.pycat input.pySolution
Walk me through it- Step 1Read the script - it is Python, not a binaryOpen input.py in any text editor. It reads one or more inputs (usually with input() or by reading lines from stdin) and compares each against a hardcoded expected value with ==. Note the exact strings/numbers it checks and the order it reads them, including any prompt text and whitespace handling (strip(), int(), etc.).bash
cat input.pybash# Note every input() call, the variable it stores, and the value it is compared to.Learn more
The challenge name is a hint: it just wants the right inputs. Because the source is plain Python, there is no reverse engineering to do - the "answer key" is written out as literals in the comparisons. Read top to bottom and list, in order, each value the script expects.
Watch for transformations on the way in:
.strip()removes surrounding whitespace,int(...)means it wants a number, and anf-stringor concatenation may mean it expects a value built from earlier inputs. Match the type and format exactly. - Step 2Map each input to the value it must equalWalk the comparisons and write down the expected value for each read, in the order the script asks for them. If a comparison is against a computed value (for example a sum, or input concatenated with a constant), satisfy that relationship rather than copying a literal.bash
# Example shapes you might find in input.py:bash# a = input('...'); assert a == 'some_string'bash# b = int(input()); assert b == 1337bash# if first + second == 'expected_combo': print(flag)Learn more
Most variants of this challenge read a handful of values and check them with
==orassert. The expected inputs are exactly the right-hand sides of those comparisons. Give the script those values, in order, and it prints the flag. - Step 3Supply the inputs and read the flagRun the script and provide the expected values. For multiple inputs, pipe them in separated by newlines so each input() call receives the next line.python
python3 input.py # then type each expected value when promptedbash# Or feed all inputs at once (one per line):bashprintf 'first_value\nsecond_value\n' | python3 input.pyLearn more
Piping with
printfis the reliable way to satisfy severalinput()calls: each\n-separated line is consumed by the next read in order. Once every comparison passes, the script reaches the branch that prints the flag.
Flag
picoCTF{...}
It is a Python script (input.py), not a binary. Read the source, note the exact value each input() is compared against, and supply those values in order to reach the flag-printing branch.