-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexploitable1.cpp
More file actions
33 lines (26 loc) · 1.04 KB
/
Copy pathexploitable1.cpp
File metadata and controls
33 lines (26 loc) · 1.04 KB
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
// **********************************************************
// Fuzzing example - simplest possible buffer overflow
//
// Copyright 2020
// Charley Lucas
// charley@zerosquared.io
// **********************************************************
#include <iostream>
#include <cstring>
int main(int argc, char* argv[]) {
char input[6]; // Allocate space for six characters plus the null
if (argc < 2) {
std::cout << "Enter at least one input string on the command line.\n";
exit(0);
}
// Print out all the command-line arguments
//std::cout << "There were " << argc << " command-line arguments passed in:" << std::endl;
//for (int i = 0; i < argc; ++i) {
// std::cout << argv[i] << std::endl;
//}
// Blindly copy the passed-in string into our fixed-width variable.
// If the passed-in string is more than six characters, the program should crash
// before we see the output printed below.
strcpy(input, argv[1]); // Crash here
std::cout << "String received: " << input << std::endl;
}