//============================================================================
// Name        : securityCourse.cpp
// Author      : Dr.Bilal Alqudah
// Version     : 1.2
// Copyright   : you are free to use the code for academic purposes 
// Description : buffer overflow attack example. try input that will allow you to login that does not match the saved password
//============================================================================
#include <stdio.h>
//#include <strings.h>
//#include <string.h>
#include <cstring>
//#include <iostream.h>
#include <iostream>
using namespace std;



int main(int argc, char *argv[]) {
            int AccessGranted = -1;
        char systemPassword[12] = "MyPwdabc";
        char incomingPasswd[12];

        gets(incomingPasswd);
        printf(" target =%s password= %s  allow_login=%d\n",systemPassword,incomingPasswd,AccessGranted);
        if (strncmp(incomingPasswd,systemPassword,10) == 0)
                AccessGranted = 1;

        if (AccessGranted == -1)
                printf("Sorry, Cannot Access files \n target =%s password=%s allow_login=%d",systemPassword,incomingPasswd,AccessGranted);
        else
                printf("[OK] .... read files now! ");
}
