Skip to main content

#LabyREnth CTF - Windows track no. 3 - SquirtleChallenge.exe

This task is also simple one. We have unpacked executable, which I put into IDA first. After quick examination, we can notice that password is hardcoded in the execuatable at address: 0x414194:
"incorrect". Here's the code of the function:

signed int passwordCompare()
{
  FILE *v0; // eax@1
  char Buf; // [sp+0h] [bp-1Ch]@1
  char Str2[8]; // [sp+Ch] [bp-10h]@1
  __int16 v4; // [sp+14h] [bp-8h]@1

  _mm_storel_epi64((__m128i *)Str2, _mm_loadl_epi64((const __m128i *)&password));
  v4 = 116;
  sub_412880("Type the password:\n");
  v0 = (FILE *)_acrt_iob_func(0);
  fgets(&Buf, 10, v0);
  sub_412880("You typed: %s \n", &Buf);
  if ( strncmp(&Buf, Str2, 0xAu) )
  {
    sub_412880("Everytime you type the password wrong a Squirtle dies.\n\n");
    system("pause");
    exit(0);
  }
  return 1;
}
After figuring out the password, code goes through various conditions that we have to fulfill to make squirtle happy. I think that best way of doing that is to put the .exe in debugger and change branch everytime we need to. 


 


It takes couple of minutes to figure out which branch we have to change. After that we will be rewarded with .jpg looking exactly like that:


This obviously is the ASCII Code of our flag. Do it by hand or use this: 

signed int passwordCompare()
{
#include &ltstdio.h&gt
#include &ltiostream&gt

using namespace std;

char flag[] = { 0x50, 0x41,
    0x4e, 0x7b,
    0x54, 0x68,
    0x33, 0x5f,
    0x24, 0x71,
    0x75, 0x69,
    0x72, 0x74,
    0x4c, 0x33,
    0x5f, 0x24,
    0x71, 0x75,
    0x40, 0x64,
    0x5f, 0x77,
    0x40, 0x7a,
    0x5f, 0x62,
    0x4c, 0x75,
    0x66, 0x66,
    0x69, 0x4e,
    0x67, 0x7d  };

int main(void)
{

 for (int i = 0; i < sizeof(flag); i++)
 {
  printf("%c", flag[i]);
 }
 cout << endl;
 return 0;
}

And that's all, we have a flag.

Comments

Popular posts from this blog

#LabyREnth CTF - Windows track no. 1 - AntiD.exe

In this task we have to reverse file called 'AntiD.exe'. After first examination of this, it looks to be simple PE32 executable, packed with UPX. Unfortunately we can't decompress it using UPX tool, so I started to unpack it manually. First thing to notice is that in PE Optional Header - DllCharasteristics is set to 8140, which means that DLLs in this executable can move around a bit (I'm usually using programs like 'CFF Explorer' or something similar to check this things out). I've changed this header to 8100, what actually terminated this behaviour ;)


To decompress this .exe I personally used x64dbg and Scylla, but the tool doesn't matter at all - it could be any runtime debugger and ImpRec I suppose. What we need to do is stop program execution at Entry Point of AntiD.exe, and run exactly one instruction : pushal - in my case, as you can see on image below (but You can also see this as PUSHAD in OllyDbg, or any other debugger).



After executing PUSHAD,…

#IceCTF - Thor's a hacker now

I've spend over half an hour on solving this task, beside of that wasn't a hard one. But thanks to this exercise I had to learn using regular expressions in my text editor :) Text file connected to this task looked exactly like that (but was much larger): 00000000: 4c5a 4950 01b3 007f b61b edf0 8440 58e3 LZIP.........@X. 00000010: 91de 1027 5861 8a67 4282 46a4 92f9 4cad ...'Xa.gB.F...L. 00000020: 2d5d 14eb 3099 2c31 01c2 d13a 74d2 c620 -]..0.,1...:t.. 00000030: de27 3a8f fa92 0644 5468 2d02 01fa 24bb .':....DTh-...$. 00000040: 719f a0fd a191 1678 8bff a2c4 2627 9871 q......x....&'.q 00000050: 83bf cff2 f8af 99fa c465 2b7c 6bdf ee3c .........e+|k..< 00000060: b71b f61b 0b5e 0ce7 d14f f6a8 0466 6470 .....^...O...fdp 00000070: de67 02da 7be1 1abd e9f0 ac87 131a bcc0 .g..{........... 00000080: 0b0b 9f31 9400 48e3 616a 8f3f 4804 79ad ...1..H.aj.?H.y. 00000090: a6bb 863a f641 01da b1ee c4fe b338 9289 ...:.A.......8.. 000000a0: 2a90 8302 4170 773c 88d3 26…

#IceCTF - Strong Feeling

You can download ELF here: ------------------------> link
To get a flag in this one, easiest way I think is to bruteforce it! After quick look of executable in decompiler we can see that program outputs different strings every time we input a proper flag character to it. The best way to check that (knowing that flags in that CTF looks like "IceCTF{xxx}") is to  input 'I' first, then "Ic", then "Ice", etc. The strings in ELF aren't obfuscated, so we can just count it to figure out number of characters in the flag. The only thing that has to be done now is bruteforcer itself. I wrote something like that:
#include &ltstdio.h&gt #include &ltstdlib.h&gt #include &ltcstring&gt using namespace std; int main(void) { char *flag = new char[32]; char *path = new char[128]; char *buffer = new char[128]; char *buf2 = new char[128]; FILE *plik; for (int i = 0; i < 32; i++) for (char j = 0x21; j < 0x7f; j++) { …