Hi folks. This post is about a Efiens challenge, easy-medium RE that my colleague Cothan publish on twitter as a part of a set of them included on Efiens CTF.

As described on his tweet, is an easy ctf that try to catch some talent people. I have spare time to participate as brucel33t kamikaze ninja. Three challenges per category that implies an easy,medium and hard levels. Let’s see our binary and it’s behaviour.

mediumRE: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=274cf5b891f49bf138e9d60a08dce32daf80b3ab, not stripped

Binary ask for a password. We can remote GDB with IDA and start analysis. Has “main” and “check” interesting functions. If we focuse on “check” function binary do a strlen check for a 30 characters password lenght setting a counter to -1 if not.

The second red rectangle is indeed the check loop. Counter must be set to 30 to get the “Good” answer, so the if block need to enter 30 times on that compare. It Compares each element of an array “encoded” with our input multiply by first 30 Fibonacci sequence adding “i” value on each iteration.

What is this encoded array? Reader at this moment will have realized that if we use a simple equation we can solve the problem. We have:

encoded data: solution of input[i] * fibo[i] + i

fibo data: first 30 fibonacci sequence

Input is what we want to know. Let’s use a python script to solve this. On each iter we must calculate (enc[i] – i)/fibo[i]. This is char value of our input.