Hey this is a hackathon ctf challenge, and this is the main function that we need to get…
- User
Hey this is a hackathon ctf challenge, and this is the main function that we need to get the flag from. Can you decrypt this? int32_t main(int32_t argc, char** argv, char** envp) { void* fsbase; int64_t rax = (fsbase + 0x28); int32_t rax_2 = sub_11c9(); printf("Give me code to execute: "); void var_118; __isoc99_scanf(&data_207b, &var_118); int32_t rax_5 = strlen(&var_118); int32_t result;
codeif ((rax_5 & 7) == 0) { int32_t rax_8 = rax_5; int32_t rdx = (rax_8 + 7); if (rax_8 < 0) rax_8 = rdx; int32_t rax_9 = (rax_8 >> 3); printf("Executing %d opcodes.\n", rax_9, rdx); int32_t var_134_1 = 0; for (int32_t i = 0; i < rax_9; i += 1) { void nptr; strncpy(&nptr, (&var_118 + (i << 3)), 8); char var_119_1 = 0; int32_t rax_15 = strtol(&nptr, nullptr, 0x10); switch (i) { case 0: { if (((rax_15 & 0xf000000) != 0x2000000 || (rax_15 & 0xff0000) != 0x100000)) { sub_1737(); /* no return */ } break; } case 1: { if (((rax_15 & 0xf000000) != 0x2000000 || (rax_15 & 0xfff) != 0x100)) { sub_1737(); /* no return */ } break; } case 2: { if (((rax_15 & 0xf000000) != 0x3000000 || (rax_15 & 0xff0000) != 0x110000)) { sub_1737(); /* no return */ } break; } case 3: { if (((rax_15 & 0xf000000) != 0x1000000 || (rax_15 & 0xff0000) != 0x120000)) { sub_1737(); /* no return */ } break; } case 4: { if (((rax_15 & 0xf000000) != 0x4000000 || (rax_15 & 0xff0000) != 0x130000)) { sub_1737(); /* no return */ } break; } } if ((rax_15 & 0xfff) > 0x100) printf("Skipping opcode #%d, value too h…", i, (rax_15 & 0xfff)); else sub_16aa(rax_2, rax_15); } sub_125c(rax_2); if ((*rax_2 == 0x200 && (rax_2[1] == 0xffffffff && (rax_2[2] == 0xffffffff && (rax_2[3] == 0 && (rax_2[0xc] == 0x10000000 && rax_9 == 5)))))) printf("This is the right answer! Valida…", &var_118); result = 0; } else { puts("Invalid code."); result = 1; } *(fsbase + 0x28); if (rax == *(fsbase + 0x28)) return result; __stack_chk_fail(); /* no return */ - Assistant