2 RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
4 Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
7 #ifndef _CHAINWALKCONTEXT_H
8 #define _CHAINWALKCONTEXT_H
10 #include "HashRoutine.h"
15 unsigned char m_PlainCharset[255];
16 int m_nPlainCharsetLen;
19 string m_sPlainCharsetName;
20 string m_sPlainCharsetContent;
22 class CChainWalkContext
26 virtual ~CChainWalkContext();
29 static string m_sHashRoutineName;
30 static HASHROUTINE m_pHashRoutine; // Configuration
31 static int m_nHashLen; // Configuration
33 // static unsigned char m_PlainCharset[256]; // Configuration
34 // static unsigned char m_PlainCharset2[256]; // Configuration
35 static vector<stCharset> m_vCharset;
36 static int m_nPlainLenMinTotal, m_nPlainLenMaxTotal;
37 static uint64 m_nPlainSpaceUpToX[MAX_PLAIN_LEN + 1]; // Performance consideration
38 static uint64 m_nPlainSpaceTotal; // Performance consideration
39 static int m_nHybridCharset;
40 static int m_nRainbowTableIndex; // Configuration
41 static uint64 m_nReduceOffset; // Performance consideration
45 unsigned char m_Plain[MAX_PLAIN_LEN];
47 unsigned char m_Hash[MAX_HASH_LEN];
48 static unsigned char m_Salt[MAX_SALT_LEN];
49 static int m_nSaltLen;
51 static bool LoadCharset(string sCharset);
54 static bool SetHashRoutine(string sHashRoutineName); // Configuration
55 static bool SetPlainCharset(string sCharsetName, int nPlainLenMin, int nPlainLenMax); // Configuration
56 static bool SetRainbowTableIndex(int nRainbowTableIndex);
57 static bool SetSalt(unsigned char *Salt, int nSaltLength);// Configuration
58 static bool SetupWithPathName(string sPathName, int& nRainbowChainLen, int& nRainbowChainCount); // Wrapper
59 static string GetHashRoutineName();
60 static int GetHashLen();
61 static string GetPlainCharsetName();
62 static string GetPlainCharsetContent();
63 static int GetPlainLenMin();
64 static int GetPlainLenMax();
65 static uint64 GetPlainSpaceTotal();
66 static int GetRainbowTableIndex();
69 void GenerateRandomIndex();
70 void SetIndex(uint64 nIndex);
71 void SetHash(unsigned char* pHash); // The length should be m_nHashLen
75 void HashToIndex(int nPos);
78 const uint64* GetIndexPtr();
81 // string GetPlainBinary();
83 bool CheckHash(unsigned char* pHash); // The length should be m_nHashLen