2 RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
4 Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
8 #pragma warning(disable : 4786)
11 #include "ChainWalkSet.h"
13 CChainWalkSet::CChainWalkSet()
15 m_sHashRoutineName = "";
16 m_sPlainCharsetName = "";
19 m_nRainbowTableIndex = 0;
20 m_nRainbowChainLen = 0;
23 CChainWalkSet::~CChainWalkSet()
28 void CChainWalkSet::DiscardAll()
30 //printf("debug: discarding all walk...\n");
32 list<ChainWalk>::iterator it;
33 for (it = m_lChainWalk.begin(); it != m_lChainWalk.end(); it++)
38 uint64* CChainWalkSet::RequestWalk(unsigned char* pHash, int nHashLen,
39 string sHashRoutineName,
40 string sPlainCharsetName, int nPlainLenMin, int nPlainLenMax,
41 int nRainbowTableIndex,
43 bool& fNewlyGenerated)
45 if ( m_sHashRoutineName != sHashRoutineName
46 || m_sPlainCharsetName != sPlainCharsetName
47 || m_nPlainLenMin != nPlainLenMin
48 || m_nPlainLenMax != nPlainLenMax
49 || m_nRainbowTableIndex != nRainbowTableIndex
50 || m_nRainbowChainLen != nRainbowChainLen)
54 m_sHashRoutineName = sHashRoutineName;
55 m_sPlainCharsetName = sPlainCharsetName;
56 m_nPlainLenMin = nPlainLenMin;
57 m_nPlainLenMax = nPlainLenMax;
58 m_nRainbowTableIndex = nRainbowTableIndex;
59 m_nRainbowChainLen = nRainbowChainLen;
62 memcpy(cw.Hash, pHash, nHashLen);
63 cw.pIndexE = new uint64[nRainbowChainLen - 1];
64 m_lChainWalk.push_back(cw);
66 fNewlyGenerated = true;
70 list<ChainWalk>::iterator it;
71 for (it = m_lChainWalk.begin(); it != m_lChainWalk.end(); it++)
73 if (memcmp(it->Hash, pHash, nHashLen) == 0)
75 fNewlyGenerated = false;
81 memcpy(cw.Hash, pHash, nHashLen);
82 cw.pIndexE = new uint64[nRainbowChainLen - 1];
83 m_lChainWalk.push_back(cw);
85 fNewlyGenerated = true;
89 void CChainWalkSet::DiscardWalk(uint64* pIndexE)
91 list<ChainWalk>::iterator it;
92 for (it = m_lChainWalk.begin(); it != m_lChainWalk.end(); it++)
94 if (it->pIndexE == pIndexE)
97 m_lChainWalk.erase(it);
102 printf("debug: pIndexE not found\n");