-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrax.cpp
More file actions
93 lines (76 loc) · 2.24 KB
/
crax.cpp
File metadata and controls
93 lines (76 loc) · 2.24 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
// ----------
// CRAX v0.7b
// Syntax: ./crax [hash] [md5/sha1] [wordlist]
// ----------
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <string>
#include <fstream>
#include <unistd.h>
#include "hashlibpp.h"
#include "hl_hashwrapper.h"
#include "timer.h"
#include "crax.h"
using namespace std;
const string version = "v0.7.1b";
int main(int argc, char* argv[]) {
nice(10);
hashwrapper *md5 = new md5wrapper();
hashwrapper *sha1 = new sha1wrapper();
timer uu;
if(argc==1){
versionOut(version);
cout << endl;
return 0;
}
string hashi = sanitizeIn(argv[1]);
if(hashi=="-i"){
char* wordl_copy = strdup("/etc/wordlists/word.lst");
cout << "crax version " << version << " starting interactive mode...";
interactiveMode(wordl_copy);
free(wordl_copy);
return 0;
}else if(argc<3){
versionOut(version);
return 0;
}
string hasht = sanitizeIn(argv[2]);
const char* wordlist = (argc > 3) ? argv[3] : "/etc/wordlists/word.lst";
string isfile = hashi.substr(0,5);
if(isfile=="file="){
string filen = hashi.substr(5,42);
const char* pasf = filen.c_str();
FILE *passfile = fopen(pasf,"r");
if ( passfile != NULL ) {
char hashf [64];
while ( fgets ( hashf, sizeof hashf, passfile ) != NULL ){
string hashfo = sanitizeIn(hashf);
char* wordlist_copy = strdup(wordlist);
if(hasht=="md5"){
md5crack(hashfo, wordlist_copy);
}else if(hasht=="sha1"){
sha1crack(hashfo, wordlist_copy);
}else{
cout << "Invalid hash type chosen." << endl;
cout << "Sorry, crax " << version << " only supports md5/sha1." << endl;
}
free(wordlist_copy);
}
fclose(passfile);
}
return 0;
}else{
char* wordlist_copy = strdup(wordlist);
if(hasht=="md5"){
md5crack(hashi, wordlist_copy);
}else if(hasht=="sha1"){
sha1crack(hashi, wordlist_copy);
}else{
cout << "Invalid hash type chosen." << endl;
cout << "Sorry, crax " << version << " only supports md5/sha1." << endl;
}
free(wordlist_copy);
}
// md5crack(argv[1],"data");
}