This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
csce465pine64backup/hw2/stack.c

28 lines
546 B
C
Raw Normal View History

2018-02-12 04:57:21 -06:00
/* 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>
int bof(char *str)
{
char buffer[12];
/* The following statement has a buffer overflow problem */
strcpy(buffer, str);
return 1;
}
2018-02-13 23:18:43 -06:00
int main(int argc, char **argv)
2018-02-12 04:57:21 -06:00
{
char str[517];
FILE *badfile;
badfile = fopen("badfile", "r");
fread(str, sizeof(char), 517, badfile);
bof(str);
printf("Returned Properly\n");
return 1;
}