]> git.sesse.net Git - freerainbowtables/blob - Client Applications/rcracki_mt/CrackEngine.h
backport rcracki_mt trunk from rcracki.sourceforge.net
[freerainbowtables] / Client Applications / rcracki_mt / CrackEngine.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 Martin Westergaard Jørgensen <martinwj2005@gmail.com>\r
7  * Copyright 2009, 2010 Daniël Niggebrugge <niggebrugge@fox-it.com>\r
8  * Copyright 2009, 2010 James Nobis <frt@quelrod.net>\r
9  * Copyright 2010 uroskn\r
10  *\r
11  * This file is part of rcracki_mt.\r
12  *\r
13  * rcracki_mt is free software: you can redistribute it and/or modify\r
14  * it under the terms of the GNU General Public License as published by\r
15  * the Free Software Foundation, either version 2 of the License, or\r
16  * (at your option) any later version.\r
17  *\r
18  * rcracki_mt is distributed in the hope that it will be useful,\r
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
21  * GNU General Public License for more details.\r
22  *\r
23  * You should have received a copy of the GNU General Public License\r
24  * along with rcracki_mt.  If not, see <http://www.gnu.org/licenses/>.\r
25  */\r
26 \r
27 #ifndef _CRACKENGINE_H\r
28 #define _CRACKENGINE_H\r
29 \r
30 #include "Public.h"\r
31 #include "HashSet.h"\r
32 #include "ChainWalkContext.h"\r
33 #include "MemoryPool.h"\r
34 #include "ChainWalkSet.h"\r
35 #include "rcrackiThread.h"\r
36 #ifdef _WIN32\r
37 #include <conio.h>\r
38 #include <windows.h>\r
39 #endif\r
40 #include <pthread.h>\r
41 \r
42 class CCrackEngine\r
43 {\r
44 public:\r
45         CCrackEngine();\r
46         virtual ~CCrackEngine();\r
47 \r
48 private:\r
49         CChainWalkSet m_cws;\r
50         int maxThreads;\r
51         uint64 maxMem;\r
52         bool writeOutput;\r
53         bool resumeSession;\r
54         string outputFile;\r
55         string sSessionPathName;\r
56         string sProgressPathName;\r
57         string sPrecalcPathName;\r
58         //string sPrecalcIndexPathName;\r
59         bool debug;\r
60         bool keepPrecalcFiles;\r
61 \r
62         // Statistics\r
63         float m_fTotalDiskAccessTime;\r
64         float m_fTotalCryptanalysisTime;\r
65         float m_fTotalPrecalculationTime;\r
66         uint64 m_nTotalChainWalkStep;\r
67         int m_nTotalFalseAlarm;\r
68         uint64 m_nTotalChainWalkStepDueToFalseAlarm;\r
69         FILE *m_fChains;\r
70 \r
71 private:\r
72         void ResetStatistics();\r
73         RainbowChain *BinarySearch(RainbowChain *pChain, int nChainCountRead, uint64 nIndex, IndexChain *pIndex, int nIndexSize, int nIndexStart);\r
74         int BinarySearchOld(RainbowChainO* pChain, int nRainbowChainCount, uint64 nIndex);\r
75         void GetChainIndexRangeWithSameEndpoint(RainbowChainO* pChain,\r
76                                                                                     int nRainbowChainCount,\r
77                                                                                     int nChainIndex,\r
78                                                                                     int& nChainIndexFrom,\r
79                                                                                     int& nChainIndexTo);\r
80         void SearchTableChunk(RainbowChain* pChain, int nRainbowChainLen, int nRainbowChainCount, CHashSet& hs, IndexChain *pIndex, int nIndexSize, int nChainStart);\r
81         void SearchTableChunkOld(RainbowChainO* pChain, int nRainbowChainLen, int nRainbowChainCount, CHashSet& hs);\r
82         //bool CheckAlarm(RainbowChain* pChain, int nGuessedPos, unsigned char* pHash, CHashSet& hs);\r
83         //bool CheckAlarmOld(RainbowChainO* pChain, int nGuessedPos, unsigned char* pHash, CHashSet& hs);\r
84 \r
85 public:\r
86         void SearchRainbowTable(string sPathName, CHashSet& hs);\r
87         void Run(vector<string> vPathName, CHashSet& hs, int i_maxThreads, uint64 i_maxMem, bool resume, bool bDebug);\r
88         float GetStatTotalDiskAccessTime();\r
89         float GetStatTotalCryptanalysisTime();\r
90         float GetStatTotalPrecalculationTime();\r
91         uint64   GetStatTotalChainWalkStep();\r
92         int   GetStatTotalFalseAlarm();\r
93         uint64   GetStatTotalChainWalkStepDueToFalseAlarm();\r
94         void setOutputFile(string sPathName);\r
95         void setSession(string sSessionPathName, string sProgressPathName, string sPrecalcPathName, bool keepPrecalc);\r
96 };\r
97 \r
98 #endif\r