Question: Develop your own exploit for getscore.c , for both Redhat8 and Redhat9. Here is a sample score file if you want to run the program

Develop your own exploit for getscore.c , for both Redhat8 and Redhat9. Here is a sample score file if you want to run the program "normally": score.txt. You can either develop one exploit for each platform or a single exploit for both. You can find the Redhat8 and Redhat9 virtual machines here (Links to an external site.)Links to an external site.. What to submit: source code of your exploit generator, a README file on how to run your generator, and a 1-2 page report documenting how you developed the exploit, so that someone else can follow the report to reproduce the result.

getscore.c:

#include

#include

FILE *scorefile;

int get_score(char *name, char *ssn, char *score);

char* str_prefix(char *prefix, char *str);

int main(int argc, char *argv[])

{

int ruid, euid;

char score[128];

if (argc != 3) {

printf("Usage: getscore name SSN ");

exit(1);

}

time_t current_time = time(NULL);

ruid = getuid ();

euid = geteuid ();

// This is to make sure the logging command will have

// sufficient privilege.

if (setreuid(euid, euid)){

perror("setreuid");

}

scorefile = fopen("score.txt", "r");

if (scorefile == NULL){

printf ("failed to open score file ");

}

else{

if (get_score(argv[1], argv[2], score)){

char command[256];

printf("Invalid user name or SSN. ");

sprintf(command, "echo \"%s: Invalid user name or SSN: %s,%s\"|cat >> error.log",

ctime(¤t_time), argv[1], argv[2]);

if (system(command)){

perror("Logging");

}

exit(-1);

}

printf("Your score is %s ", score);

}

}

int get_score(char *name, char *ssn, char *score)

{

char matching_pattern[128];

char line[128];

char *match_point;

strcpy(matching_pattern, name);

strcat(matching_pattern, ":");

strcat(matching_pattern, ssn);

while (fgets(line, 128, scorefile)!=NULL){

if (match_point=str_prefix(matching_pattern, line)){

if (*match_point++==':'){

while (*match_point!=':'){

*score++=*match_point++;

}

*score=0;

return 0;

}

}

}

return -1;

}

char* str_prefix(char *prefix, char *str){

while (*prefix && *str){

if (*prefix != *str)

return NULL;

prefix++;

str++;

}

return *prefix==0?str:NULL;

}

score.txt:

Mary Doe:123-45-6789:A+:an excellent student

Tom Smith:567-89-1234:B:pay more attention

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This question is incomplete because it involves creating an exploit which is typically an activity associated with penetration testing or ethical hack... 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!