Hash Algorithm Plugin Development


The time-memory tradeoff algorithm is general and rainbow table for any hash algorithm is possible.

RainbowCrack software supports some common hash algorithms implemented in alglib0.dll (Windows) or alglib0.so (Linux). To view the full list, just run rtgen program without any parameter.

Typical output:

hash algorithms implemented in alglib0.dll: lm, plaintext_len limit: 0 - 7 ntlm, plaintext_len limit: 0 - 15 md5, plaintext_len limit: 0 - 15 sha1, plaintext_len limit: 0 - 20 mysqlsha1, plaintext_len limit: 0 - 20 halflmchall, plaintext_len limit: 0 - 7 ntlmchall, plaintext_len limit: 0 - 15 oracle-SYSTEM, plaintext_len limit: 0 - 10 md5-half, plaintext_len limit: 0 - 15

To generate rainbow table for any hash algorithm not in that list, a hash algorithm plugin need be developed.

Source Code

Below is the source code of a fully functional hash algorithm plugin for RainbowCrack software, implementing MD5 algorithm.

File alglib1.cpp:

#include <openssl/md5.h> #ifdef _WIN32 #pragma comment(lib, "libeay32.lib") #endif #define MIN_HASH_LEN 8 #define MAX_HASH_LEN 32 void #ifdef _WIN32 __stdcall #endif TestMD5( unsigned char *pData, // [in] plaintext to be hashed unsigned int uLen, // [in] length of the plaintext unsigned char Hash[MAX_HASH_LEN]) // [out] the result hash, size of the buffer is MAX_HASH_LEN bytes { // This function must be thread safe, as more than one thread may call this function concurrently. // In this example, we directly call the MD5 function in openssl. MD5(pData, uLen, Hash); } struct HashAlgorithmEntry { const char *szName; // name of the hash algorithm void *pHashAlgorithm; // function pointer to the hash algorithm's implementation unsigned int uHashLen; // output length of the hash algorithm, MIN_HASH_LEN <= uHashLen <= MAX_HASH_LEN // input plaintext length range supported by the hash algorithm's implementation unsigned int uPlaintextLenMin; unsigned int uPlaintextLenMax; }; struct HashAlgorithmEntry HashAlgorithms[] = { // this symbol will be exported {"testmd5", (void *)TestMD5, 16, 0, 0xffffffff}, // more entries... {0, 0, 0, 0, 0}, // terminated by an entry of all zeroes };


To compile in Window (x86 or x64) with Visual C++:

cl /nologo /W3 /O2 /LD alglib1.cpp /link /EXPORT:HashAlgorithms

To compile in Linux (x84 or x86_64) with GCC:

g++ -Wall -O3 -shared -fPIC alglib1.cpp -o alglib1.so -lcrypto


Place the alglib1.dll or alglib1.so in RainbowCrack's directory.

Then generate some small rainbow tables:

rtgen md5 loweralpha 1 7 0 100 100 0 rtgen testmd5 loweralpha 1 7 0 100 100 0

The first command generates a rainbow table with built-in MD5 implementation of RainbowCrack software, and the second command generate a rainbow table with the plugin compiled above.

The two rainbow tables should be binary identical.

© 2003-2016 RainbowCrack Project