Question: #include #include #include #include #include char buffer [ 1 9 2 ] = ; char filename [ 1 9 2 ] =

#include
#include
#include
#include
#include
char buffer[192]="";
char filename[192]="";
int main(int argc, char *argv[])
{
if (argv[1]){
snprintf(filename,255,"/var/challenge/level5/%s", basename(argv[1]));
printf("Checking filename %s
", filename);
if (access(filename, X_OK)){
fprintf(stderr, "You do not have the permission to execute this file
");
return 1;
}
}
else {
fprintf(stderr, "Please provide the program name
");
return 2;
}
if (argv[2]){
strcpy(buffer, argv[2]);
}
else {
gets(buffer);
}
printf("Executing filename %s
", filename);
execlp(filename, filename, buffer, (char *)0);
return 0;
}
What are the vulnerabilities in this program? how can I exploit ?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!