반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <stdio.h>
#include <stdlib.h>
 
void open_flag() {
  char flag[120];
  char email[] = "chanbin.lee123@gmail.com";
  FILE * file;
  file = fopen("flag.txt""r");
  if (file == NULL) {
    printf("Please contact %s, I couldn't find the flag file!\n", email);
    exit(0);
  }
  fgets(flag, sizeof(flag), file);
  printf("%s", flag);
}
 
int main() {
  long key = 0x00000000;
  char buf[10];
  printf("Can you change my key to 0x12345678?\n");
  printf("I can’t open the flag otherwise!\n");
  printf("My key value is: 0x%08x\n", key);
  printf("What do you think?\n> ");
 
  gets(buf);
  printf("\nMy key is: 0x%08x\n", key);
 
  If(key == 0x12345678) {
    printf("Whoa, you changed my key! Good job!\nHere's the flag:\n");
    open_flag();
    exit(0);
  }
 
  if (key == 0x00000000) {
    printf("My key didn't change! Try again.\n");
    return 0;
  }
 
  printf("You're close! Keep trying.\n");
  return 0;
}
 
cs


hints

On a stack, where are the variables stored and in what order?

How big is the buffer? Does the program care about how long your input is?

What happens if you give an input bigger than what’s expected?

What are endians?



반응형

'STUDY > Documentation' 카테고리의 다른 글

Debugging your ROP  (0) 2019.02.18
해커스쿨 문서 백업 (Syshacks)  (0) 2019.02.17
Bufferoverflow 기법 정리  (0) 2015.09.22
핸드레이  (0) 2015.09.05
strace, 제가 한번 사용해 보겠습니다.  (0) 2014.07.22

+ Recent posts