Advertisement
Guest User

Untitled

a guest
Dec 7th, 2014
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdio.h>
  4. #include <array>
  5.  
  6. using namespace std;
  7.  
  8. string exec(const char* cmd) {
  9.     FILE* pipe = popen(cmd, "r");
  10.     if (!pipe) return "ERROR";
  11.     char buffer[128];
  12.     string result = "";
  13.     while(!feof(pipe)) {
  14.         if(fgets(buffer, 128, pipe) != NULL)
  15.             result += buffer;
  16.     }
  17.     pclose(pipe);
  18.     return result;
  19. }
  20.  
  21. string createWord(char letters[], int ziffern[])
  22. {
  23.     string word = "";
  24.    
  25.     for(int i=0; i<sizeof(ziffern); i++) { word += letters[ziffern[i]]; }
  26.    
  27.     return word;
  28. }
  29.  
  30. bool testWord(string word)
  31. {
  32.     string result = exec(("7za.exe e Brut.zip -p" + word + " -y").c_str());
  33.    
  34.     if(result[137] == 'D')
  35.     {
  36.         cout << "TRY FOR '" << word << "' - FALSE" << endl;
  37.         return false;
  38.     } else {
  39.         cout << "TRY FOR '" << word << "' - TRUE" << endl;
  40.         return true;
  41.     }
  42. }
  43.  
  44. int main()
  45. {
  46.     /* --- informationen ---
  47.      * ziffern: 6
  48.      * buchstaben: abcdefghijklmnopqrstuvwxyz12345
  49.     */
  50.    
  51.     // --- parameter ---
  52.     char letters[] = "abcdefghijklmnopqrstuvwxyz12345";
  53.     int length = 6;
  54.    
  55.     // --- ausrechnen ---
  56.     int ziffern[length];
  57.     for(int i=0; i<length; i++) { ziffern[i] = 0; }
  58.    
  59.     int times = 1;
  60.     for(int i=0; i<length; i++) { times *= (sizeof(letters))-1; }
  61.    
  62.     //int z1 = 0, z2 = 0, z3 = 0, z4 = 0, z5 = 0, z6 = 0;
  63.    
  64.     // --- vordefinitionen ---
  65.     string word;
  66.     bool stop = false;
  67.    
  68.     for(int i=0; i<times; i++)
  69.     {
  70.         if(stop == false)
  71.         {
  72.             word = createWord(letters, ziffern);
  73.             if(testWord(word)) { stop = true; }
  74.             else
  75.             {
  76.                 ziffern[sizeof(ziffern)-1]++;
  77.                 for(int i=sizeof(ziffern); i>0; i--)
  78.                 {
  79.                     if(ziffern[i] == sizeof(letters))
  80.                     {
  81.                         ziffern[i] = 0;
  82.                         ziffern[i-1]++;
  83.                     }
  84.                 }
  85.                 if(ziffern[0] == sizeof(letters))
  86.                 {
  87.                     cout << "ERROR: NO PASSWORD FOUND" << endl;
  88.                     stop = true;
  89.                 }
  90.             }
  91.         }
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement