]> git.sesse.net Git - freerainbowtables/commitdiff
UINT4 -> uint32
authorJames Nobis <quel@quelrod.net>
Wed, 3 Nov 2010 02:42:12 +0000 (21:42 -0500)
committerJames Nobis <quel@quelrod.net>
Wed, 3 Nov 2010 02:42:12 +0000 (21:42 -0500)
misc cleanup
merge some of the separate copies of files into the common versions

39 files changed:
Client Applications/converti2/Makefile
Client Applications/rcracki_mt/ChainWalkContext.cpp
Client Applications/rcracki_mt/ChainWalkContext.h
Client Applications/rcracki_mt/CrackEngine.cpp
Client Applications/rcracki_mt/HashAlgorithm.cpp
Client Applications/rcracki_mt/HashRoutine.cpp
Client Applications/rcracki_mt/HashSet.cpp
Client Applications/rcracki_mt/MemoryPool.cpp
Client Applications/rcracki_mt/MemoryPool.h
Client Applications/rcracki_mt/Public.cpp
Client Applications/rcracki_mt/Public.h
Client Applications/rcracki_mt/RTI2Reader.cpp
Client Applications/rcracki_mt/RTI2Reader.h
Client Applications/rcracki_mt/RainbowCrack.cpp
Client Applications/rcracki_mt/fast_md5.cpp
Client Applications/rcracki_mt/global.h
Client Applications/rcracki_mt/lm2ntlm.cpp
Client Applications/rcracki_mt/md4.cpp
Client Applications/rcracki_mt/rcrackiThread.cpp
Client Applications/rcracki_mt/sha1.cpp
Client Applications/rti2rto/Makefile
Client Applications/rti2rto/rti2rto.cpp
Common/rt api/BaseRTReader.cpp
Common/rt api/BaseRTReader.h
Common/rt api/ChainWalkContext.cpp
Common/rt api/ChainWalkContext.h
Common/rt api/ChainWalkSet.cpp
Common/rt api/ChainWalkSet.h
Common/rt api/HashAlgorithm.cpp
Common/rt api/HashRoutine.cpp
Common/rt api/HashRoutine.h
Common/rt api/MemoryPool.cpp
Common/rt api/MemoryPool.h
Common/rt api/Public.cpp
Common/rt api/Public.h
Common/rt api/RTI2Reader.cpp
Common/rt api/RTI2Reader.h
Common/rt api/RTIReader.cpp
Common/rt api/md4.cpp

index d3715df887e3b7ffc361adb2f59babe1375454ee..632326701d7ac2ae287116a9d37bae0f5fae458f 100644 (file)
@@ -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
index ae58f77894c6e074279bb38cf7487228df8af6b6..417d90013b4eee211aaedb431b90cd11bdd63e80 100644 (file)
@@ -83,14 +83,19 @@ bool CChainWalkContext::LoadCharset(string sName)
        bool readCharset = false;\r
        vector<string> vLine;\r
 \r
-       if ( ReadLinesFromFile("charset.txt", vLine) )\r
-               readCharset = true;\r
-       else if ( ReadLinesFromFile(GetApplicationPath() + "charset.txt", vLine) )\r
-               readCharset = true;\r
-\r
-       if (readCharset)\r
+       #ifdef BOINC\r
+               if ( boinc_ReadLinesFromFile( "charset.txt", vLine ) )\r
+                       readCharset = true;\r
+       #else\r
+               if ( ReadLinesFromFile("charset.txt", vLine) )\r
+                       readCharset = true;\r
+               else if ( ReadLinesFromFile(GetApplicationPath() + "charset.txt", vLine) )\r
+                       readCharset = true;\r
+       #endif\r
+\r
+       if ( readCharset )\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vLine.size(); i++)\r
                {\r
                        // Filter comment\r
@@ -107,7 +112,7 @@ bool CChainWalkContext::LoadCharset(string sName)
                                                                \r
                                // sCharsetName charset check\r
                                bool fCharsetNameCheckPass = true;\r
-                               UINT4 j;\r
+                               uint32 j;\r
                                for (j = 0; j < sCharsetName.size(); j++)\r
                                {\r
                                        if (   !isalpha(sCharsetName[j])\r
@@ -178,6 +183,7 @@ bool CChainWalkContext::LoadCharset(string sName)
        }\r
        else\r
                printf("can't open charset configuration file\n");\r
+\r
        return false;\r
 }\r
 \r
@@ -218,7 +224,7 @@ bool CChainWalkContext::SetPlainCharset(string sCharsetName, int nPlainLenMin, i
        m_nPlainLenMaxTotal = 0;\r
        m_nPlainLenMinTotal = 0;\r
        uint64 nTemp = 1;\r
-       UINT4 j, k = 1;\r
+       uint32 j, k = 1;\r
        for(j = 0; j < m_vCharset.size(); j++)\r
        {\r
                int i;\r
@@ -476,7 +482,7 @@ void CChainWalkContext::IndexToPlain()
        for (i = m_nPlainLen - 1; i >= 0; i--)\r
        {\r
                int nCharsetLen = 0;\r
-               for(UINT4 j = 0; j < m_vCharset.size(); j++)\r
+               for(uint32 j = 0; j < m_vCharset.size(); j++)\r
                {\r
                        nCharsetLen += m_vCharset[j].m_nPlainLenMax;\r
                        if(i < nCharsetLen) // We found the correct charset\r
@@ -503,7 +509,7 @@ void CChainWalkContext::IndexToPlain()
 #endif\r
 \r
                int nCharsetLen = 0;\r
-               for(UINT4 j = 0; j < m_vCharset.size(); j++)\r
+               for(uint32 j = 0; j < m_vCharset.size(); j++)\r
                {\r
                        nCharsetLen += m_vCharset[j].m_nPlainLenMax;\r
                        if(i < nCharsetLen) // We found the correct charset\r
@@ -515,11 +521,11 @@ void CChainWalkContext::IndexToPlain()
                }\r
        }\r
 \r
-       UINT4 nIndexOfX32 = (UINT4)nIndexOfX;\r
+       uint32 nIndexOfX32 = (uint32)nIndexOfX;\r
        for (; i >= 0; i--)\r
        {\r
                int nCharsetLen = 0;\r
-               for(UINT4 j = 0; j < m_vCharset.size(); j++)\r
+               for(uint32 j = 0; j < m_vCharset.size(); j++)\r
                {\r
                        nCharsetLen += m_vCharset[j].m_nPlainLenMax;\r
                        if(i < nCharsetLen) // We found the correct charset\r
@@ -528,14 +534,12 @@ void CChainWalkContext::IndexToPlain()
 //             m_Plain[i] = m_vCharset[j].m_PlainCharset[nIndexOfX32 % m_vCharset[j].m_nPlainCharsetLen];\r
 //             nIndexOfX32 /= m_vCharset[j].m_nPlainCharsetLen;\r
 \r
-\r
 //     moving nPlainCharsetLen into the asm body and avoiding the extra temp\r
 //     variable results in a performance gain\r
 //                             unsigned int nPlainCharsetLen = m_vCharset[j].m_nPlainCharsetLen;\r
                                unsigned int nTemp;\r
 \r
 #if defined(_WIN32) && !defined(__GNUC__)\r
-\r
                // VC++ still needs this\r
                unsigned int nPlainCharsetLen = m_vCharset[j].m_nPlainCharsetLen;\r
 \r
index 154daee9cf8edb4e01c5f9938755e5cd30895411..7262fffb437ad80979e08a1b78c61a0c3c92a82d 100644 (file)
@@ -85,7 +85,6 @@ public:
        static bool isOldFormat();\r
        static bool isRti2Format();\r
 \r
-\r
        void SetIndex(uint64 nIndex);\r
        void SetHash(unsigned char* pHash);             // The length should be m_nHashLen\r
 \r
index 1e00fce729b8a17b08db54b1293b762c6849b08a..d36ebbc74556e4717eb8ca53cf73992d4e22ccd0 100644 (file)
@@ -328,7 +328,7 @@ void CCrackEngine::SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainL
 \r
        bool pausing = false;\r
 \r
-       UINT4 nHashIndex;\r
+       uint32 nHashIndex;\r
        for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++)\r
        {\r
                #ifdef _WIN32\r
@@ -442,7 +442,7 @@ void CCrackEngine::SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainL
                        threadPool.clear();\r
                        pThreads.clear();\r
                        \r
-                       UINT4 thread_ID;\r
+                       uint32 thread_ID;\r
                        for (thread_ID = 0; thread_ID < (unsigned long)maxThreads; thread_ID++)\r
                        {\r
                                rcrackiThread* r_Thread = new rcrackiThread(TargetHash, thread_ID, nRainbowChainLen, maxThreads, pStartPosIndexE);\r
@@ -511,7 +511,7 @@ void CCrackEngine::SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainL
                        threadPool.push_back(r_Thread);\r
                }\r
 \r
-               UINT4 thread_ID = 0;\r
+               uint32 thread_ID = 0;\r
                int nPos;\r
                for (nPos = nRainbowChainLen - 2; nPos >= 0; nPos--)\r
                {\r
@@ -655,7 +655,7 @@ void CCrackEngine::SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen,
 \r
        bool pausing = false;\r
 \r
-       UINT4 nHashIndex;\r
+       uint32 nHashIndex;\r
        for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++)\r
        {\r
                #ifdef _WIN32\r
@@ -772,7 +772,7 @@ void CCrackEngine::SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen,
                        threadPool.clear();\r
                        pThreads.clear();\r
                        \r
-                       UINT4 thread_ID;\r
+                       uint32 thread_ID;\r
                        for (thread_ID = 0; thread_ID < (unsigned long)maxThreads; thread_ID++)\r
                        {\r
                                rcrackiThread* r_Thread = new rcrackiThread(TargetHash, thread_ID, nRainbowChainLen, maxThreads, pStartPosIndexE);\r
@@ -846,7 +846,7 @@ void CCrackEngine::SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen,
                        threadPool.push_back(r_Thread);\r
                }\r
 \r
-               UINT4 thread_ID = 0;\r
+               uint32 thread_ID = 0;\r
                int nPos;\r
                for (nPos = nRainbowChainLen - 2; nPos >= 0; nPos--)\r
                {\r
@@ -956,7 +956,7 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
                vector<string> sessionFinishedPathNames;\r
                if (ReadLinesFromFile(sProgressPathName.c_str(), sessionFinishedPathNames))\r
                {\r
-                       UINT4 i;\r
+                       uint32 i;\r
                        for (i = 0; i < sessionFinishedPathNames.size(); i++)\r
                        {\r
                                if (sessionFinishedPathNames[i] == sPathName)\r
@@ -1002,9 +1002,9 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
                // File length check\r
                bool doOldFormat = CChainWalkContext::isOldFormat();\r
                bool doRti2Format = CChainWalkContext::isRti2Format();\r
-               UINT4 sizeOfChain;\r
+               uint32 sizeOfChain;\r
                bool fVerified = false;\r
-               UINT4 nFileLen = GetFileLen(file);\r
+               long nFileLen = GetFileLen(file);\r
 \r
                if (doOldFormat)\r
                        sizeOfChain = 16;\r
@@ -1012,7 +1012,7 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
                        sizeOfChain = 8;\r
 \r
                //if (nFileLen % 8 != 0 || nRainbowChainCount * 8 != nFileLen)\r
-               if ( (nFileLen % sizeOfChain != 0 || nRainbowChainCount * sizeOfChain != nFileLen) && doRti2Format == false )\r
+               if ( ( (unsigned long)nFileLen % sizeOfChain != 0 || nRainbowChainCount * sizeOfChain != (unsigned long)nFileLen) && doRti2Format == false )\r
                        printf("file length mismatch\n");\r
                else\r
                {\r
@@ -1059,7 +1059,7 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
                                        //bool fVerified = false;\r
                                        while (true)    // Chunk read loop\r
                                        {\r
-                                               if ((unsigned long)ftell(file) == nFileLen)\r
+                                               if (ftell(file) == nFileLen)\r
                                                        break;\r
 \r
                                                // Load table chunk\r
@@ -1229,8 +1229,8 @@ void CCrackEngine::SearchRainbowTable(string sPathName, CHashSet& hs)
 \r
                                                                        //fseek(file, 0, SEEK_SET);\r
                                                                        //bool fVerified = false;\r
-                                                                       UINT4 nProcessedChains = 0;\r
-                                                                       while ( (unsigned long)ftell(file) != nFileLen \r
+                                                                       uint32 nProcessedChains = 0;\r
+                                                                       while (ftell(file) != nFileLen \r
                                                                                && nProcessedChains < nCoveredRainbowTableChains )      // Chunk read loop\r
                                                                        {\r
                                                                                // Load table chunk\r
@@ -1360,7 +1360,7 @@ void CCrackEngine::Run(vector<string> vPathName, CHashSet& hs, int i_maxThreads,
        ResetStatistics();\r
 \r
        // Sort vPathName (CChainWalkSet need it)\r
-       UINT4 i, j;\r
+       uint32 i, j;\r
        for (i = 0; i < vPathName.size() - 1; i++)\r
                for (j = 0; j < vPathName.size() - i - 1; j++)\r
                {\r
index bf04682e6792e0ecbee9ef9dc89960d4308a5629..4206340e73b8c3f74168640441d984af6fec58a4 100644 (file)
@@ -296,11 +296,7 @@ void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash)
                unicode_user[i*2] = username[i];\r
                unicode_user[i*2+1] = 0x00;\r
        }\r
-       /*\r
-       MD4_Init(&ctx);\r
-       MD4_Update(&ctx,unicode_pwd,nPlainLen*2);\r
-       MD4_Final(final1,&ctx);\r
-       */\r
+\r
        MD4_NEW( (unsigned char*)unicode_pwd, nPlainLen*2, final1 );\r
 \r
        MD4_Init(&ctx);\r
@@ -314,7 +310,7 @@ void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash)
        {\r
                unicode_pwd[i*2] = pPlain[i];\r
                unicode_pwd[i*2+1] = 0x00;\r
-       }*/     \r
+       }*/\r
        /*\r
        unsigned char *buf = (unsigned char*)calloc(MSCACHE_HASH_SIZE + nSaltLength, sizeof(unsigned char));    \r
        HashNTLM(pPlain, nPlainLen, buf, NULL);\r
@@ -396,10 +392,6 @@ void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
 \r
        memcpy (pass,pPlain,nPlainLen);\r
 \r
-       /*MD5_CTX ctx;\r
-       MD5_Init(&ctx);\r
-       MD5_Update(&ctx, (unsigned char *) pass, MD5_DIGEST_LENGTH);\r
-       MD5_Final(final, &ctx);*/\r
        fast_MD5((unsigned char *) pass, MD5_DIGEST_LENGTH, final);\r
 \r
        char* p = (char*) temp;\r
index c85193f95297df3e96c1c19f98720ad8a8a5067b..148f46b555a820154cddceba195fe46654e0df88 100644 (file)
@@ -71,7 +71,7 @@ void CHashRoutine::AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRout
 string CHashRoutine::GetAllHashRoutineName()\r
 {\r
        string sRet;\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < vHashRoutineName.size(); i++)\r
                sRet += vHashRoutineName[i] + " ";\r
 \r
@@ -80,7 +80,7 @@ string CHashRoutine::GetAllHashRoutineName()
 \r
 void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen)\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < vHashRoutineName.size(); i++)\r
        {\r
                if (sHashRoutineName == vHashRoutineName[i])\r
index 683af0bf5f4a182dee788dd6de03f82887080359..dedb2ba139253db37b333669c9aedc178acdd8dc 100644 (file)
@@ -42,7 +42,7 @@ void CHashSet::AddHash(string sHash)
        if (sHash == "aad3b435b51404ee")\r
                return;\r
 \r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (m_vHash[i] == sHash)\r
@@ -72,7 +72,7 @@ string CHashSet::GetHashInfo(int i)
 \r
 bool CHashSet::AnyhashLeft()\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (!m_vFound[i])\r
@@ -84,7 +84,7 @@ bool CHashSet::AnyhashLeft()
 \r
 bool CHashSet::AnyHashLeftWithLen(int nLen)\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (!m_vFound[i])\r
@@ -99,7 +99,7 @@ void CHashSet::GetLeftHashWithLen(vector<string>& vHash, int nLen)
 {\r
        vHash.clear();\r
 \r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (!m_vFound[i])\r
@@ -110,7 +110,7 @@ void CHashSet::GetLeftHashWithLen(vector<string>& vHash, int nLen)
 \r
 void CHashSet::AddHashInfo(string sHash, bool found, string sPlain, string sBinary)\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (m_vHash[i] == sHash)\r
@@ -125,7 +125,7 @@ void CHashSet::AddHashInfo(string sHash, bool found, string sPlain, string sBina
 \r
 void CHashSet::SetPlain(string sHash, string sPlain, string sBinary)\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (m_vHash[i] == sHash)\r
@@ -147,7 +147,7 @@ bool CHashSet::GetPlain(string sHash, string& sPlain, string& sBinary)
                return true;\r
        }\r
 \r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (m_vHash[i] == sHash)\r
@@ -167,7 +167,7 @@ bool CHashSet::GetPlain(string sHash, string& sPlain, string& sBinary)
 int CHashSet::GetStatHashFound()\r
 {\r
        int nHashFound = 0;\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < m_vHash.size(); i++)\r
        {\r
                if (m_vFound[i])\r
index 3673446af24dcc9e89a72418d24516deff914f5f..5c634c02df4c8cfa5515706731f76422b9c29805 100644 (file)
@@ -91,8 +91,8 @@ unsigned char* CMemoryPool::Allocate(unsigned int nFileLen, uint64& nAllocatedSi
        m_pMem = new (nothrow) unsigned char[nTargetSize];\r
        while (m_pMem == NULL && nTargetSize >= 32 * 1024 * 1024 )\r
        {\r
-          nTargetSize -= 16 * 1024 * 1024;\r
-          m_pMem = new (nothrow) unsigned char[nTargetSize];\r
+               nTargetSize -= 16 * 1024 * 1024;\r
+               m_pMem = new (nothrow) unsigned char[nTargetSize];\r
        }\r
 \r
        if (m_pMem != NULL)\r
index 62ae52766014cf4bc1740ee336cb4037b2eb8c02..6c82fc1cff4d983e52fab398e9e838f3cafd92e9 100644 (file)
@@ -3,7 +3,7 @@
  * RainbowCrack\r
  *\r
  * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>\r
- * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>\r
+ * Copyright 2010 Martin Westergaard Jørgensen <martinwj2005@gmail.com>\r
  * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>\r
  * Copyright 2009, 2010 James Nobis <frt@quelrod.net>\r
  * Copyright 2010 uroskn\r
index 41a95155ec9f47c41bf25630d5bf70aa69148481..946c79d8931c7b5681735991533a73e194e45136 100644 (file)
@@ -129,11 +129,13 @@ timeval sub_timeofday( timeval tv2, timeval tv )
        return final;\r
 }\r
 \r
-unsigned int GetFileLen(FILE* file)\r
+long GetFileLen(FILE* file)\r
 {\r
-       long int pos = ftell(file);\r
+       // XXX on x86/x86_64 linux returns long\r
+       // 32-bit this is a problem if the file is > (2^31-1) bytes\r
+       long pos = ftell(file);\r
        fseek(file, 0, SEEK_END);\r
-       long int len = ftell(file);\r
+       long len = ftell(file);\r
        fseek(file, pos, SEEK_SET);\r
 \r
        return len;\r
@@ -170,7 +172,7 @@ bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset)
        string sChar = sCharset.substr(nStart + 1, nEnd - nStart - 1);\r
        vector<string> vParts;\r
        SeperateString(sChar, ",", vParts);\r
-       for(UINT4 i = 0; i < vParts.size(); i++)\r
+       for(uint32 i = 0; i < vParts.size(); i++)\r
        {\r
                tCharset stCharset;\r
                vector<string> vParts2;\r
@@ -184,6 +186,55 @@ bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset)
        }\r
        return true;\r
 }\r
+#ifdef BOINC\r
+bool boinc_ReadLinesFromFile(string sPathName, vector<string>& vLine)\r
+{\r
+       vLine.clear();\r
+       char input_path[512];\r
+       boinc_resolve_filename(sPathName.c_str(), input_path, sizeof(input_path));\r
+       FILE *file = boinc_fopen(input_path, "rb");\r
+       if (!file) {\r
+               fprintf(stderr,\r
+                       "Couldn't find input file, resolved name %s.\n", input_path\r
+               );\r
+               exit(-1);\r
+       }\r
+\r
+       if (file != NULL)\r
+       {\r
+               unsigned int len = GetFileLen(file);\r
+               char* data = new char[len + 1];\r
+               fread(data, 1, len, file);\r
+               data[len] = '\0';\r
+               string content = data;\r
+               content += "\n";\r
+               delete [] data;\r
+\r
+               unsigned int i;\r
+               for (i = 0; i < content.size(); i++)\r
+               {\r
+                       if (content[i] == '\r')\r
+                               content[i] = '\n';\r
+               }\r
+\r
+               string::size_type n;\r
+               while ((n = content.find("\n", 0)) != string::npos)\r
+               {\r
+                       string line = content.substr(0, n);\r
+                       line = TrimString(line);\r
+                       if (line != "")\r
+                               vLine.push_back(line);\r
+                       content = content.substr(n + 1);\r
+               }\r
+\r
+               fclose(file);\r
+       }\r
+       else\r
+               return false;\r
+\r
+       return true;\r
+}\r
+#endif\r
 bool ReadLinesFromFile(string sPathName, vector<string>& vLine)\r
 {\r
        vLine.clear();\r
@@ -303,7 +354,7 @@ string HexToStr(const unsigned char* pData, int nLen)
        return sRet;\r
 }\r
 \r
-uint64 GetAvailPhysMemorySize()\r
+unsigned long GetAvailPhysMemorySize()\r
 {\r
 #if defined(_WIN32)\r
        MEMORYSTATUS ms;\r
@@ -335,10 +386,11 @@ string GetApplicationPath()
        GetModuleFileName(NULL, fullPath, FILENAME_MAX);\r
 #else\r
        char szTmp[32];\r
-       // XXX linux/proc file system dependen\r
+       // XXX linux/proc file system dependent\r
        sprintf(szTmp, "/proc/%d/exe", getpid());\r
        int bytes = readlink(szTmp, fullPath, FILENAME_MAX);\r
-       if(bytes >= 0)\r
+\r
+       if( bytes >= 0 )\r
                fullPath[bytes] = '\0';\r
 #endif\r
 \r
@@ -352,13 +404,12 @@ string GetApplicationPath()
        if ( nIndex != string::npos )\r
                sApplicationPath = sApplicationPath.substr(0, nIndex+1);\r
 \r
-       //printf ("\n\nDebug: The application directory is %s\n", sApplicationPath.c_str());\r
        return sApplicationPath;\r
 }\r
 \r
 void ParseHash(string sHash, unsigned char* pHash, int& nHashLen)\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < sHash.size() / 2; i++)\r
        {\r
                string sSub = sHash.substr(i * 2, 2);\r
index 27d4dcda5a99703a651412695d4cb4d9c4847371..d359371b98cd756265a7d1dc0d1dff0c1a7b0633 100644 (file)
@@ -121,14 +121,15 @@ void tty_flush(void);
 \r
 timeval sub_timeofday( timeval tv2, timeval tv );\r
 \r
-unsigned int GetFileLen(FILE* file);\r
+long GetFileLen(FILE* file);\r
 string TrimString(string s);\r
+bool boinc_ReadLinesFromFile(string sPathName, vector<string>& vLine);\r
 bool ReadLinesFromFile(string sPathName, vector<string>& vLine);\r
 bool SeperateString(string s, string sSeperator, vector<string>& vPart);\r
 string uint64tostr(uint64 n);\r
 string uint64tohexstr(uint64 n);\r
 string HexToStr(const unsigned char* pData, int nLen);\r
-uint64 GetAvailPhysMemorySize();\r
+unsigned long GetAvailPhysMemorySize();\r
 string GetApplicationPath();\r
 void ParseHash(string sHash, unsigned char* pHash, int& nHashLen);\r
 bool GetHybridCharsets(string sCharset, vector<tCharset>& vCharset);\r
index 692c73e0961ab6ae9de8668816d77906b9a523d1..abd855076517797a322f22c81be219e749963112 100644 (file)
@@ -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;
 }
 
index cd36e7db26c693943dde77b3cdd30e3720aa6ee3..35450359f5f4bf1ae197de6e4d0b53df7a330974 100644 (file)
@@ -3,7 +3,6 @@
  * RainbowCrack
  *
  * Copyright 2010 Martin Westergaard Jørgensen <martinwj2005@gmail.com>
- * Copyright 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
  * Copyright 2010 James Nobis <frt@quelrod.net>
  *
  * 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:
index 2959787041a0f828af291ccaf256b48f7dc850f8..812035411f55ffad9875543c12552ed8717f5614 100644 (file)
@@ -183,7 +183,7 @@ bool NormalizeHash(string& sHash)
                return false;\r
 \r
        // Make lower\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < sNormalizedHash.size(); i++)\r
        {\r
                if (sNormalizedHash[i] >= 'A' && sNormalizedHash[i] <= 'F')\r
@@ -207,7 +207,7 @@ void LoadLMHashFromPwdumpFile(string sPathName, vector<string>& vUserName, vecto
        vector<string> vLine;\r
        if (ReadLinesFromFile(sPathName, vLine))\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vLine.size(); i++)\r
                {\r
                        vector<string> vPart;\r
@@ -241,7 +241,7 @@ void LoadLMHashFromCainLSTFile(string sPathName, vector<string>& vUserName, vect
        vector<string> vLine;\r
        if (ReadLinesFromFile(sPathName, vLine))\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vLine.size(); i++)\r
                {\r
                        vector<string> vPart;\r
@@ -313,7 +313,7 @@ bool LMPasswordCorrectCase(string sLMPassword, unsigned char* pNTLMHash, string&
        }\r
 \r
        unsigned char* pLMPassword = new unsigned char[sLMPassword.size() * 2];\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < sLMPassword.size(); i++)\r
        {\r
                pLMPassword[i * 2    ] = sLMPassword[i];\r
@@ -399,7 +399,7 @@ int main(int argc, char* argv[])
        }\r
        if (readFromIni)\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vLine.size(); i++)\r
                {\r
                        if (vLine[i].substr(0,1) != "#")\r
@@ -540,7 +540,7 @@ int main(int argc, char* argv[])
                vector<string> sSessionData;\r
                if (ReadLinesFromFile(sSessionPathName.c_str(), sSessionData))\r
                {\r
-                       UINT4 i;\r
+                       uint32 i;\r
                        for (i = 0; i < sSessionData.size(); i++)\r
                        {\r
                                vector<string> vPart;\r
@@ -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\r
        if (useDefaultRainbowTablePath && !resumeSession)\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vDefaultRainbowTablePath.size(); i++)\r
                {\r
                        vector<string> vPart;\r
@@ -630,7 +630,7 @@ int main(int argc, char* argv[])
                vector<string> vLine;\r
                if (ReadLinesFromFile(sPathName, vLine))\r
                {\r
-                       UINT4 i;\r
+                       uint32 i;\r
                        for (i = 0; i < vLine.size(); i++)\r
                        {\r
                                string sHash = vLine[i];\r
@@ -676,13 +676,13 @@ int main(int argc, char* argv[])
 \r
        if (fCrackerType)\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vHash.size(); i++)\r
                        hs.AddHash(vHash[i]);\r
        }\r
        else\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vLMHash.size(); i++)\r
                {\r
                        hs.AddHash(vLMHash[i].substr(0, 16));\r
@@ -696,7 +696,7 @@ int main(int argc, char* argv[])
                vector<string> sSessionData;\r
                if (ReadLinesFromFile(sSessionPathName.c_str(), sSessionData))\r
                {\r
-                       UINT4 i;\r
+                       uint32 i;\r
                        for (i = 0; i < sSessionData.size(); i++)\r
                        {\r
                                vector<string> vPart;\r
@@ -732,7 +732,7 @@ int main(int argc, char* argv[])
                        buffer += "sInputType=" + sInputType + "\n";\r
                        buffer += "sInput=" + sInput + "\n";\r
 \r
-                       UINT4 i;\r
+                       uint32 i;\r
                        for (i = 0; i < vPathName.size(); i++)\r
                        {\r
                                buffer += "sPathName=" + vPathName[i] + "\n";\r
@@ -786,7 +786,7 @@ int main(int argc, char* argv[])
        printf("-------------------------------------------------------\n");\r
        if (fCrackerType)\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vHash.size(); i++)\r
                {\r
                        string sPlain, sBinary;\r
@@ -801,7 +801,7 @@ int main(int argc, char* argv[])
        }\r
        else\r
        {\r
-               UINT4 i;\r
+               uint32 i;\r
                for (i = 0; i < vLMHash.size(); i++)\r
                {\r
                        string sPlain1, sBinary1;\r
index 514be09b0eed9b1e9c7520f42ad4d05079f2549b..934e9c6b8b62ea69322e1e90d742230a6f760341 100644 (file)
 
 
 #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;
                }
        }
index 952aab45deee9077d71d07fa21b5e9cb38435d40..9e6cbf1c6277555eddb9c5bec26cad5911c7a748 100644 (file)
@@ -24,8 +24,6 @@
 #ifndef _GLOBAL_H
 #define _GLOBAL_H
 
-//#include <stdint.h>
-
 #if defined(_WIN32) && !defined(__GNUC__)
        #define uint64 unsigned __int64
 #else
 
 #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
 
index 33fd94d2abb3d9dda07baaf9eb0ae4feb13f0821..c3d385804e0168bb50a6596a696777dd3b870542 100644 (file)
@@ -50,7 +50,7 @@ bool LM2NTLMcorrector::LMPasswordCorrectUnicode(string hexPassword, unsigned cha
 {\r
        string sPlain = "";\r
 \r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < hexPassword.size() / 2; i++)\r
        {\r
                string sSub = hexPassword.substr(i * 2, 2);\r
index e5d9c2f4fe4d752a43648acf4dbb7670fe639616..34ae50e359604a8606d5d6b10729a58eae5d8629 100644 (file)
                (a) = ROTATE_LEFT ((a), (s)); \\r
        }\r
 #define GG(a, b, c, d, x, s) { \\r
-               (a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; \\r
+               (a) += G ((b), (c), (d)) + (x) + (uint32)0x5a827999; \\r
                (a) = ROTATE_LEFT ((a), (s)); \\r
        }\r
 #define HH(a, b, c, d, x, s) { \\r
-               (a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; \\r
+               (a) += H ((b), (c), (d)) + (x) + (uint32)0x6ed9eba1; \\r
                (a) = ROTATE_LEFT ((a), (s)); \\r
        }\r
 #define S11 3\r
@@ -66,8 +66,8 @@
 void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest)\r
 {\r
        // access data as 4-byte word\r
-       #define uData                           ((UINT4 *)pData)\r
-       #define uDigest                         ((UINT4 *)pDigest)\r
+       #define uData                           ((uint32 *)pData)\r
+       #define uDigest                         ((uint32 *)pDigest)\r
 \r
        // pad word and append bit at appropriate location\r
        #define MD4_pad_w0()            (0x00000080)\r
@@ -76,12 +76,12 @@ void MD4_NEW( unsigned char * pData, int length, unsigned char * pDigest)
        #define MD4_pad_w3(data)        (((data) & 0x00FFFFFF) | 0x80000000)\r
 \r
        // For the hash working space\r
-       //__attribute__((aligned(16))) UINT4 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
-       //__declspec(align(16)) UINT4 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
-       UINT4 data[MD4_DIGEST_LENGTH] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
+       //__attribute__((aligned(16))) uint32 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
+       //__declspec(align(16)) uint32 data[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
+       uint32 data[MD4_DIGEST_LENGTH] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};\r
 \r
        // For the output result\r
-       UINT4 a,b,c,d;\r
+       uint32 a,b,c,d;\r
 \r
        switch (length)\r
        {\r
index 0b64a7a6346d11f8fcab294943e5a50d59328559..b960bbc36f3dca4aba3b46349630d9ba6a206e19 100644 (file)
@@ -139,7 +139,7 @@ void rcrackiThread::PreCalculate()
 \r
 void rcrackiThread::CheckAlarm()\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < t_pChainsFound.size(); i++)\r
        {\r
                RainbowChain* t_pChain = t_pChainsFound[i];\r
@@ -179,7 +179,7 @@ void rcrackiThread::CheckAlarm()
 \r
 void rcrackiThread::CheckAlarmO()\r
 {\r
-       UINT4 i;\r
+       uint32 i;\r
        for (i = 0; i < t_pChainsFoundO.size(); i++)\r
        {\r
                RainbowChainO* t_pChain = t_pChainsFoundO[i];\r
index 40c0e9f26c9b517fa2bfedf2d9535f4f9b4ed98d..e1218544755ab2e2f1e94304728de769f924361c 100644 (file)
@@ -82,12 +82,12 @@ void SHA1_NEW( unsigned char * pData, int length, unsigned char * pDigest)
        if (length > 16)\r
                return;\r
 \r
-       UINT4 Message_Block_Index    = 0;\r
+       uint32 Message_Block_Index    = 0;\r
 \r
        union\r
        {\r
                unsigned char Message_Block[64];\r
-               UINT4 Message_Block_W[16];\r
+               uint32 Message_Block_W[16];\r
        };\r
 \r
        Message_Block_W[0] = 0x00000000;\r
@@ -96,7 +96,7 @@ void SHA1_NEW( unsigned char * pData, int length, unsigned char * pDigest)
        Message_Block_W[3] = 0x00000000;\r
        Message_Block_W[4] = 0x00000000;\r
 \r
-       UINT4 Intermediate_Hash[5] = { H0, H1, H2, H3, H4 };\r
+       uint32 Intermediate_Hash[5] = { H0, H1, H2, H3, H4 };\r
        \r
        memcpy(Message_Block, pData, length);\r
        Message_Block_Index += length;\r
@@ -104,12 +104,12 @@ void SHA1_NEW( unsigned char * pData, int length, unsigned char * pDigest)
        //padMessage\r
        Message_Block[length] = 0x80;\r
        \r
-       UINT4 W_15 = length << 3;\r
+       uint32 W_15 = length << 3;\r
 \r
        int           t;                 /* Loop counter                */\r
-       UINT4      temp;              /* Temporary word value        */\r
-       UINT4      W[80];             /* Word sequence               */\r
-       UINT4      A, B, C, D, E;     /* Word buffers                */\r
+       uint32      temp;              /* Temporary word value        */\r
+       uint32      W[80];             /* Word sequence               */\r
+       uint32      A, B, C, D, E;     /* Word buffers                */\r
 \r
     /*\r
      *  Initialize the first 16 words in the array W\r
index 3eadfbf8275cbb4e87bad9bfa29f12f2913242e6..f9ca133d81ec0e365c42a7c0d17d440f5b4ece12 100644 (file)
@@ -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
index e4ee4fc740cfd88cd60e7c0322a3f00252ad95a7..e69ed184cfdc3d4c4b775969ae538dcb55531a91 100644 (file)
@@ -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;
                        
index d762e2690ed1d8dae80adca0656005f9e0e65009..5e08a97bcb34775b8dc4eb458668e7450ccad14e 100644 (file)
@@ -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 <martinwj2005@gmail.com>
+ * Copyright 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
+#include "BaseRTReader.h"
index b94114f8e432287ea9ab8dfe303dea0002693f19..66f2f10f7fe593431ba51c782aa0486e3e272cca 100644 (file)
@@ -1,11 +1,37 @@
+/*
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright 2010 Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
 #ifndef __BASERTREADER_H__
 #define __BASERTREADER_H__
 
 #include "Public.h"
 #include <string>
-#ifdef WIN32
-#include <io.h>
+
+#if defined(_WIN32) && !defined(__GNUC__)
+       #include <io.h>
 #endif
+
 using namespace std;
 
 class BaseRTReader
index 52c9091e8c5b280f8b39082fbf6de02b65ad9044..f551d639b5fc6fd397efe3b34bee9937719a62f3 100644 (file)
@@ -8,7 +8,7 @@
  * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
  * 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<stCharset> 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<string> 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;
+}
index de7e2fb430373b0fe9260cb226bd0400f9d641da..9854c59e0f2ef9f2f678723f6bed40ccfd437c1c 100644 (file)
@@ -1,8 +1,26 @@
 /*
-   RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
 #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<stCharset> 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
 
index a081eb8279c4d386f28008974a1a6feec3d208ea..e2d71c9f6328de2e91c0dfdfef6c969d718f5fa2 100644 (file)
@@ -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 <shuanglei@hotmail.com>
+ * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
-
-#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<ChainWalk>::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<string> 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<string> 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;
 }
 
index 427689454c9df7b71ae927c9ecb6162225feaecc..6d991fe81fb3bfa6f421800e0e974c646feb0362 100644 (file)
@@ -1,8 +1,27 @@
 /*
-   RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
 #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<ChainWalk> m_lChainWalk;
+       bool   debug;
+       string sPrecalcPathName;
+       int    preCalcPart;
+       vector<string> 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
index e6f92c0c17a586e969c7380fee5bfc9b71ff031d..4815fc6ac83d650de88e160c5fec597682516187 100644 (file)
@@ -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;
index 6d72c4b3813163b281a4d852a2bc83fa67a6484d..72f7f67331798b0ade1620440121df061a46ccfa 100644 (file)
@@ -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 <shuanglei@hotmail.com>
+ * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
-
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__GNUC__)
        #pragma warning(disable : 4786)
 #endif
 
index 4b53c1474139fe48af90c79cbdbd55f23585ea56..cc0dcdc563e28986215f498b1930f1e952a4f91a 100644 (file)
@@ -1,8 +1,27 @@
 /*
-   RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
 #ifndef _HASHROUTINE_H
 #define _HASHROUTINE_H
index 1019b4f736212ce01b987e1d9fa729da48240a36..053db7a04b5fff229fe08a321768693291e7f9b9 100644 (file)
@@ -1,8 +1,28 @@
 /*
-   RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
 #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;
        }
index 9f2ea4ed21f3c0e9532536a903544e161fbad176..d40d5a7d6bcf7fa8f7d927f2396704a01c082c2b 100644 (file)
@@ -1,12 +1,34 @@
 /*
-   RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
-   Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
+ * Copyright 2010 Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ * 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 <http://www.gnu.org/licenses/>.
+ */
 
 #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;
 
index 66e8ce46638521020d0dc13b4f76bd3c3e171403..6cd04822eff639376ddd191ad9b6fba60cac3428 100644 (file)
@@ -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 <http://www.gnu.org/licenses/>.
 */
 
-#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 <cstdio>
 #include <cctype>
 #include <ctime>
 
 #ifdef _WIN32
        #include <windows.h>
+#endif
+
+#if defined(_WIN32) && !defined(__GNUC__)
+       #include <windows.h>
+       #include <time.h>
+
+       #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))
 
        #elif defined(__linux__)
                #include <sys/sysinfo.h>
        #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<tCharset>& 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<string> vParts;
        SeperateString(sChar, ",", vParts);
-       for(UINT4 i = 0; i < vParts.size(); i++)
+       for(uint32 i = 0; i < vParts.size(); i++)
        {
                tCharset stCharset;
                vector<string> vParts2;
@@ -152,8 +236,8 @@ bool boinc_ReadLinesFromFile(string sPathName, vector<string>& 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<string>& vLine)
 
        return true;
 }
-#endif 
+#endif
 bool ReadLinesFromFile(string sPathName, vector<string>& 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<string>& 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<string>& 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<string>& 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<string>& vPart)
 {
@@ -217,14 +315,18 @@ bool SeperateString(string s, string sSeperator, vector<string>& 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 <shuanglei@hotmail.com>\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
index b3103f7d3dda3cedba6f0f9037081448af467967..6708d3ad70815b33745fc2b6e31657b7f3e9f918 100644 (file)
@@ -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 <unistd.h>
+#include <termios.h>
+#include <fcntl.h>
+
+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 <sys/time.h>
+#endif
+
+timeval sub_timeofday( timeval tv2, timeval tv );
+
+long GetFileLen(FILE* file);
 string TrimString(string s);
 bool boinc_ReadLinesFromFile(string sPathName, vector<string>& vLine);
 bool ReadLinesFromFile(string sPathName, vector<string>& vLine);
@@ -93,10 +117,11 @@ bool SeperateString(string s, string sSeperator, vector<string>& 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<tCharset>& vCharset);
 void Logo();
+bool writeResultLineToFile(string sOutputFile, string sHash, string sPlain, string sBinary);
 
 #endif
index 443fd1c7029d81fcc566a047cedabe25717559af..6fb0cb914507ef011bd4a07cb0c58d0e9aa3df1b 100644 (file)
@@ -1,6 +1,30 @@
+/*
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright 2010 Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
 #include "RTI2Reader.h"
 
 #include <math.h>
+
 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++;
        }
index fb17dd8f8e7e830a447ae0567a821fd72e5cdb77..902344aae3dfea17cd3af83653d0473c7b98b8dd 100644 (file)
@@ -1,13 +1,39 @@
+/*
+ * freerainbowtables is a project for generating, distributing, and using
+ * perfect rainbow tables
+ *
+ * Copyright 2010 Martin Westergaard Jørgensen <martinwj2005@gmail.com>
+ * Copyright 2010 James Nobis <frt@quelrod.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
 #ifndef __RTI2READER_H__
 #define __RTI2READER_H__
 
 #include "Public.h"
 #include <string>
-#ifdef WIN32
-#include <io.h>
+
+#if defined(_WIN32) && !defined(__GNUC__)
+       #include <io.h>
 #endif
+
 #include <vector>
 #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:
index b72dbe2d214c4fdcee088957bbe6e32ef9ec3d21..1a977861d80bc43b7a585c9f88f9c9e744758339 100644 (file)
@@ -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;
index 7a6f91a1bde0a98d578269e0c7e2d7c3f7f86b42..c4d6c38c5e04355e8087966b472895d5c66461d2 100644 (file)
     (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
 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;