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 #define stricmp strcasecmp
22 for(int i = 0; i < m_vIndices.size(); i++)
27 int CHashSet::GetLookupID(string sHash)
30 for (i = 0; i < m_vHash.size(); i++)
32 if(stricmp(m_vHash[i].c_str(),sHash.c_str()) == 0)
34 return m_vLookupIDs[i];
39 void CHashSet::AddHash(string sHash, uint64 *pIndices, int nLookupID)
41 if (sHash == "aad3b435b51404ee")
45 for (i = 0; i < m_vHash.size(); i++)
47 if (m_vHash[i] == sHash)
51 //printf("debug: adding hash %s\n", sHash.c_str());
53 m_vHash.push_back(sHash);
54 m_vFound.push_back(false);
55 m_vPlain.push_back("");
56 m_vBinary.push_back("");
57 m_vIndices.push_back(pIndices);
58 m_vLookupIDs.push_back(nLookupID);
60 m_vFoundChains.push_back(vec);
63 bool CHashSet::AnyhashLeft()
66 for (i = 0; i < m_vHash.size(); i++)
75 bool CHashSet::AnyHashLeftWithLen(int nLen)
78 for (i = 0; i < m_vHash.size(); i++)
81 if (m_vHash[i].size() == nLen * 2)
88 void CHashSet::GetLeftHashWithLen(vector<string>& vHash, vector<uint64 *>& vIndices, int nLen)
93 for (i = 0; i < m_vHash.size(); i++)
96 if (m_vHash[i].size() == nLen * 2)
98 vHash.push_back(m_vHash[i]);
99 vIndices.push_back(m_vIndices[i]);
104 void CHashSet::SetPlain(string sHash, string sPlain, string sBinary)
107 for (i = 0; i < m_vHash.size(); i++)
109 if(stricmp(m_vHash[i].c_str(),sHash.c_str()) == 0)
112 m_vPlain[i] = sPlain;
113 m_vBinary[i] = sBinary;
118 // Add a chain to verify (matching endpoint)
119 void CHashSet::AddChain(string sHash, FoundRainbowChain &Chain)
122 for (i = 0; i < m_vHash.size(); i++)
124 if(stricmp(m_vHash[i].c_str(),sHash.c_str()) == 0)
126 m_vFoundChains[i].push_back(Chain);
132 vector<RainbowChain> CHashSet::GetChains(string sHash)
135 for (i = 0; i < m_vHash.size(); i++)
137 if(stricmp(m_vHash[i].c_str(),sHash.c_str()) == 0)
139 return m_vFoundChains[i];
145 bool CHashSet::GetPlain(string sHash, string& sPlain, string& sBinary)
147 if (stricmp(sHash.c_str(),"aad3b435b51404ee") == 0)
155 for (i = 0; i < m_vHash.size(); i++)
157 if (m_vHash[i] == sHash)
161 sPlain = m_vPlain[i];
162 sBinary = m_vBinary[i];
171 int CHashSet::GetStatHashFound()
175 for (i = 0; i < m_vHash.size(); i++)
184 int CHashSet::GetStatHashTotal()
186 return m_vHash.size();
189 void CHashSet::GetFoundChains(map<string, VECTOR_CHAIN> &mHashList)
191 // map<string, string> *mHashList = new map<string, string>;
192 for(int i = 0; i < m_vHash.size(); i++)
194 mHashList[m_vHash[i]] = m_vFoundChains[i];