0

I am trying to do buffer overflow attack.

I have disabled address space layout randomization (ASLR) using command: sudo sysctl -w kernel.randomize_va_space=0

Instead of crashing the program I want to print the "Holla.. Holla.." Statement in the code by using buffer overflow to overwrite return address on the stack to point to target() function address which contains the printf() statement and print Holla.. Holla... instead of crashing the program

I am using the following code:

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

void target(){
    printf("Holla.. Holla..\n");
    exit(0);
}

void prompt(){
    char buf[100];

    gets(buf);
    printf("You entered: %s\n", buf);

}

int main(){
    prompt();

    return 0;
}
  • What did you already try? – Gumbo Dec 13 '14 at 20:16
  • I am a newbie and trying buffer overflow for the first time. I tried applying the following stackoverflow.com/questions/7344226/buffer-overflow-attack but was unsuccessful in doing it. a detailed explanation of the various steps to follow will be of great help – Mrugesh Verekar Dec 13 '14 at 22:54

0 Answers0