Created
October 28, 2021 07:36
-
-
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 .
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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