Protostar/Stack 4

If you get stuck, you can watch the solution and explanation here:

This video shows you how to take over control of a program with a buffer overflow

Stack4 takes a look at overwriting saved EIP and standard buffer overflows.

This level is at /opt/protostar/bin/stack4

Hints:
A variety of introductory papers into buffer overflows may help.
gdb lets you do "run < input"
EIP is not directly after the end of buffer, compiler padding can also increase the size.

stack4.c

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

void win()
{
  printf("code flow successfully changed\n");
}

int main(int argc, char **argv)
{
  char buffer[64];

  gets(buffer);
}

See also

This video introduces http://exploit-exercises.com, how to connect to the VM with ssh and explains what setuid binaries are.

We will write our first Buffer Overflow for the stack0 level of exploit-exercises.com.

This is a mirror. Copyright and original can be found here: exploit-exercises.com/protostar/stack4/