Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- w3b_cr4ck v1.0
- */
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <ctime>
- #include "parse_args.hpp"
- using namespace std;
- bool VERBOSE = false;
- bool RANDOMIZE = false;
- enum Hash_Type { NaN = -1, MD5 = 1, SHA1 = 2 } HT = NaN;
- int w3b_cr4ck(int, int, string);
- char *display_date_time() {
- time_t uts;
- struct tm *time_info;
- time(&uts);
- time_info = localtime(&uts);
- return(asctime(time_info));
- }
- bool set_hash_type(string hash) {
- for(unsigned int x = 0; x < hash.length(); x++)
- {
- if(!(((hash[x] > (0x2F)) && (hash[x] < (0x3A))) || ((hash[x] > (0x60)) && (hash[x] < (0x67)))))
- {
- cout << "\n\n~! hash is invalid !~\n\n";
- return(false);
- }
- }
- switch(hash.length())
- {
- case(32):
- HT = MD5;
- if(VERBOSE) cout << "\nHASH TYPE : MD5\n";
- return(true);
- case(40):
- HT = SHA1;
- if(VERBOSE) cout << "\nHASH TYPE : SHA1\n";
- return(true);
- default:
- cout << "\n\n~! hash is invalid !~\n\n";
- return(false);
- }
- }
- int main(int argc, char *argv[]) {
- cout << "\nw3b_cr4ck started " << display_date_time();
- options opts = parse_args(argc, argv);
- if(!opts.single_hash.empty())
- {
- if(set_hash_type(opts.single_hash))
- {
- if(VERBOSE) cout << "attempting to crack " << opts.single_hash;
- w3b_cr4ck(HT, opts.top, opts.single_hash);
- } else return(-1);
- } else { // file of hashes
- ifstream FILE(opts.file_loc.c_str());
- if(FILE.is_open())
- {
- char hash[41];
- float cracked = 0, total = 0;
- if(VERBOSE) cout << endl << opts.file_loc.c_str() << "opened succesfully!\n\n";
- while(1337)
- {
- FILE.getline(hash, 41);
- if(FILE.eof()) break;
- if(set_hash_type(hash))
- {
- if(VERBOSE) cout << "attempting to crack " << hash << endl;
- cracked += w3b_cr4ck(HT, opts.top, hash);
- total += 1;
- } else cout << "\nskipping to the next hash\n";
- }
- if(VERBOSE)
- {
- cout.precision(4);
- cout << "\ncracked (" << cracked << " / " << total << ") valid hashes [ " << ((cracked*100)/total) << "% ]\n";
- }
- } else {
- cout << "\n\n~! Unable to open file !~\n\n";
- return(-1);
- }
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement