본문 바로가기

[Wargame Write-up]/Exploit-Exercises

[Exploit-Exercises] [Protostar] Stack 1

또 지역변수 변조 문제이다.




이번에는 modified 변수의 값을 0x61626364라는 특정한 값으로 변조해야 한다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#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);
  }
}
cs



인자를 주고 실행하면, 아래와 같은 문자열을 출력한다.




아래처럼 little endian으로 payload를 구성하면 된다.


아직까지는 쉽다.