Some string Operations
Last updated
Last updated
strops.bin
Upon opening it in Ghidra we see this:
I copied it into sublime and simplified it
Things learned from the code:
Initial variables are declared
setup() is called -> no idea so far what it does
read() function is used to read STDIN till 64 characters
A loop begins where i is currently 0 so 1st if condition is false.
Next if condition is encountered. If that is also false, goto makes the statement go to it's label where return 0 is there.
Conclusion: Only 1 input is supposed to happen where a correct flag is supposed to be entered.
Also, 2nd if condition on line 17 is the key
I inspected setup() and nothing special is happening
So, line 17 must be the key. Let's understand what is happening in English
if ((char)~flag[(int)i] != input[(int)i])
Translation: if the character encoded NOT value of the array flag[i] where i is the current iteration, is not equal to the input[i] then display "Nope"
But if it is, continue iteration until 48 correct inputs are given. If 47 inputs are correct display "Correct!"
So, we have to input correct flag array input by input
Another way to understand this translation: If (char)NOT flag[i] ==input[i], value is correct
So, let's inspect this flag array
This means, we have to pick up all these characters, bitwise NOT them and then input it in the program
So, first character is 99 in hex. Which means NOT(99) = 66. So on. I utilized ChatGPT to write me a code.
Let's translate this hex in ASCII: https://www.rapidtables.com/convert/number/hex-to-ascii.html
Found the flag. EZ through manual execution