X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=Client%20Applications%2Frcracki_mt%2FCrackEngine.cpp;h=0343588f38015dcead7af0a10818659b97a01cc4;hb=86bbf0fd5ba4e07d3279b4179fd8fc808198eaae;hp=1e00fce729b8a17b08db54b1293b762c6849b08a;hpb=5d57ae2db712bc64a209b349ed46ed5edbb65309;p=freerainbowtables diff --git a/Client Applications/rcracki_mt/CrackEngine.cpp b/Client Applications/rcracki_mt/CrackEngine.cpp index 1e00fce..0343588 100644 --- a/Client Applications/rcracki_mt/CrackEngine.cpp +++ b/Client Applications/rcracki_mt/CrackEngine.cpp @@ -3,7 +3,7 @@ * RainbowCrack * * Copyright (C) Zhu Shuanglei - * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Martin Westergaard Jørgensen * Copyright 2009, 2010 Daniël Niggebrugge * Copyright 2009, 2010 James Nobis * Copyright 2010 uroskn @@ -328,7 +328,7 @@ void CCrackEngine::SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainL bool pausing = false; - UINT4 nHashIndex; + uint32 nHashIndex; for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++) { #ifdef _WIN32 @@ -442,7 +442,7 @@ void CCrackEngine::SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainL threadPool.clear(); pThreads.clear(); - UINT4 thread_ID; + uint32 thread_ID; for (thread_ID = 0; thread_ID < (unsigned long)maxThreads; thread_ID++) { rcrackiThread* r_Thread = new rcrackiThread(TargetHash, thread_ID, nRainbowChainLen, maxThreads, pStartPosIndexE); @@ -511,7 +511,7 @@ void CCrackEngine::SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainL threadPool.push_back(r_Thread); } - UINT4 thread_ID = 0; + uint32 thread_ID = 0; int nPos; for (nPos = nRainbowChainLen - 2; nPos >= 0; nPos--) { @@ -655,7 +655,7 @@ void CCrackEngine::SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen, bool pausing = false; - UINT4 nHashIndex; + uint32 nHashIndex; for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++) { #ifdef _WIN32 @@ -772,7 +772,7 @@ void CCrackEngine::SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen, threadPool.clear(); pThreads.clear(); - UINT4 thread_ID; + uint32 thread_ID; for (thread_ID = 0; thread_ID < (unsigned long)maxThreads; thread_ID++) { rcrackiThread* r_Thread = new rcrackiThread(TargetHash, thread_ID, nRainbowChainLen, maxThreads, pStartPosIndexE); @@ -846,7 +846,7 @@ void CCrackEngine::SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen, threadPool.push_back(r_Thread); } - UINT4 thread_ID = 0; + uint32 thread_ID = 0; int nPos; for (nPos = nRainbowChainLen - 2; nPos >= 0; nPos--) { @@ -956,7 +956,7 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) vector sessionFinishedPathNames; if (ReadLinesFromFile(sProgressPathName.c_str(), sessionFinishedPathNames)) { - UINT4 i; + uint32 i; for (i = 0; i < sessionFinishedPathNames.size(); i++) { if (sessionFinishedPathNames[i] == sPathName) @@ -1002,9 +1002,9 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) // File length check bool doOldFormat = CChainWalkContext::isOldFormat(); bool doRti2Format = CChainWalkContext::isRti2Format(); - UINT4 sizeOfChain; + uint32 sizeOfChain; bool fVerified = false; - UINT4 nFileLen = GetFileLen(file); + long nFileLen = GetFileLen(file); if (doOldFormat) sizeOfChain = 16; @@ -1012,7 +1012,7 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) sizeOfChain = 8; //if (nFileLen % 8 != 0 || nRainbowChainCount * 8 != nFileLen) - if ( (nFileLen % sizeOfChain != 0 || nRainbowChainCount * sizeOfChain != nFileLen) && doRti2Format == false ) + if ( ( (unsigned long)nFileLen % sizeOfChain != 0 || nRainbowChainCount * sizeOfChain != (unsigned long)nFileLen) && doRti2Format == false ) printf("file length mismatch\n"); else { @@ -1044,11 +1044,16 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) } static CMemoryPool mp(bytesForChainWalkSet, debug, maxMem); - RainbowChainO* pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize); - #ifdef _WIN32 - if (debug) printf("Allocated %I64u bytes, filelen %lu\n", nAllocatedSize, (unsigned long)nFileLen); + RainbowChainO* pChain = NULL; + if(doRti2Format) { + pChain = (RainbowChainO*)mp.Allocate(pReader->GetChainsLeft() * 16, nAllocatedSize); + } else { + pChain = (RainbowChainO*)mp.Allocate(nFileLen, nAllocatedSize); + } + #if defined(_WIN32) && !defined(__GNUC__) + if (debug) printf("Allocated %I64 bytes, filelen %ld\n", nAllocatedSize, nFileLen); #else - if (debug) printf("Allocated %llu bytes, filelen %lu\n", nAllocatedSize, (unsigned long)nFileLen); + if (debug) printf("Allocated %llu bytes, filelen %ld\n", nAllocatedSize, nFileLen); #endif if (pChain != NULL) @@ -1059,18 +1064,20 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) //bool fVerified = false; while (true) // Chunk read loop { - if ((unsigned long)ftell(file) == nFileLen) + if (ftell(file) == nFileLen) break; // Load table chunk if (debug) printf("reading...\n"); - unsigned int nDataRead = 0, nDataToRead = 0; + unsigned int nDataRead = 0; gettimeofday( &tv, NULL ); if ( doRti2Format ) { - nDataToRead = nAllocatedSize / 16; - nDataRead = nDataToRead; + nDataRead = nAllocatedSize / 16; + if(pReader->GetChainsLeft() <= 0) // No more data + break; pReader->ReadChains(nDataRead, pChain); + nDataRead *= 8; // Convert from chains read to bytes } else @@ -1086,6 +1093,10 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) int nRainbowChainCountRead = nDataRead / 16; + if(doRti2Format) { + nRainbowChainCountRead = nDataRead / 8; + } + // Verify table chunk if (!fVerified) { @@ -1137,12 +1148,15 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) if (!hs.AnyHashLeftWithLen(CChainWalkContext::GetHashLen())) break; +/* + // XXX eliminated by PB - check correctness // finished the current table if( doRti2Format && nDataToRead > (nDataRead / 8) ) { delete pReader; break; } +*/ } } else @@ -1162,21 +1176,21 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) if(fIndex != NULL) { // File length check - unsigned int nFileLenIndex = GetFileLen(fIndex); + long nFileLenIndex = GetFileLen(fIndex); //unsigned int nRows = nFileLenIndex / 11; //unsigned int nSize = nRows * sizeof(IndexChain); //printf("Debug: 8\n"); if (nFileLenIndex % 11 != 0) - printf("index file length mismatch (%u bytes)\n", nFileLenIndex); + printf("index file length mismatch (%ld bytes)\n", nFileLenIndex); else { //printf("index nSize: %d\n", nSize); //pIndex = (IndexChain*)new unsigned char[nSize]; IndexChain *pIndex = (IndexChain*)mpIndex.Allocate(nFileLenIndex, nAllocatedSizeIndex); #ifdef _WIN32 - if (debug) printf("Debug: Allocated %I64u bytes for index with filelen %u\n", nAllocatedSizeIndex, nFileLenIndex); + if (debug) printf("Debug: Allocated %I64u bytes for index with filelen %ld\n", nAllocatedSizeIndex, nFileLenIndex); #else - if (debug) printf("Debug: Allocated %llu bytes for index with filelen %u\n", nAllocatedSizeIndex, nFileLenIndex); + if (debug) printf("Debug: Allocated %llu bytes for index with filelen %ld\n", nAllocatedSizeIndex, nFileLenIndex); #endif static CMemoryPool mp(bytesForChainWalkSet + nAllocatedSizeIndex, debug, maxMem); @@ -1187,7 +1201,7 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) fseek(fIndex, 0, SEEK_SET); - while ( (unsigned long)ftell(fIndex) != nFileLenIndex ) // Index chunk read loop + while ( ftell(fIndex) != nFileLenIndex ) // Index chunk read loop { // Load index chunk #ifdef _WIN32 @@ -1229,8 +1243,8 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs) //fseek(file, 0, SEEK_SET); //bool fVerified = false; - UINT4 nProcessedChains = 0; - while ( (unsigned long)ftell(file) != nFileLen + uint32 nProcessedChains = 0; + while ( ftell(file) != nFileLen && nProcessedChains < nCoveredRainbowTableChains ) // Chunk read loop { // Load table chunk @@ -1360,7 +1374,7 @@ void CCrackEngine::Run(vector vPathName, CHashSet& hs, int i_maxThreads, ResetStatistics(); // Sort vPathName (CChainWalkSet need it) - UINT4 i, j; + uint32 i, j; for (i = 0; i < vPathName.size() - 1; i++) for (j = 0; j < vPathName.size() - i - 1; j++) {