Advertisement
skindervik

HASH_BREAKER_SERIES_V4/4

Jul 26th, 2020 (edited)
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.43 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. #include<chrono>
  10.  
  11. int TO_DECIMAL(char input[], char input_size) {
  12.     int output = 0;
  13.     char input_type = 16, offset = 48;
  14.     char int_set[] = { 0,1,2,3,4,5,6,7,8,9 ,'|','|','|','|','|','|','|', 10,11,12,13,14,15,16 };
  15.     for (char i = 0; i < input_size; i++)
  16.         output += int_set[input[i] - offset] * std::pow(input_type, input_size - i - 1);
  17.     return output;
  18. }
  19.  
  20. int main() {
  21.  
  22.     //USER INPUT VERIABLE
  23.     unsigned char hash_to_brake_as_int[SHA256_DIGEST_LENGTH];
  24.  
  25.     //ASKS USER FOR INPUT
  26.     char hash_to_brake[65];
  27.     std::cout << "ENTER SHA256 HASH: \n";
  28.     std::cin >> hash_to_brake;
  29.    
  30.     //CONVERTS 64 LONG HASH TO 32 CHAR LONG HASH
  31.     for (int i = 0; i < 64; i+=2)
  32.     {
  33.         char hex[2];
  34.         hex[0] = hash_to_brake[i];
  35.         hex[1] = hash_to_brake[i+1];
  36.         hash_to_brake_as_int[i / 2] = TO_DECIMAL(hex, 2);
  37.        
  38.     }
  39.  
  40.     //VERIABLES FOR COMBINATION CREATION
  41.     char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  42.     std::vector<int> password = { 0 };
  43.     char* hash_input = new char[password.size()];
  44.  
  45.     //SIZES OF VERIABLES FOR COMBINATION CREATION
  46.     int chars_length = (sizeof(chars) / sizeof(char)) - 1;
  47.     int password_length = password.size();
  48.  
  49.     //VERIABLES FOR HASH CREATION
  50.     SHA256_CTX sha256;
  51.     unsigned char hash[SHA256_DIGEST_LENGTH];
  52.  
  53.     //OTHER VERIABLES
  54.     bool finished = false;
  55.  
  56.     //VERIABLES FOR STATUS
  57.     int s = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
  58.     int ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
  59.     int hash_count = 0;
  60.  
  61.     //ADD AN ADDITIONAL CHARACTER TO PASSWORD VECTOR FOREVER IN A LOOP
  62.     while (true)  {
  63.  
  64.         //CYCKLE TROUGH ALL OF THE COMBINATIONS
  65.         for (int i = 0; i < pow(chars_length, password_length); i++) {
  66.  
  67.             //CYCKLE TROUGH ALL OF THE VERIABLES IN ARRAY
  68.             for (int i2 = 0; i2 < password_length; i2++) {
  69.                 //IF VERIABLE IN "PASSWORD" ARRAY IS THE LAST VERIABLE IN CHAR "CHARS" ARRRAY
  70.                 if (password[i2] == chars_length) {
  71.                     //THEN INCREMENT THE NEXT VERIABLE IN "PASSWORD" ARRAY
  72.                     password[i2 + 1]++;
  73.                     //AND RESET THE VERIABLE BACK TO ZERO
  74.                     password[i2] = 0;
  75.                 }
  76.             }
  77.  
  78.              //CREATE THE COMBINATION
  79.              for (int i2 = 0; i2 < password_length; i2++) {
  80.                  hash_input[i2] = chars[password[i2]];
  81.              }
  82.            
  83.  
  84.  
  85.             //CREATE THE HASH
  86.             SHA256_Init(&sha256);
  87.             SHA256_Update(&sha256, hash_input, password_length);
  88.             SHA256_Final(hash, &sha256);
  89.          
  90.             //COMPARE HASHES
  91.             if (memcmp(hash, hash_to_brake_as_int, SHA256_DIGEST_LENGTH) == 0) {
  92.                 finished = true;
  93.                 break;
  94.             }
  95.  
  96.             //UPDATE STATUS
  97.             int ms_now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
  98.             if (ms <= ms_now - 1000) {
  99.                 ms = ms_now;
  100.                
  101.                 printf_s("%d h/s\n", hash_count);
  102.  
  103.                 hash_count = 0;
  104.             }
  105.             hash_count++;
  106.  
  107.             //INCREMENT THE FIRST VERIABLE IN ARRAY
  108.             password[0]++;
  109.         }
  110.  
  111.         if (finished == true) break;
  112.  
  113.         //ADDS ANOTHER CHARACTER TO THE PASSWORD VECTOR
  114.         password.push_back(0);
  115.  
  116.         //UPDATE THE SIZE OF THE PASSWORD VECTOR
  117.         password_length = password.size();
  118.         hash_input = new char[password_length];
  119.  
  120.         //RESET PASSWORD VECTOR ELEMENTS BACK TO ZEROES
  121.         std::fill(password.begin(), password.end(), 0);
  122.     }
  123.  
  124.     //REPORT WHEN CORRECT HASH IS FOUND
  125.     int s_now = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
  126.     std::cout << "completed in: " << s_now - s << "s\n";
  127.     std::cout << hash_to_brake << " = ";
  128.     for (size_t i = 0; i < password_length; i++)
  129.         std::cout << hash_input[i];
  130.     std::cout << "\n";
  131.     system("pause");
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement