BH01 - 500pts
Briefing
Download the file and find a way to get the flag. Contents: program
Challenge Files:
Solution
Inputting some random letters into the program prints some of the flag:
However, the amount of the flag that is printed changes each time we run the program using the same input. There appears to be 4 different variations so a random number generator is involved. Using an input that consists of a single character seems to always produce the same output.
We can decompile the binary using Ghidra to see what the program does:
main
function:The program picks a random byte from
local_7d
and uses that byte to index the user input to get a single characteruVar4
. Next, a loop runs that prints the flag character by character. However, it only iterates trough the loopuVar4 - 0x5a
times. Therefore, the letter that is selected from the input has to have an ascii code minus0x5a
(90) that is greater than the length of the flag.}
has a large ascii value. If we sent a lot of}
s into the program, it will print the flag:python -c "print('}'*50)" | ./program
. This is because the program selects a random character from our input, subtracts 90 from it, and then prints that many characters of the flag. So,125 - 90 = 35
which means the loop runs 35 times and successfully displays the 29 character flag. We cannot use just one}
because the program selects a random character from the input and it a character does not exist at the chosen index, it selects\x00
(a null byte).
Flag
aLittLeObfuScatIonalCharActEr
Last updated