CSE497b - Project #5 - Configure Buffer Overflow

Due Date: May 3rd, 2007.

In this assignment, you will configure an attack program to compromise a buffer overflow vulnerability in a victim program. The victim program is instrumented to provide traces that will be helpful in determining how to leverage that vulnerability. Your task will be to modify the attack program, based on the victim traces, to overflow the buffer and start a shell program.

Note that this buffer overflow is 32-bit, x86-specific, so you must use such a machine. You can do this assignment in your Playpen (that is where I did mine), and that is where we will test it. You will need to test it there too.

In theory, this project could be done very quickly, so if you get stuck please seek help from us. There are some ad hoc materials online, but these may not help too much. This is not a recommendation to wait to the last minute, but to not slog on your own for too long.

Follow these instructions:

  1. Get the project tarball from here. The project tarball contains: (1) a victim program, cse497b-victim.c, which contains a buffer overflow vulnerability and (2) an attack program, cse497b-attack.c, which contains code to leverage buffer overflow vulnerabilities in victims.

  2. Unpack the tarfile on an x86 32-bit machine (Playpen). We will test on the Playpen, so it would probably be best to use you Playpen.

  3. Two modifications to the attack program are necessary: (1) specify the stack offset between the vulnerable buffer and the return address of the victim (both are on the stack) and (2) the new return address for the running a shell on the victim. These are specified as variables in the attack program (see variables with "= fill in"). You just need to set those values in the attack program successfully to complete the assignment.

  4. To determine the stack offset, build the victim program (make victim). The victim program takes a sequence of strings and concatenates them into a buffer (our target) that is allocated on the stack. The victim also contains instrumentation to print the buffer address (and others see below) and the stack of the function with the vulnerable buffer buf (the function is also called victim). From this information, you can see where the buffer is allocated. The return address is also in the stack trace, but you need to locate it. Assign the distance in bytes between the start of the buffer and the start of the return address in the variable rtn_addr_distance in cse497b-attack.c. Hint: The return address is an address inside the function that calls the victim function (i.e., main calls victim).

  5. To determine the new return address (i.e., to run our attack code), we need locate the code we want to run in the victim (./victim foo bar). In this case, we are going to jump to some code in the victim program. The function shell in the victim opens a shell. Our exploit must call the shell function which executes a shell.

  6. To find the address of the shell function and enable the attack program's exploit to jump to this address, we need to:

  7. When you have completed the buffer overflow code, email it to the course professor by 5:00pm on the 3rd. Make sure that you have tested it in your Playpen prior to submission. We will build and run your attack (which launches the victim) to verify it. Failure to build either program may result in a failing grade for this assignment.

Notes

  1. All the information that you need should be available via these instructions and the project slides. Let the instructor or TA know of any other questions.

  2. You are to complete this on your own. Any sharing of code or help during the coding of this project is expressly forbidden. Do not discuss this project with anyone.


Trent Jaeger
Last modified: Apr 23 23:43:07 EST 2007