Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MY CRAPPY YOUTUBE https://www.youtube.com/channel/UC9kD0oE90HfCZvMAPzRLf3w
- #include<iostream>
- #include<math.h>
- #include<vector>
- #include<sstream>
- #include<openssl/sha.h>
- #include<iomanip>
- #include<chrono>
- int TO_DECIMAL(char input[], char input_size) {
- int output = 0;
- char input_type = 16, offset = 48;
- char int_set[] = { 0,1,2,3,4,5,6,7,8,9 ,'|','|','|','|','|','|','|', 10,11,12,13,14,15,16 };
- for (char i = 0; i < input_size; i++)
- output += int_set[input[i] - offset] * std::pow(input_type, input_size - i - 1);
- return output;
- }
- int main() {
- //USER INPUT VERIABLE
- unsigned char hash_to_brake_as_int[SHA256_DIGEST_LENGTH];
- //ASKS USER FOR INPUT
- char hash_to_brake[65];
- std::cout << "ENTER SHA256 HASH: \n";
- std::cin >> hash_to_brake;
- //CONVERTS 64 LONG HASH TO 32 CHAR LONG HASH
- for (int i = 0; i < 64; i+=2)
- {
- char hex[2];
- hex[0] = hash_to_brake[i];
- hex[1] = hash_to_brake[i+1];
- hash_to_brake_as_int[i / 2] = TO_DECIMAL(hex, 2);
- }
- //VERIABLES FOR COMBINATION CREATION
- char chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- std::vector<int> password = { 0 };
- char* hash_input = new char[password.size()];
- //SIZES OF VERIABLES FOR COMBINATION CREATION
- int chars_length = (sizeof(chars) / sizeof(char)) - 1;
- int password_length = password.size();
- //VERIABLES FOR HASH CREATION
- SHA256_CTX sha256;
- unsigned char hash[SHA256_DIGEST_LENGTH];
- //OTHER VERIABLES
- bool finished = false;
- //VERIABLES FOR STATUS
- int s = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
- int ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
- int hash_count = 0;
- //ADD AN ADDITIONAL CHARACTER TO PASSWORD VECTOR FOREVER IN A LOOP
- while (true) {
- //CYCKLE TROUGH ALL OF THE COMBINATIONS
- for (int i = 0; i < pow(chars_length, password_length); i++) {
- //CYCKLE TROUGH ALL OF THE VERIABLES IN ARRAY
- for (int i2 = 0; i2 < password_length; i2++) {
- //IF VERIABLE IN "PASSWORD" ARRAY IS THE LAST VERIABLE IN CHAR "CHARS" ARRRAY
- if (password[i2] == chars_length) {
- //THEN INCREMENT THE NEXT VERIABLE IN "PASSWORD" ARRAY
- password[i2 + 1]++;
- //AND RESET THE VERIABLE BACK TO ZERO
- password[i2] = 0;
- }
- }
- //CREATE THE COMBINATION
- for (int i2 = 0; i2 < password_length; i2++) {
- hash_input[i2] = chars[password[i2]];
- }
- //CREATE THE HASH
- SHA256_Init(&sha256);
- SHA256_Update(&sha256, hash_input, password_length);
- SHA256_Final(hash, &sha256);
- //COMPARE HASHES
- if (memcmp(hash, hash_to_brake_as_int, SHA256_DIGEST_LENGTH) == 0) {
- finished = true;
- break;
- }
- //UPDATE STATUS
- int ms_now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
- if (ms <= ms_now - 1000) {
- ms = ms_now;
- printf_s("%d h/s\n", hash_count);
- hash_count = 0;
- }
- hash_count++;
- //INCREMENT THE FIRST VERIABLE IN ARRAY
- password[0]++;
- }
- if (finished == true) break;
- //ADDS ANOTHER CHARACTER TO THE PASSWORD VECTOR
- password.push_back(0);
- //UPDATE THE SIZE OF THE PASSWORD VECTOR
- password_length = password.size();
- hash_input = new char[password_length];
- //RESET PASSWORD VECTOR ELEMENTS BACK TO ZEROES
- std::fill(password.begin(), password.end(), 0);
- }
- //REPORT WHEN CORRECT HASH IS FOUND
- int s_now = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
- std::cout << "completed in: " << s_now - s << "s\n";
- std::cout << hash_to_brake << " = ";
- for (size_t i = 0; i < password_length; i++)
- std::cout << hash_input[i];
- std::cout << "\n";
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement