// Author: Sh3llc0d3
// For: P-Teo@iExploit
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <stdio.h>
#include <string.h>
using std::cout; using std::cin; using std::endl; // better than including the entire namespace
bool strGet(char password, char local); // prototype
bool strGet(char password, char local) { // bool function for checking password
if(password == local) { // if correct...
return true; // true
} else { // if not....
return false; // false.
}
}
int main() {
char cAlphaNum[] = "abcdefghijklmnopqrstuvwxyz1234567890"; // alpha-numeric string for password generation
int Attempts = 1; // attempt counter
char *entered = new char[10]; // char array for entered password
char *cLocalPass = new char[10]; // char array (locally generated password
srand(time(NULL)); // srand() used to setup pseudo-random generator
for(int i=0;i<=9;i++) {
cLocalPass[i] = cAlphaNum[rand()%37]; // filling each char in array with a randomly generated letter/num from cAlphaNum [% = modulus]
}
cout << "================================" << endl;
cout << "Current Password: " << cLocalPass << endl;
cout << "================================" << endl;
cout << endl << "Password: ";
cin >> entered;
while(Attempts != 4) { // restricting password attempts to 4, we do this for the stdout counter (looks nicer)
if(strGet(*entered,*cLocalPass)) { // use function to find out if the entered pass is the same as the local pass or not
cout << "================================" << endl;
cout << "Welcome to the CIA..." << endl;
cout << "================================" << endl;
break;
} else { // if not... print another prompt
cout << "Failure" << endl;
cout << "Attempts: " << Attempts << " out of 3"
<< endl << "Password: ";
cin >> entered;
}
Attempts++; // increment attempt counter
}
cin.ignore(); // clear cin
cin.get(); // cin.get() is a good idea.
return 0; // exit with status 0
}