Created
February 27, 2019 13:14
-
-
Save olealgoritme/a7078f33cc5e4805efa61385ee44c071 to your computer and use it in GitHub Desktop.
buffer overflow (stack smashing)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <string.h> | |
char password[] = "password"; | |
int get_password() { | |
int auth_ok = 0; | |
char buff[16]; | |
printf("Enter password: "); | |
scanf("%s", buff); | |
if(strncmp(buff, password, sizeof(password)) == 0) | |
auth_ok = 1; | |
return auth_ok; | |
} | |
void success() { | |
printf("Success!\n"); | |
} | |
int main(int argc, char** argv) { | |
int res = get_password(); | |
if (res == 0) { | |
printf("Failure\n"); | |
return 0; | |
} | |
success(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment