Soon, I am due to be giving a presentation to my class (doing a degree in computer science) where I want to give a basic example of a buffer overflow and why it's a problem. However, I can't get my buffer overflow to work.
The issue is that as soon as the crash is caused, the process is terminated, even if the process is attached to a debugger like xdbg (in VS, an exception is thrown). I think this is caused by one of the protections built into Windows 10. I have gone through the following article trying to disable them and made sure to compile the project with /GS
disabled in the project properties, but the problem is still happening.
Code is below:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string input;
char overflow[5];
cin >> input;
strcpy(overflow, input.c_str());
}