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