-
Notifications
You must be signed in to change notification settings - Fork 0
/
RainbowTable.h
54 lines (48 loc) · 1.75 KB
/
RainbowTable.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef RAINBOW_TABLE_H
#define RAINBOW_TABLE_H
/*
Stuart's MacBook can generate ~ 712 chains of length 2000 per second
*/
#include <unordered_map>
#include <fstream>
#include <iostream>
#include <string>
#include <list>
#include <random>
#include <openssl/evp.h>
using std::unordered_map;
using std::cout;
using std::vector;
using std::string;
using std::ifstream;
using std::ofstream;
using std::cerr;
using std::list;
using std::mt19937_64;
class RainbowTable
{
public:
RainbowTable(string fileName);
RainbowTable(int chainLength, string dictName);
RainbowTable(int chainLength, string dictName, bool variants); //TODO: Write a version where we end up with ~1000 variants on each dictionary entry
RainbowTable(int chainLength, int numChains);
void produceTable(int chainLength, int numChains, string outputFile);
void outputToFile(string fileName);
string batchLookup(vector<string>& endpoints, unsigned char * hashVal);
void generateReductions(list<std::pair<int, unsigned char*> >& hashes, unsigned int reductions, list< vector< string > >& precomputed);
string lookup(unsigned char* hashVal);
~RainbowTable();
private:
unsigned _chainLength;
EVP_MD_CTX *mdctx;
unordered_map<string,string> table;
const string FirstLetter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string Domain = "abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()";
string numberToKey(uint64_t n);
string reduce(unsigned char* hashVal, unsigned int size, int reductionNumber);
void printHash(unsigned char* hash, unsigned int size);
unsigned int applyHash(string &password, unsigned char* result);
string walkChain(string currKey, unsigned char* lookupHash);
bool equalHashes(unsigned char* hash1, unsigned char* hash2, unsigned size);
};
#endif