diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cac952..0ee3f2b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ set(SOURCE_FILES src/RH_Utils.cpp RH_Main.cpp COPYING - README + README.md ) #Ajout de openssl find_package(OpenSSL REQUIRED) @@ -36,4 +36,4 @@ link_libraries(${CMAKE_THREAD_LIBS_INIT}) #find_package(Crypto REQUIRED) -add_executable(testPassV8 ${SOURCE_FILES}) +add_executable(rizzlehash ${SOURCE_FILES}) diff --git a/RH_Main.cpp b/RH_Main.cpp index 750d0bc..f4a14e4 100644 --- a/RH_Main.cpp +++ b/RH_Main.cpp @@ -23,8 +23,6 @@ #include #include #include - -#include "include/RH_App.h" #include "include/RH_GUI.h" #include "include/RH_ProcessBruteForce.h" diff --git a/include/RH_Encryption.h b/include/RH_Encryption.h index b3a85b3..f51f72f 100644 --- a/include/RH_Encryption.h +++ b/include/RH_Encryption.h @@ -17,6 +17,11 @@ class RH_Encryption { public: RH_Encryption(); + static function getFunctionHashLambda(string hashMethode); + //static function hashForLambda(function functionLambda, string value); + virtual ~RH_Encryption(); + protected: + private: static function none(); static function md5(); static function sha1(); @@ -24,10 +29,7 @@ class RH_Encryption static function sha384(); static function sha256(); static function sha512(); - //static function hashForLambda(function functionLambda, string value); - virtual ~RH_Encryption(); - protected: - private: + static string bytesArrayToStrinctString(uint8_t, unsigned char*); }; #endif // RH_ENCRYPTION_H diff --git a/include/RH_ProcessBruteForce.h b/include/RH_ProcessBruteForce.h index 19143f5..825fc70 100644 --- a/include/RH_ProcessBruteForce.h +++ b/include/RH_ProcessBruteForce.h @@ -56,7 +56,6 @@ class ProcessBruteForce void operator()(); virtual ~ProcessBruteForce(); private: - function getFunctionHash(string hashMethode); void bruteForce(); void recursiveFunction(uint32_t index); void testSpeed(string currentWord); diff --git a/src/RH_Encryption.cpp b/src/RH_Encryption.cpp index 1937088..1eb9a32 100644 --- a/src/RH_Encryption.cpp +++ b/src/RH_Encryption.cpp @@ -23,52 +23,60 @@ RH_Encryption::RH_Encryption(){ } function RH_Encryption::md5(){ - - return [] (string value){ - const char* stringValue = value.c_str(); + function methode = [] (string value){ + const unsigned char* stringValue = (unsigned char *) value.c_str(); MD5_CTX md5; MD5_Init(&md5); MD5_Update(&md5,(const unsigned char*)stringValue, value.length()); - unsigned char buffer[16]; + unsigned char buffer[MD5_DIGEST_LENGTH]; MD5_Final(buffer, &md5); - char mdString[32]; - string result; - - for (uint16_t i = 0; i < 16; i++) { - sprintf(mdString, "%02x", buffer[i]); - result.append(mdString); - } - return result; + return bytesArrayToStrinctString(MD5_DIGEST_LENGTH,buffer); }; + return methode; } function RH_Encryption::sha1(){ return [](string value){ - return value; + const unsigned char* stringValue = (unsigned char *) value.c_str(); + unsigned char buffer[SHA_DIGEST_LENGTH]; + SHA(stringValue,value.length(),buffer); + return bytesArrayToStrinctString(SHA_DIGEST_LENGTH,buffer); }; } function RH_Encryption::sha224(){ return [](string value){ - return value; + const unsigned char* stringValue = (unsigned char *) value.c_str(); + unsigned char buffer[SHA224_DIGEST_LENGTH]; + SHA224(stringValue,value.length(),buffer); + return bytesArrayToStrinctString(SHA224_DIGEST_LENGTH,buffer); }; } function RH_Encryption::sha384(){ return [](string value){ - return value; + const unsigned char* stringValue = (unsigned char *) value.c_str(); + unsigned char buffer[SHA384_DIGEST_LENGTH]; + SHA384(stringValue,value.length(),buffer); + return bytesArrayToStrinctString(SHA384_DIGEST_LENGTH,buffer); }; } function RH_Encryption::sha256(){ return [](string value){ - return value; + const unsigned char* stringValue = (unsigned char *) value.c_str(); + unsigned char buffer[SHA256_DIGEST_LENGTH]; + SHA256(stringValue,value.length(),buffer); + return bytesArrayToStrinctString(SHA256_DIGEST_LENGTH,buffer); }; } function RH_Encryption::sha512( ){ return [](string value){ - return value; + const unsigned char* stringValue = (unsigned char *) value.c_str(); + unsigned char buffer[SHA512_DIGEST_LENGTH]; + SHA256(stringValue,value.length(),buffer); + return bytesArrayToStrinctString(SHA512_DIGEST_LENGTH,buffer); }; } @@ -78,10 +86,34 @@ function RH_Encryption::none(){ }; } +function RH_Encryption::getFunctionHashLambda(string hashMethode) { + function resultMethode; + + if (hashMethode == "md5") resultMethode = md5(); + else if(hashMethode == "sha1") resultMethode = sha1(); + else if(hashMethode == "sha224") resultMethode = sha224(); + else if(hashMethode == "sha384") resultMethode = sha384(); + else if(hashMethode == "sha256") resultMethode = sha256(); + else if(hashMethode == "sha512") resultMethode = sha512(); + else resultMethode = none(); + + return resultMethode; +} + + /*function RH_Encryption::hashForLambda(function functionLambda, string value){ return functionLambda(value); }*/ +string RH_Encryption::bytesArrayToStrinctString(uint8_t lenght, unsigned char * bytes) { + char resString[2]; + string result; + for (uint8_t i = 0; i < lenght; i++){ + sprintf(resString,"%02x", bytes[i]); + result.append(resString); + } + return result; +} RH_Encryption::~RH_Encryption(){ diff --git a/src/RH_ProcessBruteForce.cpp b/src/RH_ProcessBruteForce.cpp index 2bb451c..7598dcd 100644 --- a/src/RH_ProcessBruteForce.cpp +++ b/src/RH_ProcessBruteForce.cpp @@ -1,5 +1,5 @@ /* - * Copyright � 2015 Matthieu DUVAL, Rudy DUCHE + * Copyright © 2015 Matthieu DUVAL, Rudy DUCHE * * This file is part of RizzleHash. * @@ -36,7 +36,7 @@ void ProcessBruteForce::init(queue * q,int idx,int nbInstence,string this->idx = idx; this->nbInstence = nbInstence; this->hashString = hashString; - this->hashMethodeFunction = this->getFunctionHash(hashMethode); + this->hashMethodeFunction = RH_Encryption::getFunctionHashLambda(hashMethode); this->clef = clef; this->limite = limite; this->verbose = verbose; @@ -51,14 +51,6 @@ void ProcessBruteForce::init(queue * q,int idx,int nbInstence,string } } -function ProcessBruteForce::getFunctionHash(string hashMethode){ - if(hashMethode == "md5"){ - return RH_Encryption::md5(); - }else{ - return RH_Encryption::none(); - } -} - void ProcessBruteForce::operator()() { this->clock = time(NULL);// on initialise la clock locale