Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 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. void bof(char *str)
  8. {
  9. char buffer[12];
  10. /* The following statement has a buffer overflow problem */
  11. strcpy(buffer, str);
  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 Properlyn");
  21. return 1;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement