How to Support New Hash Algorithm in RainbowCrack
Introduction
The time-memory tradeoff algorithm is hash algorithm independent, so rainbow table of any hash algorithm is possible.
In RainbowCrack 1.3 and later versions, all hash algorithms are implemented in dynamic link library (.dll of windows operating system).
This document describes the programming interface in c language.
Source Code
alglib.c:
#define MIN_HASH_LEN 8
#define MAX_HASH_LEN 32
void __stdcall MD5(
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
{
// implementation of the hash algorithm
// this function must be thread safe, because more than one thread may call this function concurrently
}
struct HashAlgorithmEntry
{
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
unsigned int uPlaintextLenMin; // minimum plaintext length, use 0 to support plaintext of any length
unsigned int uPlaintextLenMax; // maximum plaintext length, use 0xffffffff to support plaintext of any length
};
struct HashAlgorithmEntry HashAlgorithms[] = { // this symbol will be exported
{"md5", MD5, 16, 0, 0xffffffff},
// more entries...
{0, 0, 0, 0, 0}, // terminated by an entry of all zeroes
};
|
To Compile
The source code above can be compiled with Visual C++ 2005 Express Edition or Visual C++ 2008 Express Edition.
Use one of the following commands to compile:
cl /O2 alglib.c /LD /Fealglib0.dll /link /EXPORT:HashAlgorithms
cl /O2 alglib.c /LD /Fealglib1.dll /link /EXPORT:HashAlgorithms
cl /O2 alglib.c /LD /Fealglib2.dll /link /EXPORT:HashAlgorithms
Then put the outputted .dll file in RainbowCrack's directory.
The rtgen and rcrack program will search the hash algorithms in alglib0.dll, alglib1.dll and then alglib2.dll. The first one that matches the hash algorithm name and plaintext length requirement will be used.
Run rtgen or rcrack program without any parameter to list all hash algorithms implemented in alglib*.dll.
Copyright 2003-2012 RainbowCrack Project. All rights reserved.