Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <windows.h>
- #include <time.h>
- #include <math.h>
- #include <fstream>
- using namespace std;
- int COUNT_PASSWORDS=15;
- int ENTRIES_COMMANDS=5;
- string aCommands[]={
- "exit",
- "printmem",
- "login",
- "password",
- "help",
- };
- int exist=1;
- int idx=0;
- int pw[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
- string pw5[]={
- "ACTOR",
- "ADAPT",
- "ADIOS",
- "ADULT",
- "ADMIT",
- "BAKER",
- "BASIS",
- "BEAST",
- "CAMEL",
- "CARGO",
- "CAUSE",
- "CHART",
- "CHILD",
- "DATUM",
- "DECAY",
- "DEOXY",
- "DITCH",
- "EAGLE",
- "ELVES",
- "ENZYM",
- "EPOCH",
- "FATTY",
- "FAULT",
- "FAUST",
- "FIFTH",
- "FILTH",
- "GAGES",
- "GENRE",
- "GERMS",
- "GIFTS",
- "GIVER",
- "GIVEN",
- "GUTSY",
- "HABIT",
- "HEATS",
- "HEAVY",
- "HORNY",
- "ICING",
- "IDIOT",
- "ITEMS",
- "IRONY",
- "JALOP",
- "JIFFS",
- "JIHAD",
- "JUDGE",
- "KAIAK",
- "KARMA",
- "KITTY",
- "KNIFE",
- "LAMER",
- "LASER",
- "LEVER",
- "LOAFS",
- "MACES",
- "MAFIA",
- "METER",
- "MEZZO",
- "NACHO",
- "NAILS",
- "NAMES",
- "NIGHT",
- "NINJA",
- "NURSE",
- "OBESE",
- "OILED",
- "OPIUM",
- "OVENS",
- "OXIDE",
- "PAINT",
- "PAIRS",
- "PENNY",
- "PLAIN",
- "PLATE",
- "QUANT",
- "QUEEN",
- "QUIET",
- "RAINY",
- "RAPID",
- "REARS",
- "ROOMS",
- "SAGAS",
- "SAGES",
- "SAVVY",
- "SCAPE",
- "SCENE",
- "TABLE",
- "TAPES",
- "TARGE",
- "TEACH",
- "UNBAN",
- "UNCUT",
- "USUAL",
- };
- int pointerPos=0;
- void delayprint(string s){
- if(s=="endl"){
- cout<<endl;
- pointerPos=0;
- return;
- }
- int length=s.length();
- int i=0;
- ofstream outf;
- while (i<length){
- Sleep(1);
- cout<<s[i]<<flush;
- i++;
- pointerPos++;
- if(pointerPos>30){
- cout<<endl;
- pointerPos=0;
- }
- }
- }
- int comparestrings(string s1, string s2){
- int hits=0;
- for(unsigned int i=0;i<s2.length();i++){
- if(tolower(s1[i])==tolower(s2[i]))
- hits++;
- }
- return hits;
- }
- int GetPassword(int add){
- srand(time(NULL)+add);
- int size=sizeof(pw5)/sizeof("ABC");
- int idx=rand()%size;
- return idx;
- }
- int randomrange(int x){
- srand(time(NULL));
- int idx=rand()%x;
- return idx;
- }
- int iRandHelp=0;
- int randHelp(){
- iRandHelp++;
- if(iRandHelp>50)
- iRandHelp=0;
- return iRandHelp;
- }
- char cRandoms[]={'&','$','=','(',')','/','!','?','§','[',']','{','}',',','.','-'};
- string randomchars(){
- string s="";
- srand(time(NULL)+randHelp());
- for(int i=0;i<rand()%30;i++){
- srand(time(NULL)+randHelp()+i);
- s=s+cRandoms[rand()%(sizeof(cRandoms)/sizeof('x'))];
- }
- return s;
- }
- void printmemory(void){
- for(int i=0;i<=COUNT_PASSWORDS;i++){
- delayprint(randomchars());
- delayprint(pw5[pw[i]]);
- delayprint(randomchars());
- }
- delayprint("endl");
- }
- int main(void){
- idx=randomrange(COUNT_PASSWORDS);
- for(int i=0;i<=COUNT_PASSWORDS;i++){
- for(int i2=0;i2<=COUNT_PASSWORDS;i2++){
- if(pw[i]!=pw[i2]){
- pw[i]=GetPassword(i);
- break;
- }
- }
- }
- bool bNextIsPasswort=false;
- bool loggedin=false;
- int attempts=0;
- delayprint("endl");
- while(exist&&attempts<4){
- string guess="";
- cin>>guess;
- if(guess=="exit")
- return EXIT_SUCCESS;
- if(!loggedin){
- if(bNextIsPasswort){
- if(guess.length()==5){
- int hits=comparestrings(guess, pw5[pw[idx]]);
- if(hits<5){
- cout<<hits;
- delayprint(" Matches, ");
- cout<<(3-attempts);
- delayprint(" attempts left");
- delayprint("endl");
- attempts++;
- }else{
- delayprint("SUCCESS! Perfect Match.");
- delayprint("endl");
- delayprint("The Secret Phrase is: ");
- delayprint("endl");
- Sleep(1000);
- delayprint("\"Need a dispenser here!\"");
- delayprint("endl");
- loggedin=true;
- }
- }else{
- delayprint("invalid length, ");
- cout<<(3-attempts);
- delayprint(" attempts left");
- delayprint("endl");
- attempts++;
- }
- if(attempts>=4){
- delayprint("No attempts left, exiting");
- Sleep(2000);
- }
- bNextIsPasswort=false;
- }else if (!bNextIsPasswort){
- if(guess=="printmem"){
- printmemory();
- }else if(guess=="help"){
- for(int i=0;ENTRIES_COMMANDS>i;i++){
- delayprint(aCommands[i]);
- delayprint("endl");
- }
- }else if(guess=="login"||guess=="password"){
- bNextIsPasswort=true;
- }else{
- delayprint("not a registered command");
- delayprint("endl");
- }
- }
- }
- }
- return EXIT_SUCCESS;
- }
Add Comment
Please, Sign In to add comment