Advertisement
Guest User

lol2

a guest
Apr 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. /*stack.c*/
  2. /*This program has a buffer overflow vulnerability.*/
  3. /*Our task is to exploit this vulnerability*/
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. int bof(char*str)
  8. {
  9.     char buffer[24]; /* The following statement has a buffer overflow problem*/
  10.     strcpy(buffer, str);
  11. return 1;
  12. }
  13. int main(int argc, char**argv)
  14. {
  15.     char str[517];
  16.     FILE *badfile;
  17.     badfile = fopen("badfile", "r");
  18.     fread(str, sizeof(char), 517, badfile);
  19.     bof(str);
  20.     printf("Returned Properly\n");
  21.     return 1;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement