This challenge is a rather simple challenge in which there are two flagcheck
functions, each checking the first 10 and last 10 characters respectively after encoding the two parts of flag with hardcoded values.
encode1
function encodes first part of the flag. It reverses the bits of each element and the calls myfunc
which is actually returns xor
of its arguments.
1
2
3
4
5
//encode1
for ( i = 0; i <= 9; ++i ){
*(_BYTE *)(i + input) = reverse((unsigned int)*(char *)(i + input));
*(_BYTE *)(i + input) = myfunc(32LL, (unsigned int)*(char *)(i + input));
}
encode2
takes xor
of i
th
with i+1
th
element and stores in i
th
element.
1
2
*(_BYTE *)(i + input) = myfunc((unsigned int)*(char *)(i + 1LL + input), (unsigned int)*(char *)(i + input));
Solve Script
Here is the solve script:-
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
p1 = [58, 44, 110, 218, 172, 238, 218, 46, 44, 206]
flag_part1= ""
for i in range(len(p1)):
p1[i] = p1[i]^32
flag_part1 += chr(int(bin(p1[i])[2:][::-1].ljust(8, '0') ,2))
p2 = [65, 20, 19, 25, 51, 45, 65, 115, 113, 49][::-1]
flag_part2=chr(p2[0])
for i in range(1,len(p2)):
p2[i] = p2[i] ^ p2[i-1]
flag_part2 += chr(p2[i])
print(flag_part1+flag_part2[::-1])
# X0r_1s_p0w3rful_r3@1
Flag
Wrap it up in flag format and we have the flag p_ctf{X0r_1s_p0w3rful_r3@1}