/*
-* Copyright (C) Daniël Niggebrugge <niggebrugge@fox-it.com>
-* All rights reserved.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, [...] etc :p
-*/
+ * rcracki_mt is a multithreaded implementation and fork of the original
+ * RainbowCrack
+ *
+ * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
+ * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
+ *
+ * This file is part of rcracki_mt.
+ *
+ * rcracki_mt 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,
+ * 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/>.
+ */
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(__GNUC__)
#pragma warning(disable : 4786 4267 4018)
#endif
{
string sPlain = "";
- int i;
+ UINT4 i;
for (i = 0; i < hexPassword.size() / 2; i++)
{
string sSub = hexPassword.substr(i * 2, 2);
sPlain += (unsigned char)nValue;
}
- memcpy(NTLMHash, pNTLMHash, 16);
+ memcpy(NTLMHash, pNTLMHash, MD4_DIGEST_LENGTH);
- int tmpLength = sPlain.size() * 2;
+ unsigned long int tmpLength = sPlain.size() * 2;
unsigned char* pLMPassword = new unsigned char[tmpLength];
//printf("Searching for unicode password.\n");
tty_init();
#endif
- if (startCorrecting(sPlain, NTLMHash, sNTLMPassword, pLMPassword))
+ if (startCorrecting(sPlain, sNTLMPassword, pLMPassword))
{
sBinary = ByteToStr(pLMPassword, tmpLength).c_str();
//printf("\nFound unicode password: %s\n", sNTLMPassword.c_str());
}
}
-bool LM2NTLMcorrector::startCorrecting(string sLMPassword, unsigned char* pNTLMHash, string& sNTLMPassword, unsigned char* pLMPassword)
+bool LM2NTLMcorrector::startCorrecting(string sLMPassword, string& sNTLMPassword, unsigned char* pLMPassword)
{
if (sLMPassword.size() == 0)
{
setupCombinationAtPositions(length, pMuteMe, pTempMute, jAtPos, fullAtPos, sizeAtPos);
- if (checkPermutations(length, pMuteMe, pTempMute, jAtPos, sizeAtPos, pLMPassword, sNTLMPassword))
+ if (checkPermutations(length, pTempMute, jAtPos, sizeAtPos, pLMPassword, sNTLMPassword))
{
return true;
}
if (fullAtPos[i] == true)
{
unsigned char muteChar = pMuteMe[i];
- int sizeMapForChar = m_mapChar[muteChar].size()/2; // 2 bytes per char
+ long unsigned int sizeMapForChar = m_mapChar[muteChar].size()/2; // 2 bytes per char
sizeAtPos[i] = sizeMapForChar;
}
else
}
// go check all permutations for this combination
-bool LM2NTLMcorrector::checkPermutations(int length, unsigned char* pMuteMe, unsigned char* pTempMute, int* jAtPos, int* sizeAtPos, unsigned char* pLMPassword, string& sNTLMPassword)
+bool LM2NTLMcorrector::checkPermutations(int length, unsigned char* pTempMute, int* jAtPos, int* sizeAtPos, unsigned char* pLMPassword, string& sNTLMPassword)
{
int pos = length - 1;
// check password, maybe integrate this function in checkPermutations() for performance reasons.
bool LM2NTLMcorrector::checkNTLMPassword(unsigned char* pLMPassword, int nLMPasswordLen, string& sNTLMPassword)
{
- unsigned char md[16];
+ unsigned char md[MD4_DIGEST_LENGTH];
//MD4(pLMPassword, nLMPasswordLen * 2, md);
+ /*
MD4_CTX ctx;
MD4_Init(&ctx);
MD4_Update(&ctx, pLMPassword, nLMPasswordLen * 2);
- MD4_Final(md, &ctx);
+ MD4_Final(md, &ctx);*/
- if (memcmp(md, NTLMHash, 16) == 0)
+ MD4_NEW( pLMPassword, nLMPasswordLen * 2, md );
+
+ if (memcmp(md, NTLMHash, MD4_DIGEST_LENGTH) == 0)
{
sNTLMPassword = "";
int i;
return factorial(length) / (factorial(setSize) * factorial(length-setSize));
}
-
int LM2NTLMcorrector::factorial (int num)
{
int result = 1;
void LM2NTLMcorrector::addToMapW(unsigned char key, unsigned char value1, unsigned char value2)
{
- int cnt = m_mapChar[key].size();
+ unsigned long int cnt = m_mapChar[key].size();
m_mapChar[key][cnt] = value2;
m_mapChar[key][cnt+1] = value1; //reverse for endiannes
}