Skip to content

Instantly share code, notes, and snippets.

@wenhoujx
Last active August 29, 2015 14:02
Show Gist options
  • Save wenhoujx/8688d902a3e93f5555a6 to your computer and use it in GitHub Desktop.
Save wenhoujx/8688d902a3e93f5555a6 to your computer and use it in GitHub Desktop.
buffer overflow example
#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