From 0fb676244827a448dc60118d6558c4a4e346ffee Mon Sep 17 00:00:00 2001 From: James Nobis Date: Tue, 2 Nov 2010 21:42:12 -0500 Subject: [PATCH] UINT4 -> uint32 misc cleanup merge some of the separate copies of files into the common versions --- Client Applications/converti2/Makefile | 6 +- .../rcracki_mt/ChainWalkContext.cpp | 34 +-- .../rcracki_mt/ChainWalkContext.h | 1 - .../rcracki_mt/CrackEngine.cpp | 28 +- .../rcracki_mt/HashAlgorithm.cpp | 12 +- .../rcracki_mt/HashRoutine.cpp | 4 +- Client Applications/rcracki_mt/HashSet.cpp | 16 +- Client Applications/rcracki_mt/MemoryPool.cpp | 4 +- Client Applications/rcracki_mt/MemoryPool.h | 2 +- Client Applications/rcracki_mt/Public.cpp | 69 ++++- Client Applications/rcracki_mt/Public.h | 5 +- Client Applications/rcracki_mt/RTI2Reader.cpp | 12 +- Client Applications/rcracki_mt/RTI2Reader.h | 7 +- .../rcracki_mt/RainbowCrack.cpp | 28 +- Client Applications/rcracki_mt/fast_md5.cpp | 26 +- Client Applications/rcracki_mt/global.h | 5 +- Client Applications/rcracki_mt/lm2ntlm.cpp | 2 +- Client Applications/rcracki_mt/md4.cpp | 16 +- .../rcracki_mt/rcrackiThread.cpp | 4 +- Client Applications/rcracki_mt/sha1.cpp | 14 +- Client Applications/rti2rto/Makefile | 3 + Client Applications/rti2rto/rti2rto.cpp | 4 +- Common/rt api/BaseRTReader.cpp | 25 +- Common/rt api/BaseRTReader.h | 30 ++- Common/rt api/ChainWalkContext.cpp | 33 ++- Common/rt api/ChainWalkContext.h | 40 ++- Common/rt api/ChainWalkSet.cpp | 239 +++++++++++++++++- Common/rt api/ChainWalkSet.h | 40 ++- Common/rt api/HashAlgorithm.cpp | 9 +- Common/rt api/HashRoutine.cpp | 29 ++- Common/rt api/HashRoutine.h | 27 +- Common/rt api/MemoryPool.cpp | 47 +++- Common/rt api/MemoryPool.h | 31 ++- Common/rt api/Public.cpp | 231 ++++++++++++++--- Common/rt api/Public.h | 37 ++- Common/rt api/RTI2Reader.cpp | 59 ++++- Common/rt api/RTI2Reader.h | 36 ++- Common/rt api/RTIReader.cpp | 11 +- Common/rt api/md4.cpp | 22 +- 39 files changed, 986 insertions(+), 262 deletions(-) diff --git a/Client Applications/converti2/Makefile b/Client Applications/converti2/Makefile index d3715df..6323267 100644 --- a/Client Applications/converti2/Makefile +++ b/Client Applications/converti2/Makefile @@ -19,8 +19,8 @@ clean: rebuild: clean all -MemoryPool.o: $(COMMON_API_PATH)/MemoryPool.h $(COMMON_API_PATH)/MemoryPool.cpp Public.h +MemoryPool.o: $(COMMON_API_PATH)/MemoryPool.h $(COMMON_API_PATH)/MemoryPool.cpp $(COMMON_API_PATH)/Public.h $(CC) $(CFLAGS) $(COMMON_API_PATH)/MemoryPool.cpp -Public.o: Public.h Public.cpp - $(CC) $(CFLAGS) Public.cpp +Public.o: $(COMMON_API_PATH)/Public.h $(COMMON_API_PATH)/Public.cpp + $(CC) $(CFLAGS) $(COMMON_API_PATH)/Public.cpp diff --git a/Client Applications/rcracki_mt/ChainWalkContext.cpp b/Client Applications/rcracki_mt/ChainWalkContext.cpp index ae58f77..417d900 100644 --- a/Client Applications/rcracki_mt/ChainWalkContext.cpp +++ b/Client Applications/rcracki_mt/ChainWalkContext.cpp @@ -83,14 +83,19 @@ bool CChainWalkContext::LoadCharset(string sName) bool readCharset = false; vector vLine; - if ( ReadLinesFromFile("charset.txt", vLine) ) - readCharset = true; - else if ( ReadLinesFromFile(GetApplicationPath() + "charset.txt", vLine) ) - readCharset = true; - - if (readCharset) + #ifdef BOINC + if ( boinc_ReadLinesFromFile( "charset.txt", vLine ) ) + readCharset = true; + #else + if ( ReadLinesFromFile("charset.txt", vLine) ) + readCharset = true; + else if ( ReadLinesFromFile(GetApplicationPath() + "charset.txt", vLine) ) + readCharset = true; + #endif + + if ( readCharset ) { - UINT4 i; + uint32 i; for (i = 0; i < vLine.size(); i++) { // Filter comment @@ -107,7 +112,7 @@ bool CChainWalkContext::LoadCharset(string sName) // sCharsetName charset check bool fCharsetNameCheckPass = true; - UINT4 j; + uint32 j; for (j = 0; j < sCharsetName.size(); j++) { if ( !isalpha(sCharsetName[j]) @@ -178,6 +183,7 @@ bool CChainWalkContext::LoadCharset(string sName) } else printf("can't open charset configuration file\n"); + return false; } @@ -218,7 +224,7 @@ bool CChainWalkContext::SetPlainCharset(string sCharsetName, int nPlainLenMin, i m_nPlainLenMaxTotal = 0; m_nPlainLenMinTotal = 0; uint64 nTemp = 1; - UINT4 j, k = 1; + uint32 j, k = 1; for(j = 0; j < m_vCharset.size(); j++) { int i; @@ -476,7 +482,7 @@ void CChainWalkContext::IndexToPlain() for (i = m_nPlainLen - 1; i >= 0; i--) { int nCharsetLen = 0; - for(UINT4 j = 0; j < m_vCharset.size(); j++) + for(uint32 j = 0; j < m_vCharset.size(); j++) { nCharsetLen += m_vCharset[j].m_nPlainLenMax; if(i < nCharsetLen) // We found the correct charset @@ -503,7 +509,7 @@ void CChainWalkContext::IndexToPlain() #endif int nCharsetLen = 0; - for(UINT4 j = 0; j < m_vCharset.size(); j++) + for(uint32 j = 0; j < m_vCharset.size(); j++) { nCharsetLen += m_vCharset[j].m_nPlainLenMax; if(i < nCharsetLen) // We found the correct charset @@ -515,11 +521,11 @@ void CChainWalkContext::IndexToPlain() } } - UINT4 nIndexOfX32 = (UINT4)nIndexOfX; + uint32 nIndexOfX32 = (uint32)nIndexOfX; for (; i >= 0; i--) { int nCharsetLen = 0; - for(UINT4 j = 0; j < m_vCharset.size(); j++) + for(uint32 j = 0; j < m_vCharset.size(); j++) { nCharsetLen += m_vCharset[j].m_nPlainLenMax; if(i < nCharsetLen) // We found the correct charset @@ -528,14 +534,12 @@ void CChainWalkContext::IndexToPlain() // m_Plain[i] = m_vCharset[j].m_PlainCharset[nIndexOfX32 % m_vCharset[j].m_nPlainCharsetLen]; // nIndexOfX32 /= m_vCharset[j].m_nPlainCharsetLen; - // moving nPlainCharsetLen into the asm body and avoiding the extra temp // variable results in a performance gain // unsigned int nPlainCharsetLen = m_vCharset[j].m_nPlainCharsetLen; unsigned int nTemp; #if defined(_WIN32) && !defined(__GNUC__) - // VC++ still needs this unsigned int nPlainCharsetLen = m_vCharset[j].m_nPlainCharsetLen; diff --git a/Client Applications/rcracki_mt/ChainWalkContext.h b/Client Applications/rcracki_mt/ChainWalkContext.h index 154daee..7262fff 100644 --- a/Client Applications/rcracki_mt/ChainWalkContext.h +++ b/Client Applications/rcracki_mt/ChainWalkContext.h @@ -85,7 +85,6 @@ public: static bool isOldFormat(); static bool isRti2Format(); - void SetIndex(uint64 nIndex); void SetHash(unsigned char* pHash); // The length should be m_nHashLen diff --git a/Client Applications/rcracki_mt/CrackEngine.cpp b/Client Applications/rcracki_mt/CrackEngine.cpp index 1e00fce..d36ebbc 100644 --- a/Client Applications/rcracki_mt/CrackEngine.cpp +++ b/Client Applications/rcracki_mt/CrackEngine.cpp @@ -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 { @@ -1059,7 +1059,7 @@ 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 @@ -1229,8 +1229,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 +1360,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++) { diff --git a/Client Applications/rcracki_mt/HashAlgorithm.cpp b/Client Applications/rcracki_mt/HashAlgorithm.cpp index bf04682..4206340 100644 --- a/Client Applications/rcracki_mt/HashAlgorithm.cpp +++ b/Client Applications/rcracki_mt/HashAlgorithm.cpp @@ -296,11 +296,7 @@ void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash) unicode_user[i*2] = username[i]; unicode_user[i*2+1] = 0x00; } - /* - MD4_Init(&ctx); - MD4_Update(&ctx,unicode_pwd,nPlainLen*2); - MD4_Final(final1,&ctx); - */ + MD4_NEW( (unsigned char*)unicode_pwd, nPlainLen*2, final1 ); MD4_Init(&ctx); @@ -314,7 +310,7 @@ void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash) { unicode_pwd[i*2] = pPlain[i]; unicode_pwd[i*2+1] = 0x00; - }*/ + }*/ /* unsigned char *buf = (unsigned char*)calloc(MSCACHE_HASH_SIZE + nSaltLength, sizeof(unsigned char)); HashNTLM(pPlain, nPlainLen, buf, NULL); @@ -396,10 +392,6 @@ void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) memcpy (pass,pPlain,nPlainLen); - /*MD5_CTX ctx; - MD5_Init(&ctx); - MD5_Update(&ctx, (unsigned char *) pass, MD5_DIGEST_LENGTH); - MD5_Final(final, &ctx);*/ fast_MD5((unsigned char *) pass, MD5_DIGEST_LENGTH, final); char* p = (char*) temp; diff --git a/Client Applications/rcracki_mt/HashRoutine.cpp b/Client Applications/rcracki_mt/HashRoutine.cpp index c85193f..148f46b 100644 --- a/Client Applications/rcracki_mt/HashRoutine.cpp +++ b/Client Applications/rcracki_mt/HashRoutine.cpp @@ -71,7 +71,7 @@ void CHashRoutine::AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRout string CHashRoutine::GetAllHashRoutineName() { string sRet; - UINT4 i; + uint32 i; for (i = 0; i < vHashRoutineName.size(); i++) sRet += vHashRoutineName[i] + " "; @@ -80,7 +80,7 @@ string CHashRoutine::GetAllHashRoutineName() void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen) { - UINT4 i; + uint32 i; for (i = 0; i < vHashRoutineName.size(); i++) { if (sHashRoutineName == vHashRoutineName[i]) diff --git a/Client Applications/rcracki_mt/HashSet.cpp b/Client Applications/rcracki_mt/HashSet.cpp index 683af0b..dedb2ba 100644 --- a/Client Applications/rcracki_mt/HashSet.cpp +++ b/Client Applications/rcracki_mt/HashSet.cpp @@ -42,7 +42,7 @@ void CHashSet::AddHash(string sHash) if (sHash == "aad3b435b51404ee") return; - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (m_vHash[i] == sHash) @@ -72,7 +72,7 @@ string CHashSet::GetHashInfo(int i) bool CHashSet::AnyhashLeft() { - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (!m_vFound[i]) @@ -84,7 +84,7 @@ bool CHashSet::AnyhashLeft() bool CHashSet::AnyHashLeftWithLen(int nLen) { - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (!m_vFound[i]) @@ -99,7 +99,7 @@ void CHashSet::GetLeftHashWithLen(vector& vHash, int nLen) { vHash.clear(); - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (!m_vFound[i]) @@ -110,7 +110,7 @@ void CHashSet::GetLeftHashWithLen(vector& vHash, int nLen) void CHashSet::AddHashInfo(string sHash, bool found, string sPlain, string sBinary) { - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (m_vHash[i] == sHash) @@ -125,7 +125,7 @@ void CHashSet::AddHashInfo(string sHash, bool found, string sPlain, string sBina void CHashSet::SetPlain(string sHash, string sPlain, string sBinary) { - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (m_vHash[i] == sHash) @@ -147,7 +147,7 @@ bool CHashSet::GetPlain(string sHash, string& sPlain, string& sBinary) return true; } - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (m_vHash[i] == sHash) @@ -167,7 +167,7 @@ bool CHashSet::GetPlain(string sHash, string& sPlain, string& sBinary) int CHashSet::GetStatHashFound() { int nHashFound = 0; - UINT4 i; + uint32 i; for (i = 0; i < m_vHash.size(); i++) { if (m_vFound[i]) diff --git a/Client Applications/rcracki_mt/MemoryPool.cpp b/Client Applications/rcracki_mt/MemoryPool.cpp index 3673446..5c634c0 100644 --- a/Client Applications/rcracki_mt/MemoryPool.cpp +++ b/Client Applications/rcracki_mt/MemoryPool.cpp @@ -91,8 +91,8 @@ unsigned char* CMemoryPool::Allocate(unsigned int nFileLen, uint64& nAllocatedSi m_pMem = new (nothrow) unsigned char[nTargetSize]; while (m_pMem == NULL && nTargetSize >= 32 * 1024 * 1024 ) { - nTargetSize -= 16 * 1024 * 1024; - m_pMem = new (nothrow) unsigned char[nTargetSize]; + nTargetSize -= 16 * 1024 * 1024; + m_pMem = new (nothrow) unsigned char[nTargetSize]; } if (m_pMem != NULL) diff --git a/Client Applications/rcracki_mt/MemoryPool.h b/Client Applications/rcracki_mt/MemoryPool.h index 62ae527..6c82fc1 100644 --- a/Client Applications/rcracki_mt/MemoryPool.h +++ b/Client Applications/rcracki_mt/MemoryPool.h @@ -3,7 +3,7 @@ * RainbowCrack * * Copyright (C) Zhu Shuanglei - * Copyright Martin Westergaard Jørgensen + * Copyright 2010 Martin Westergaard Jørgensen * Copyright 2009, 2010 Daniël Niggebrugge * Copyright 2009, 2010 James Nobis * Copyright 2010 uroskn diff --git a/Client Applications/rcracki_mt/Public.cpp b/Client Applications/rcracki_mt/Public.cpp index 41a9515..946c79d 100644 --- a/Client Applications/rcracki_mt/Public.cpp +++ b/Client Applications/rcracki_mt/Public.cpp @@ -129,11 +129,13 @@ timeval sub_timeofday( timeval tv2, timeval tv ) return final; } -unsigned int GetFileLen(FILE* file) +long GetFileLen(FILE* file) { - long int pos = ftell(file); + // XXX on x86/x86_64 linux returns long + // 32-bit this is a problem if the file is > (2^31-1) bytes + long pos = ftell(file); fseek(file, 0, SEEK_END); - long int len = ftell(file); + long len = ftell(file); fseek(file, pos, SEEK_SET); return len; @@ -170,7 +172,7 @@ bool GetHybridCharsets(string sCharset, vector& vCharset) string sChar = sCharset.substr(nStart + 1, nEnd - nStart - 1); vector vParts; SeperateString(sChar, ",", vParts); - for(UINT4 i = 0; i < vParts.size(); i++) + for(uint32 i = 0; i < vParts.size(); i++) { tCharset stCharset; vector vParts2; @@ -184,6 +186,55 @@ bool GetHybridCharsets(string sCharset, vector& vCharset) } return true; } +#ifdef BOINC +bool boinc_ReadLinesFromFile(string sPathName, vector& vLine) +{ + vLine.clear(); + char input_path[512]; + boinc_resolve_filename(sPathName.c_str(), input_path, sizeof(input_path)); + FILE *file = boinc_fopen(input_path, "rb"); + if (!file) { + fprintf(stderr, + "Couldn't find input file, resolved name %s.\n", input_path + ); + exit(-1); + } + + if (file != NULL) + { + unsigned int len = GetFileLen(file); + char* data = new char[len + 1]; + fread(data, 1, len, file); + data[len] = '\0'; + string content = data; + content += "\n"; + delete [] data; + + unsigned int i; + for (i = 0; i < content.size(); i++) + { + if (content[i] == '\r') + content[i] = '\n'; + } + + string::size_type n; + while ((n = content.find("\n", 0)) != string::npos) + { + string line = content.substr(0, n); + line = TrimString(line); + if (line != "") + vLine.push_back(line); + content = content.substr(n + 1); + } + + fclose(file); + } + else + return false; + + return true; +} +#endif bool ReadLinesFromFile(string sPathName, vector& vLine) { vLine.clear(); @@ -303,7 +354,7 @@ string HexToStr(const unsigned char* pData, int nLen) return sRet; } -uint64 GetAvailPhysMemorySize() +unsigned long GetAvailPhysMemorySize() { #if defined(_WIN32) MEMORYSTATUS ms; @@ -335,10 +386,11 @@ string GetApplicationPath() GetModuleFileName(NULL, fullPath, FILENAME_MAX); #else char szTmp[32]; - // XXX linux/proc file system dependen + // XXX linux/proc file system dependent sprintf(szTmp, "/proc/%d/exe", getpid()); int bytes = readlink(szTmp, fullPath, FILENAME_MAX); - if(bytes >= 0) + + if( bytes >= 0 ) fullPath[bytes] = '\0'; #endif @@ -352,13 +404,12 @@ string GetApplicationPath() if ( nIndex != string::npos ) sApplicationPath = sApplicationPath.substr(0, nIndex+1); - //printf ("\n\nDebug: The application directory is %s\n", sApplicationPath.c_str()); return sApplicationPath; } void ParseHash(string sHash, unsigned char* pHash, int& nHashLen) { - UINT4 i; + uint32 i; for (i = 0; i < sHash.size() / 2; i++) { string sSub = sHash.substr(i * 2, 2); diff --git a/Client Applications/rcracki_mt/Public.h b/Client Applications/rcracki_mt/Public.h index 27d4dcd..d359371 100644 --- a/Client Applications/rcracki_mt/Public.h +++ b/Client Applications/rcracki_mt/Public.h @@ -121,14 +121,15 @@ void tty_flush(void); timeval sub_timeofday( timeval tv2, timeval tv ); -unsigned int GetFileLen(FILE* file); +long GetFileLen(FILE* file); string TrimString(string s); +bool boinc_ReadLinesFromFile(string sPathName, vector& vLine); bool ReadLinesFromFile(string sPathName, vector& vLine); bool SeperateString(string s, string sSeperator, vector& vPart); string uint64tostr(uint64 n); string uint64tohexstr(uint64 n); string HexToStr(const unsigned char* pData, int nLen); -uint64 GetAvailPhysMemorySize(); +unsigned long GetAvailPhysMemorySize(); string GetApplicationPath(); void ParseHash(string sHash, unsigned char* pHash, int& nHashLen); bool GetHybridCharsets(string sCharset, vector& vCharset); diff --git a/Client Applications/rcracki_mt/RTI2Reader.cpp b/Client Applications/rcracki_mt/RTI2Reader.cpp index 692c73e..abd8550 100644 --- a/Client Applications/rcracki_mt/RTI2Reader.cpp +++ b/Client Applications/rcracki_mt/RTI2Reader.cpp @@ -45,11 +45,11 @@ RTI2Reader::RTI2Reader(string Filename) } m_chainPosition = 0; - unsigned int len = GetFileLen(pFileIndex); + long len = GetFileLen(pFileIndex); fseek(pFileIndex, 0, SEEK_SET); m_pIndex = new unsigned char[len]; - if(fread(m_pIndex, 1, len, pFileIndex) != len) + if(fread(m_pIndex, 1, len, pFileIndex) != (unsigned long)len) { printf("Error while reading index file"); exit(1); @@ -59,15 +59,15 @@ RTI2Reader::RTI2Reader(string Filename) memcpy(m_pHeader, m_pIndex, sizeof(RTI2Header)); m_pHeader->m_cppos = (unsigned int*)(m_pIndex + 8); m_pHeader->prefixstart = *(uint64*)(m_pIndex + 8 + (m_pHeader->rti_cplength * 4)); - m_chainsizebytes = (UINT4)ceil((float)(m_pHeader->rti_startptlength + m_pHeader->rti_endptlength + m_pHeader->rti_cplength) / 8); // Get the size of each chain in bytes - m_indexrowsizebytes = (UINT4)ceil((float)m_pHeader->rti_index_numchainslength / 8); + m_chainsizebytes = (uint32)ceil((float)(m_pHeader->rti_startptlength + m_pHeader->rti_endptlength + m_pHeader->rti_cplength) / 8); // Get the size of each chain in bytes + m_indexrowsizebytes = (uint32)ceil((float)m_pHeader->rti_index_numchainslength / 8); // Check the filesize fseek(m_pFile, 0, SEEK_END); len = ftell(m_pFile); fseek(m_pFile, 0, SEEK_SET); if(len % m_chainsizebytes > 0) { - printf("Invalid filesize %u\n", len); + printf("Invalid filesize %ld\n", len); return; } @@ -83,7 +83,7 @@ RTI2Reader::~RTI2Reader(void) unsigned int RTI2Reader::GetChainsLeft() { - int len = GetFileLen(m_pFile); + long len = GetFileLen(m_pFile); return len / m_chainsizebytes - m_chainPosition; } diff --git a/Client Applications/rcracki_mt/RTI2Reader.h b/Client Applications/rcracki_mt/RTI2Reader.h index cd36e7d..3545035 100644 --- a/Client Applications/rcracki_mt/RTI2Reader.h +++ b/Client Applications/rcracki_mt/RTI2Reader.h @@ -3,7 +3,6 @@ * RainbowCrack * * Copyright 2010 Martin Westergaard Jørgensen - * Copyright 2010 Daniël Niggebrugge * Copyright 2010 James Nobis * * This file is part of rcracki_mt. @@ -49,12 +48,12 @@ class RTI2Reader : BaseRTReader { private: FILE *m_pFile; - UINT4 m_chainPosition; + uint32 m_chainPosition; unsigned char *m_pPos, *m_pChainPos; static RTI2Header *m_pHeader; unsigned char *m_pIndex; - UINT4 m_chainsizebytes; - UINT4 m_indexrowsizebytes; + uint32 m_chainsizebytes; + uint32 m_indexrowsizebytes; public: diff --git a/Client Applications/rcracki_mt/RainbowCrack.cpp b/Client Applications/rcracki_mt/RainbowCrack.cpp index 2959787..8120354 100644 --- a/Client Applications/rcracki_mt/RainbowCrack.cpp +++ b/Client Applications/rcracki_mt/RainbowCrack.cpp @@ -183,7 +183,7 @@ bool NormalizeHash(string& sHash) return false; // Make lower - UINT4 i; + uint32 i; for (i = 0; i < sNormalizedHash.size(); i++) { if (sNormalizedHash[i] >= 'A' && sNormalizedHash[i] <= 'F') @@ -207,7 +207,7 @@ void LoadLMHashFromPwdumpFile(string sPathName, vector& vUserName, vecto vector vLine; if (ReadLinesFromFile(sPathName, vLine)) { - UINT4 i; + uint32 i; for (i = 0; i < vLine.size(); i++) { vector vPart; @@ -241,7 +241,7 @@ void LoadLMHashFromCainLSTFile(string sPathName, vector& vUserName, vect vector vLine; if (ReadLinesFromFile(sPathName, vLine)) { - UINT4 i; + uint32 i; for (i = 0; i < vLine.size(); i++) { vector vPart; @@ -313,7 +313,7 @@ bool LMPasswordCorrectCase(string sLMPassword, unsigned char* pNTLMHash, string& } unsigned char* pLMPassword = new unsigned char[sLMPassword.size() * 2]; - UINT4 i; + uint32 i; for (i = 0; i < sLMPassword.size(); i++) { pLMPassword[i * 2 ] = sLMPassword[i]; @@ -399,7 +399,7 @@ int main(int argc, char* argv[]) } if (readFromIni) { - UINT4 i; + uint32 i; for (i = 0; i < vLine.size(); i++) { if (vLine[i].substr(0,1) != "#") @@ -540,7 +540,7 @@ int main(int argc, char* argv[]) vector sSessionData; if (ReadLinesFromFile(sSessionPathName.c_str(), sSessionData)) { - UINT4 i; + uint32 i; for (i = 0; i < sSessionData.size(); i++) { vector vPart; @@ -581,7 +581,7 @@ int main(int argc, char* argv[]) // don't load these if we are resuming a session that already has a list of tables if (useDefaultRainbowTablePath && !resumeSession) { - UINT4 i; + uint32 i; for (i = 0; i < vDefaultRainbowTablePath.size(); i++) { vector vPart; @@ -630,7 +630,7 @@ int main(int argc, char* argv[]) vector vLine; if (ReadLinesFromFile(sPathName, vLine)) { - UINT4 i; + uint32 i; for (i = 0; i < vLine.size(); i++) { string sHash = vLine[i]; @@ -676,13 +676,13 @@ int main(int argc, char* argv[]) if (fCrackerType) { - UINT4 i; + uint32 i; for (i = 0; i < vHash.size(); i++) hs.AddHash(vHash[i]); } else { - UINT4 i; + uint32 i; for (i = 0; i < vLMHash.size(); i++) { hs.AddHash(vLMHash[i].substr(0, 16)); @@ -696,7 +696,7 @@ int main(int argc, char* argv[]) vector sSessionData; if (ReadLinesFromFile(sSessionPathName.c_str(), sSessionData)) { - UINT4 i; + uint32 i; for (i = 0; i < sSessionData.size(); i++) { vector vPart; @@ -732,7 +732,7 @@ int main(int argc, char* argv[]) buffer += "sInputType=" + sInputType + "\n"; buffer += "sInput=" + sInput + "\n"; - UINT4 i; + uint32 i; for (i = 0; i < vPathName.size(); i++) { buffer += "sPathName=" + vPathName[i] + "\n"; @@ -786,7 +786,7 @@ int main(int argc, char* argv[]) printf("-------------------------------------------------------\n"); if (fCrackerType) { - UINT4 i; + uint32 i; for (i = 0; i < vHash.size(); i++) { string sPlain, sBinary; @@ -801,7 +801,7 @@ int main(int argc, char* argv[]) } else { - UINT4 i; + uint32 i; for (i = 0; i < vLMHash.size(); i++) { string sPlain1, sBinary1; diff --git a/Client Applications/rcracki_mt/fast_md5.cpp b/Client Applications/rcracki_mt/fast_md5.cpp index 514be09..934e9c6 100644 --- a/Client Applications/rcracki_mt/fast_md5.cpp +++ b/Client Applications/rcracki_mt/fast_md5.cpp @@ -245,7 +245,7 @@ #ifndef MD5_pad_w1 -static inline UINT4 MD5_pad_w1(UINT4 data) +static inline uint32 MD5_pad_w1(uint32 data) { // XXX x86 specific __asm__ ( @@ -263,7 +263,7 @@ static inline UINT4 MD5_pad_w1(UINT4 data) #endif #ifndef MD5_pad_w3 -static inline UINT4 MD5_pad_w3(UINT4 data) +static inline uint32 MD5_pad_w3(uint32 data) { // XXX x86 specific __asm__ ( @@ -279,7 +279,7 @@ static inline UINT4 MD5_pad_w3(UINT4 data) #endif -static inline void MD5_copy_pad_block(UINT4 *dData, UINT4 *wIn, int blocklen, int len) +static inline void MD5_copy_pad_block(uint32 *dData, uint32 *wIn, int blocklen, int len) { register int cl; @@ -313,7 +313,7 @@ static inline void MD5_copy_pad_block(UINT4 *dData, UINT4 *wIn, int blocklen, in // fast initializer array //__attribute__((aligned(16))) //__declspec(align(16)) -static const UINT4 CC[4] = {Ca, Cb, Cc, Cd}; +static const uint32 CC[4] = {Ca, Cb, Cc, Cd}; @@ -323,13 +323,13 @@ static const UINT4 CC[4] = {Ca, Cb, Cc, Cd}; */ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest) { - #define wIn ((UINT4 *)pData) - #define wOut ((UINT4 *)pDigest) + #define wIn ((uint32 *)pData) + #define wOut ((uint32 *)pDigest) - register UINT4 a; - register UINT4 b; - register UINT4 c; - register UINT4 d; + register uint32 a; + register uint32 b; + register uint32 c; + register uint32 d; switch (len) { case 0: @@ -383,7 +383,7 @@ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest) } // data block used for padding - UINT4 dData[16]; + uint32 dData[16]; if (len < 56) { // 16 < length < 56 @@ -404,7 +404,7 @@ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest) } else { // len >= 56 - #define wIn ((UINT4 *)pData) + #define wIn ((uint32 *)pData) // original len int tlen = len; @@ -479,7 +479,7 @@ void fast_MD5(unsigned char *pData, int len, unsigned char *pDigest) ); #undef wIn - #define wIn ((UINT4 *)pData) + #define wIn ((uint32 *)pData) return; } } diff --git a/Client Applications/rcracki_mt/global.h b/Client Applications/rcracki_mt/global.h index 952aab4..9e6cbf1 100644 --- a/Client Applications/rcracki_mt/global.h +++ b/Client Applications/rcracki_mt/global.h @@ -24,8 +24,6 @@ #ifndef _GLOBAL_H #define _GLOBAL_H -//#include - #if defined(_WIN32) && !defined(__GNUC__) #define uint64 unsigned __int64 #else @@ -38,11 +36,14 @@ #if defined(_WIN32) && !defined(__GNUC__) #define UINT4 unsigned __int32 + #define uint32 unsigned __int32 #else #ifndef u_int32_t #define UINT4 unsigned int + #define uint32 unsigned int #else #define UINT4 u_int32_t + #define uint32 u_int32_t #endif #endif diff --git a/Client Applications/rcracki_mt/lm2ntlm.cpp b/Client Applications/rcracki_mt/lm2ntlm.cpp index 33fd94d..c3d3858 100644 --- a/Client Applications/rcracki_mt/lm2ntlm.cpp +++ b/Client Applications/rcracki_mt/lm2ntlm.cpp @@ -50,7 +50,7 @@ bool LM2NTLMcorrector::LMPasswordCorrectUnicode(string hexPassword, unsigned cha { string sPlain = ""; - UINT4 i; + uint32 i; for (i = 0; i < hexPassword.size() / 2; i++) { string sSub = hexPassword.substr(i * 2, 2); diff --git a/Client Applications/rcracki_mt/md4.cpp b/Client Applications/rcracki_mt/md4.cpp index e5d9c2f..34ae50e 100644 --- a/Client Applications/rcracki_mt/md4.cpp +++ b/Client Applications/rcracki_mt/md4.cpp @@ -42,11 +42,11 @@ (a) = ROTATE_LEFT ((a), (s)); \ } #define GG(a, b, c, d, x, s) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \ + (a) += G ((b), (c), (d)) + (x) + (uint32)0x5a827999; \ (a) = ROTATE_LEFT ((a), (s)); \ } #define HH(a, b, c, d, x, s) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \ + (a) += H ((b), (c), (d)) + (x) + (uint32)0x6ed9eba1; \ (a) = ROTATE_LEFT ((a), (s)); \ } #define S11 3 @@ -66,8 +66,8 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) { // access data as 4-byte word - #define uData ((UINT4 *)pData) - #define uDigest ((UINT4 *)pDigest) + #define uData ((uint32 *)pData) + #define uDigest ((uint32 *)pDigest) // pad word and append bit at appropriate location #define MD4_pad_w0() (0x00000080) @@ -76,12 +76,12 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) #define MD4_pad_w3(data) (((data) & 0x00FFFFFF) | 0x80000000) // For the hash working space - //__attribute__((aligned(16))) UINT4 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - //__declspec(align(16)) UINT4 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - UINT4 data[MD4_DIGEST_LENGTH] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + //__attribute__((aligned(16))) uint32 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + //__declspec(align(16)) uint32 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + uint32 data[MD4_DIGEST_LENGTH] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // For the output result - UINT4 a,b,c,d; + uint32 a,b,c,d; switch (length) { diff --git a/Client Applications/rcracki_mt/rcrackiThread.cpp b/Client Applications/rcracki_mt/rcrackiThread.cpp index 0b64a7a..b960bbc 100644 --- a/Client Applications/rcracki_mt/rcrackiThread.cpp +++ b/Client Applications/rcracki_mt/rcrackiThread.cpp @@ -139,7 +139,7 @@ void rcrackiThread::PreCalculate() void rcrackiThread::CheckAlarm() { - UINT4 i; + uint32 i; for (i = 0; i < t_pChainsFound.size(); i++) { RainbowChain* t_pChain = t_pChainsFound[i]; @@ -179,7 +179,7 @@ void rcrackiThread::CheckAlarm() void rcrackiThread::CheckAlarmO() { - UINT4 i; + uint32 i; for (i = 0; i < t_pChainsFoundO.size(); i++) { RainbowChainO* t_pChain = t_pChainsFoundO[i]; diff --git a/Client Applications/rcracki_mt/sha1.cpp b/Client Applications/rcracki_mt/sha1.cpp index 40c0e9f..e121854 100644 --- a/Client Applications/rcracki_mt/sha1.cpp +++ b/Client Applications/rcracki_mt/sha1.cpp @@ -82,12 +82,12 @@ void SHA1_NEW( unsigned char * pData, int length, unsigned char * pDigest) if (length > 16) return; - UINT4 Message_Block_Index = 0; + uint32 Message_Block_Index = 0; union { unsigned char Message_Block[64]; - UINT4 Message_Block_W[16]; + uint32 Message_Block_W[16]; }; Message_Block_W[0] = 0x00000000; @@ -96,7 +96,7 @@ void SHA1_NEW( unsigned char * pData, int length, unsigned char * pDigest) Message_Block_W[3] = 0x00000000; Message_Block_W[4] = 0x00000000; - UINT4 Intermediate_Hash[5] = { H0, H1, H2, H3, H4 }; + uint32 Intermediate_Hash[5] = { H0, H1, H2, H3, H4 }; memcpy(Message_Block, pData, length); Message_Block_Index += length; @@ -104,12 +104,12 @@ void SHA1_NEW( unsigned char * pData, int length, unsigned char * pDigest) //padMessage Message_Block[length] = 0x80; - UINT4 W_15 = length << 3; + uint32 W_15 = length << 3; int t; /* Loop counter */ - UINT4 temp; /* Temporary word value */ - UINT4 W[80]; /* Word sequence */ - UINT4 A, B, C, D, E; /* Word buffers */ + uint32 temp; /* Temporary word value */ + uint32 W[80]; /* Word sequence */ + uint32 A, B, C, D, E; /* Word buffers */ /* * Initialize the first 16 words in the array W diff --git a/Client Applications/rti2rto/Makefile b/Client Applications/rti2rto/Makefile index 3eadfbf..f9ca133 100644 --- a/Client Applications/rti2rto/Makefile +++ b/Client Applications/rti2rto/Makefile @@ -19,6 +19,9 @@ clean: debug: DEBUG += -DDEBUG -g debug: all +m32: DEBUG += -m32 +m32: rti2rto + rebuild: clean all MemoryPool.o: $(COMMON_API_PATH)/MemoryPool.h $(COMMON_API_PATH)/MemoryPool.cpp $(COMMON_API_PATH)/Public.h diff --git a/Client Applications/rti2rto/rti2rto.cpp b/Client Applications/rti2rto/rti2rto.cpp index e4ee4fc..e69ed18 100644 --- a/Client Applications/rti2rto/rti2rto.cpp +++ b/Client Applications/rti2rto/rti2rto.cpp @@ -117,7 +117,7 @@ void ConvertRainbowTable(string sPathName, string sResultFileName, string sType) while(reader->GetChainsLeft() > 0) { reader->ReadChains(nChains, pChain); - for(UINT4 i = 0; i < nChains; i++) + for(uint32 i = 0; i < nChains; i++) { fwrite(&pChain[i], 1, 16, fResult); } @@ -158,7 +158,7 @@ int main(int argc, char* argv[]) printf("no rainbow table found\n"); return 0; } - for (UINT4 i = 0; i < vPathName.size(); i++) + for (uint32 i = 0; i < vPathName.size(); i++) { string sResultFile, sType; diff --git a/Common/rt api/BaseRTReader.cpp b/Common/rt api/BaseRTReader.cpp index d762e26..5e08a97 100644 --- a/Common/rt api/BaseRTReader.cpp +++ b/Common/rt api/BaseRTReader.cpp @@ -1,2 +1,25 @@ -#include "BaseRTReader.h" +/* + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright 2010 Martin Westergaard Jørgensen + * Copyright 2010 Daniël Niggebrugge + * Copyright 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ +#include "BaseRTReader.h" diff --git a/Common/rt api/BaseRTReader.h b/Common/rt api/BaseRTReader.h index b94114f..66f2f10 100644 --- a/Common/rt api/BaseRTReader.h +++ b/Common/rt api/BaseRTReader.h @@ -1,11 +1,37 @@ +/* + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright 2010 Martin Westergaard Jørgensen + * Copyright 2010 Daniël Niggebrugge + * Copyright 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ + #ifndef __BASERTREADER_H__ #define __BASERTREADER_H__ #include "Public.h" #include -#ifdef WIN32 -#include + +#if defined(_WIN32) && !defined(__GNUC__) + #include #endif + using namespace std; class BaseRTReader diff --git a/Common/rt api/ChainWalkContext.cpp b/Common/rt api/ChainWalkContext.cpp index 52c9091..f551d63 100644 --- a/Common/rt api/ChainWalkContext.cpp +++ b/Common/rt api/ChainWalkContext.cpp @@ -8,7 +8,7 @@ * Copyright 2009, 2010 James Nobis * Copyright 2010 Yngve AAdlandsvik * - * This file is part of rcracki_mt. + * This file is part of freerainbowtables. * * freerainbowtables is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,8 @@ int CChainWalkContext::m_nHashLen; int CChainWalkContext::m_nPlainLenMinTotal = 0; int CChainWalkContext::m_nPlainLenMaxTotal = 0; int CChainWalkContext::m_nHybridCharset = 0; +bool CChainWalkContext::isOldRtFormat = false; +bool CChainWalkContext::isRti2RtFormat = false; vector CChainWalkContext::m_vCharset; uint64 CChainWalkContext::m_nPlainSpaceUpToX[MAX_PLAIN_LEN + 1]; uint64 CChainWalkContext::m_nPlainSpaceTotal; @@ -280,13 +282,24 @@ bool CChainWalkContext::SetupWithPathName(string sPathName, int& nRainbowChainLe printf("%s is not a rainbow table\n", sPathName.c_str()); return false; } - /* - if (sPathName.substr(sPathName.size() - 4) != ".rti") + if (sPathName.substr(sPathName.size() - 5) == ".rti2") + { + isRti2RtFormat = true; + } + else if (sPathName.substr(sPathName.size() - 4) == ".rti") + { + isOldRtFormat = false; + } + else if (sPathName.substr(sPathName.size() - 3) == ".rt") + { + isOldRtFormat = true; + } + else { printf("%s is not a rainbow table\n", sPathName.c_str()); return false; } -*/ + // Parse vector vPart; if (!SeperateString(sPathName, "___x_", vPart)) @@ -475,6 +488,7 @@ void CChainWalkContext::IndexToPlain() } } } + #elif defined(_M_X64) || defined(_M_IX86) || defined(__i386__) || defined(__x86_64__) // Fast ia32 version @@ -488,6 +502,7 @@ void CChainWalkContext::IndexToPlain() if (nIndexOfX < 0x100000000llu) break; #endif + int nCharsetLen = 0; for(uint32 j = 0; j < m_vCharset.size(); j++) { @@ -620,3 +635,13 @@ bool CChainWalkContext::CheckHash(unsigned char* pHash) return false; } + +bool CChainWalkContext::isOldFormat() +{ + return isOldRtFormat; +} + +bool CChainWalkContext::isRti2Format() +{ + return isRti2RtFormat; +} diff --git a/Common/rt api/ChainWalkContext.h b/Common/rt api/ChainWalkContext.h index de7e2fb..9854c59 100644 --- a/Common/rt api/ChainWalkContext.h +++ b/Common/rt api/ChainWalkContext.h @@ -1,8 +1,26 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #ifndef _CHAINWALKCONTEXT_H #define _CHAINWALKCONTEXT_H @@ -13,7 +31,7 @@ typedef struct { unsigned char m_PlainCharset[255]; - int m_nPlainCharsetLen; + unsigned int m_nPlainCharsetLen; int m_nPlainLenMin; int m_nPlainLenMax; string m_sPlainCharsetName; @@ -25,17 +43,16 @@ public: CChainWalkContext(); virtual ~CChainWalkContext(); -private: +//private: static string m_sHashRoutineName; static HASHROUTINE m_pHashRoutine; // Configuration static int m_nHashLen; // Configuration - -// static unsigned char m_PlainCharset[256]; // Configuration -// static unsigned char m_PlainCharset2[256]; // Configuration + static bool isOldRtFormat; + static bool isRti2RtFormat; static vector m_vCharset; static int m_nPlainLenMinTotal, m_nPlainLenMaxTotal; - static uint64 m_nPlainSpaceUpToX[MAX_PLAIN_LEN + 1]; // Performance consideration static uint64 m_nPlainSpaceTotal; // Performance consideration + static uint64 m_nPlainSpaceUpToX[MAX_PLAIN_LEN + 1]; // Performance consideration static int m_nHybridCharset; static int m_nRainbowTableIndex; // Configuration static uint64 m_nReduceOffset; // Performance consideration @@ -65,8 +82,9 @@ public: static uint64 GetPlainSpaceTotal(); static int GetRainbowTableIndex(); static void Dump(); + static bool isOldFormat(); + static bool isRti2Format(); -// void GenerateRandomIndex(); void SetIndex(uint64 nIndex); void SetHash(unsigned char* pHash); // The length should be m_nHashLen diff --git a/Common/rt api/ChainWalkSet.cpp b/Common/rt api/ChainWalkSet.cpp index a081eb8..e2d71c9 100644 --- a/Common/rt api/ChainWalkSet.cpp +++ b/Common/rt api/ChainWalkSet.cpp @@ -1,10 +1,29 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ - Copyright (C) Zhu Shuanglei -*/ - -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) #pragma warning(disable : 4786) #endif @@ -18,6 +37,9 @@ CChainWalkSet::CChainWalkSet() m_nPlainLenMax = 0; m_nRainbowTableIndex = 0; m_nRainbowChainLen = 0; + debug = false; + sPrecalcPathName = ""; + preCalcPart = 0; } CChainWalkSet::~CChainWalkSet() @@ -31,17 +53,207 @@ void CChainWalkSet::DiscardAll() list::iterator it; for (it = m_lChainWalk.begin(); it != m_lChainWalk.end(); it++) - delete it->pIndexE; + delete [] it->pIndexE; m_lChainWalk.clear(); } +string CChainWalkSet::CheckOrRotatePreCalcFile() +{ + char sPreCalcFileName[255]; + + // 255 files limit to be sure + for (; preCalcPart < 255; preCalcPart++) + { + sprintf(sPreCalcFileName, "%s.%d", sPrecalcPathName.c_str(), preCalcPart); + string sReturnPreCalcPath(sPreCalcFileName); + + unsigned int fileLen = 0; + + FILE* file = fopen(sReturnPreCalcPath.c_str(), "ab"); + if(file!=NULL) + { + fileLen = GetFileLen(file); + long unsigned int nextFileLen = fileLen + (sizeof(uint64) * (m_nRainbowChainLen-1)); + // Rotate to next file if we are going to pass 2GB filesize + if (nextFileLen < ((unsigned)2 * 1024 * 1024 * 1024)) + { + // We might want to vPrecalcFiles.push_back(sReturnPreCalcPath) if we just created this file + // We don't as only newly generated chainwalksets will be stored to this new file, so we don't have to look there + if (debug) printf("Debug: Using for precalc: %s\n", sReturnPreCalcPath.c_str()); + fclose(file); + return sReturnPreCalcPath; + } + fclose(file); + } + } + + return string(""); +} + +void CChainWalkSet::updateUsedPrecalcFiles() +{ + // we might also use this function to search a wildcard path of precalc files + vPrecalcFiles.clear(); + char sPreCalcFileName[255]; + + int i; + // 255 files max + for (i = 0; i < 255; i++) + { + sprintf(sPreCalcFileName, "%s.%d", sPrecalcPathName.c_str(), i); + string sTryPreCalcPath(sPreCalcFileName); + FILE* file = fopen(sTryPreCalcPath.c_str(), "rb"); + if(file!=NULL) { + vPrecalcFiles.push_back(sTryPreCalcPath); + fclose(file); + } + else { + break; + } + } +} + +void CChainWalkSet::removePrecalcFiles() +{ + if (debug) printf("Debug: Removing precalc files.\n"); + updateUsedPrecalcFiles(); + string sCurrentPrecalcPathName = ""; + string sCurrentPrecalcIndexPathName = ""; + + int i; + for (i = 0; i < (int)vPrecalcFiles.size(); i++) + { + sCurrentPrecalcPathName = vPrecalcFiles[i]; + sCurrentPrecalcIndexPathName = sCurrentPrecalcPathName + ".index"; + + if (debug) printf("Debug: Removing precalc file: %s\n", sCurrentPrecalcPathName.c_str()); + + if (remove(sCurrentPrecalcPathName.c_str()) != 0) + if (debug) printf("Debug: Failed removing precalc file: %s\n", sCurrentPrecalcPathName.c_str()); + + if (debug) printf("Debug: Removing precalc index file: %s\n", sCurrentPrecalcIndexPathName.c_str()); + + if (remove(sCurrentPrecalcIndexPathName.c_str()) != 0) + if (debug) printf("Debug: Failed removing precalc index file: %s\n", sCurrentPrecalcIndexPathName.c_str()); + + } +} + +bool CChainWalkSet::FindInFile(uint64* pIndexE, unsigned char* pHash, int nHashLen) +{ + int gotPrecalcOnLine = -1; + char precalculationLine[255]; + sprintf(precalculationLine, "%s_%s#%d-%d_%d_%d:%s\n", m_sHashRoutineName.c_str(), m_sPlainCharsetName.c_str(), m_nPlainLenMin, m_nPlainLenMax, m_nRainbowTableIndex, m_nRainbowChainLen, HexToStr(pHash, nHashLen).c_str() ); + string precalcString(precalculationLine); + + string sCurrentPrecalcPathName = ""; + string sCurrentPrecalcIndexPathName = ""; + long unsigned int offset; + + int i; + for (i = 0; i < (int)vPrecalcFiles.size() && gotPrecalcOnLine == -1; i++) + { + sCurrentPrecalcPathName = vPrecalcFiles[i]; + sCurrentPrecalcIndexPathName = sCurrentPrecalcPathName + ".index"; + + offset = 0; + + vector precalcLines; + if (ReadLinesFromFile(sCurrentPrecalcIndexPathName.c_str(), precalcLines)) + { + int j; + for (j = 0; j < (int)precalcLines.size(); j++) + { + if (precalcString.compare(0, precalcString.size()-1, precalcLines[j]) == 0) + { + gotPrecalcOnLine = j; + break; + } + + // Parse + vector vPart; + if (SeperateString(precalcLines[j], "___:", vPart)) + { + // add to offset + offset += ((atoi(vPart[3].c_str())-1) * sizeof(uint64)); + } + else { + // corrupt file + printf("Corrupted precalculation file!\n"); + gotPrecalcOnLine = -1; + break; + } + } + } + } + + if (gotPrecalcOnLine > -1) + { + if (debug) printf("Debug: Reading pre calculations from file, line %d offset %lu\n", gotPrecalcOnLine, offset); + + FILE* fp = fopen(sCurrentPrecalcPathName.c_str(), "rb"); + + if (fp!=NULL) { + fseek(fp, offset, SEEK_SET); + + // We should do some verification here, for example by recalculating the middle chain, to catch corrupted files + if(fread(pIndexE, sizeof(uint64), (unsigned long)m_nRainbowChainLen-1, fp) != (unsigned long)m_nRainbowChainLen-1) + printf("File read error."); + fclose(fp); + } + else + printf("Cannot open precalculation file %s.\n", sCurrentPrecalcPathName.c_str()); + + //printf("\npIndexE[0]: %s\n", uint64tostr(pIndexE[0]).c_str()); + //printf("\npIndexE[nRainbowChainLen-2]: %s\n", uint64tostr(pIndexE[m_nRainbowChainLen-2]).c_str()); + + return true; + } + + return false; +} + +void CChainWalkSet::StoreToFile(uint64* pIndexE, unsigned char* pHash, int nHashLen) +{ + if (debug) printf("\nDebug: Storing precalc\n"); + + string sCurrentPrecalcPathName = CheckOrRotatePreCalcFile(); + string sCurrentPrecalcIndexPathName = sCurrentPrecalcPathName + ".index"; + + FILE* fp = fopen(sCurrentPrecalcPathName.c_str(), "ab"); + if(fp!=NULL) + { + if(fwrite(pIndexE, sizeof(uint64), (unsigned long)m_nRainbowChainLen-1, fp) != (unsigned long)m_nRainbowChainLen-1) + printf("File write error."); + else + { + FILE* file = fopen(sCurrentPrecalcIndexPathName.c_str(), "a"); + if (file!=NULL) + { + char precalculationLine[255]; + sprintf(precalculationLine, "%s_%s#%d-%d_%d_%d:%s\n", m_sHashRoutineName.c_str(), m_sPlainCharsetName.c_str(), m_nPlainLenMin, m_nPlainLenMax, m_nRainbowTableIndex, m_nRainbowChainLen, HexToStr(pHash, nHashLen).c_str() ); + fputs (precalculationLine, file); + fclose (file); + } + } + fclose(fp); + } + else + printf("Cannot open precalculation file %s\n", sCurrentPrecalcPathName.c_str()); +} + uint64* CChainWalkSet::RequestWalk(unsigned char* pHash, int nHashLen, string sHashRoutineName, string sPlainCharsetName, int nPlainLenMin, int nPlainLenMax, int nRainbowTableIndex, int nRainbowChainLen, - bool& fNewlyGenerated) + bool& fNewlyGenerated, + bool setDebug, + string sPrecalc) { + debug = setDebug; + sPrecalcPathName = sPrecalc; + if ( m_sHashRoutineName != sHashRoutineName || m_sPlainCharsetName != sPlainCharsetName || m_nPlainLenMin != nPlainLenMin @@ -63,7 +275,13 @@ uint64* CChainWalkSet::RequestWalk(unsigned char* pHash, int nHashLen, cw.pIndexE = new uint64[nRainbowChainLen - 1]; m_lChainWalk.push_back(cw); - fNewlyGenerated = true; + // Only update this list when we search through another rainbow table + updateUsedPrecalcFiles(); + + if (!FindInFile(cw.pIndexE, pHash, nHashLen)) + fNewlyGenerated = true; + else + fNewlyGenerated = false; return cw.pIndexE; } @@ -82,7 +300,10 @@ uint64* CChainWalkSet::RequestWalk(unsigned char* pHash, int nHashLen, cw.pIndexE = new uint64[nRainbowChainLen - 1]; m_lChainWalk.push_back(cw); - fNewlyGenerated = true; + if (!FindInFile(cw.pIndexE, pHash, nHashLen)) + fNewlyGenerated = true; + else + fNewlyGenerated = false; return cw.pIndexE; } diff --git a/Common/rt api/ChainWalkSet.h b/Common/rt api/ChainWalkSet.h index 4276894..6d991fe 100644 --- a/Common/rt api/ChainWalkSet.h +++ b/Common/rt api/ChainWalkSet.h @@ -1,8 +1,27 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #ifndef _CHAINWALKSET_H #define _CHAINWALKSET_H @@ -30,9 +49,16 @@ private: int m_nRainbowTableIndex; // Discard all if not match int m_nRainbowChainLen; // Discard all if not match list m_lChainWalk; + bool debug; + string sPrecalcPathName; + int preCalcPart; + vector vPrecalcFiles; private: void DiscardAll(); + bool FindInFile(uint64* pIndexE, unsigned char* pHash, int nHashLen); + string CheckOrRotatePreCalcFile(); + void updateUsedPrecalcFiles(); public: uint64* RequestWalk(unsigned char* pHash, int nHashLen, @@ -40,8 +66,12 @@ public: string sPlainCharsetName, int nPlainLenMin, int nPlainLenMax, int nRainbowTableIndex, int nRainbowChainLen, - bool& fNewlyGenerated); + bool& fNewlyGenerated, + bool setDebug, + string sPrecalc); void DiscardWalk(uint64* pIndexE); + void StoreToFile(uint64* pIndexE, unsigned char* pHash, int nHashLen); + void removePrecalcFiles(); }; #endif diff --git a/Common/rt api/HashAlgorithm.cpp b/Common/rt api/HashAlgorithm.cpp index e6f92c0..4815fc6 100644 --- a/Common/rt api/HashAlgorithm.cpp +++ b/Common/rt api/HashAlgorithm.cpp @@ -175,13 +175,13 @@ void HashORACLE(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) DES_key_schedule ks1,ks2; unsigned char deskey_fixed[]={ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}; int i,j; -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) strcpy_s(username, sizeof(username), "SYS"); #else strcpy(username, "SYS"); #endif int userlen = 3; -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) _strupr((char*) pPlain); #else strupr((char*) pPlain); @@ -210,6 +210,7 @@ void HashORACLE(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) memcpy (pHash,iv2,8); } */ + void HashNTLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) { unsigned char UnicodePlain[MAX_PLAIN_LEN * 2]; @@ -392,10 +393,6 @@ void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) memcpy (pass,pPlain,nPlainLen); - MD5_CTX ctx; - MD5_Init(&ctx); - MD5_Update(&ctx, (unsigned char *) pass, MD5_DIGEST_LENGTH); - MD5_Final(final, &ctx); MD5_NEW((unsigned char *) pass, MD5_DIGEST_LENGTH, final); char* p = (char*) temp; diff --git a/Common/rt api/HashRoutine.cpp b/Common/rt api/HashRoutine.cpp index 6d72c4b..72f7f67 100644 --- a/Common/rt api/HashRoutine.cpp +++ b/Common/rt api/HashRoutine.cpp @@ -1,10 +1,29 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ - Copyright (C) Zhu Shuanglei -*/ - -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) #pragma warning(disable : 4786) #endif diff --git a/Common/rt api/HashRoutine.h b/Common/rt api/HashRoutine.h index 4b53c14..cc0dcdc 100644 --- a/Common/rt api/HashRoutine.h +++ b/Common/rt api/HashRoutine.h @@ -1,8 +1,27 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #ifndef _HASHROUTINE_H #define _HASHROUTINE_H diff --git a/Common/rt api/MemoryPool.cpp b/Common/rt api/MemoryPool.cpp index 1019b4f..053db7a 100644 --- a/Common/rt api/MemoryPool.cpp +++ b/Common/rt api/MemoryPool.cpp @@ -1,8 +1,28 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * Copyright 2010 uroskn + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #include "MemoryPool.h" #include "Public.h" @@ -27,7 +47,7 @@ CMemoryPool::~CMemoryPool() { if (m_pMem != NULL) { - delete m_pMem; + delete [] m_pMem; m_pMem = NULL; m_nMemSize = 0; } @@ -50,20 +70,20 @@ unsigned char* CMemoryPool::Allocate(unsigned int nFileLen, unsigned int& nAlloc // Free existing memory if (m_pMem != NULL) { - delete m_pMem; + delete [] m_pMem; m_pMem = NULL; m_nMemSize = 0; } // Allocate new memory //printf("allocating %u bytes memory\n", nTargetSize); -// m_pMem = new unsigned char[nTargetSize]; -m_pMem = new (nothrow) unsigned char[nTargetSize]; -while (m_pMem == NULL && nTargetSize >= 512 * 1024 * 1024 ) -{ - nTargetSize -= 16 * 1024 * 1024; - m_pMem = new (nothrow) unsigned char[nTargetSize]; -} + m_pMem = new (nothrow) unsigned char[nTargetSize]; + while (m_pMem == NULL && nTargetSize >= 512 * 1024 * 1024 ) + { + nTargetSize -= 16 * 1024 * 1024; + m_pMem = new (nothrow) unsigned char[nTargetSize]; + } + if (m_pMem != NULL) { m_nMemSize = nTargetSize; @@ -72,6 +92,7 @@ while (m_pMem == NULL && nTargetSize >= 512 * 1024 * 1024 ) } else { + m_nMemSize = 0; nAllocatedSize = 0; return NULL; } diff --git a/Common/rt api/MemoryPool.h b/Common/rt api/MemoryPool.h index 9f2ea4e..d40d5a7 100644 --- a/Common/rt api/MemoryPool.h +++ b/Common/rt api/MemoryPool.h @@ -1,12 +1,34 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright 2010 Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * Copyright 2010 uroskn + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #ifndef _MEMORYPOOL_H #define _MEMORYPOOL_H +#include "global.h" + class CMemoryPool { public: @@ -14,6 +36,7 @@ public: virtual ~CMemoryPool(); private: + bool debug; unsigned char* m_pMem; unsigned int m_nMemSize; diff --git a/Common/rt api/Public.cpp b/Common/rt api/Public.cpp index 66e8ce4..6cd0482 100644 --- a/Common/rt api/Public.cpp +++ b/Common/rt api/Public.cpp @@ -11,8 +11,7 @@ * * freerainbowtables is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. + * the Free Software Foundation, either version 2 of the License. * * freerainbowtables is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,7 +22,7 @@ * along with freerainbowtables. If not, see . */ -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__GNUC__) #pragma warning(disable : 4786) #endif @@ -32,7 +31,7 @@ #include "boinc_win.h" #endif #else -#include "config.h" +//#include "config.h" #include #include #include @@ -50,6 +49,73 @@ #ifdef _WIN32 #include +#endif + +#if defined(_WIN32) && !defined(__GNUC__) + #include + #include + + #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 + #else + #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL + #endif + + struct timezone + { + int tz_minuteswest; /* minutes W of Greenwich */ + int tz_dsttime; /* type of dst correction */ + }; + + int gettimeofday(struct timeval *tv, struct timezone *tz) + { + // Define a structure to receive the current Windows filetime + FILETIME ft; + + // Initialize the present time to 0 and the timezone to UTC + unsigned __int64 tmpres = 0; + static int tzflag = 0; + + if (NULL != tv) + { + GetSystemTimeAsFileTime(&ft); + + // The GetSystemTimeAsFileTime returns the number of 100 nanosecond + // intervals since Jan 1, 1601 in a structure. Copy the high bits to + // the 64 bit tmpres, shift it left by 32 then or in the low 32 bits. + tmpres |= ft.dwHighDateTime; + tmpres <<= 32; + tmpres |= ft.dwLowDateTime; + + // Convert to microseconds by dividing by 10 + tmpres /= 10; + + // The Unix epoch starts on Jan 1 1970. Need to subtract the difference + // in seconds from Jan 1 1601. + tmpres -= DELTA_EPOCH_IN_MICROSECS; + + // Finally change microseconds to seconds and place in the seconds value. + // The modulus picks up the microseconds. + tv->tv_sec = (long)(tmpres / 1000000UL); + tv->tv_usec = (long)(tmpres % 1000000UL); + } + + if (NULL != tz) + { + if (!tzflag) + { + _tzset(); + tzflag++; + } + + // Adjust for the timezone west of Greenwich + tz->tz_minuteswest = _timezone / 60; + tz->tz_dsttime = _daylight; + } + + return 0; + } + #elif defined(__APPLE__) || \ ((defined(__unix__) || defined(unix)) && !defined(USG)) @@ -60,17 +126,35 @@ #elif defined(__linux__) #include #else - #error Unsupported Operating system + #error Unsupported Operating System #endif #endif ////////////////////////////////////////////////////////////////////// -unsigned int GetFileLen(FILE* file) +timeval sub_timeofday( timeval tv2, timeval tv ) { - unsigned int pos = ftell(file); + timeval final; + + final.tv_usec = tv2.tv_usec - tv.tv_usec; + final.tv_sec = tv2.tv_sec - tv.tv_sec; + + if ( final.tv_usec < 0 ) + { + final.tv_usec += 1000000; + --final.tv_sec; + } + + return final; +} + +long GetFileLen(FILE* file) +{ + // XXX on x86/x86_64 linux returns long + // 32-bit this is a problem if the file is > (2^31-1) bytes + long pos = ftell(file); fseek(file, 0, SEEK_END); - unsigned int len = ftell(file); + long len = ftell(file); fseek(file, pos, SEEK_SET); return len; @@ -102,12 +186,12 @@ bool GetHybridCharsets(string sCharset, vector& vCharset) if(sCharset.substr(0, 6) != "hybrid") // Not hybrid charset return false; - UINT4 nEnd = (int) sCharset.rfind(')'); - UINT4 nStart = (int) sCharset.rfind('('); + string::size_type nEnd = sCharset.rfind(')'); + string::size_type nStart = (int) sCharset.rfind('('); string sChar = sCharset.substr(nStart + 1, nEnd - nStart - 1); vector vParts; SeperateString(sChar, ",", vParts); - for(UINT4 i = 0; i < vParts.size(); i++) + for(uint32 i = 0; i < vParts.size(); i++) { tCharset stCharset; vector vParts2; @@ -152,8 +236,8 @@ bool boinc_ReadLinesFromFile(string sPathName, vector& vLine) content[i] = '\n'; } - int n; - while ((n = content.find("\n", 0)) != -1) + string::size_type n; + while ((n = content.find("\n", 0)) != string::npos) { string line = content.substr(0, n); line = TrimString(line); @@ -169,11 +253,12 @@ bool boinc_ReadLinesFromFile(string sPathName, vector& vLine) return true; } -#endif +#endif bool ReadLinesFromFile(string sPathName, vector& vLine) { vLine.clear(); - FILE *file = fopen(sPathName.c_str(), "rb"); + + FILE* file = fopen(sPathName.c_str(), "rb"); if (file != NULL) { unsigned int len = GetFileLen(file); @@ -182,7 +267,7 @@ bool ReadLinesFromFile(string sPathName, vector& vLine) data[len] = '\0'; string content = data; content += "\n"; - delete data; + delete [] data; unsigned int i; for (i = 0; i < content.size(); i++) @@ -191,8 +276,8 @@ bool ReadLinesFromFile(string sPathName, vector& vLine) content[i] = '\n'; } - int n; - while ((n = content.find("\n", 0)) != -1) + string::size_type n; + while ((n = content.find("\n", 0)) != string::npos) { string line = content.substr(0, n); line = TrimString(line); @@ -209,6 +294,19 @@ bool ReadLinesFromFile(string sPathName, vector& vLine) return true; } +bool writeResultLineToFile(string sOutputFile, string sHash, string sPlain, string sBinary) +{ + FILE* file = fopen(sOutputFile.c_str(), "a"); + if (file!=NULL) + { + string buffer = sHash + ":" + sPlain + ":" + sBinary + "\n"; + fputs (buffer.c_str(), file); + fclose (file); + return true; + } + else + return false; +} bool SeperateString(string s, string sSeperator, vector& vPart) { @@ -217,14 +315,18 @@ bool SeperateString(string s, string sSeperator, vector& vPart) unsigned int i; for (i = 0; i < sSeperator.size(); i++) { - int n = s.find(sSeperator[i]); - if (n != -1) + string::size_type n; + if ( (n = s.find(sSeperator[i])) != string::npos) { vPart.push_back(s.substr(0, n)); s = s.substr(n + 1); } else + { + printf("not found: %c\n", sSeperator[i]); + printf("s: %s\n", s.c_str()); return false; + } } vPart.push_back(s); @@ -271,16 +373,27 @@ string HexToStr(const unsigned char* pData, int nLen) return sRet; } -unsigned int GetAvailPhysMemorySize() +unsigned long GetAvailPhysMemorySize() { #ifdef _WIN32 - MEMORYSTATUS ms; - GlobalMemoryStatus(&ms); - return ms.dwAvailPhys; -#else + MEMORYSTATUS ms; + GlobalMemoryStatus(&ms); + return ms.dwAvailPhys; +#elif defined(BSD) + int mib[2] = { CTL_HW, HW_PHYSMEM }; + uint64 physMem; + //XXX warning size_t isn't portable + size_t len; + len = sizeof(physMem); + sysctl(mib, 2, &physMem, &len, NULL, 0); + return physMem; +#elif defined(__linux__) struct sysinfo info; - sysinfo(&info); // This function is Linux-specific - return info.freeram; + sysinfo(&info); + return ( info.freeram + info.bufferram ) * (unsigned long) info.mem_unit; +#else + return 0; + #error Unsupported Operating System #endif } @@ -302,12 +415,12 @@ string GetApplicationPath() string sApplicationPath = fullPath; #ifdef _WIN32 - int nIndex = sApplicationPath.find_last_of('\\'); + string::size_type nIndex = sApplicationPath.find_last_of('\\'); #else - int nIndex = sApplicationPath.find_last_of('/'); + string::size_type nIndex = sApplicationPath.find_last_of('/'); #endif - if ( nIndex != -1 ) + if ( nIndex != string::npos ) sApplicationPath = sApplicationPath.substr(0, nIndex+1); return sApplicationPath; @@ -324,7 +437,7 @@ void ParseHash(string sHash, unsigned char* pHash, int& nHashLen) pHash[i] = (unsigned char)nValue; } - nHashLen = sHash.size() / 2; + nHashLen = (int) sHash.size() / 2; } void Logo() @@ -335,3 +448,59 @@ void Logo() printf("original code by Zhu Shuanglei \n"); printf("http://www.antsight.com/zsl/rainbowcrack/\n\n"); } + +// XXX nmap is GPL2, will check newer releases regarding license +// Code comes from nmap, used for the linux implementation of kbhit() +#ifndef _WIN32 + +static int tty_fd = 0; +struct termios saved_ti; + +int tty_getchar() +{ + int c, numChars; + + if (tty_fd && tcgetpgrp(tty_fd) == getpid()) { + c = 0; + numChars = read(tty_fd, &c, 1); + if (numChars > 0) return c; + } + + return -1; +} + +void tty_done() +{ + if (!tty_fd) return; + + tcsetattr(tty_fd, TCSANOW, &saved_ti); + + close(tty_fd); + tty_fd = 0; +} + +void tty_init() +{ + struct termios ti; + + if (tty_fd) + return; + + if ((tty_fd = open("/dev/tty", O_RDONLY | O_NONBLOCK)) < 0) return; + + tcgetattr(tty_fd, &ti); + saved_ti = ti; + ti.c_lflag &= ~(ICANON | ECHO); + ti.c_cc[VMIN] = 1; + ti.c_cc[VTIME] = 0; + tcsetattr(tty_fd, TCSANOW, &ti); + + atexit(tty_done); +} + +void tty_flush(void) +{ + tcflush(tty_fd, TCIFLUSH); +} +// end nmap code +#endif diff --git a/Common/rt api/Public.h b/Common/rt api/Public.h index b3103f7..6708d3a 100644 --- a/Common/rt api/Public.h +++ b/Common/rt api/Public.h @@ -10,8 +10,7 @@ * * freerainbowtables is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. + * the Free Software Foundation, either version 2 of the License. * * freerainbowtables is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -52,8 +51,8 @@ struct RainbowChainCP struct IndexChain { uint64 nPrefix; - UINT4 nFirstChain; - UINT4 nChainCount; + uint32 nFirstChain; + uint32 nChainCount; }; struct FoundRainbowChain { @@ -85,7 +84,32 @@ typedef struct #define MAX_HASH_LEN 256 #define MAX_SALT_LEN 256 -unsigned int GetFileLen(FILE* file); +// XXX nmap is GPL2, will check newer releases regarding license +// Code comes from nmap, used for the linux implementation of kbhit() +#ifndef _WIN32 +#include +#include +#include + +int tty_getchar(); +void tty_done(); +void tty_init(); +void tty_flush(void); +// end nmap code + +#endif + +#if defined(_WIN32) && !defined(__GNUC__) + int gettimeofday( struct timeval *tv, struct timezone *tz ); +#endif + +#if !defined(_WIN32) || defined(__GNUC__) + #include +#endif + +timeval sub_timeofday( timeval tv2, timeval tv ); + +long GetFileLen(FILE* file); string TrimString(string s); bool boinc_ReadLinesFromFile(string sPathName, vector& vLine); bool ReadLinesFromFile(string sPathName, vector& vLine); @@ -93,10 +117,11 @@ bool SeperateString(string s, string sSeperator, vector& vPart); string uint64tostr(uint64 n); string uint64tohexstr(uint64 n); string HexToStr(const unsigned char* pData, int nLen); -unsigned int GetAvailPhysMemorySize(); +unsigned long GetAvailPhysMemorySize(); string GetApplicationPath(); void ParseHash(string sHash, unsigned char* pHash, int& nHashLen); bool GetHybridCharsets(string sCharset, vector& vCharset); void Logo(); +bool writeResultLineToFile(string sOutputFile, string sHash, string sPlain, string sBinary); #endif diff --git a/Common/rt api/RTI2Reader.cpp b/Common/rt api/RTI2Reader.cpp index 443fd1c..6fb0cb9 100644 --- a/Common/rt api/RTI2Reader.cpp +++ b/Common/rt api/RTI2Reader.cpp @@ -1,6 +1,30 @@ +/* + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright 2010 Martin Westergaard Jørgensen + * Copyright 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ + #include "RTI2Reader.h" #include + RTI2Header *RTI2Reader::m_pHeader = NULL; RTI2Reader::RTI2Reader(string Filename) { @@ -20,11 +44,11 @@ RTI2Reader::RTI2Reader(string Filename) } m_chainPosition = 0; - unsigned int len = GetFileLen(pFileIndex); + long len = GetFileLen(pFileIndex); fseek(pFileIndex, 0, SEEK_SET); m_pIndex = new unsigned char[len]; - if(fread(m_pIndex, 1, len, pFileIndex) != len) + if(fread(m_pIndex, 1, len, pFileIndex) != (unsigned long)len) { printf("Error while reading index file"); exit(1); @@ -34,15 +58,15 @@ RTI2Reader::RTI2Reader(string Filename) memcpy(m_pHeader, m_pIndex, sizeof(RTI2Header)); m_pHeader->m_cppos = (unsigned int*)(m_pIndex + 8); m_pHeader->prefixstart = *(uint64*)(m_pIndex + 8 + (m_pHeader->rti_cplength * 4)); - m_chainsizebytes = ceil((float)(m_pHeader->rti_startptlength + m_pHeader->rti_endptlength + m_pHeader->rti_cplength) / 8); // Get the size of each chain in bytes - m_indexrowsizebytes = ceil((float)m_pHeader->rti_index_numchainslength / 8); + m_chainsizebytes = (uint32)ceil((float)(m_pHeader->rti_startptlength + m_pHeader->rti_endptlength + m_pHeader->rti_cplength) / 8); // Get the size of each chain in bytes + m_indexrowsizebytes = (uint32)ceil((float)m_pHeader->rti_index_numchainslength / 8); // Check the filesize fseek(m_pFile, 0, SEEK_END); len = ftell(m_pFile); fseek(m_pFile, 0, SEEK_SET); if(len % m_chainsizebytes > 0) { - printf("Invalid filesize %u\n", len); + printf("Invalid filesize %ld\n", len); return; } @@ -58,7 +82,7 @@ RTI2Reader::~RTI2Reader(void) unsigned int RTI2Reader::GetChainsLeft() { - int len = GetFileLen(m_pFile); + long len = GetFileLen(m_pFile); return len / m_chainsizebytes - m_chainPosition; } @@ -78,7 +102,12 @@ int RTI2Reader::ReadChains(unsigned int &numChains, RainbowChainCP *pData) { // ALERT: Possible problem here if m_indexrowsizebytes > 1 as pNumChains is a unsigned char. unsigned int NumChainsInRow = (unsigned int)*(pNumChains + indexRow * m_indexrowsizebytes); - if(m_indexrowsizebytes > 1) { printf("Have to find a solution to this problem"); exit(2);} + if(m_indexrowsizebytes > 1) + { + //XXX Have to find a solution to this problem + printf( "FATAL: m_indexrowsizebytes > 1: %d\n", m_indexrowsizebytes ); + exit(2); + } if(i + NumChainsInRow > m_chainPosition) { curRowPosition = m_chainPosition - i; @@ -91,7 +120,7 @@ int RTI2Reader::ReadChains(unsigned int &numChains, RainbowChainCP *pData) uint64 chainrow = 0; // Buffer to store a single read chain unsigned int chainsProcessed = 0; // Number of chains processed - // ALERT: same problem with unsigned char here. + // XXX: same problem with unsigned char here. unsigned int NumChainsInRow = *(pNumChains + indexRow); while(chainsProcessed < numChains && fread(&chainrow, 1, m_chainsizebytes, m_pFile) == m_chainsizebytes) { @@ -108,14 +137,18 @@ int RTI2Reader::ReadChains(unsigned int &numChains, RainbowChainCP *pData) curRowPosition = 0; } // Load the starting point from the data - pData[chainsProcessed].nIndexS = chainrow << 64 - m_pHeader->rti_startptlength; - pData[chainsProcessed].nIndexS = pData[chainsProcessed].nIndexS >> 64 - m_pHeader->rti_startptlength; + pData[chainsProcessed].nIndexS = chainrow << ( 64 - m_pHeader->rti_startptlength ); + pData[chainsProcessed].nIndexS = pData[chainsProcessed].nIndexS >> ( 64 - m_pHeader->rti_startptlength ); // Load the ending point prefix - pData[chainsProcessed].nIndexE = m_pHeader->prefixstart + indexRow << m_pHeader->rti_endptlength; + pData[chainsProcessed].nIndexE = ( m_pHeader->prefixstart + indexRow ) << m_pHeader->rti_endptlength; // Append the ending point suffix - pData[chainsProcessed].nIndexE |= (chainrow & (0xFFFFFFFFFFFFFFFF >> m_pHeader->rti_cplength)) >> m_pHeader->rti_startptlength; - pData[chainsProcessed].nCheckPoint = (chainrow >> m_pHeader->rti_startptlength + m_pHeader->rti_endptlength); +#if defined(_WIN32) && !defined(__GNUC__) + pData[chainsProcessed].nIndexE |= (chainrow & (0xFFFFFFFFFFFFFFFFI64 >> m_pHeader->rti_cplength)) >> m_pHeader->rti_startptlength; +#else + pData[chainsProcessed].nIndexE |= (chainrow & (0xFFFFFFFFFFFFFFFFllu >> m_pHeader->rti_cplength)) >> m_pHeader->rti_startptlength; +#endif + //pData[chainsProcessed].nCheckPoint = (chainrow >> m_pHeader->rti_startptlength + m_pHeader->rti_endptlength); curRowPosition++; chainsProcessed++; } diff --git a/Common/rt api/RTI2Reader.h b/Common/rt api/RTI2Reader.h index fb17dd8..902344a 100644 --- a/Common/rt api/RTI2Reader.h +++ b/Common/rt api/RTI2Reader.h @@ -1,13 +1,39 @@ +/* + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright 2010 Martin Westergaard Jørgensen + * Copyright 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ + #ifndef __RTI2READER_H__ #define __RTI2READER_H__ #include "Public.h" #include -#ifdef WIN32 -#include + +#if defined(_WIN32) && !defined(__GNUC__) + #include #endif + #include #include "BaseRTReader.h" + using namespace std; typedef struct @@ -22,12 +48,12 @@ class RTI2Reader : BaseRTReader { private: FILE *m_pFile; - unsigned int m_chainPosition; + uint32 m_chainPosition; unsigned char *m_pPos, *m_pChainPos; static RTI2Header *m_pHeader; unsigned char *m_pIndex; - unsigned int m_chainsizebytes; - unsigned int m_indexrowsizebytes; + uint32 m_chainsizebytes; + uint32 m_indexrowsizebytes; public: diff --git a/Common/rt api/RTIReader.cpp b/Common/rt api/RTIReader.cpp index b72dbe2..1a97786 100644 --- a/Common/rt api/RTIReader.cpp +++ b/Common/rt api/RTIReader.cpp @@ -17,22 +17,21 @@ RTIReader::RTIReader(string Filename) m_chainPosition = 0; // Load the index file - unsigned int nIndexFileLen = GetFileLen(pFileIndex); - unsigned int nFileLen = GetFileLen(m_pFile); + long nIndexFileLen = GetFileLen(pFileIndex); + long nFileLen = GetFileLen(m_pFile); unsigned int nTotalChainCount = nFileLen / 8; if (nFileLen % 8 != 0) - printf("file length mismatch (%u bytes)\n", nFileLen); + printf("file length mismatch (%ld bytes)\n", nFileLen); else { // File length check if (nIndexFileLen % 11 != 0) - printf("index file length mismatch (%u bytes)\n", nIndexFileLen); + printf("index file length mismatch (%ld bytes)\n", nIndexFileLen); else { m_pIndex = new IndexChain[nIndexFileLen / 11]; memset(m_pIndex, 0x00, sizeof(IndexChain) * (nIndexFileLen / 11)); fseek(pFileIndex, 0, SEEK_SET); - int nRead = 0; int nRows; for(nRows = 0; (nRows * 11) < nIndexFileLen; nRows++) { @@ -82,7 +81,7 @@ int RTIReader::ReadChains(unsigned int &numChains, RainbowChainCP *pData) memset(pData, 0x00, sizeof(RainbowChainCP) * numChains); unsigned int readChains = 0; unsigned int chainsleft = GetChainsLeft(); - for(int i = 0; i < m_nIndexSize; i++) + for(unsigned int i = 0; i < m_nIndexSize; i++) { if(m_chainPosition + readChains > m_pIndex[i].nFirstChain + m_pIndex[i].nChainCount) // We found the matching index continue; diff --git a/Common/rt api/md4.cpp b/Common/rt api/md4.cpp index 7a6f91a..c4d6c38 100644 --- a/Common/rt api/md4.cpp +++ b/Common/rt api/md4.cpp @@ -20,11 +20,11 @@ (a) = ROTATE_LEFT ((a), (s)); \ } #define GG(a, b, c, d, x, s) { \ - (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \ + (a) += G ((b), (c), (d)) + (x) + (uint32)0x5a827999; \ (a) = ROTATE_LEFT ((a), (s)); \ } #define HH(a, b, c, d, x, s) { \ - (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \ + (a) += H ((b), (c), (d)) + (x) + (uint32)0x6ed9eba1; \ (a) = ROTATE_LEFT ((a), (s)); \ } #define S11 3 @@ -45,10 +45,10 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) { // For the hash working space - UINT4 b0,b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15; + uint32 b0,b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15; // For the output result - UINT4 a,b,c,d; + uint32 a,b,c,d; b0 = 0x00000000; b1 = 0x00000000; @@ -76,7 +76,7 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) memcpy(in, pData, length); in[2] = 0x80; in[3] = 0x00; - UINT4 * pUiIn = (UINT4 *) in; + uint32 * pUiIn = (uint32 *) in; b0 = pUiIn[0]; } break; @@ -84,7 +84,7 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) { unsigned char in[4]; memcpy(in, pData, length); - UINT4 * pUiIn = (UINT4 *) in; + uint32 * pUiIn = (uint32 *) in; b0 = pUiIn[0]; b1 = 0x00000080; } @@ -95,7 +95,7 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) memcpy(in, pData, length); in[6] = 0x80; in[7] = 0x00; - UINT4 * pUiIn = (UINT4 *) in; + uint32 * pUiIn = (uint32 *) in; b0 = pUiIn[0]; b1 = pUiIn[1]; } @@ -104,7 +104,7 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) { unsigned char in[8]; memcpy(in, pData, length); - UINT4 * pUiIn = (UINT4 *) in; + uint32 * pUiIn = (uint32 *) in; b0 = pUiIn[0]; b1 = pUiIn[1]; b2 = 0x00000080; @@ -116,7 +116,7 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) memcpy(in, pData, length); in[10] = 0x80; in[11] = 0x00; - UINT4 * pUiIn = (UINT4 *) in; + uint32 * pUiIn = (uint32 *) in; b0 = pUiIn[0]; b1 = pUiIn[1]; b2 = pUiIn[2]; @@ -128,7 +128,7 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) memcpy(in, pData, length); in[length] = 0x80; memset(in + length + 1, 0, 32 - length - 1); - UINT4 * pUiIn = (UINT4 *) in; + uint32 * pUiIn = (uint32 *) in; b0 = pUiIn[0]; b1 = pUiIn[1]; b2 = pUiIn[2]; @@ -209,7 +209,7 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest) c += 0x98badcfe; d += 0x10325476; - UINT4 buf[4] = { a, b, c, d}; + uint32 buf[4] = { a, b, c, d}; memcpy(pDigest, buf, 16); return; -- 2.39.2