Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/prog/-challenge: HAX MY ANUS

Name: Anonymous 2010-08-31 18:13

Your task:

Write a program that exploits the buffer overflow in the following program, to let it display the string ``Hello World'' on Linux i386:

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

char *readstuff(int length) {
  char *buffa;

  if((buffa = malloc(length)) == NULL)
    return;
  gets(buffa);
  return buffa;
}

int main(int argc, char **argv) {
  char *buffa;

  buffa = readstuff(argc);
  free(buffa);
  return EXIT_SUCCESS;
}


Deadline is this sunday night 23:59:59

Name: Anonymous 2010-09-01 3:11

>>1
This isn't a "traditional" buffer overflow, it's just completely incorrect code.

The readstuff function allocates a buffer of size N where N is the number of arguments passed to the program.  So if you just run ./buffa as you specified, then argc will be zero.

So then when you hit this line of code:

  if((buffa = malloc(length)) == NULL)
    return;


malloc will probably return zero (who knows) and you'll just return, but that function must return a value... shit, your code won't even compile.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List