-
Notifications
You must be signed in to change notification settings - Fork 0
/
passCracker3.cc
55 lines (49 loc) · 1.62 KB
/
passCracker3.cc
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
55
#include <iostream>
#include <cmath>
#include <chrono>
#include <fstream>
#include <iomanip>
using namespace std;
int main() {
string password;
string input;
string numoutput;
string csvoutput;
string charset;
string charsetname;
string fullinfo = "combined_OUT.csv";
ofstream csvout(fullinfo, std::ios::trunc);
csvout << "Password, Time, PasswordType" << endl;
for(int i = 0; i < 2; ++i) {
if(i == 0) {
input = "all_characters.txt";
charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
charsetname = "Mixed Characters";
}
if(i == 1) {
input = "numbers.txt";
charset = "0123456789";
charsetname = "Numbers Only";
}
fstream stream(input);
ofstream txtout(numoutput, std::ios::trunc);
while(stream >> password) {
if(password.length() > 12) continue;
double ta = 0;
double attspeed = 1000000;
int setsize = charset.size();
for(int i = 1; i < password.size(); ++i) {
ta += pow(setsize, i);
}
for(int i = password.size() - 1; i > 0; --i) {
ta += pow(setsize, i) * charset.find(password[i]);
}
double seconds = ta / attspeed;
txtout << std::fixed << std::setprecision(3) << seconds << endl;
csvout << password << ", " << std::fixed << std::setprecision(5) << seconds << ", " << charsetname << endl;
}
txtout.close();
stream.close();
}
csvout.close();
}