]> git.sesse.net Git - freerainbowtables/blob - Client Applications/rcracki_mt/ChainWalkContext.h
UINT4 -> uint32
[freerainbowtables] / Client Applications / rcracki_mt / ChainWalkContext.h
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 2009, 2010 DaniĆ«l Niggebrugge <niggebrugge@fox-it.com>\r
7  * Copyright 2009, 2010 James Nobis <frt@quelrod.net>\r
8  *\r
9  * This file is part of rcracki_mt.\r
10  *\r
11  * rcracki_mt is free software: you can redistribute it and/or modify\r
12  * it under the terms of the GNU General Public License as published by\r
13  * the Free Software Foundation, either version 2 of the License, or\r
14  * (at your option) any later version.\r
15  *\r
16  * rcracki_mt is distributed in the hope that it will be useful,\r
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
19  * GNU General Public License for more details.\r
20  *\r
21  * You should have received a copy of the GNU General Public License\r
22  * along with rcracki_mt.  If not, see <http://www.gnu.org/licenses/>.\r
23  */\r
24 \r
25 #ifndef _CHAINWALKCONTEXT_H\r
26 #define _CHAINWALKCONTEXT_H\r
27 \r
28 #include "HashRoutine.h"\r
29 #include "Public.h"\r
30 \r
31 typedef struct \r
32 {\r
33         unsigned char m_PlainCharset[255];\r
34         unsigned int m_nPlainCharsetLen;\r
35         int m_nPlainLenMin;\r
36         int m_nPlainLenMax;\r
37         string m_sPlainCharsetName;\r
38         string m_sPlainCharsetContent;\r
39 } stCharset;\r
40 class CChainWalkContext \r
41 {\r
42 public:\r
43         CChainWalkContext();\r
44         virtual ~CChainWalkContext();\r
45 \r
46 private:\r
47         static string m_sHashRoutineName;       \r
48         static HASHROUTINE m_pHashRoutine;                                                      // Configuration\r
49         static int m_nHashLen;                                                                          // Configuration\r
50         static bool isOldRtFormat;\r
51         static bool isRti2RtFormat;\r
52         static vector<stCharset> m_vCharset;\r
53         static int m_nPlainLenMinTotal, m_nPlainLenMaxTotal;\r
54         static uint64 m_nPlainSpaceUpToX[MAX_PLAIN_LEN + 1];            // Performance consideration\r
55         static uint64 m_nPlainSpaceTotal;                                                       // Performance consideration\r
56         static int m_nHybridCharset;\r
57         static int m_nRainbowTableIndex;                                                        // Configuration\r
58         static uint64 m_nReduceOffset;                                                          // Performance consideration\r
59 \r
60         // Context\r
61         uint64 m_nIndex;\r
62         unsigned char m_Plain[MAX_PLAIN_LEN];\r
63         int m_nPlainLen;\r
64         unsigned char m_Hash[MAX_HASH_LEN];\r
65         static unsigned char m_Salt[MAX_SALT_LEN];\r
66         static int m_nSaltLen;\r
67 private:\r
68         static bool LoadCharset(string sCharset);\r
69 \r
70 public:\r
71         static bool SetHashRoutine(string sHashRoutineName);                                                                                            // Configuration\r
72         static bool SetPlainCharset(string sCharsetName, int nPlainLenMin, int nPlainLenMax);                           // Configuration\r
73         static bool SetRainbowTableIndex(int nRainbowTableIndex);       \r
74         static bool SetSalt(unsigned char *Salt, int nSaltLength);// Configuration\r
75         static bool SetupWithPathName(string sPathName, int& nRainbowChainLen, int& nRainbowChainCount);        // Wrapper\r
76         static string GetHashRoutineName();\r
77         static int GetHashLen();\r
78         static string GetPlainCharsetName();\r
79         static string GetPlainCharsetContent();\r
80         static int GetPlainLenMin();\r
81         static int GetPlainLenMax();\r
82         static uint64 GetPlainSpaceTotal();\r
83         static int GetRainbowTableIndex();\r
84         static void Dump();\r
85         static bool isOldFormat();\r
86         static bool isRti2Format();\r
87 \r
88         void SetIndex(uint64 nIndex);\r
89         void SetHash(unsigned char* pHash);             // The length should be m_nHashLen\r
90 \r
91         void IndexToPlain();\r
92         void PlainToHash();\r
93         void HashToIndex(int nPos);\r
94 \r
95         uint64 GetIndex();\r
96         const uint64* GetIndexPtr();\r
97         string GetPlain();\r
98         string GetBinary();\r
99         string GetHash();\r
100         bool CheckHash(unsigned char* pHash);   // The length should be m_nHashLen\r
101 };\r
102 \r
103 #endif\r