Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <stdio.h>
- #include <array>
- #include <sstream>
- using namespace std;
- string exec(const char* cmd) {
- FILE* pipe = popen(cmd, "r");
- if (!pipe) return "ERROR";
- char buffer[128];
- string result = "";
- while(!feof(pipe)) {
- if(fgets(buffer, 128, pipe) != NULL)
- result += buffer;
- }
- pclose(pipe);
- return result;
- }
- string createWord(char letters[], int ziffern[])
- {
- string word = "";
- for(int i=0; i<sizeof(ziffern); i++) { word += letters[ziffern[i]]; }
- return word;
- }
- void testWord(string word, stringstream *stream, bool *stop)
- {
- string result = exec(("7za.exe e Brut.zip -p" + word + " -y").c_str());
- if(result[137] == 'D')
- {
- stream << "TRY FOR '" << word << "' - FALSE" << endl;
- } else {
- stream << "TRY FOR '" << word << "' - TRUE" << endl;
- stop = true;
- }
- }
- int main()
- {
- /* --- informationen ---
- * ziffern: 6
- * buchstaben: abcdefghijklmnopqrstuvwxyz12345
- */
- // --- 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;
- stringstream stream;
- for(int i=0; i<times; i++)
- {
- if(i % 5000 == 0)
- {
- cout << stream;
- stream.str(string());
- }
- if(stop == false)
- {
- word = createWord(letters, ziffern);
- testWord(word, &stream, &stop);
- if(stop == false)
- {
- //ziffern[sizeof(ziffern)-1]++;
- ziffern[sizeof(ziffern) / sizeof(ziffern[0])]++;
- //for(int i=sizeof(ziffern); i>0; i--)
- for(int i=(sizeof(ziffern) / sizeof(ziffern[0])); i>0; i--)
- {
- if(ziffern[i] == (sizeof(letters) / sizeof(ziffern[0])))
- //if(ziffern[i] == sizeof(letters))
- {
- ziffern[i] = 0;
- ziffern[i-1]++;
- }
- }
- if(ziffern[0] == sizeof(letters))
- {
- stream << "ERROR: NO PASSWORD FOUND" << endl;
- stop = true;
- }
- }
- } else {
- cout << stream;
- stream.str(string());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement