Stack-OverFlow-Example

#StackOverFlowExample
# include <stdio.h>
# include <string.h>
//Stack overflow Example Allowing user to control string size or input

int func(char* input,int p1,int p2){
char buffer [10];
strcpy(buffer, input);//Copying input to buffer
}
int main(int argc, char*argv[]){

func(argv[1],22,3.14);
return 0;
}


//Note
//1. by default in Linux today gcc are protected by default from buffer overflow
//2. To stop protection  gcc stackbufferoverflow.c -fno-statck-protector -o stackbufferoverflow
// run ./stackbufferoverflow 123456789 no problem
// ./ stackbufferoverflow 1234567890123456 can see memory maps
  
Reactions:

0 comments:

Post a Comment