-# 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 <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/>.
-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
#include "Public.h"
// Rainbowcrack code
#include "ChainWalkContext.h"
-typedef unsigned int uint32;
-//typedef unsigned __int64 uint64;
-
using std::string;
*/
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];
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];
// 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);
--- /dev/null
+../../../Common/rt api/global.h
\ No newline at end of file
/*
- 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 multithreaded implementation and fork of the original
+ * RainbowCrack
+ *
+ * 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 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 <http://www.gnu.org/licenses/>.
+ */
#ifdef _WIN32
#pragma warning(disable : 4786)
{
m_nHybridCharset = 1;
}
+
+ bool readCharset = false;
vector<string> 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
// sCharsetName charset check
bool fCharsetNameCheckPass = true;
- int j;
+ uint32 j;
for (j = 0; j < sCharsetName.size(); j++)
{
if ( !isalpha(sCharsetName[j])
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;
}
else
printf("can't open charset configuration file\n");
+
return false;
}
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;
}
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;
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
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
}
}
- 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
}
"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];
/*
- 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/>.
+ *
+ * Changes: not using OpenSSL routines the slow way anymore, as suggested by jci.
+ */
#include "HashAlgorithm.h"
#include "Public.h"
+
#include <string.h>
+
+//#include <openssl/md2.h>
#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 <des.h>
+#endif
+
#define MSCACHE_HASH_SIZE 16
void setup_des_key(unsigned char key_56[], des_key_schedule &ks)
{
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);
}
/*
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);
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)
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);
{
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);
/*
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)
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)
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;
free (pass);
}
*/
+#if !defined(_WIN32) || defined(__GNUC__)
+char *strupr(char *s1)
+{
+ char *p = s1;
+ while(*p)
+ {
+ *p = (char) toupper(*p);
+ p++;
+ }
+ return s1;
+}
+#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 _HASHALGORITHM_H
#define _HASHALGORITHM_H
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);
// 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
string CHashRoutine::GetAllHashRoutineName()
{
string sRet;
- int i;
+ uint32 i;
for (i = 0; i < vHashRoutineName.size(); i++)
sRet += vHashRoutineName[i] + " ";
void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen)
{
- int i;
+ uint32 i;
for (i = 0; i < vHashRoutineName.size(); i++)
{
if (sHashRoutineName == vHashRoutineName[i])
#include <string>
#include <vector>
+
+#include "global.h"
+
using namespace std;
typedef void (*HASHROUTINE)(unsigned char* pPlain, int nPlainLen, unsigned char* pHash);
/*
- 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/>.
*/
#ifdef _WIN32
#ifdef _WIN32
#include <windows.h>
-#else
- #include <sys/sysinfo.h>
+#elif defined(__APPLE__) || \
+ ((defined(__unix__) || defined(unix)) && !defined(USG))
+
+ #include <sys/param.h>
+
+ #if defined(BSD)
+ #include <sys/sysctl.h>
+ #elif defined(__linux__)
+ #include <sys/sysinfo.h>
+ #else
+ #error Unsupported Operating system
+ #endif
#endif
//////////////////////////////////////////////////////////////////////
// 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<string> vParts;
SeperateString(sChar, ",", vParts);
- for(int i = 0; i < vParts.size(); i++)
+ for(UINT4 i = 0; i < vParts.size(); i++)
{
tCharset stCharset;
vector<string> vParts2;
bool boinc_ReadLinesFromFile(string sPathName, vector<string>& 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);
data[len] = '\0';
string content = data;
content += "\n";
- delete data;
+ delete [] data;
unsigned int i;
for (i = 0; i < content.size(); i++)
#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);
/*
- 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 _PUBLIC_H
#define _PUBLIC_H
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <string>
#include <vector>
#include <list>
-using namespace std;
-#ifdef _WIN32
- #define uint64 unsigned __int64
-#else
- #define uint64 u_int64_t
-#endif
+#include "global.h"
+
+using namespace std;
struct RainbowChain
{
struct IndexChain
{
uint64 nPrefix;
- int nFirstChain;
- unsigned int nChainCount;
+ UINT4 nFirstChain;
+ UINT4 nChainCount;
};
struct FoundRainbowChain
{
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<tCharset>& vCharset);
void Logo();
#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
*/
#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)
/*
- * 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 <niggebrugge@fox-it.com>
* Copyright 2009, 2010 James Nobis <frt@quelrod.net>
*
- * 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 <http://www.gnu.org/licenses/>.
+ * along with freerainbowtables. If not, see <http://www.gnu.org/licenses/>.
*/
#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
#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);
#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);
+++ /dev/null
-/*
- RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
- Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
-
-#include "HashAlgorithm.h"
-
-#include "Public.h"
-
-#include <openssl/des.h>
-#include <openssl/md2.h>
-#include <openssl/md4.h>
-#include <openssl/md5.h>
-#include <openssl/sha.h>
-#include <openssl/ripemd.h>
-#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<userlen; i++,j++)
- {
- ToEncrypt[i] = username[j];
- i++;
- }
-
- for (j=0; j<nPlainLen; i++,j++)
- {
- ToEncrypt[i] = pPlain[j];
- i++;
- }
-
- i=i-1;
- memset (iv,0,8);
- memset (iv2,0,8);
- DES_set_key((DES_cblock*) deskey_fixed, &ks1);
- DES_ncbc_encrypt((unsigned char*) ToEncrypt, (unsigned char*) temp, i, &ks1, &iv, DES_ENCRYPT);
- DES_set_key((DES_cblock*) &iv, &ks2);
- DES_ncbc_encrypt((unsigned char*) ToEncrypt, (unsigned char*) temp, i, &ks2, &iv2, DES_ENCRYPT);
- memcpy (pHash,iv2,8);
-}
-
-void HashNTLM(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
-{
- unsigned char UnicodePlain[MAX_PLAIN_LEN * 2];
- int i;
- for (i = 0; i < nPlainLen; i++)
- {
- UnicodePlain[i * 2] = pPlain[i];
- UnicodePlain[i * 2 + 1] = 0x00;
- }
-
- MD4(UnicodePlain, nPlainLen * 2, pHash);
-}
-
-void HashMD2(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
-{
- MD2(pPlain, nPlainLen, pHash);
-}
-
-void HashMD4(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
-{
- MD4(pPlain, nPlainLen, pHash);
-}
-
-void HashMD5(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
-{
- MD5(pPlain, nPlainLen, pHash);
-}
-
-void HashSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
-{
- SHA1(pPlain, nPlainLen, pHash);
-}
-
-void HashRIPEMD160(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
-{
- RIPEMD160(pPlain, nPlainLen, pHash);
-}
-
-void HashMSCACHE(unsigned char *pPlain, int nPlainLen, unsigned char* pHash)
-{
- char unicode_pwd[256];
- char unicode_user[256];
- static unsigned char username[] = "administrator";
- static int userlen = 13;
- unsigned char final1[MD4_DIGEST_LENGTH];
- MD4_CTX ctx;
- int i;
-
-// strcpy (username, "administrator");
-// userlen = 13;
-
- for (i=0; i<nPlainLen; i++)
- {
- unicode_pwd[i*2] = pPlain[i];
- unicode_pwd[i*2+1] = 0x00;
- }
-
- for (i=0; i<userlen; i++)
- {
- unicode_user[i*2] = username[i];
- unicode_user[i*2+1] = 0x00;
- }
-
- MD4_Init(&ctx);
- MD4_Update(&ctx,unicode_pwd,nPlainLen*2);
- MD4_Final(final1,&ctx);
-
- MD4_Init(&ctx);
- MD4_Update(&ctx,final1,MD4_DIGEST_LENGTH);
- MD4_Update(&ctx,(unsigned char*) unicode_user,userlen*2);
- MD4_Final(pHash,&ctx);
-
- /*
- unsigned char unicode_pwd[256];
- for (int i=0; i<nPlainLen; i++)
- {
- 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);
- //MD4(unicode_pwd, nPlainLen*2, buf);
- memcpy(buf + MSCACHE_HASH_SIZE, pSalt, nSaltLength);
- MD4(buf, MSCACHE_HASH_SIZE + nSaltLength, pHash);
- free(buf);
- */
-}
-
-//*********************************************************************************
-// Code for MySQL password hashing
-//*********************************************************************************
-
-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); /* 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)
-{
- unsigned long hash_pass[2];
- unsigned char* f = (unsigned char*) hash_pass;
-
- unsigned char* pass = (unsigned char*) calloc (nPlainLen+4,sizeof(unsigned char));
- memcpy(pass,pPlain,nPlainLen);
-
- mysql_hash_password_323(hash_pass, (char*) pass);
- pHash[0]=*(f+3); pHash[1]=*(f+2); pHash[2]=*(f+1); pHash[3]=*(f+0);
- pHash[4]=*(f+7); pHash[5]=*(f+6); pHash[6]=*(f+5); pHash[7]=*(f+4);
-
- free (pass);
-}
-
-void HashMySQLSHA1(unsigned char* pPlain, int nPlainLen, unsigned char* pHash)
-{
- unsigned char hash_stage1[SHA_DIGEST_LENGTH];
- SHA_CTX ctx;
-
- SHA1_Init(&ctx);
- SHA1_Update(&ctx, (unsigned char *) pPlain, nPlainLen);
- SHA1_Final(hash_stage1, &ctx);
- SHA1_Init(&ctx);
- SHA1_Update(&ctx, hash_stage1, SHA_DIGEST_LENGTH);
- SHA1_Final(pHash, &ctx);
-}
-
-//*********************************************************************************
-// Code for PIX password hashing
-//*********************************************************************************
-static char itoa64[] = /* 0 ... 63 => 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);
-}
+++ /dev/null
-/*
- RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
- Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
-
-#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
+++ /dev/null
-/*
- RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
- Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
-
-#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;
-}
+++ /dev/null
-/*
- RainbowCrack - a general propose implementation of Philippe Oechslin's faster time-memory trade-off technique.
-
- Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
-*/
-
-#ifndef _HASHROUTINE_H
-#define _HASHROUTINE_H
-
-#include <string>
-#include <vector>
-using namespace std;
-
-typedef void (*HASHROUTINE)(unsigned char* pPlain, int nPlainLen, unsigned char* pHash);
-
-class CHashRoutine
-{
-public:
- CHashRoutine();
- virtual ~CHashRoutine();
-
-private:
- vector<string> vHashRoutineName;
- vector<HASHROUTINE> vHashRoutine;
- vector<int> vHashLen;
- void AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRoutine, int nHashLen);
-
-public:
- string GetAllHashRoutineName();
- void GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen);
-};
-
-#endif