(40 points) This problem asks you to implement a buffer overflow attack on a program. In the Homework area of Desire2Learn (or the Homework area of the nob.cs.ucdavis.edu class web site) is a program bad.c. This program contains a buffer overflow vulnerability; see the call to gets(3) at line 13. Your job is to exploit the overflow by providing input to the running process that will cause the program to invoke the function trap (which, you may notice, is not called anywhere else). You will know you’ve succeeded when you run the program, give it your input, and it prints “texttt{Gotcha!}” Please do this on the CSIF systems. These run Fedora Linux, and are named “pcnn.cs.ucdavis.edu”, where nn is an integer less than or equal to 60. You can see the status of the systems at http://angel.cs.ucdavis.edu/cgi-bin/status.cgi?hostgroup=all&style=hostdetail.
The following questions will help guide you. Please turn in your answers to them, a hex dump of the input you use to call trap, and a typescript or screen shot of you running the program bad, giving it your input, and showing its output.
- What is the address of the function trap()? How did you determine this?
- What is the address on the stack that your input must overwrite (please give both the address of the memory location(s), and their contents)? How did you locate this address?
- What is the address of buf?
- The sled is the input you give to alter the return address stored on the stack. What is the minimum length your sled must be?