#include <stdio.h>
#include <string.h>
int main(void) {
char buff[15];
buff[14] = 0;
printf(“\n Enter the password : \n”);
gets(buff);
if(strcmp(buff, “password”)) {
printf (“\n Wrong Password \n”);
} else {
printf (“\n Correct Password \n”);
buff[14] = 1;
}
if(buff[14]) {
/* Now Give root or admin rights to user*/
printf (“\n Root privileges given to the user \n”);
}
return 0;
}
/*
Output:
mnvsngv@M17xR4:~/C$ ./BufferOverflow
Enter the password :
password
Correct Password
mnvsngv@M17xR4:~/C$ ./BufferOverflow
Enter the password :
wrongpassword
Wrong Password
mnvsngv@M17xR4:~/C$ ./BufferOverflow
Enter the password :
wrongpassof15+chars
Wrong Password
Root privileges given to the user
*/