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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
|
#include <iostream>
#include <fstream> // File Stream... I believe your familiar
#include <string>
#include <Windows.h> // This enables special features such as Sleep... Very useful but constrains your api to windows only of course.
#include <time.h>
#include "conio.h" // This allows getch/ get character to be used. getch can be used to get a character or generically make a pause/continue.
#pragma comment(lib, "winmm.lib") // This enables the music
using namespace std;
int staticLoad() // Exterior function
{
cout << "Loading";
Sleep(100); // A more simple delay that works by milliseconds. It goes along with the Windows header
cout << ".";
Sleep(100);
cout << ".";
Sleep(100);
cout << ".";
Sleep(800);
system("cls");
cout << "Loading";
Sleep(100);
cout << ".";
Sleep(100);
cout << ".";
Sleep(100);
cout << "." << flush; // Flush just clears the input buffer. Its not needed but is a good thing to use every now and then.
system("cls");
return 0;
}
int main() // Main function
{
system("title SYSTEM LOG-IN");
//PlaySound(TEXT("FILENAME.wav"), NULL, SND_ASYNC | SND_LOOP); Music playing statement. Music file must be in . WAV format and be in the directory.
//PlaySound(NULL, NULL, NULL); This stops the music.
SetForegroundWindow(GetConsoleWindow()); // All these 5 lines are used to make the window fullscreen. In my experience it always runs with XP,
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), 0, 0); //not windows 7 for some reason... Not sure if it will work because of my limitations of OS.
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0);
keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), KEYEVENTF_KEYUP, 0);
keybd_event(VK_MENU, MapVirtualKey(VK_MENU, 0), KEYEVENTF_KEYUP, 0);
staticLoad(); // Load the exterior function above that makes a fake loading timer
Sleep(500);
int ntTries=0; // Tries timer that will increase every failed password, and at 5 wrong information inputs it will shutdown the computer though an
// If evaluation
string szUACt_1 = "Drue"; // sz means string so you can identify it later on; User-Account-Control Title: 1(Account Username 1)
string szUACp_1 = "Blake"; // User-Account-Control Password: 1(Account Password 1)
RETRY: // This used when the user had incorrect input, and gets another chance to try again by returning to the question and evaluation.
system("color a"); // Simple system color [green]
time_t rawtime; // time stamp stuff so that the time the program is executed is logged in an external text file.
time ( &rawtime );
string szTime = ctime (&rawtime); // Set the timestamp equal to a alpha variable.
string szUsername; // sz doesn't change anything, its just a coding technique to let you know wherever its used that it is a string/ sz.
string szPassword;
string szPasswordChar;
string szCharacterDisp; // What the final output of ****** characters will be when user enters password
string szGetChar_1, szGetChar_2, szGetChar_3, szGetChar_4, szGetChar_5, szGetChar_6, szGetChar_7, szGetChar_8, szGetChar_9;
BOOL vkReturn_1, vkReturn_2, vkReturn_3, vkReturn_4, vkReturn_5, vkReturn_6, vkReturn_7, vkReturn_8; // Regular variables, based on the purpose of the ENTER key for an if statement.
cout << "USERNAME: ";
cout << " ";
cin >> szUsername;
cout << "PASSWORD: ";
szGetChar_1 = _getch(); // getch makes it where you can invisibly input a character and save it to a variable.[get character]
vkReturn_1 = GetKeyState(VK_RETURN); // This determines if enter was pressed.
if (vkReturn_1){ // If enter was pressed(meaning password is done) then do the following... skip the password input and evaluate input data.
goto NEXT;
}
szPassword += "*";
szGetChar_2 = _getch();
vkReturn_2 = GetKeyState(VK_RETURN);
if (vkReturn_2){
goto NEXT;
}
szPassword += "*";
szGetChar_3 = _getch();
vkReturn_3 = GetKeyState(VK_RETURN);
if (vkReturn_3){
goto NEXT;
}
szPassword += "*";
szGetChar_4 = _getch();
vkReturn_4 = GetKeyState(VK_RETURN);
if (vkReturn_4){
goto NEXT;
}
szPassword += "*";
szGetChar_5 = _getch();
vkReturn_5 = GetKeyState(VK_RETURN);
if (vkReturn_5){
goto NEXT;
}
szPassword += "*";
szGetChar_6 = _getch();
vkReturn_6 = GetKeyState(VK_RETURN);
if (vkReturn_6){
goto NEXT;
}
szPassword += "*";
szGetChar_7 = _getch();
vkReturn_7 = GetKeyState(VK_RETURN);
if (vkReturn_7){
goto NEXT;
}
szPassword += "*";
szGetChar_8 = _getch();
vkReturn_8 = GetKeyState(VK_RETURN);
if (vkReturn_8){
goto NEXT;
}
szPassword += "*";
szGetChar_9 = _getch(); // Only goes up to nine... Dont use a password that is more than 9 characters.
NEXT:
/*Output the password*/
cout << " ";
cout << szPassword;
cout << endl;
staticLoad();
system("cls");
/*Log Access request*/
ofstream Log;
Log.open("C:/Users/Matt/Documents/log-in events/Log.txt", ios::app);
Log << "[ACCESS ENTRY]\n\nDATE: " << szTime << "\nUSERNAME: " << szUsername << "\nPASSWORD: " << szCharacterDisp << "\n\n";
/*Compare User Input to database*/
if (szUsername == szUACt_1){ // If what they entered equal the username the console knows of, then continue...
if (szPassword == szUACp_1){
// ALLOW ACCESS TO USER
goto VERIFIED;
}
}
else { // If not then do this.
ntTries += 1;
system("cls");
if (ntTries == 1){
cout << "The Username/ Password is incorrect.";
Sleep(1500);
system("cls");
goto RETRY;
}
if (ntTries == 2){
cout << "The Username/ Password is incorrect.";
Sleep(1500);
system("cls");
goto RETRY;
}
if (ntTries == 3){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
cout << "The Username/ Password is incorrect.";
Sleep(1500);
system("cls");
Sleep(125);
cout << "The Username/ Password is incorrect.";
system("cls");
Sleep(125);
cout << "The Username/ Password is incorrect.";
Sleep(2500);
system("cls");
goto RETRY;
}
if (ntTries == 4){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
cout << "The Username/ Password is incorrect.";
Sleep(1500);
system("cls");
Sleep(125);
cout << "The Username/ Password is incorrect.";
system("cls");
Sleep(125);
cout << "The Username/ Password is incorrect.";
Sleep(2500);
system("cls");
goto RETRY;
}
if (ntTries == 5){
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
cout << "The Username/ Password is incorrect.";
Sleep(2500);
system("cls");
Sleep(125);
cout << "The Username/ Password is incorrect.";
system("cls");
Sleep(125);
cout << "The Username/ Password is incorrect.";
system("cls");
Sleep(125);
cout << "The Username/ Password is incorrect.";
Sleep(2500);
system("cls");
Sleep(2500);
cout << "ACCESS DENIED." << endl;
Sleep(1000);
}
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 240);
cout << "This machine will now shutdown";
Sleep(2000);
cout << ".";
Sleep(2000);
cout << ".";
Sleep(2000);
cout << ".";
system("shutdown /f /s /t 6"); // The program will shutdown the computer and print a message to the screen. 6 seconds is better so no damage is done by user.
return 0;
// EXIT PROGRAM AND COMPUTER.
}
VERIFIED:
cout << "Welcome. Access Granted." << endl; // Allows access without interruption.
Sleep(2500);
return 0;
}
|