Adm1n_0v3rride

Simple Buffer overflow

Mar 2nd, 2018
126
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. // Simple Buffer overflow
  3. // by Adm1n_ 0v3rride (C) 2018
  4. //
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9.  
  10. int main(int argc,char* argv[]) {
  11.    
  12.     char buffer_a[8],buffer_b[8]; // char 'a' repesents the First buffer char 'b' repesents Secound buffer
  13.     int x = 5;
  14.    
  15.     strcpy(buffer_a, "one");
  16.     strcpy(buffer_b, "two");
  17.    
  18.     printf("First Step: Filling the buffer...\n\n");
  19.     printf("[BEFORE] buffer_a is at %p and houses \'%s\'\n", buffer_a, &buffer_a);
  20.     printf("[BEFORE] buffer_b is at %p\n and houses \'%s\'\n", buffer_b, &buffer_b);
  21.     printf("The value of x is %p at %p and the pointer is (0x%08x)\n\n",&x,x,x);
  22.    
  23.     printf("Secound Step: Strlen is now copying %d bytes into b\n", strlen(argv[1]));
  24.     strcpy(buffer_b, argv[1]);
  25.    
  26.     printf("Third Step: The overflow\n");
  27.     printf("[AFTER...] buffer_a is now at %p and now contains \'%s\'\n", buffer_a, buffer_a);
  28.     printf("[AFTER...] buffer_b is now at %p and now contains \'%s\'\n", buffer_b, buffer_b);
  29.     printf("[AFTER...] The Value has a pointer at %p and at %d (0x%08x)\n",&x,x,x);
  30.    
  31. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×