Reverse [Reverse]

Reverse

This program seems to get stuck while running... Can you get it to continue past the broken function?

Recon

Loaded the file in ghidra, it contains the print function which was decompiled to:

void print(void)

{
  undefined *puVar1;
  char *flg;
  char rb;
  char lb;
  char g;
  char a;
  char l;
  char f;

  puVar1 = (undefined *)malloc(0x15);
  *puVar1 = 0x77;
  puVar1[1] = 0x33;
  puVar1[2] = 99;
  puVar1[3] = 0x6f;
  puVar1[4] = 0x6e;
  puVar1[5] = 0x37;
  puVar1[6] = 0x72;
  puVar1[7] = 0x30;
  puVar1[8] = 0x6c;
  puVar1[9] = 0x74;
  puVar1[10] = 0x68;
  puVar1[0xb] = 0x33;
  puVar1[0xc] = 0x62;
  puVar1[0xd] = 0x31;
  puVar1[0xe] = 0x6e;
  puVar1[0xf] = 0x61;
  puVar1[0x10] = 0x72;
  puVar1[0x11] = 0x69;
  puVar1[0x12] = 0x33;
  puVar1[0x13] = 0x73;
  puVar1[0x14] = 0;
  printf("%c%c%c%c%c%s%c\n",0x66,0x6c,0x61,0x67,0x7b,puVar1,0x7d);
  return;
}

So seems this will print the flag. We translate it to python and ran it.

Code

data = [0x77, 0x33, 99, 0x6f, 0x6e, 0x37, 0x72, 0x30,
        0x6c, 0x74, 0x68, 0x33, 0x62, 0x31, 0x6e, 0x61,
        0x72, 0x69, 0x33, 0x73]

out = "666c61677b".decode("hex")
for i in data:
    out += chr(i)
out += "7d".decode("hex")
print out

Running it:

$ python solve.py 
flag{w3con7r0lth3b1nari3s}

Flag

flag{w3con7r0lth3b1nari3s}