Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include "include/CkZip.h"
- using namespace std;
- string createWord(char letters[], int ziffern[])
- {
- string word = "";
- for(int i=0; i<sizeof(ziffern); i++) { word += letters[ziffern[i]]; }
- return word;
- }
- bool testWord(string word)
- {
- CkZip zip;
- zip.UnlockComponent("Du hast es geschaft!.txt");
- zip.SetPassword(word.c_str());
- bool success = zip.OpenZip("Brut.zip");
- if(!success)
- {
- cout << "TRY FOR '" << word << "' - FALSE" << endl;
- return false;
- } else {
- cout << "TRY FOR '" << word << "' - TRUE" << endl;
- int numFilesUnzipped = zip.Unzip("extract");
- if(numFilesUnzipped < 0)
- {
- cout << "PACK OUT ERROR" << endl;
- }
- return true;
- }
- }
- int main()
- {
- /* --- informationen ---
- * ziffern: 6
- * buchstaben: abcdprsuw1234
- */
- // --- parameter ---
- char letters[] = "abcdprsuw1234";
- int length = 6;
- // --- ausrechnen ---
- int ziffern[length];
- for(int i=0; i<length; i++) { ziffern[i] = 0; }
- int times = 1;
- for(int i=0; i<length; i++) { times *= (sizeof(letters))-1; }
- // --- vordefinitionen ---
- string word;
- bool stop = false;
- for(int i=0; i<times; i++)
- {
- if(stop == false)
- {
- word = createWord(letters, ziffern);
- if(testWord(word)) { stop = true; }
- else
- {
- ziffern[sizeof(ziffern)-1]++;
- for(int i=sizeof(ziffern); i>0; i--)
- {
- if(ziffern[i] == sizeof(letters))
- {
- ziffern[i] = 0;
- ziffern[i-1]++;
- }
- }
- if(ziffern[0] == sizeof(letters))
- {
- cout << "ERROR: NO PASSWORD FOUND" << endl;
- stop = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement