-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
122 lines (95 loc) · 3.02 KB
/
main.cpp
File metadata and controls
122 lines (95 loc) · 3.02 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
* Verexa's Word List Generator
*
* Please read the accompanying LICENSE file
*/
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include "wordgen.h"
using namespace std;
string lower = "abcdefghijklmnopqrstuvwxyz", upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", numbers = "1234567890", special = "_-+=!$%?*()^@#?/\\{}[]~";
// Main function
int main(int argc, char* argv[]){
printf(" Verexa's Word List Generator\n\n");
int max_limit, min_limit;
string list, resume;
FILE *out;
bool will_out = false;
// Parse command line input
for(int a = 0; a < argc; a++){
string opts = argv[a], opt = "", val = "", pch = "";
for(int x = 0; x < opts.size(); x++){
if(opts.at(x) == ':'){
for(int y = 0; y < x; y++){
opt += opts[y];
}
for(int z = x + 1; z < opts.size(); z++){
val += opts[z];
}
break;
}
}
if(opt == "min") min_limit = atoi(val.c_str());
else if(opt == "max") max_limit = atoi(val.c_str());
else if(opt == "list"){
for(int i = 0; i < val.size(); i++){
pch = val[i];
if(pch == "u") list += upper;
else if(pch == "l") list += lower;
else if(pch == "n") list += numbers;
else if(pch == "s") list += special;
}
}
else if(opt == "out"){
out = fopen(val.c_str(), "w");
if(out != NULL) will_out = true;
}
else if(opt == "from"){
if(!val.empty()){
resume = val;
max_limit = resume.size();
printf(" Resume From: %s\n", resume.c_str(), max_limit);
}
}
}
if(max_limit > 0 && min_limit > 0 && min_limit <= max_limit && list.size() != 0){
printf(" Choice of Letters Size: %i\n\n Generating Word List...\n", list.size());
WordGen gen(max_limit, min_limit, list);
long double on = 0, total = 0;
int cur = 0;
// Clock timing variables
clock_t start, now, then;
double final;
if(!resume.empty()){
total = gen.resume(resume);
} else {
for(int a = max_limit; a >= min_limit; a--)
total += pow((double)list.size(), a);
}
// Run the program
start = clock();
then = start;
now = start;
string str = gen.next();
while(!str.empty()){
on++;
if(will_out) fprintf(out, "%s\n", str.c_str());
if(cur != gen.current || (double(now - then) / CLOCKS_PER_SEC) >= 2){
printf(" %i W: %.0Lf of %.0Lf\n", gen.current, on, total);
then = now;
cur = gen.current;
}
str = gen.next();
now = clock();
}
final = (double(now - start) / CLOCKS_PER_SEC);
if(will_out) fclose(out);
printf(" Completed Word List Generation!\n\n Time Taken: %.2lfs\n", final);
}
else{
printf(" Usage: %s [opt]:[val] ...\n\n [opt] [val]\n max e.g. 6\n min e.g. 3\n list e.g. lu (l = lowercase, u = uppercase, n = numbers, s = symbols)\n out e.g. output.txt\n from e.g. ha32s\n", argv[0]);
}
}