Note: this is extra credit for a homework assignment
I'm trying to figure out how to call win() via stdin. I assumed that the vulnerability would be exploited by a buffer overflow, but I can't even figure out how to overflow the buffer (if I input a 45-character string, it prints all 45 characters). What sort of vulnerability should I be looking for here, and how would I go about exploiting it?
int win()
{
printf("Great Job\n");
exit(0);
}
int main()
{
char buffer[40];
unsigned long long target;
scanf("%s", buffer);
printf("You sent: %s\n", buffer);
exit(1);
}
targetis defined but not used. As is, you could maybe leak some addresses, but after a quick look, I don't see a way to hijack execution flow as it stands (due to theexit()).exit().