Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the lab for my secure coding course. I have to do formatting labs for this programs please can anyone help me out thru

This is the lab for my secure coding course.

I have to do formatting labs for this programs please can anyone help me out thru this thanks!

so what we have to do for this " We need to protect exploit.c from a formatted output vulnerability.

1) exploit_func_ptr.c

2) exploit_working.c

3) exploit.c

image text in transcribed

image text in transcribed

image text in transcribed

#include #include #include static void (*func_ptr) (const char *str) void function (const char* str) printf("%s ", str); int main (int argc, char **argv) char buffer[512; char format[1024]; unsigned char foo[4] -t0); if (argc print f ("&func-ptr-> %p ", %p ", func-ptr ); &func-ptr); strcpy (format, argv[1]); snprintf (buffer, sizeof (buffer), format) buffersizeof (buffer) -1] - x00 print f print f ("func-ptr-> ("&func-ptr-> %p ", %p ", func-ptr ); &func-ptr); print f ("%02x%02x%02x%02x at address %p ", foo[3], foo[2], foo [1], foo[0], &foo ) ; printf( "goodbye"); (voi ("done") id) (*func ptr) return 0; #include #include #include int main (int argc, char **argv) char buffer[512; char format[ 1024]; unsigned char foo[ 4] -0)i if (argc2) return -1; strcpy(format, argv[1]); snprintf (buffer, sizeof (buffer), format); buffer[sizeof (buffer) - 1] x00 fprintf(stdout, fprintf ( stdout, " you entered "%02x%02x%02x%02x %s ", buffer ); address : at %pin", foo [3], foo [ 2] , foo[1], foo[0], &foo); printf("goodbye") printf(" "); exit (0) #include #include #include int main (int argc, char **argv) char buffer 512 unsigned char foo[4O if (argc static void (*func_ptr) (const char *str) void function (const char* str) printf("%s ", str); int main (int argc, char **argv) char buffer[512; char format[1024]; unsigned char foo[4] -t0); if (argc print f ("&func-ptr-> %p ", %p ", func-ptr ); &func-ptr); strcpy (format, argv[1]); snprintf (buffer, sizeof (buffer), format) buffersizeof (buffer) -1] - x00 print f print f ("func-ptr-> ("&func-ptr-> %p ", %p ", func-ptr ); &func-ptr); print f ("%02x%02x%02x%02x at address %p ", foo[3], foo[2], foo [1], foo[0], &foo ) ; printf( "goodbye"); (voi ("done") id) (*func ptr) return 0; #include #include #include int main (int argc, char **argv) char buffer[512; char format[ 1024]; unsigned char foo[ 4] -0)i if (argc2) return -1; strcpy(format, argv[1]); snprintf (buffer, sizeof (buffer), format); buffer[sizeof (buffer) - 1] x00 fprintf(stdout, fprintf ( stdout, " you entered "%02x%02x%02x%02x %s ", buffer ); address : at %pin", foo [3], foo [ 2] , foo[1], foo[0], &foo); printf("goodbye") printf(" "); exit (0) #include #include #include int main (int argc, char **argv) char buffer 512 unsigned char foo[4O if (argc

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

(1 point) Calculate 3 sin x cos x dx.

Answered: 1 week ago

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago