Skip to main content

#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++)
  {
   if (j == '\'') j++;
   flag[i] = j;
   sprintf(path, "echo '%s' | ./a_strong_feeling > plik.txt", flag);
   system(path);
   plik = fopen("plik.txt", "r");
    fgets(buffer, sizeof(buffer), plik);
   fclose(plik);
   if (j > 0x21 && strcmp(buf2, buffer) != 0) 
   {
    printf("%c", j);
    break;
   }
   strcpy(buf2, buffer);
  }
 printf("\n");
 return 0;
}
And that's all - flag will be printed in the console in just a second!

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 I mp Rec 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). Aft

#LabyREnth CTF - Windows track no. 2 - BabbySay.exe

This task is really very simple one. We are provided with .NET application named: "BabbySay.exe", wchich is a simple app that spawns a piano window for us. We can play some tunes by clicking black and white keys. I've started by its decompilation with "ILSpy", which is nice tool to do that . After quick examination in ILSpy we can clearly see the function responsible for printing the flag for us, w i thout any doubt h as to be:  key_click(object, EventArgs): // BabbySay.Form1 public void key_click(object sender, EventArgs args) { KeyButton keyButton = sender as KeyButton; keyButton.player.Play(); if (keyButton.number == 16 && keyButton.is_black && this.dat_state == 0) { this.dat_state = 1; this.thangs[3] = " _|| || | |_ ___ `. | || | _ | || | \\_ `. " + this.thangs[3]; this.thangs[10] = this.thangs[10] + " '----------------' '----------------' '----------------' '"