Skip to content

Instantly share code, notes, and snippets.

@sayantanHack
Created October 28, 2021 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sayantanHack/06c0e827a43a6e56ce117961998d535b to your computer and use it in GitHub Desktop.
Save sayantanHack/06c0e827a43a6e56ce117961998d535b to your computer and use it in GitHub Desktop.
This is a simple code for Buffer Overflow in C. Allocates the memory for specific range if exceed then shell command can be executed .
#include<stdio.h>
#include<stdlib.h>
int main()
{
//variables assigned
char *place;
char *systemcmd;
place=(char *)malloc(10);
systemcmd=(char *)malloc(128);
//Print line
printf("Memory Adress of Place: %d\n",place);
printf("Memory Adress of Systemcmd: %d\n",systemcmd);
printf("The space between Place & systemcmd: %d\n",systemcmd - place);
printf("What is Buffer area?");
gets(place);
//systemcommand
printf("The buffer area is: %s\n", place)
system(systemcmd);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment