here is the source code of the program.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int check_authentication(char *password)
{
if(strcmp(password, "brillig") == 0)
return 1;
if(strcmp(password, "outgrabe") == 0)
return 1;
return 0;
}
int main(int argc, char *argv[])
{
if(argc < 2)
{
printf("Usage: %s <password>\n", argv[0]);
exit(0);
}
if(check_authentication(argv[1]))
{
printf("\n-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
printf(" Access Granted.\n");
printf("-=-=-=-=-=-=-=-=-=-=-=-=-=-\n");
}
else
{
printf("\nAccess Denied.\n");
}
return 0;
}
What Am I exactly doing to the program in this image?
https://i.stack.imgur.com/FSQCg.png.
When I try to run this program in windows I can’t input anything into it, but in UBUNTU I think I’m inputting something, but I’m not really sure what’s going on.
This is what happens if I run it in windows https://i.stack.imgur.com/Zt7gw.png,
By the way the whole point of the program was to demonstrate a buffer overflow.
Linux invocations, taken from screenshot:
$ ./auth_overflow AAAAAAAAAAAAAAAA
Access Denied.
$ ./auth_overflow AAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Access Granted.
-=-=-=-=-=-=-=-=-=-=-=-=-=-
From the OP’s comment:
You are reading your input from
argv, which is the list of paramaters provided on the command-line when your program is run. When you use the ‘run’ command built into your IDE, your program is run with no command-line arguments (by default, at least). Instead of running the program through your IDE, open a command prompt and run the program manually. That way, you can run the program with parameters (like you did in the Linux shell) so that there is something inargvfor your program to read.