-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
56 lines (44 loc) · 1.73 KB
/
main.cpp
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
#include <iostream>
#include "argparse.h"
#include "jwlt_func.h"
std::string USAGE = " jwlt --help / -h\t\tDisplay this help message\n"
" jwlt --charset / -c\t\tCharacters to use (e.g. 0123456789)\n"
" jwlt --lenght / -l\t\tLenght of the password to generate\n"
" jwlt --adiacent-check / -a\tExclude password with same adiacent chars\n";
int main(int argc, char **argv){
Argparse args(argc, argv);
if (args.check_arg("--help", "-h")){
std::cerr << USAGE;
return -1;
}
if (argc < 4){
std::cerr << " [!] Missing argument.\n [i] Usage: \n";
std::cerr << USAGE;
return -1;
}
size_t C_LEN;
const char *CHARSET = args.get_value("--charset", "-c");
if (CHARSET == NULL || (C_LEN = strlen((char*)CHARSET)) == 0){
std::cerr << "Missing argument value for --charset/-c\n";
return -1;
}
if ( !args.check_arg("--lenght", "-l")){
std::cerr << "Missing argument value for --lenght/-l\n";
return -1;
}
int PSWD_LEN = atoi(args.get_value("--lenght", "-l"));
if (PSWD_LEN <= 0){
std::cerr << "--lenght/-l value must be greater than 0.\n";
return -1;
}
bool ADIACENT_CHECK = args.check_arg("--adiacent-check", "-a");
size_t tracker[PSWD_LEN];
for (size_t i=0; i<PSWD_LEN; i++){
tracker[i] = 0;
}
std::cerr << "Charset: " << CHARSET << std::endl;
std::cerr << "Charset lenght: " << C_LEN << std::endl;
std::cerr << "Password lenght: " << PSWD_LEN << std::endl;
std::cerr << "Adiacent check: " << (ADIACENT_CHECK ? "yes" : "no") << std::endl;
wordlist_generator(tracker, CHARSET, PSWD_LEN, C_LEN, ADIACENT_CHECK);
}