Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // Simple Buffer overflow
- // by Adm1n_ 0v3rride (C) 2018
- //
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(int argc,char* argv[]) {
- char buffer_a[8],buffer_b[8]; // char 'a' repesents the First buffer char 'b' repesents Secound buffer
- int x = 5;
- strcpy(buffer_a, "one");
- strcpy(buffer_b, "two");
- printf("First Step: Filling the buffer...\n\n");
- printf("[BEFORE] buffer_a is at %p and houses \'%s\'\n", buffer_a, &buffer_a);
- printf("[BEFORE] buffer_b is at %p\n and houses \'%s\'\n", buffer_b, &buffer_b);
- printf("The value of x is %p at %p and the pointer is (0x%08x)\n\n",&x,x,x);
- printf("Secound Step: Strlen is now copying %d bytes into b\n", strlen(argv[1]));
- strcpy(buffer_b, argv[1]);
- printf("Third Step: The overflow\n");
- printf("[AFTER...] buffer_a is now at %p and now contains \'%s\'\n", buffer_a, buffer_a);
- printf("[AFTER...] buffer_b is now at %p and now contains \'%s\'\n", buffer_b, buffer_b);
- printf("[AFTER...] The Value has a pointer at %p and at %d (0x%08x)\n",&x,x,x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement