-
-
Save wenhoujx/8688d902a3e93f5555a6 to your computer and use it in GitHub Desktop.
buffer overflow example
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> | |
int main(void) { | |
char buff[15]; | |
int passed = 0; | |
printf("Pleaes enter your password \n" ) ; | |
gets(buff) ; | |
// equal strings return 0 | |
if(strcmp(buff, "kkk")){ | |
printf( "wrong password \n"); | |
} | |
else{ | |
printf("corrct password \n") ; | |
pass = 1; | |
} | |
if (passed){ | |
printf( "you're now the root \n"); | |
} | |
return 0 ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment