In: Computer Science
Write a testing program (not sort.c from task 2) that contains a stack buffer overflow vulnerability. Show what the stack layout looks like and explain how to exploit it. In particular, please include in your diagram: (1) The order of parameters (if applicable), return address, saved registers (if applicable), and local variable(s), (2) their sizes in bytes, (3) size of the overflowing buffer to reach return address, and (4) the overflow direction in the stack (5) What locations within the stack are actually overwritten with your target data to exploit a stack to cause the routine you want to execute to be invoked? You are not required to write the real exploit code, but you may want to use some figures to make your description clear and concise.
Raw Copyable Code:
//header files
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
//the test function
void testFunction (char *inString)
{
char buffer[12];
/*the below statement will results in a buffer
overflow
problem*/
strcpy (buffer, inString);
}
//The main
int main()
{
//the character array
char *inString = "The string input has size more than
12";
//call the function
testFunction (inString);
//return 0
return 0;
}