I'm trying to get the following C program to execute the win function by making use of a buffer overflow, however, I'm completely stuck as I cannot figure out the correct input. In this challenge, I was given a compiled executable and the below code was analyzed and extracted with Ghidra.
main function:
undefined8 main(void)
{
char *local_28;
char local_1a [9];
char local_11;
code *local_10;
local_11 = '\x01';
local_1a[0] = -0x11;
printf("Enter number: ");
fgets(local_1a,10,stdin);
local_10 = (code *)strtol(local_1a,&local_28,10);
printf("Parsed to %ld\n",local_10);
if (local_11 == '\0') {
(*local_10)();
}
return 0;
}
win function:
void win(void)
{
puts("FLAG{it worked");
return;
}
So far I've tried to use gdb to figure out the offset and pass the address of the win function, but no matter what I try I get a segmentation fault.