Question: Study the following program and answer the questions. [total 6 points] #include #include int main(void) { char buff[15]; int pass = 0; printf( Enter the

Study the following program and answer the questions. [total 6 points]

#include

#include

int main(void)

{

    char buff[15];

    int pass = 0;

    printf(" Enter the password : ");

    gets(buff);

    if(strcmp(buff, "thegeekstuff"))

    {

        printf (" Wrong Password ");

    }

    else

    {

        printf (" Correct Password ");

        pass = 1;

    }

    if(pass)

    {

       /* Now Give root or admin rights to user*/

        printf (" Root privileges given to the user ");

    }

    return 0;

  1. What vulnerability does the above program have and why? [1 point]
  2. If there is an attack that exploits the vulnerability, which part of memory will be affected – stack or heap? Explain your answer. [1 point]
  3. Explain with appropriate illustration and tracing of the program, how the vulnerability can be exploited to get the root privilege without entering correct password. [2 points]
  4. Fix the program to remove the vulnerability, while keeping the intended functionality (submit the solution as a .cpp file). [2 points]

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

What vulnerability does the above program have and why 1point it is buffer overflow attack as you ca... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!