Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are given the code below: #include #include #include int check_authentication(char *password) { int auth_flag = 0; char *password_buffer; char *dept; password_buffer = (char *)

You are given the code below:

#include

#include

#include

int check_authentication(char *password) {

int auth_flag = 0;

char *password_buffer;

char *dept;

password_buffer = (char *) malloc (16);

dept = (char *) malloc(10);

strcpy(password_buffer, password);

if(strcmp(password_buffer, "AsiaPacificInst") == 0){

printf("Your Department:");

gets(dept);

printf(" User from Department: ");

printf(dept);

if(strcmp(dept,"NSF")==0) {

auth_flag = 1;

}

}

else if(strcmp(password_buffer, "AsiaPacificUni") == 0){

printf("Your Department:");

gets(dept);

printf(" User from Department: ");

printf(dept);

if(strcmp(dept,"TM")==0) {

auth_flag = 1;

}

}

else {

auth_flag = 0;

}

return auth_flag;

}

int main() {

char errmsg[512];

char outbuf[512];

char user[20];

char password[20];

printf("Username: ");

gets(user);

if (strcmp(user,"Adm1n") == 0){

printf("Authorised User ");

sprintf(errmsg, "Authorised User %400s",user);

sprintf(outbuf,errmsg);

printf("Password: ");

gets(password);

if(check_authentication(password)) {

printf(" -=-=-=-=-=-=-=-=-=-=-=-=-=- ");

printf(" Access Granted. ");

printf("-=-=-=-=-=-=-=-=-=-=-=-=-=- ");

} else {

printf(" -=-=-=-=-=-=-=-=-=-=-=-=-=- ");

printf(" Access Denied. ");

printf(" -=-=-=-=-=-=-=-=-=-=-=-=-=- ");

}

}

else {

printf("Unauthorised user! ");

exit(0);

}

}

Perform the static and dynamic code analysis to:

  1. Identify Four (4) vulnerabilities that exist in the code and discuss on the possible attack that can be performed to the code.
  2. Simulate on the attack and show detail evidence(s) on how the attack can be done with screenshot and detail explanation.
  3. Amend the code to provide solution in preventing the attack that being simulated in b) and explain in detail the solution(s) provided.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Networking A Top-Down Approach

Authors: James Kurose, Keith Ross

7th edition

978-0133594140

More Books

Students also viewed these Computer Network questions

Question

Explain the various methods of job evaluation

Answered: 1 week ago

Question

Differentiate Personnel Management and Human Resource Management

Answered: 1 week ago

Question

Describe the functions of Human resource management

Answered: 1 week ago