/* Homework: Example with a buffer overflow vulnerability. To see if you must compile with: gcc -g -D_FORTIFY_SOURCE=0 -w -o authCheck authCheck.c Created: Dan Fleck, Oct 2013 */ #include #include int main(void) { int userpass = 0; int correctPass=123; char username[15]; printf("\n Enter your name: \n"); gets(username); printf("\n Enter your password (number from 1 to 1000): \n"); scanf("%d", &userpass); printf("\nName was: %s ", username); printf("\nPass was %d ", userpass); printf("\nCorrectPass is %d ", correctPass); if(userpass==correctPass) { /* Now Give root or admin rights to user*/ printf ("\n\nRoot privileges given to the user \n\n"); } return 0; }