]> git.sesse.net Git - freerainbowtables/blob - Client Applications/rcracki_mt/HashRoutine.cpp
test
[freerainbowtables] / Client Applications / rcracki_mt / HashRoutine.cpp
1 /*
2  * rcracki_mt is a multithreaded implementation and fork of the original 
3  * RainbowCrack
4  *
5  * Copyright (C) Zhu Shuanglei <shuanglei@hotmail.com>
6  * Copyright Martin Westergaard Jørgensen <martinwj2005@gmail.com>
7  * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>
8  * Copyright 2009, 2010 James Nobis <frt@quelrod.net>
9  *
10  * This file is part of rcracki_mt.
11  *
12  * rcracki_mt is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * rcracki_mt is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with rcracki_mt.  If not, see <http://www.gnu.org/licenses/>.
24  */
25
26 #if defined(_WIN32) && !defined(__GNUC__)
27         #pragma warning(disable : 4786 4267 4018)
28 #endif
29
30 #include "HashRoutine.h"
31 #include "HashAlgorithm.h"
32
33 //////////////////////////////////////////////////////////////////////
34
35 CHashRoutine::CHashRoutine()
36 {
37         // Notice: MIN_HASH_LEN <= nHashLen <= MAX_HASH_LEN
38
39
40         AddHashRoutine("lm",   HashLM,   8);
41         AddHashRoutine("ntlm", HashNTLM, 16);
42 //      AddHashRoutine("md2",  HashMD2,  16);
43         AddHashRoutine("md4",  HashMD4,  16);
44         AddHashRoutine("md5",  HashMD5,  16);
45         AddHashRoutine("doublemd5",  HashDoubleMD5,  16);
46         AddHashRoutine("sha1", HashSHA1, 20);
47 //      AddHashRoutine("ripemd160", HashRIPEMD160, 20);
48         AddHashRoutine("mysql323", HashMySQL323, 8);
49         AddHashRoutine("mysqlsha1", HashMySQLSHA1, 20);
50         AddHashRoutine("ciscopix", HashPIX, 16);
51         AddHashRoutine("mscache", HashMSCACHE, 16);
52         AddHashRoutine("halflmchall", HashHALFLMCHALL, 8);
53
54         // Added from mao
55         AddHashRoutine("lmchall", HashLMCHALL, 24);
56         AddHashRoutine("ntlmchall", HashNTLMCHALL, 24);
57         AddHashRoutine("oracle", HashORACLE, 8);
58 }
59
60 CHashRoutine::~CHashRoutine()
61 {
62 }
63
64 void CHashRoutine::AddHashRoutine(string sHashRoutineName, HASHROUTINE pHashRoutine, int nHashLen)
65 {
66         vHashRoutineName.push_back(sHashRoutineName);
67         vHashRoutine.push_back(pHashRoutine);
68         vHashLen.push_back(nHashLen);
69 }
70
71 string CHashRoutine::GetAllHashRoutineName()
72 {
73         string sRet;
74         UINT4 i;
75         for (i = 0; i < vHashRoutineName.size(); i++)
76                 sRet += vHashRoutineName[i] + " ";
77
78         return sRet;
79 }
80
81 void CHashRoutine::GetHashRoutine(string sHashRoutineName, HASHROUTINE& pHashRoutine, int& nHashLen)
82 {
83         UINT4 i;
84         for (i = 0; i < vHashRoutineName.size(); i++)
85         {
86                 if (sHashRoutineName == vHashRoutineName[i])
87                 {
88                         pHashRoutine = vHashRoutine[i];
89                         nHashLen = vHashLen[i];
90                         return;
91                 }
92         }
93
94         pHashRoutine = NULL;
95         nHashLen = 0;
96 }