본문 바로가기

[Wargame Write-up]/Exploit-Exercises

[Exploit-Exercises] [Protostar] Stack 4

EIP 등에 대한 설명이 이루어져 있다.




gets 함수 다음 다른 구문이 없는 것으로 보아, RET 주소를 변조하여 win 함수를 실행시켜야 할 것 같다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
 
void win()
{
  printf("code flow successfully changed\n");
}
 
int main(int argc, char **argv)
{
  char buffer[64];
 
  gets(buffer);
}
cs



Segmentation fault가 발생하지 않는 입력값을 찾아다녔다. A 72개에서는 정상적으로 처리된다.




우선 win 함수의 주소가 필요하니, objdump 명령어를 이용해 win 함수의 주소를 획득하자.




A 76개를 넣은 후 win 함수의 주소를 little endian 방식으로 넣어야 win 함수로 흐름이 변경된다.


EIP와 ESP의 offset 차이가 76인 모양이다.