IJCTF 2021
Sanity [100 pts] - Reverse Engineering

Link to Solutions
Last updated

Last updated
undefined8 main(void) {
undefined *__s2;
int iVar1;
ulong uVar2;
size_t sVar3;
ulong uVar4;
size_t asStack192 [3];
undefined local_a8 [103];
byte local_41;
undefined *local_40;
long local_38;
asStack192[0] = 0x10118c;
asStack192[1] = strlen(flag);
local_38 = asStack192[1] - 1;
asStack192[2] = 0;
uVar2 = (asStack192[1] + 0xf) / 0x10;
local_40 = (undefined *)(asStack192[1] + uVar2 * 0x1ffffffffffffffe);
int local_2c = 0;
while( true ) {
uVar4 = SEXT48(local_2c);
asStack192[uVar2 * 0x1ffffffffffffffe] = 0x101238;
sVar3 = strlen(flag,*(undefined *)(asStack192 + uVar2 * 0x1ffffffffffffffe));
if (sVar3 <= uVar4) break;
local_41 = key[local_2c] ^ flag[local_2c];
local_40[local_2c] = key[local_2c] ^ flag[local_2c];
local_2c = local_2c + 1;
}
asStack192[uVar2 * 0x1ffffffffffffffe] = 0x101249;
puts("Whats the flag?",*(undefined *)(asStack192 + uVar2 * 0x1ffffffffffffffe));
asStack192[uVar2 * 0x1ffffffffffffffe] = 0x101264;
__isoc99_scanf(&DAT_00102066,local_a8);
__s2 = local_40;
asStack192[uVar2 * 0x1ffffffffffffffe] = 0x10127a;
iVar1 = strcmp(local_a8,__s2,*(undefined *)(asStack192 + uVar2 * 0x1ffffffffffffffe));
if (iVar1 == 0) {
asStack192[uVar2 * 0x1ffffffffffffffe] = 0x10128a;
puts("Correct!",*(undefined *)(asStack192 + uVar2 * 0x1ffffffffffffffe));
}
else {
asStack192[uVar2 * 0x1ffffffffffffffe] = 0x101298;
puts("Wrong!",*(undefined *)(asStack192 + uVar2 * 0x1ffffffffffffffe));
}
return 0;
}key = "00 00 00 00 00 00 0a 06 18 2f 08 0c 3b 2c 0f 01 1d 2b 1f 3e 0f 004 3a 05 04 2d 39 06 06 00 10 08 05 01 11 4c 00 00 00 00".split(" ")
flag = "IJCTF{simple_sanity_check_for_babies}"
new_flag = ""
for i in range(0, len(flag)):
tmp = ord(flag[i]) ^ int(key[i],16)
new_flag += chr(tmp)
print(new_flag)