Array of Sunshine
This is the easiest challenge of the CTF which simply let us to write something in an array position Here is the main function that is loop called
void basket(void){
int index;
// Fruit from the BSS
printf("\nWhich fruit would you like to eat [0-3] >>> ");
scanf("%d", &index);
printf("Replace it with a new fruit.\n",*(char *)(fruits + (long)index * 8));
printf("Type of new fruit >>>");
// No Boundary checks
scanf("%24s",fruits + (long)index * 8);
exit(-1);
}
As you can see there is no boundary check so we cna just insert which index we want and write an arbitrary value in so it si basically a write-what-where challenge
This is the bss where we can write we have some functions before but if we look before the array there is something interesting
There is the exit()
's got entry which is located at -8
, so we can just overwrite it with the win()
function
We successfully overwrote the entry and thats the flag