Stack Four

Stack Four takes a look at what can happen when you can overwrite the saved instruction pointer (standard buffer overflow).


 * phoenix/stack-four, by
 * The aim is to execute the function complete_level by modifying the
 * saved return address, and pointing it to the complete_level() function.
 * Why were the apple and orange all alone? Because the bananna split.

#include <err.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define BANNER \
  "Welcome to " LEVELNAME ", brought to you by"

char *gets(char *);

void complete_level() {
  printf("Congratulations, you've finished " LEVELNAME " :-) Well done!\n");

void start_level() {
  char buffer[64];
  void *ret;


  ret = __builtin_return_address(0);
  printf("and will be returning to %p\n", ret);

int main(int argc, char **argv) {
  printf("%s\n", BANNER);