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