Practical: buffer overflow
what is buffer overflow?
buffer is a type of a memory which is stores data for a temporary use of it & overflow here is mean we are overflowing the memory region like overloading the memory to corrupt it or crushing the system haha sounds cool na !!!
how it work?
suppose there is a memory which doesn't check the written data size it accepting if a data is huge in a number, it can cause memory segmentation fault or memory can’t handle it in a simple meaning it is being overload or overflow now i will show you in a practical way to make you well understand .
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void unsafeFunction(char *input) {
char buffer[50]; // Small buffer of 50 bytes
// Unsafe copy of input to buffer
// No bounds checking, so input longer than 50 bytes will overflow the buffer
strcpy(buffer, input);
// Print the buffer content
printf("Buffer content: %s\n", buffer);
}
int main() {
char input[100];
printf("Enter some text (up to 100 characters):\n");
fgets(input, sizeof(input), stdin); // Read input from user
input[strcspn(input, "\n")] = 0;
unsafeFunction(input); // Call the function with unsafe buffer handling
return 0;
}This code is of c, I have declared buffer which stores almost 50 bytes & sytrcpy copy the input into the buffer now here it did’nt do any king of bound checking which makes it overflow , so if the entered input is more than the 50 bytes will cause overflow the buffer & lasty we called the function without any protection of handling data .
see here the normal program which have less than 100 characters worked well yea now i will saw you howwe gonna overflow it
Get Devilx0x1’s stories in your inbox
Join Medium for free to get updates from this writer.
payload must be any word more than 100 characters can do with py also thrugh :
print("A " * 105)A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A Ahere we run the program and enter this payload see it will say segmentation fault mean memory has successfully corrupted see the below image:
boom!!! intresting na
thank you don’t forget me to follow me on instagram @computer_boy5







