Bryan Seeds

21Oct/090

SmashTheStack.org IO Level-2

This post is to show how I completed the smashthestack.org's first episode io level 2 challenge.

*Update* It has been stated that this post is verbatim to deadc0de's prior blog posting on the net, and to respect this author you may also want to read his solution and article here.

*Note* This post assumes you have basic knowledge of shell commands, linux x86 assembler, C programming, disassembly, and the GNU Compiler Collection.

Open any SSH Client and connect with :

host : io.smashthestack.org -p 2224
user : level2
pass : <found from level 1>

Once logged in, you will see the MOTD and the basic instructions.  Change directories to appropriate one (levels).

level1@io:~$ cd /levels


Now try to run the level2 binary.

Ok, well when we execute the program with no arguments passed, we get output that shows :

level2@io:/levels$ ./level2
Append the 39th through 42nd numbers in the sequence as a string and feed it to this binary via argv[1]. 1, 2, 3, 5, 8, 13, 21...
The 4th through the 7th numbers would give you 581321

Alright, well this seems pretty straightforward. This level2 binary is wanting as the first parameter a concatenated string that is made of the 39th through the 42nd numbers in the displayed pattern.   At first glance if you look at the pattern you will hopefully notice what it is, and in case you don't know it is called a fibonacci number.  Moving on let us write a C program to do the mathematics for us.  At the shell go ahead and navigate to the '/tmp' directory for the level2 so you can save your code and compile it.  From '/tmp/level2' run your favorite text editor, I used the command 'vim fibo_calc.c'.  Below  is the code for my fibonacci calculator :

#include 
 
int main()
{
int number[43];
int x;
number[1] = 1;
number[2] = 2;
for(x=3; x&lt;=42; x++){
number[x]=number[x-1]+number[x-2];
printf("%d : %d\n", x, number[x]);
}
}

Go ahead and compile the code with the command :
level2@io:/tmp/level2$ gcc fibo_calc.c -o fibo_calc

Now run the new binary :
level2@io:/tmp/level2$ ./calc_seq

The output should be as we coded it. Output should be like :
level2@io:/tmp/level2$ ./calc_seq
36: 24157817
37: 39088169
38: 63245986
39: 102334155
40: 165580141
41: 267914296
42: 433494437


So there we have it :
level2@io:/levels$ ./level2 102334155165580141267914296433494437
Win.
sh-3.2$

Now just get the level3 password :
sh-3.2$ cat /home/level3/.pass
duf2dido

Add these guys on facebook, smashthestack rocks!

VN:F [1.9.10_1130]
Rating: 5.5/6 (4 votes cast)
SmashTheStack.org IO Level-2, 5.5 out of 6 based on 4 ratings
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

(required)

No trackbacks yet.