Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* stack.c */
- /* This program has a buffer overflow vulnerability. */
- /* Our task is to exploit this vulnerability */
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- void bof(char *str)
- {
- char buffer[12];
- /* The following statement has a buffer overflow problem */
- strcpy(buffer, str);
- }
- int main(int argc, char **argv)
- {
- char str[517];
- FILE *badfile;
- badfile = fopen("badfile", "r");
- fread(str, sizeof(char), 517, badfile);
- bof(str);
- printf("Returned Properlyn");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement