OverTheWire.org
Hacker Community
Contribute to OverTheWire ?
Click here!
News (2012-01-07):
Best wishes for 2012 ! We released the HES2010 wargame ! Read more...
Discuss this level on the forum

Level 11

Deja vue
/rdx/vl1b is vortex level1 with a slight modification to make things a little bit harder.

Thanks to andrewg for inspiration.

Suggested reading: manpages: popen, dup2
Code listing (level11.c)
 1 #include <stdlib.h>
 2 #include <unistd.h>
 3 #include <string.h>
 4 #include <stdio.h>
 5 
 6 
 7 // code by andrewg, modified by aton
 8 
 9 #define e(); if(((unsigned int)ptr & 0xff000000)==0xca000000) { setresuid(geteuid(), geteuid(), geteuid()); execlp("/bin/sh", "sh", "-i", NULL); }
10 
11 void print(unsigned char *buf, int len)
12 {
13         int i;
14 
15         printf("[ ");
16         for(i=0; i < len; i++) printf("%x ", buf[i]);
17         printf(" ]\n");
18 }
19 
20 int main()
21 {
22         unsigned char buf[512];
23         unsigned char *ptr = buf + (sizeof(buf)/2);
24         unsigned int x;
25 
26         while((x = getchar()) != EOF) {
27                 switch(x) {
28                         case '\n': print(buf, sizeof(buf)); continue; break;
29                         case '\\': ptr--; break;
30                         default: e(); if(ptr > buf + sizeof(buf)) continue; ptr++; break;
31                 }
32         }
33         printf("All done\n");
34 }