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
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
\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
}\r
else\r
printf("can't open charset configuration file\n");\r
+\r
return false;\r
}\r
\r
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
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
#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
}\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
// 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
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
\r
bool pausing = false;\r
\r
- UINT4 nHashIndex;\r
+ uint32 nHashIndex;\r
for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++)\r
{\r
#ifdef _WIN32\r
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
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
\r
bool pausing = false;\r
\r
- UINT4 nHashIndex;\r
+ uint32 nHashIndex;\r
for (nHashIndex = 0; nHashIndex < vHash.size(); nHashIndex++)\r
{\r
#ifdef _WIN32\r
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
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
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
// 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
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
//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
\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
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
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
{\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
\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
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
\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
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
\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
\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
{\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
\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
\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
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
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
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
* 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
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
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
}\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
return sRet;\r
}\r
\r
-uint64 GetAvailPhysMemorySize()\r
+unsigned long GetAvailPhysMemorySize()\r
{\r
#if defined(_WIN32)\r
MEMORYSTATUS ms;\r
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
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
\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
}
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);
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;
}
unsigned int RTI2Reader::GetChainsLeft()
{
- int len = GetFileLen(m_pFile);
+ long len = GetFileLen(m_pFile);
return len / m_chainsizebytes - m_chainPosition;
}
* 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.
{
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:
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
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
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
}\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
}\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
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
// 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
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
\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
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
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
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
}\r
else\r
{\r
- UINT4 i;\r
+ uint32 i;\r
for (i = 0; i < vLMHash.size(); i++)\r
{\r
string sPlain1, sBinary1;\r
#ifndef MD5_pad_w1
-static inline UINT4 MD5_pad_w1(UINT4 data)
+static inline uint32 MD5_pad_w1(uint32 data)
{
// XXX x86 specific
__asm__ (
#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__ (
#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;
// 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};
*/
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:
}
// data block used for padding
- UINT4 dData[16];
+ uint32 dData[16];
if (len < 56) {
// 16 < length < 56
} else {
// len >= 56
- #define wIn ((UINT4 *)pData)
+ #define wIn ((uint32 *)pData)
// original len
int tlen = len;
);
#undef wIn
- #define wIn ((UINT4 *)pData)
+ #define wIn ((uint32 *)pData)
return;
}
}
#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
{\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
(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
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
#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
\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
\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
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
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
//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
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
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);
}
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;
-#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"
+/*
+ * 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
* 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
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;
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))
}
}
}
+
#elif defined(_M_X64) || defined(_M_IX86) || defined(__i386__) || defined(__x86_64__)
// Fast ia32 version
if (nIndexOfX < 0x100000000llu)
break;
#endif
+
int nCharsetLen = 0;
for(uint32 j = 0; j < m_vCharset.size(); j++)
{
return false;
}
+
+bool CChainWalkContext::isOldFormat()
+{
+ return isOldRtFormat;
+}
+
+bool CChainWalkContext::isRti2Format()
+{
+ return isRti2RtFormat;
+}
/*
- 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
typedef struct
{
unsigned char m_PlainCharset[255];
- int m_nPlainCharsetLen;
+ unsigned int m_nPlainCharsetLen;
int m_nPlainLenMin;
int m_nPlainLenMax;
string m_sPlainCharsetName;
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
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
/*
- 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
m_nPlainLenMax = 0;
m_nRainbowTableIndex = 0;
m_nRainbowChainLen = 0;
+ debug = false;
+ sPrecalcPathName = "";
+ preCalcPart = 0;
}
CChainWalkSet::~CChainWalkSet()
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
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;
}
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;
}
/*
- 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
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,
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
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);
memcpy (pHash,iv2,8);
}
*/
+
void HashNTLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
{
unsigned char UnicodePlain[MAX_PLAIN_LEN * 2];
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;
/*
- 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
/*
- 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
/*
- 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"
{
if (m_pMem != NULL)
{
- delete m_pMem;
+ delete [] m_pMem;
m_pMem = NULL;
m_nMemSize = 0;
}
// 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;
}
else
{
+ m_nMemSize = 0;
nAllocatedSize = 0;
return NULL;
}
/*
- 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:
virtual ~CMemoryPool();
private:
+ bool debug;
unsigned char* m_pMem;
unsigned int m_nMemSize;
*
* 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
* along with freerainbowtables. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__GNUC__)
#pragma warning(disable : 4786)
#endif
#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;
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;
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);
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);
data[len] = '\0';
string content = data;
content += "\n";
- delete data;
+ delete [] data;
unsigned int i;
for (i = 0; i < content.size(); i++)
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);
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)
{
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);
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
}
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;
pHash[i] = (unsigned char)nValue;
}
- nHashLen = sHash.size() / 2;
+ nHashLen = (int) sHash.size() / 2;
}
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
*
* 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
struct IndexChain
{
uint64 nPrefix;
- UINT4 nFirstChain;
- UINT4 nChainCount;
+ uint32 nFirstChain;
+ uint32 nChainCount;
};
struct FoundRainbowChain
{
#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);
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
+/*
+ * 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)
{
}
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);
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;
}
unsigned int RTI2Reader::GetChainsLeft()
{
- int len = GetFileLen(m_pFile);
+ long len = GetFileLen(m_pFile);
return len / m_chainsizebytes - m_chainPosition;
}
{
// 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;
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)
{
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++;
}
+/*
+ * 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
{
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:
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++)
{
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;
(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;
memcpy(in, pData, length);
in[2] = 0x80;
in[3] = 0x00;
- UINT4 * pUiIn = (UINT4 *) in;
+ uint32 * pUiIn = (uint32 *) in;
b0 = pUiIn[0];
}
break;
{
unsigned char in[4];
memcpy(in, pData, length);
- UINT4 * pUiIn = (UINT4 *) in;
+ uint32 * pUiIn = (uint32 *) in;
b0 = pUiIn[0];
b1 = 0x00000080;
}
memcpy(in, pData, length);
in[6] = 0x80;
in[7] = 0x00;
- UINT4 * pUiIn = (UINT4 *) in;
+ uint32 * pUiIn = (uint32 *) in;
b0 = pUiIn[0];
b1 = pUiIn[1];
}
{
unsigned char in[8];
memcpy(in, pData, length);
- UINT4 * pUiIn = (UINT4 *) in;
+ uint32 * pUiIn = (uint32 *) in;
b0 = pUiIn[0];
b1 = pUiIn[1];
b2 = 0x00000080;
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];
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];
c += 0x98badcfe;
d += 0x10325476;
- UINT4 buf[4] = { a, b, c, d};
+ uint32 buf[4] = { a, b, c, d};
memcpy(pDigest, buf, 16);
return;