Project 7: Buffer overflows


Tutor: Guillaume Didier guillaume.didier AT irisa.fr

Context

Out of bound accesses (and writes) to buffer are a recurring issue in computer security, especially for code bases written in C based language. In this project we explore how to exploit buffer overflows (that is writes past the end of buffers) in order to hijack the control flow of the program.

This project will involve learning about the program stack memory layout, assembly, and in the last part memory allocator structures.

Aim

Your mission is to exploit our target programs in various ways to demonstrate that you are able to execute code of your choice.

You should be able to each time take control of the instruction pointer and pass parameters of your choice to the target function.

You should start with the unprotected stack target, then the protected stack, and last with the heap buffer overflow.

Logistics

We will provide a Virtual machine on which to run the targets, in order to have a reproducible environment. You can find more details on how to exploit the target here: [PDF]

We expect a report of how you set up your different attacks. We also expect you to provide the hex representation of all your attack strings.

Progression

On the first target, ctarget :

  1. Call a function that takes no argument and then exits
  2. Call a function that expects arguments
  3. Call a function that expects a string
  4. Execute code on the stack that then restore the stack and continues execution normally

On the second target you should try to:

  1. Call a function that expects a register argument
  2. Call a function that expects a string parameter

On the last target, you are expected to create an exploit string that:

  1. Calls a function with no argument
  2. Calls a function with a single register argument
  3. Calls a function with a string argument

We’re bored

Are you, really?

You can explore how to get an actual shell instead of calling target functions.

Bibliography

Read this seminal publication first to familiarize yourself with buffer overflows:

During the final presentation, you should summarize these two papers:

More publications about attacks on the heap for the last part of the project (to read in order):

And other resources for more background information: