Last updated
Last updated
Using linux command line utility file, we can analyse the type of the file and see that it is a ELF ARM 64 bits.
Opening it with IDA, we can see that the program's logic is quite simple.
First, the program uses scanf to retrieve two numbers from the input and do three checks:
If the first number is equal 0
If the seconds number is equal 0 or 1
If the result of the first number divided by the seconds number is equal the first number
And if all these checks are correct, the program prints the output of the flag.txt file.
We can see that the type of the numbers are signed int, meaning that we can we can use the sign feature to manipulate these operations for our profit.
But if we pass 2147483648, as the maximum value of 32 signed integers is 2147483647, the value is overflowed and transformed in -2147483648.
So, if we pass the numbers 2147483648 and -1 to the program:
The program will transform 2147483648 to -2147483648, due the maximum value being reached.
After it, the program will execute the divide instruction, dividing -2147483648 to -1 and transforming it back in the number above the maximum 32 signed integer value supported.
And as the result of the operation will be equal the first number, the flag will be printed.
Using an , we can see that -2147483648 is represented as 1 at the most valuable bit and a sequence of zeroes on all the other bits.