From df8d800454d70f0fb39ab0c227ca55f91b581da7 Mon Sep 17 00:00:00 2001 From: James Nobis Date: Sun, 17 Oct 2010 00:27:58 -0500 Subject: [PATCH] 64-bit fixes for distrrtgen misc 64-bit fixes cleanup --- .../BOINC client apps/distrrtgen/Makefile | 87 ++++- .../distrrtgen/distrrtgen.cpp | 9 +- .../BOINC client apps/distrrtgen/global.h | 1 + Common/rt api/ChainWalkContext.cpp | 88 +++-- Common/rt api/HashAlgorithm.cpp | 177 ++++++--- Common/rt api/HashAlgorithm.h | 41 +- Common/rt api/HashRoutine.cpp | 4 +- Common/rt api/HashRoutine.h | 3 + Common/rt api/Public.cpp | 98 ++++- Common/rt api/Public.h | 42 ++- Common/rt api/des.h | 5 +- Common/rt api/des_enc.c | 1 + Common/rt api/global.h | 17 +- Common/rt api/md4.h | 3 +- Common/rt api/md5.h | 4 +- Common/rt api/tmp/HashAlgorithm.cpp | 349 ------------------ Common/rt api/tmp/HashAlgorithm.h | 38 -- Common/rt api/tmp/HashRoutine.cpp | 62 ---- Common/rt api/tmp/HashRoutine.h | 33 -- 19 files changed, 430 insertions(+), 632 deletions(-) create mode 120000 BOINC software/BOINC client apps/distrrtgen/global.h delete mode 100644 Common/rt api/tmp/HashAlgorithm.cpp delete mode 100644 Common/rt api/tmp/HashAlgorithm.h delete mode 100644 Common/rt api/tmp/HashRoutine.cpp delete mode 100644 Common/rt api/tmp/HashRoutine.h diff --git a/BOINC software/BOINC client apps/distrrtgen/Makefile b/BOINC software/BOINC client apps/distrrtgen/Makefile index 503fd08..153f289 100644 --- a/BOINC software/BOINC client apps/distrrtgen/Makefile +++ b/BOINC software/BOINC client apps/distrrtgen/Makefile @@ -1,33 +1,96 @@ -# This should work on Linux. Modify as needed for other platforms. +# freerainbowtables is a project for generating, distributing, and using +# perfect rainbow tables +# +# Copyright (C) Zhu Shuanglei +# Copyright Martin Westergaard Jørgensen +# Copyright 2009, 2010 Daniël Niggebrugge +# Copyright 2009, 2010 James Nobis +# +# This file is part of freerainbowtables. +# +# freerainbowtables is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# freerainbowtables is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with freerainbowtables. If not, see . -BOINC_DIR = /home/ubuntu/boinc +SHELL = /bin/sh + +#BOINC_DIR = /home/ubuntu/boinc +BOINC_DIR = /usr/share/boinc-dev BOINC_API_DIR = $(BOINC_DIR)/api BOINC_LIB_DIR = $(BOINC_DIR)/lib COMMON_LIB_DIR = /usr/lib +OPTIMIZATION = -O3 + CXXFLAGS = -g \ -static -static-libgcc \ -I$(BOINC_DIR) \ -I$(BOINC_LIB_DIR) \ -I$(BOINC_API_DIR) \ - -L$(BOINC_API_DIR) \ - -L$(BOINC_LIB_DIR) \ - -L /usr/X11R6/lib \ - -L. + -Wall \ + -c \ + -DBOINC \ + $(OPTIMIZATION) + +LFLAGS = -static -static-libgcc -Wall $(OPTIMIZATION) -L$(BOINC_API_DIR) \ + -L$(BOINC_LIB_DIR) -L /usr/X11R6/lib -L. + +LIBS = -lboinc_api -lboinc -lpthread -lssl libstdc++.a $(COMMON_LIB_DIR)/libssl.a $(COMMON_LIB_DIR)/libpthread.a +OBJS = ChainWalkContext.o des_enc.o des_setkey.o distrrtgen.o ecb_enc.o HashAlgorithm.o HashRoutine.o md4.o md5.o Public.o +OSNAME = $(shell uname -s) -PROGS = distrrtgen \ +all: distrrtgen -all: $(PROGS) +distrrtgen: libstdc++.a $(BOINC_API_DIR)/libboinc_api.a $(BOINC_LIB_DIR)/libboinc.a $(OBJS) + $(CXX) $(LFLAGS) $(OBJS) $(LIBS) -o distrrtgen libstdc++.a: ln -s `g++ -print-file-name=libstdc++.a` clean: - /bin/rm -f $(PROGS) *.o + /bin/rm -f distrrtgen *.o distclean: - /bin/rm -f $(PROGS) *.o libstdc++.a + /bin/rm -f distrrtgen *.o libstdc++.a + +rebuild: clean all + +ChainWalkContext.o: ChainWalkContext.h ChainWalkContext.cpp HashRoutine.h Public.h + $(CXX) $(CXXFLAGS) ChainWalkContext.cpp + +des_enc.o: des_enc.c des_locl.h spr.h + $(CXX) $(CXXFLAGS) des_enc.c + +des_setkey.o: des_setkey.c des_locl.h podd.h sk.h + $(CXX) $(CXXFLAGS) des_setkey.c + +distrrtgen.o: distrrtgen.cpp distrrtgen.h ChainWalkContext.h Public.h + $(CXX) $(CXXFLAGS) distrrtgen.cpp + +ecb_enc.o: ecb_enc.c des_locl.h spr.h + $(CXX) $(CXXFLAGS) ecb_enc.c + +HashAlgorithm.o: HashAlgorithm.h HashAlgorithm.cpp Public.h md4.h md5.h + $(CXX) $(CXXFLAGS) HashAlgorithm.cpp + +HashRoutine.o: HashRoutine.h HashRoutine.cpp global.h HashAlgorithm.h + $(CXX) $(CXXFLAGS) HashRoutine.cpp + +md4.o: md4.h md4.cpp global.h + $(CXX) $(CXXFLAGS) md4.cpp + +md5.o: md5.h md5.cpp global.h + $(CXX) $(CXXFLAGS) md5.cpp -distrrtgen: distrrtgen.o libstdc++.a $(BOINC_API_DIR)/libboinc_api.a $(BOINC_LIB_DIR)/libboinc.a - $(CXX) *.c *.cpp $(CXXFLAGS) -o distrrtgen distrrtgen.o libstdc++.a $(COMMON_LIB_DIR)/libssl.a $(COMMON_LIB_DIR)/libpthread.a -lboinc_api -lboinc -lpthread -lssl -O3 +Public.o: Public.h Public.cpp global.h + $(CXX) $(CXXFLAGS) Public.cpp diff --git a/BOINC software/BOINC client apps/distrrtgen/distrrtgen.cpp b/BOINC software/BOINC client apps/distrrtgen/distrrtgen.cpp index 5271512..d936785 100644 --- a/BOINC software/BOINC client apps/distrrtgen/distrrtgen.cpp +++ b/BOINC software/BOINC client apps/distrrtgen/distrrtgen.cpp @@ -58,9 +58,6 @@ #include "Public.h" // Rainbowcrack code #include "ChainWalkContext.h" -typedef unsigned int uint32; -//typedef unsigned __int64 uint64; - using std::string; @@ -72,7 +69,7 @@ double cpu_time = 20, comp_result; */ int QuickSortPartition(RainbowChainCP* pChain, int nLow, int nHigh) { - int nRandomIndex = nLow + ((unsigned int)rand() * (RAND_MAX + 1) + (unsigned int)rand()) % (nHigh - nLow + 1); + int nRandomIndex = nLow + ((uint32)rand() * ((uint32)RAND_MAX + 1) + (uint32)rand()) % (nHigh - nLow + 1); RainbowChainCP TempChain; TempChain = pChain[nLow]; pChain[nLow] = pChain[nRandomIndex]; @@ -130,7 +127,7 @@ int main(int argc, char **argv) { return -1; } string sHashRoutineName, sCharsetName, sSalt, sCheckPoints; - uint32 nRainbowChainCount, nPlainLenMin, nPlainLenMax, nRainbowTableIndex, nRainbowChainLen; + int nRainbowChainCount, nPlainLenMin, nPlainLenMax, nRainbowTableIndex, nRainbowChainLen; uint64 nChainStart; sHashRoutineName = argv[1]; sCharsetName = argv[2]; @@ -242,7 +239,7 @@ int main(int argc, char **argv) { // std::cout << "Starting to generate chains" << std::endl; for(int nCurrentCalculatedChains = nDataLen / 18; nCurrentCalculatedChains < nRainbowChainCount; nCurrentCalculatedChains++) { - int cpcheck = 0; + uint32 cpcheck = 0; unsigned short checkpoint = 0; fd = (double)nCurrentCalculatedChains / (double)nRainbowChainCount; boinc_fraction_done(fd); diff --git a/BOINC software/BOINC client apps/distrrtgen/global.h b/BOINC software/BOINC client apps/distrrtgen/global.h new file mode 120000 index 0000000..a5e31dc --- /dev/null +++ b/BOINC software/BOINC client apps/distrrtgen/global.h @@ -0,0 +1 @@ +../../../Common/rt api/global.h \ No newline at end of file diff --git a/Common/rt api/ChainWalkContext.cpp b/Common/rt api/ChainWalkContext.cpp index 3d7dcf8..4597fc2 100644 --- a/Common/rt api/ChainWalkContext.cpp +++ b/Common/rt api/ChainWalkContext.cpp @@ -1,8 +1,28 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a multithreaded implementation and fork of the original + * RainbowCrack + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * Copyright 2010 Yngve AAdlandsvik + * + * This file is part of rcracki_mt. + * + * 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 . + */ #ifdef _WIN32 #pragma warning(disable : 4786) @@ -58,10 +78,23 @@ bool CChainWalkContext::LoadCharset(string sName) { m_nHybridCharset = 1; } + + bool readCharset = false; vector vLine; - if (ReadLinesFromFile("charset.txt", vLine)) + + #ifdef BOINC + if ( boinc_ReadLinesFromFile( "charset.txt", vLine ) ) + readCharset = true; + #else + if ( ReadLinesFromFile("charset.txt", vLine) ) + readCharset = true; + else if ( ReadLinesFromFile(GetApplicationPath() + "charset.txt", vLine) ) + readCharset = true; + #endif + + if ( readCharset ) { - int i; + uint32 i; for (i = 0; i < vLine.size(); i++) { // Filter comment @@ -78,7 +111,7 @@ bool CChainWalkContext::LoadCharset(string sName) // sCharsetName charset check bool fCharsetNameCheckPass = true; - int j; + uint32 j; for (j = 0; j < sCharsetName.size(); j++) { if ( !isalpha(sCharsetName[j]) @@ -120,7 +153,7 @@ bool CChainWalkContext::LoadCharset(string sName) GetHybridCharsets(sName, vCharsets); if(sCharsetName == vCharsets[m_vCharset.size()].sName) { - stCharset tCharset = {0}; + stCharset tCharset; tCharset.m_nPlainCharsetLen = sCharsetContent.size(); memcpy(tCharset.m_PlainCharset, sCharsetContent.c_str(), tCharset.m_nPlainCharsetLen); tCharset.m_sPlainCharsetName = sCharsetName; @@ -149,6 +182,7 @@ bool CChainWalkContext::LoadCharset(string sName) } else printf("can't open charset configuration file\n"); + return false; } @@ -189,7 +223,7 @@ bool CChainWalkContext::SetPlainCharset(string sCharsetName, int nPlainLenMin, i m_nPlainLenMaxTotal = 0; m_nPlainLenMinTotal = 0; uint64 nTemp = 1; - int j, k = 1; + uint32 j, k = 1; for(j = 0; j < m_vCharset.size(); j++) { int i; @@ -280,7 +314,7 @@ bool CChainWalkContext::SetupWithPathName(string sPathName, int& nRainbowChainLe } else { - if (sCharsetDefinition.find('#') == -1) // For backward compatibility, "#1-7" is implied + if ( sCharsetDefinition.find('#') == string::npos ) // For backward compatibility, "#1-7" is implied { sCharsetName = sCharsetDefinition; nPlainLenMin = 1; @@ -424,29 +458,32 @@ void CChainWalkContext::IndexToPlain() m_nPlainLen = m_nPlainLenMinTotal; uint64 nIndexOfX = m_nIndex - m_nPlainSpaceUpToX[m_nPlainLen - 1]; -#ifdef _WIN64 +// this is the generic code for non ia32 x86 platforms +#if !defined(_M_X86) && !defined(__i386__) - // Slow version + // 32-bit/generic version (slow for non 64-bit platforms) for (i = m_nPlainLen - 1; i >= 0; i--) { int nCharsetLen = 0; - for(int j = 0; j < m_vCharset.size(); i++) + for(uint32 j = 0; j < m_vCharset.size(); i++) { nCharsetLen += m_vCharset[j].m_nPlainLenMax; if(i < nCharsetLen) // We found the correct charset { - m_Plain[i] = m_vCharset[j].m_PlainCharset[nIndexOfX % m_nPlainCharsetLen]; + m_Plain[i] = m_vCharset[j].m_PlainCharset[nIndexOfX % m_vCharset[j].m_nPlainCharsetLen]; nIndexOfX /= m_vCharset[j].m_nPlainCharsetLen; + break; } } } #else - // Fast version + // Fast ia32 version for (i = m_nPlainLen - 1; i >= 0; i--) { -#ifdef _WIN32 + // 0x100000000 = 2^32 +#ifdef _M_X86 if (nIndexOfX < 0x100000000I64) break; #else @@ -454,7 +491,7 @@ void CChainWalkContext::IndexToPlain() break; #endif int nCharsetLen = 0; - for(int j = 0; j < m_vCharset.size(); j++) + for(uint32 j = 0; j < m_vCharset.size(); j++) { nCharsetLen += m_vCharset[j].m_nPlainLenMax; if(i < nCharsetLen) // We found the correct charset @@ -466,27 +503,30 @@ void CChainWalkContext::IndexToPlain() } } - unsigned int nIndexOfX32 = (unsigned int)nIndexOfX; + uint32 nIndexOfX32 = (uint32)nIndexOfX; for (; i >= 0; i--) { int nCharsetLen = 0; - for(int j = 0; j < m_vCharset.size(); j++) + for(uint32 j = 0; j < m_vCharset.size(); j++) { nCharsetLen += m_vCharset[j].m_nPlainLenMax; if(i < nCharsetLen) // We found the correct charset { -// m_Plain[i] = m_PlainCharset[nIndexOfX32 % m_vCharset[j].m_nPlainCharsetLen]; +// m_Plain[i] = m_vCharset[j].m_PlainCharset[nIndexOfX32 % m_vCharset[j].m_nPlainCharsetLen]; // nIndexOfX32 /= m_vCharset[j].m_nPlainCharsetLen; - unsigned int nPlainCharsetLen = m_vCharset[j].m_nPlainCharsetLen; +// moving nPlainCharsetLen into the asm body and avoiding the extra temp +// variable results in performance gain +// unsigned int nPlainCharsetLen = m_vCharset[j].m_nPlainCharsetLen; unsigned int nTemp; -#ifdef _WIN32 + +#if defined(_WIN32) && !defined(__GNUC__) __asm { mov eax, nIndexOfX32 xor edx, edx - div nPlainCharsetLen + div m_vCharset[j].m_nPlainCharsetLen mov nIndexOfX32, eax mov nTemp, edx } @@ -498,7 +538,7 @@ void CChainWalkContext::IndexToPlain() "mov %%eax, %0;" "mov %%edx, %1;" : "=m"(nIndexOfX32), "=m"(nTemp) - : "m"(nIndexOfX32), "m"(nPlainCharsetLen) + : "m"(nIndexOfX32), "m"(m_vCharset[j].m_nPlainCharsetLen) : "%eax", "%edx" ); m_Plain[i] = m_vCharset[j].m_PlainCharset[nTemp]; diff --git a/Common/rt api/HashAlgorithm.cpp b/Common/rt api/HashAlgorithm.cpp index 909f79c..e6f92c0 100644 --- a/Common/rt api/HashAlgorithm.cpp +++ b/Common/rt api/HashAlgorithm.cpp @@ -1,16 +1,49 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + * + * Changes: not using OpenSSL routines the slow way anymore, as suggested by jci. + */ #include "HashAlgorithm.h" #include "Public.h" + #include + +//#include #include "md4.h" #include "md5.h" #include "des.h" +//#include "sha1.h" +#if defined(_WIN32) && !defined(__GNUC__) + #pragma comment(lib, "libeay32.lib") +#endif + +#ifdef __NetBSD__ + #include +#endif + #define MSCACHE_HASH_SIZE 16 void setup_des_key(unsigned char key_56[], des_key_schedule &ks) { @@ -97,32 +130,38 @@ void HashHALFLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) void HashNTLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) { - unsigned char UnicodePlain[MAX_PLAIN_LEN]; - static unsigned char spoofed_challange[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; - - int len = (nPlainLen < 127) ? nPlainLen : 127; - int i; - - for (i = 0; i < len; i++) - { - UnicodePlain[i * 2] = pPlain[i]; - UnicodePlain[i * 2 + 1] = 0x00; - } - - des_key_schedule ks; - unsigned char lm[21]; - - MD4_NEW(UnicodePlain, len * 2, lm); - lm[16] = lm[17] = lm[18] = lm[19] = lm[20] = 0; - - setup_des_key(lm, ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)pHash, ks, DES_ENCRYPT); - - setup_des_key(&lm[7], ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[8], ks, DES_ENCRYPT); - - setup_des_key(&lm[14], ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[16], ks, DES_ENCRYPT); + unsigned char UnicodePlain[MAX_PLAIN_LEN]; + static unsigned char spoofed_challange[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; + + int len = (nPlainLen < 127) ? nPlainLen : 127; + int i; + + for (i = 0; i < len; i++) + { + UnicodePlain[i * 2] = pPlain[i]; + UnicodePlain[i * 2 + 1] = 0x00; + } + + des_key_schedule ks; + unsigned char lm[21]; + + /*MD4_CTX ctx; + MD4_Init(&ctx); + MD4_Update(&ctx, UnicodePlain, len * 2); + MD4_Final(lm, &ctx); */ + MD4_NEW(UnicodePlain, len * 2, lm); + + //MD4(UnicodePlain, len * 2, lm); + lm[16] = lm[17] = lm[18] = lm[19] = lm[20] = 0; + + setup_des_key(lm, ks); + des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)pHash, ks, DES_ENCRYPT); + + setup_des_key(&lm[7], ks); + des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[8], ks, DES_ENCRYPT); + + setup_des_key(&lm[14], ks); + des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[16], ks, DES_ENCRYPT); } /* @@ -183,12 +222,19 @@ void HashNTLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) MD4_NEW(UnicodePlain, nPlainLen * 2, pHash); } + /* void HashMD2(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) { - MD2(pPlain, nPlainLen, pHash); + MD2_CTX ctx; + MD2_Init(&ctx); + MD2_Update(&ctx, pPlain, nPlainLen); + MD2_Final(pHash, &ctx); + + //MD2(pPlain, nPlainLen, pHash); } */ + void HashMD4(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) { MD4_NEW(pPlain, nPlainLen, pHash); @@ -205,15 +251,24 @@ void HashDoubleMD5(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) memcpy(hash, pHash, 16); MD5_NEW(hash, 16, pHash); } + /* void HashSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) { - SHA1(pPlain, nPlainLen, pHash); + SHA_CTX ctx; + SHA1_Init(&ctx); + SHA1_Update(&ctx, (unsigned char *) pPlain, nPlainLen); + SHA1_Final(pHash, &ctx); } void HashRIPEMD160(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) { - RIPEMD160(pPlain, nPlainLen, pHash); + RIPEMD160_CTX ctx; + RIPEMD160_Init(&ctx); + RIPEMD160_Update(&ctx, pPlain, nPlainLen); + RIPEMD160_Final(pHash, &ctx); + + //RIPEMD160(pPlain, nPlainLen, pHash); } void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash) @@ -241,9 +296,7 @@ void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash) unicode_user[i*2+1] = 0x00; } - MD4_Init(&ctx); - MD4_Update(&ctx,unicode_pwd,nPlainLen*2); - MD4_Final(final1,&ctx); + MD4_NEW( (unsigned char*)unicode_pwd, nPlainLen*2, final1 ); MD4_Init(&ctx); MD4_Update(&ctx,final1,MD4_DIGEST_LENGTH); @@ -256,7 +309,7 @@ void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash) { unicode_pwd[i*2] = pPlain[i]; unicode_pwd[i*2+1] = 0x00; - }*/ + }*/ /* unsigned char *buf = (unsigned char*)calloc(MSCACHE_HASH_SIZE + nSaltLength, sizeof(unsigned char)); HashNTLM(pPlain, nPlainLen, buf, NULL); @@ -273,19 +326,19 @@ void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash) /* inline void mysql_hash_password_323(unsigned long *result, const char *password) { - register unsigned long nr=1345345333L, add=7, nr2=0x12345671L; - unsigned long tmp; - for (; *password ; password++) - { - if (*password == ' ' || *password == '\t') continue; - tmp= (unsigned long) (unsigned char) *password; - nr^= (((nr & 63)+add)*tmp)+ (nr << 8); - nr2+=(nr2 << 8) ^ nr; - add+=tmp; - } - result[0]=nr & (((unsigned long) 1L << 31) -1L); ; - result[1]=nr2 & (((unsigned long) 1L << 31) -1L); - return; + register unsigned long nr=1345345333L, add=7, nr2=0x12345671L; + unsigned long tmp; + for (; *password ; password++) + { + if (*password == ' ' || *password == '\t') continue; + tmp= (unsigned long) (unsigned char) *password; + nr^= (((nr & 63)+add)*tmp)+ (nr << 8); + nr2+=(nr2 << 8) ^ nr; + add+=tmp; + } + result[0]=nr & (((unsigned long) 1L << 31) -1L); // Don't use sign bit (str2int) + result[1]=nr2 & (((unsigned long) 1L << 31) -1L); + return; } void HashMySQL323(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) @@ -316,18 +369,19 @@ void HashMySQLSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) SHA1_Final(pHash, &ctx); } */ + //********************************************************************************* // Code for PIX password hashing //********************************************************************************* static char itoa64[] = /* 0 ... 63 => ascii - 64 */ - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; void _crypt_to64(char *s, unsigned long v, int n) { - while (--n >= 0) { - *s++ = itoa64[v&0x3f]; - v >>= 6; - } + while (--n >= 0) { + *s++ = itoa64[v&0x3f]; + v >>= 6; + } } /* void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) @@ -342,6 +396,7 @@ void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) 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; _crypt_to64(p,*(unsigned long*) (final+0),4); p += 4; @@ -355,3 +410,15 @@ void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) free (pass); } */ +#if !defined(_WIN32) || defined(__GNUC__) +char *strupr(char *s1) +{ + char *p = s1; + while(*p) + { + *p = (char) toupper(*p); + p++; + } + return s1; +} +#endif diff --git a/Common/rt api/HashAlgorithm.h b/Common/rt api/HashAlgorithm.h index 667245a..01a4d74 100644 --- a/Common/rt api/HashAlgorithm.h +++ b/Common/rt api/HashAlgorithm.h @@ -1,8 +1,27 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #ifndef _HASHALGORITHM_H #define _HASHALGORITHM_H @@ -13,20 +32,23 @@ void HashNTLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); void HashMD4(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); void HashMD5(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); void HashDoubleMD5(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -/*void HashSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashRIPEMD160(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); +void HashSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); +//void HashRIPEMD160(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash); + //**************************************************************************** // MySQL Password Hashing //**************************************************************************** + void HashMySQL323(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); void HashMySQLSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); //**************************************************************************** // Cisco PIX Password Hashing //**************************************************************************** + void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -*/ + //**************************************************************************** // (HALF) LM CHALL hashing void HashLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); @@ -34,6 +56,9 @@ void HashHALFLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) // From mao void HashNTLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -//void HashORACLE(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); +void HashORACLE(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); +#if !defined(_WIN32) || defined(__GNUC__) +char *strupr(char *s1); +#endif #endif diff --git a/Common/rt api/HashRoutine.cpp b/Common/rt api/HashRoutine.cpp index 496f399..6d72c4b 100644 --- a/Common/rt api/HashRoutine.cpp +++ b/Common/rt api/HashRoutine.cpp @@ -53,7 +53,7 @@ void CHashRoutine::AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRout string CHashRoutine::GetAllHashRoutineName() { string sRet; - int i; + uint32 i; for (i = 0; i < vHashRoutineName.size(); i++) sRet += vHashRoutineName[i] + " "; @@ -62,7 +62,7 @@ string CHashRoutine::GetAllHashRoutineName() void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen) { - int i; + uint32 i; for (i = 0; i < vHashRoutineName.size(); i++) { if (sHashRoutineName == vHashRoutineName[i]) diff --git a/Common/rt api/HashRoutine.h b/Common/rt api/HashRoutine.h index 681fa78..4b53c14 100644 --- a/Common/rt api/HashRoutine.h +++ b/Common/rt api/HashRoutine.h @@ -9,6 +9,9 @@ #include #include + +#include "global.h" + using namespace std; typedef void (*HASHROUTINE)(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); diff --git a/Common/rt api/Public.cpp b/Common/rt api/Public.cpp index f917d37..66e8ce4 100644 --- a/Common/rt api/Public.cpp +++ b/Common/rt api/Public.cpp @@ -1,7 +1,26 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright Martin Westergaard Jørgensen + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . */ #ifdef _WIN32 @@ -31,8 +50,18 @@ #ifdef _WIN32 #include -#else - #include +#elif defined(__APPLE__) || \ + ((defined(__unix__) || defined(unix)) && !defined(USG)) + + #include + + #if defined(BSD) + #include + #elif defined(__linux__) + #include + #else + #error Unsupported Operating system + #endif #endif ////////////////////////////////////////////////////////////////////// @@ -72,12 +101,13 @@ bool GetHybridCharsets(string sCharset, vector& vCharset) // Example: hybrid(mixalpha-numeric-all-space#1-6,numeric#1-4) if(sCharset.substr(0, 6) != "hybrid") // Not hybrid charset return false; - size_t nEnd = sCharset.rfind(')'); - size_t nStart = sCharset.rfind('('); + + UINT4 nEnd = (int) sCharset.rfind(')'); + UINT4 nStart = (int) sCharset.rfind('('); string sChar = sCharset.substr(nStart + 1, nEnd - nStart - 1); vector vParts; SeperateString(sChar, ",", vParts); - for(int i = 0; i < vParts.size(); i++) + for(UINT4 i = 0; i < vParts.size(); i++) { tCharset stCharset; vector vParts2; @@ -95,15 +125,16 @@ bool GetHybridCharsets(string sCharset, vector& vCharset) bool boinc_ReadLinesFromFile(string sPathName, vector& vLine) { vLine.clear(); - char input_path[512]; - boinc_resolve_filename(sPathName.c_str(), input_path, sizeof(input_path)); - FILE *file = boinc_fopen(input_path, "rb"); - if (!file) { - fprintf(stderr, - "Couldn't find input file, resolved name %s.\n", input_path - ); - exit(-1); - } + char input_path[512]; + boinc_resolve_filename(sPathName.c_str(), input_path, sizeof(input_path)); + FILE *file = boinc_fopen(input_path, "rb"); + if (!file) { + fprintf(stderr, + "Couldn't find input file, resolved name %s.\n", input_path + ); + exit(-1); + } + if (file != NULL) { unsigned int len = GetFileLen(file); @@ -112,7 +143,7 @@ bool boinc_ReadLinesFromFile(string sPathName, vector& vLine) data[len] = '\0'; string content = data; content += "\n"; - delete data; + delete [] data; unsigned int i; for (i = 0; i < content.size(); i++) @@ -253,9 +284,38 @@ unsigned int GetAvailPhysMemorySize() #endif } +string GetApplicationPath() +{ + char fullPath[FILENAME_MAX]; + +#ifdef _WIN32 + GetModuleFileName(NULL, fullPath, FILENAME_MAX); +#else + char szTmp[32]; + // XXX linux/proc file system dependent + sprintf(szTmp, "/proc/%d/exe", getpid()); + int bytes = readlink(szTmp, fullPath, FILENAME_MAX); + + if( bytes >= 0 ) + fullPath[bytes] = '\0'; +#endif + + string sApplicationPath = fullPath; +#ifdef _WIN32 + int nIndex = sApplicationPath.find_last_of('\\'); +#else + int nIndex = sApplicationPath.find_last_of('/'); +#endif + + if ( nIndex != -1 ) + sApplicationPath = sApplicationPath.substr(0, nIndex+1); + + return sApplicationPath; +} + void ParseHash(string sHash, unsigned char* pHash, int& nHashLen) { - int i; + uint32 i; for (i = 0; i < sHash.size() / 2; i++) { string sSub = sHash.substr(i * 2, 2); diff --git a/Common/rt api/Public.h b/Common/rt api/Public.h index 3a315ae..b3103f7 100644 --- a/Common/rt api/Public.h +++ b/Common/rt api/Public.h @@ -1,24 +1,41 @@ /* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables + * + * Copyright (C) Zhu Shuanglei + * Copyright 2009, 2010 Daniël Niggebrugge + * Copyright 2009, 2010 James Nobis + * + * This file is part of freerainbowtables. + * + * freerainbowtables is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * freerainbowtables is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with freerainbowtables. If not, see . + */ #ifndef _PUBLIC_H #define _PUBLIC_H #include +#include +#include #include #include #include -using namespace std; -#ifdef _WIN32 - #define uint64 unsigned __int64 -#else - #define uint64 u_int64_t -#endif +#include "global.h" + +using namespace std; struct RainbowChain { @@ -35,8 +52,8 @@ struct RainbowChainCP struct IndexChain { uint64 nPrefix; - int nFirstChain; - unsigned int nChainCount; + UINT4 nFirstChain; + UINT4 nChainCount; }; struct FoundRainbowChain { @@ -77,6 +94,7 @@ string uint64tostr(uint64 n); string uint64tohexstr(uint64 n); string HexToStr(const unsigned char* pData, int nLen); unsigned int GetAvailPhysMemorySize(); +string GetApplicationPath(); void ParseHash(string sHash, unsigned char* pHash, int& nHashLen); bool GetHybridCharsets(string sCharset, vector& vCharset); void Logo(); diff --git a/Common/rt api/des.h b/Common/rt api/des.h index abe1401..8063f1e 100644 --- a/Common/rt api/des.h +++ b/Common/rt api/des.h @@ -54,8 +54,11 @@ #ifdef __cplusplus extern "C" { #endif -typedef unsigned int u_int32_t; +#ifndef u_int32_t + typedef unsigned int u_int32_t; +#endif + /* must be 32bit quantity */ #define DES_LONG u_int32_t diff --git a/Common/rt api/des_enc.c b/Common/rt api/des_enc.c index 320f570..a2dd913 100644 --- a/Common/rt api/des_enc.c +++ b/Common/rt api/des_enc.c @@ -60,6 +60,7 @@ */ #include "des_locl.h" +#include "spr.h" extern const DES_LONG des_SPtrans[8][64]; void des_encrypt1(DES_LONG *data, des_key_schedule ks, int enc) diff --git a/Common/rt api/global.h b/Common/rt api/global.h index 04c4e80..56aa04e 100644 --- a/Common/rt api/global.h +++ b/Common/rt api/global.h @@ -1,31 +1,29 @@ /* - * rcracki_mt is a multithreaded implementation and fork of the original - * RainbowCrack + * freerainbowtables is a project for generating, distributing, and using + * perfect rainbow tables * * Copyright 2009, 2010 Daniël Niggebrugge * Copyright 2009, 2010 James Nobis * - * This file is part of racrcki_mt. + * This file is part of freerainbowtables. * - * rcracki_mt is free software: you can redistribute it and/or modify + * 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. * - * rcracki_mt is distributed in the hope that it will be useful, + * 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 rcracki_mt. If not, see . + * along with freerainbowtables. If not, see . */ #ifndef _GLOBAL_H #define _GLOBAL_H -//#include - #if defined(_WIN32) && !defined(__GNUC__) #define uint64 unsigned __int64 #else @@ -38,11 +36,14 @@ #if defined(_WIN32) && !defined(__GNUC__) #define UINT4 unsigned __int32 + #define uint32 unsigned __int32 #else #ifndef u_int32_t #define UINT4 unsigned int + #define uint32 unsigned int #else #define UINT4 u_int32_t + #define uint32 u_int32_t #endif #endif diff --git a/Common/rt api/md4.h b/Common/rt api/md4.h index 8a5c428..249ebcd 100644 --- a/Common/rt api/md4.h +++ b/Common/rt api/md4.h @@ -1,8 +1,7 @@ #ifndef MD4_H #define MD4_H -//typedef unsigned long uint32; -typedef unsigned long UINT4; +#include "global.h" //Main function void MD4_NEW( unsigned char * buf, int len, unsigned char * pDigest); diff --git a/Common/rt api/md5.h b/Common/rt api/md5.h index 1d3da9e..f245420 100644 --- a/Common/rt api/md5.h +++ b/Common/rt api/md5.h @@ -1,7 +1,9 @@ #ifndef MD5_H #define MD5_H -typedef unsigned long uint32; +#include "global.h" + +#define MD5_DIGEST_LENGTH 16 //Main function void MD5_NEW( unsigned char * buf, int len, unsigned char * pDigest); diff --git a/Common/rt api/tmp/HashAlgorithm.cpp b/Common/rt api/tmp/HashAlgorithm.cpp deleted file mode 100644 index 07cebe5..0000000 --- a/Common/rt api/tmp/HashAlgorithm.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ - -#include "HashAlgorithm.h" - -#include "Public.h" - -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 - #pragma comment(lib, "libeay32.lib") -#endif -#define MSCACHE_HASH_SIZE 16 -void setup_des_key(unsigned char key_56[], des_key_schedule &ks) -{ - des_cblock key; - - key[0] = key_56[0]; - key[1] = (key_56[0] << 7) | (key_56[1] >> 1); - key[2] = (key_56[1] << 6) | (key_56[2] >> 2); - key[3] = (key_56[2] << 5) | (key_56[3] >> 3); - key[4] = (key_56[3] << 4) | (key_56[4] >> 4); - key[5] = (key_56[4] << 3) | (key_56[5] >> 5); - key[6] = (key_56[5] << 2) | (key_56[6] >> 6); - key[7] = (key_56[6] << 1); - - //des_set_odd_parity(&key); - des_set_key(&key, ks); -} - -void HashLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) -{ - /* - unsigned char data[7] = {0}; - memcpy(data, pPlain, nPlainLen > 7 ? 7 : nPlainLen); - */ - - int i; - for (i = nPlainLen; i < 7; i++) - pPlain[i] = 0; - - static unsigned char magic[] = {0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; - des_key_schedule ks; - //setup_des_key(data, ks); - setup_des_key(pPlain, ks); - des_ecb_encrypt((des_cblock*)magic, (des_cblock*)pHash, ks, DES_ENCRYPT); -} - -void HashLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) -{ - unsigned char pass[14]; - unsigned char pre_lmresp[21]; - static unsigned char magic[] = {0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; - static unsigned char spoofed_challange[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; - des_key_schedule ks; - - memset (pass,0,sizeof(pass)); - memset (pre_lmresp,0,sizeof(pre_lmresp)); - - memcpy (pass,pPlain, nPlainLen); - - setup_des_key(pass, ks); - des_ecb_encrypt((des_cblock*)magic, (des_cblock*)pre_lmresp, ks, DES_ENCRYPT); - - setup_des_key(&pass[7], ks); - des_ecb_encrypt((des_cblock*)magic, (des_cblock*)&pre_lmresp[8], ks, DES_ENCRYPT); - - setup_des_key(pre_lmresp, ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)pHash, ks, DES_ENCRYPT); - - setup_des_key(&pre_lmresp[7], ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[8], ks, DES_ENCRYPT); - - setup_des_key(&pre_lmresp[14], ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[16], ks, DES_ENCRYPT); - -} - -void HashHALFLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) -{ - unsigned char pre_lmresp[8]; - static unsigned char magic[] = {0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25}; - static unsigned char salt[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; - - des_key_schedule ks; - unsigned char plain[8] = {0}; - memcpy(plain, pPlain, nPlainLen); - setup_des_key(plain, ks); - des_ecb_encrypt((des_cblock*)magic, (des_cblock*)pre_lmresp, ks, DES_ENCRYPT); - - setup_des_key(pre_lmresp, ks); - des_ecb_encrypt((des_cblock*)salt, (des_cblock*)pHash, ks, DES_ENCRYPT); -} - - - -void HashNTLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) -{ - unsigned char UnicodePlain[MAX_PLAIN_LEN]; - static unsigned char spoofed_challange[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; - - int len = (nPlainLen < 127) ? nPlainLen : 127; - int i; - - for (i = 0; i < len; i++) - { - UnicodePlain[i * 2] = pPlain[i]; - UnicodePlain[i * 2 + 1] = 0x00; - } - - des_key_schedule ks; - unsigned char lm[21]; - - MD4(UnicodePlain, len * 2, lm); - lm[16] = lm[17] = lm[18] = lm[19] = lm[20] = 0; - - setup_des_key(lm, ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)pHash, ks, DES_ENCRYPT); - - setup_des_key(&lm[7], ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[8], ks, DES_ENCRYPT); - - setup_des_key(&lm[14], ks); - des_ecb_encrypt((des_cblock*)spoofed_challange, (des_cblock*)&pHash[16], ks, DES_ENCRYPT); -} - - -void HashORACLE(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) -{ - char ToEncrypt[256]; - char temp[256]; - char username[256]; - - DES_cblock iv,iv2; - DES_key_schedule ks1,ks2; - unsigned char deskey_fixed[]={ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef}; - int i,j; - - strcpy (username, "SYS"); - int userlen = 3; - -// strupr ((char*) pPlain); - memset (ToEncrypt,0,sizeof(ToEncrypt)); - - for (i=1,j=0; j ascii - 64 */ - "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; - -void _crypt_to64(char *s, unsigned long v, int n) -{ - while (--n >= 0) { - *s++ = itoa64[v&0x3f]; - v >>= 6; - } -} - -void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash) -{ - char temp[MD5_DIGEST_LENGTH+1]; - unsigned char final[MD5_DIGEST_LENGTH]; - char* pass = (char*) calloc (nPlainLen+MD5_DIGEST_LENGTH,sizeof(char)); - - memcpy (pass,pPlain,nPlainLen); - - MD5_CTX ctx; - MD5_Init(&ctx); - MD5_Update(&ctx, (unsigned char *) pass, MD5_DIGEST_LENGTH); - MD5_Final(final, &ctx); - - char* p = (char*) temp; - _crypt_to64(p,*(unsigned long*) (final+0),4); p += 4; - _crypt_to64(p,*(unsigned long*) (final+4),4); p += 4; - _crypt_to64(p,*(unsigned long*) (final+8),4); p += 4; - _crypt_to64(p,*(unsigned long*) (final+12),4); p += 4; - *p=0; - - memcpy(pHash,temp,MD5_DIGEST_LENGTH); - - free (pass); -} diff --git a/Common/rt api/tmp/HashAlgorithm.h b/Common/rt api/tmp/HashAlgorithm.h deleted file mode 100644 index b617f9f..0000000 --- a/Common/rt api/tmp/HashAlgorithm.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ - -#ifndef _HASHALGORITHM_H -#define _HASHALGORITHM_H - -void HashLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashNTLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashMD2(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashMD4(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashMD5(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashRIPEMD160(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash); -//**************************************************************************** -// MySQL Password Hashing -//**************************************************************************** -void HashMySQL323(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashMySQLSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); - -//**************************************************************************** -// Cisco PIX Password Hashing -//**************************************************************************** -void HashPIX(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); - -//**************************************************************************** -// (HALF) LM CHALL hashing -void HashLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashHALFLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); - -// From mao -void HashNTLMCHALL(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); -void HashORACLE(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); - -#endif diff --git a/Common/rt api/tmp/HashRoutine.cpp b/Common/rt api/tmp/HashRoutine.cpp deleted file mode 100644 index b61ae63..0000000 --- a/Common/rt api/tmp/HashRoutine.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ - -#ifdef _WIN32 - #pragma warning(disable : 4786) -#endif - -#include "HashRoutine.h" -#include "HashAlgorithm.h" - -////////////////////////////////////////////////////////////////////// - -CHashRoutine::CHashRoutine() -{ - // Notice: MIN_HASH_LEN <= nHashLen <= MAX_HASH_LEN - - AddHashRoutine("lm", HashLM, 8); - AddHashRoutine("md5", HashMD5, 16); - AddHashRoutine("sha1", HashSHA1, 20); - AddHashRoutine("ntlm", HashNTLM, 16); -} - -CHashRoutine::~CHashRoutine() -{ -} - -void CHashRoutine::AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRoutine, int nHashLen) -{ - vHashRoutineName.push_back(sHashRoutineName); - vHashRoutine.push_back(pHashRoutine); - vHashLen.push_back(nHashLen); -} - -string CHashRoutine::GetAllHashRoutineName() -{ - string sRet; - int i; - for (i = 0; i < vHashRoutineName.size(); i++) - sRet += vHashRoutineName[i] + " "; - - return sRet; -} - -void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen) -{ - int i; - for (i = 0; i < vHashRoutineName.size(); i++) - { - if (sHashRoutineName == vHashRoutineName[i]) - { - pHashRoutine = vHashRoutine[i]; - nHashLen = vHashLen[i]; - return; - } - } - - pHashRoutine = NULL; - nHashLen = 0; -} diff --git a/Common/rt api/tmp/HashRoutine.h b/Common/rt api/tmp/HashRoutine.h deleted file mode 100644 index 681fa78..0000000 --- a/Common/rt api/tmp/HashRoutine.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique. - - Copyright (C) Zhu Shuanglei -*/ - -#ifndef _HASHROUTINE_H -#define _HASHROUTINE_H - -#include -#include -using namespace std; - -typedef void (*HASHROUTINE)(unsigned char* pPlain, int nPlainLen, unsigned char* pHash); - -class CHashRoutine -{ -public: - CHashRoutine(); - virtual ~CHashRoutine(); - -private: - vector vHashRoutineName; - vector vHashRoutine; - vector vHashLen; - void AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRoutine, int nHashLen); - -public: - string GetAllHashRoutineName(); - void GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen); -}; - -#endif -- 2.39.2