Tags: ptrace __do_global_ctors_aux xor reversing 


## Challenge
Whats the matter it's just an xor

Note that provided zip file also has solution by organizer ctf team.

### main function
undefined8 main(void)

int iVar1;
FILE *__stream;
long in_FS_OFFSET;
ulong local_b8;
long local_b0;
ulong local_a8 [8];
char local_68 [72];
long local_20;

local_20 = *(long *)(in_FS_OFFSET + 0x28);
puts("password pls, no brute forcing:");
fgets((char *)local_a8,0x40,stdin);
local_b8 = xor_key ^ local_a8[0];
local_b0 = (long)local_b8 >> 0x3f;
iVar1 = strcmp((char *)&local_b8,"yoteyeet");
if (iVar1 == 0) {
__stream = fopen("flag.txt","r");
printf("nice work, here\'s the flag! %s",local_68);
else {
puts("that aint it dawg\n");
if (local_20 != *(long *)(in_FS_OFFSET + 0x28)) {
/* WARNING: Subroutine does not return */
return 0;

### __do_global_ctors_aux
void __do_global_ctors_aux(void)

int i_8;
ulong *local_20;

for (i_8 = 0; (i_8 < 0x100 &&
(local_20 = (ulong *)(&data_start + i_8), *local_20 != 0x539053905390539));
i_8 = i_8 + 8) {
*local_20 = *local_20 ^ 0x119011901190119;

## Solution
I was think it is a basic XOR challenge but whenever try to send data generated with xor key `0x0539053905390539` it just not worked.
Then I tried to attach with pwntools gdb attach but it just not worked, because it was calling `ptrace()` syscall in somewhere, so I realesed that there is an logic in `__do_global_ctors_aux` to ptrace and change actual XOR key to `0x420042004200420`. Note that `__do_global_ctors_aux` function executes before main function.