Advertisement
Guest User

Untitled

a guest
Feb 19th, 2014
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. char oText[] = {71, 114, 101, 97, 116, 32, 87, 111, 114, 107, 33};
  7. char kText[] = {70, 97, 105, 108, 101, 100, 33, 32, 84, 114, 121, 32, 105, 116, 32, 97, 110, 111, 116, 104, 101, 114, 32, 116, 105, 109, 101, 33};
  8. char uText[] = {85, 115, 101, 114, 58, 32};
  9. char pText[] = {80, 97, 115, 115, 119, 58, 32};
  10.  
  11. void WriteInfo()
  12. {
  13.   cout << "------------ Welcome to CrackMe1 ------------" << endl;
  14.   cout << "|                                           |" << endl;
  15.   cout << "| Objectives:                               |" << endl;
  16.   cout << "|   1. Patch me for any key                 |" << endl;
  17.   cout << "|   2. Create a keygen                      |" << endl;
  18.   cout << "|   3. Create a DLL to patch me             |" << endl;
  19.   cout << "|                                           |" << endl;
  20.   cout << "-------------- The game starts --------------" << endl;
  21.   cout << endl;
  22. }
  23.  
  24. int GetUser()
  25. {
  26.   string user;
  27.   cout << uText;
  28.   cin >> user;
  29.  
  30.   int result1 = 0;
  31.   int result2 = 0;
  32.  
  33.   for (int i=0; i < user.length(); ++i)// Makes a XOR between the char and (user.length()-i)*7 and addit to result1
  34.   {
  35.     int value = 0;
  36.     value = user[i];
  37.     result1 += value ^ (user.length() - i)*7;
  38.   }
  39.  
  40.   while (result1 != 0) // Reverse the value of result1 and changes individual values for his "opposite"
  41.   {
  42.     result2 = 10 - (result1 % 10);
  43.     result1 = result1/10;
  44.     result2 = result2*10;
  45.   }
  46.   return result2;
  47. }
  48.  
  49. string TransformPassw(string& passw) //Transforms the passw. If a number or char, rests 1, else convert the char to a char number
  50. {
  51.   for (int i=0; i < passw.length(); ++i)
  52.   {
  53.     if( (passw[i] >= 48 && passw[i] <= 57) || (passw[i] >= 65 && passw[i] <= 90) || (passw[i] >= 97 && passw[i] <= 122) )
  54.     {
  55.       switch(passw[i])
  56.       {
  57.     case 48: passw[i] = 57; break;
  58.     case 65: passw[i] = 122; break;
  59.     case 97: passw[i] = 90; break;
  60.       };
  61.     }
  62.     else passw[i] = 48 + (passw[i] % 10);
  63.   }
  64.   return passw;
  65. }
  66.  
  67. int GetPassw()
  68. {
  69.   string passw;
  70.   cout << pText;
  71.   cin >> passw;
  72.  
  73.   int pairs = 1;
  74.   int odds = 1;
  75.   passw = TransformPassw(passw);
  76.   for (int i=1; i < passw.length(); i += 2)
  77.   {
  78.     int value = passw[i-1];
  79.     passw[i-1] = passw[i];
  80.     passw[i] = value;
  81.    
  82.     pairs *= passw[i-1] / 10;
  83.     odds *= passw[i] % 10;
  84.   }
  85.   return (pairs+odds);
  86. }
  87.  
  88. bool CompareValues(int user, int passw)
  89. {
  90.   bool resul = ((user ^ 1234) == (passw ^ 4321));
  91.   if (resul) cout << oText << endl;
  92.   else cout << kText << endl;
  93.   return resul;
  94. }
  95.  
  96. int main()
  97. {
  98.   WriteInfo();
  99.  
  100.   bool reg = false;
  101.   while (!reg)
  102.   {
  103.     int user = GetUser();
  104.     int passw = GetPassw();
  105.     reg = CompareValues(user, passw);
  106.   }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement