Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.
#include <Windows.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
#include <conio.h>
using namespace std;
struct first
{
string user;
};
struct second
{
string user;
};
void WelcomeUser(const struct first& A)
{
string fname;
size_t pos = A.user.find(' '); // locate blank
if (string::npos == pos) // no blank?
{
cout << "Welcome " << A.user; // OK, full name
}
fname = A.user.substr(0,pos); // extract first name
cout << "Welcome " << fname;
}
void WelcomeUser(const struct second& B)
{
string fname;
size_t pos = B.user.find(' '); // locate blank
if (string::npos == pos) // no blank?
{
cout << "Hello " << B.user; // OK, full name
}
fname = B.user.substr(0,pos); // extract first name
cout << "Hello " << fname;
}
int main()
{
system("color 0F");
struct first A;
struct second B;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << " Press Enter";
cin.ignore();
system("CLS");
cout << "Initiating Program..." << endl;
Sleep (1000);
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "NOW LOADING...: ";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
system("CLS");
cout << "Please Verify Your Name..." << endl;
getline(cin, A.user);
getline(cin, B.user);
bool correctName=false;
while(!correctName)
{
//Set A.user here...
if (A.user == "Josh Sarge" || B.user == "Mike Sarge")
{
correctName=true;
cout << "" << endl;
cout << "Program Now Processing...Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
cout << "Verification Complete..." << endl;
Sleep (2000);
Sleep (1000);
system ("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
cout << "Access Granted..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
WelcomeUser(A);
cout << "" << endl;
Sleep (2000);
Sleep (1000);
system("pause");
return 0;
}
else
{
cout << "" << endl;
cout << "Program Processing. Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
cout << "Access Denied..." << endl;
Sleep (2000);
Sleep (1000);
cout << "" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
cout << "Please Enter Your Full Name" << endl;
cout << "" << endl;
getline(cin, A.user);
getline(cin ,B.user);
}
}
}
Do more with
if (A.user == "Josh Sarge")
{
correctName=true;
cout << "" << endl;
cout << "Program Now Processing...Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
cout << "Verification Complete..." << endl;
Sleep (2000);
Sleep (1000);
system ("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
cout << "Access Granted..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
WelcomeUser(A);
cout << "" << endl;
Sleep (2000);
Sleep (1000);
system("pause");
return 0;
}
if (A.user == "Mike Sarge")
{
correctName=true;
cout << "" << endl;
cout << "Program Now Processing...Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
cout << "Verification Complete..." << endl;
Sleep (2000);
Sleep (1000);
system ("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
cout << "Access Granted..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
WelcomeUser(A);
cout << "" << endl;
Sleep (2000);
Sleep (1000);
system("pause");
return 0;
}
cout << "" << endl;
cout << "Program Processing. Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
cout << "Access Denied..." << endl;
Sleep (2000);
Sleep (1000);
cout << "" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
cout << "Please Enter Your Full Name" << endl;
cout << "" << endl;
getline(cin, A.user);
getline(cin ,B.user);
B.user = A.user;
but that's not really good design. I'd rather try the following:#include <Windows.h>
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <cmath>
#include <conio.h>
using namespace std;
struct first
{
string user;
};
void WelcomeUser1(const struct first& A)
{
string fname;
size_t pos = A.user.find(' '); // locate blank
if (string::npos == pos) // no blank?
{
cout << "Welcome " << A.user; // OK, full name
}
fname = A.user.substr(0,pos); // extract first name
cout << "Welcome " << fname;
}
void WelcomeUser2(const struct first& B)
{
string fname;
size_t pos = B.user.find(' '); // locate blank
if (string::npos == pos) // no blank?
{
cout << "Hello " << B.user; // OK, full name
}
fname = B.user.substr(0,pos); // extract first name
cout << "Hello " << fname;
}
int main()
{
system("color 0F");
struct first A;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << " Press Enter";
cin.ignore();
system("CLS");
cout << "Initiating Program..." << endl;
Sleep (1000);
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "" << endl;
cout << "NOW LOADING...: ";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
Sleep (500);
cout << "|";
system("CLS");
cout << "Please Verify Your Name..." << endl;
getline(cin, A.user);
bool correctName=false;
while(!correctName)
{
//Set A.user here...
if (A.user == "Josh Sarge")
{
correctName=true;
cout << "" << endl;
cout << "Program Now Processing...Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
cout << "Verification Complete..." << endl;
Sleep (2000);
Sleep (1000);
system ("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
cout << "Access Granted..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
WelcomeUser1(A);
cout << "" << endl;
Sleep (2000);
Sleep (1000);
system("pause");
return 0;
}
if (A.user == "Mike Sarge")
{
correctName=true;
cout << "" << endl;
cout << "Program Now Processing...Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
cout << "Verification Complete..." << endl;
Sleep (2000);
Sleep (1000);
system ("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
cout << "Access Granted..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
WelcomeUser2(A);
cout << "" << endl;
Sleep (2000);
Sleep (1000);
system("pause");
return 0;
}
else
{
cout << "" << endl;
cout << "Program Processing. Please Wait..." << endl;
Sleep (2000);
Sleep (1000);
system("CLS");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
cout << "Access Denied..." << endl;
Sleep (2000);
Sleep (1000);
cout << "" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
cout << "Please Enter Your Full Name" << endl;
cout << "" << endl;
getline(cin, A.user);
}
}
}
Premium Content
You need an Expert Office subscription to comment.Start Free Trial