Simple input checker binary, but there’s suspicious logic in main.
Breakpoints placed inside main are not hit, suggesting that some other code is
running before main.
This leads to constructor array, especially the function _INIT_1. It contains
the main logic for the challenge.
A stack array is constructed with specific values.
Userinput is processed in a predicate pipeline that conditionaly increments a
variable, and the variable must have final value 0x1e.
C
1
2
3
4
5
6
7
8
9
10
11
12
13
while(true){if(0x1e<i){puts("Correct flag!");/* WARNING: Subroutine does not return */exit(0);}DAT_0040406c=i+local_128[i%10];a=get_confusing_0040163d();b=get_confusing_0040163d();c=get_confusing_0040163d();if((b+((int)inp[i]^a)^c)!=local_f8[i])break;i=i+1;}
i is incremented when (b + (inp[i] ^ a) ^ c) is equal to corresponding stack value.
So we have to solve for inp[i]. This looks like it can be easily solved with a
smt solver like z3, but It seems to not find the solution (for some reason I don’t understand)
So instead I write a bruteforce script in C, since inp[i] can have only 0xff
values afterall, and value at each index is independent.