skindervik

HASH_BREAKER_SERIES_V3/4

Jul 26th, 2020 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.57 KB | None | 0 0
  1. //MY CRAPPY YOUTUBE https://www.youtube.com/channel/UC9kD0oE90HfCZvMAPzRLf3w
  2.  
  3. #include<iostream>
  4. #include<math.h>
  5. #include<vector>
  6. #include<sstream>
  7. #include<openssl/sha.h>
  8. #include<iomanip>
  9.  
  10. int main() {
  11.  
  12.     //VERIABLES
  13.     char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  14.     std::vector<int> password = { 0 };
  15.  
  16.     SHA256_CTX sha256;
  17.     std::stringstream hash_input;
  18.     std::stringstream hash_output;
  19.     unsigned char hash[SHA256_DIGEST_LENGTH];
  20.  
  21.     //SIZES OF VERIABLES
  22.     int chars_length = (sizeof(chars) / sizeof(char))-1;
  23.     int password_length = password.size();
  24.  
  25.     //ADD AN ADDITIONAL CHARACTER TO PASSWORD VECTOR FOREVER IN A LOOP
  26.     while (true) {
  27.  
  28.         //CYCKLE TROUGH ALL OF THE COMBINATIONS
  29.         for (int i = 0; i < pow(chars_length, password_length); i++) {
  30.  
  31.             //CYCKLE TROUGH ALL OF THE VERIABLES IN ARRAY
  32.             for (int i2 = 0; i2 < password_length; i2++) {
  33.                 //IF VERIABLE IN "PASSWORD" ARRAY IS THE LAST VERIABLE IN CHAR "CHARS" ARRRAY
  34.                 if (password[i2] == chars_length) {
  35.                     //THEN INCREMENT THE NEXT VERIABLE IN "PASSWORD" ARRAY
  36.                     password[i2 + 1]++;
  37.                     //AND RESET THE VERIABLE BACK TO ZERO
  38.                     password[i2] = 0;
  39.                 }
  40.             }
  41.  
  42.             //CLEAR hash_input and hash_output
  43.             hash_input.str("");
  44.             hash_output.str("");
  45.  
  46.             //CREATE THE COMBINATION
  47.             for (int i2 = 0; i2 < password_length; i2++) {
  48.                 hash_input << chars[password[i2]];
  49.             }
  50.            
  51.             //CREATE THE HASH
  52.             SHA256_Init(&sha256);
  53.             SHA256_Update(&sha256, hash_input.str().c_str(), hash_input.str().size());
  54.             SHA256_Final(hash, &sha256);
  55.  
  56.             //CONVERT HASH TO PROPER HEX
  57.             for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
  58.             {
  59.                 hash_output << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
  60.             }
  61.  
  62.             //PRINT OUT THE HASH
  63.             std::cout << hash_input.str() << " = " << hash_output.str() << std::endl;
  64.  
  65.             //INCREMENT THE FIRST VERIABLE IN ARRAY
  66.             password[0]++;
  67.         }
  68.  
  69.         //ADDS ANOTHER CHARACTER TO THE PASSWORD VECTOR
  70.         password.push_back(0);
  71.  
  72.         //UPDATE THE SIZE OF THE PASSWORD VECTOR
  73.         password_length = password.size();
  74.  
  75.         //RESET PASSWORD VECTOR ELEMENTS BACK TO ZEROES
  76.         std::fill(password.begin(), password.end(), 0);
  77.     }
  78. }
Add Comment
Please, Sign In to add comment