-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbufferoverflow.cpp
More file actions
36 lines (29 loc) · 912 Bytes
/
bufferoverflow.cpp
File metadata and controls
36 lines (29 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Name: Aaron Pritchard, Josh Brinker
// Filename: bufferoverflow.cpp
// Class: CSC328
// Prof: Dr. Frye
// Major: CS
// Date: 25 November 2020
// Assignment: Buffer overflow security program
// Due: 3 December 2020
// Compile: make
// Execute: make test
// Purpose: Illustrates a program susceptible to buffer overflow attack.
//
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
int number = 1;
int buffer[10];
cout << "Pre buffer overflow: " << endl;
cout << "Number: " << number << endl;
for (int i = 0; i <= 15; i++) // Here we are clearly going out of bounds in the declared elts in the array
{
buffer[i] = 20;
}
// This illustrates the overflow into another variable.
cout << "Post buffer overflow: " << endl;
cout << "Number: " << number << endl;
return 0;
}