Tags: rev 

Rating:

# Cheat Code

We were given a [binary](https://gr007.tech/writeups/2023/backdoor/beginner/cheat_code/intro.out) which was very easy to reverse using ghidra. The binary asks for some input (cheat) and then does some xor and conditional check. The conditions were pretty easy to reverse. We also had some part of the flag in plain text. The below c code prints out the flag:

```c
#include <stdio.h>

int main() {
char f16[16];
f16[0] = 'f';
f16[1] = 'l';
f16[2] = 'a';
f16[3] = 'g';
f16[4] = '{';
f16[5] = 'c';
f16[6] = '4';
f16[7] = 'n';
f16[8] = '\'';
f16[9] = 't';
f16[10] = '_';
f16[11] = 'H';
f16[12] = 'E';
f16[13] = 'S';
f16[14] = 'O';
f16[15] = 'Y';
int key[16];
key[0] = 0x1b;
key[1] = 0x19;
key[2] = 0x51;
key[3] = 0x1e;
key[4] = 0x24;
key[5] = 0xd;
key[6] = 0;
key[7] = 0xd;
key[8] = 0x78;
key[9] = 0x41;
key[10] = 0x6e;
key[11] = 0x20;
key[12] = 0x72;
key[13] = 0xc;
key[14] = 2;
key[15] = 0x18;
printf("%s", f16);
for (int i = 15; i >= 0; i--) {
printf("%c", key[i] ^ f16[i]);
}
}
```

```sh
backdoor/beg/cheat via C v13.2.1-gcc took 1m4s
❯ ./sol
flag{c4n't_HESOYAM_7h15_c4n_y0u}
```

flag: `flag{c4n't_HESOYAM_7h15_c4n_y0u}`

Original writeup (https://gr007.tech/writeups/2023/backdoor/index.html#cheat-code).