-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordCracker.java
More file actions
132 lines (116 loc) · 4.16 KB
/
PasswordCracker.java
File metadata and controls
132 lines (116 loc) · 4.16 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
123
124
125
126
127
128
129
130
131
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
public class PasswordCracker {
public void createDatabase(ArrayList<String> commonPasswords, DatabaseInterface db1) {
//Creates database with all password variants
for (int i = 0; i < commonPasswords.size(); i++) {
String pass = commonPasswords.get(i);
//Normal
try {
String hash = Sha1.hash(pass);
db1.save(pass, hash);
} catch (UnsupportedEncodingException e) {
System.out.println("Couldn't hash String");
}
//Cap first letter
try {
String cap = CapFirstLetter(pass);
db1.save(cap, Sha1.hash(cap));
} catch (UnsupportedEncodingException e) {
System.out.println("Couldn't hash String");
}
//Concat Year
try {
String year = ConcatYear(pass);
db1.save(year, Sha1.hash(year));
} catch (UnsupportedEncodingException e) {
System.out.println("Couldn't hash String");
}
//Replace A
try {
String A = ReplaceA(pass);
db1.save(A, Sha1.hash(A));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("Couldn't hash String");
}
//Replace E
try {
String E = ReplaceE(pass);
db1.save(E, Sha1.hash(E));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("Couldn't hash String");
}
//Replace I
try {
String I = ReplaceI(pass);
db1.save(I, Sha1.hash(I));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("Couldn't hash String");
}
try {
String I = ReplaceE(pass);
I = ReplaceA(I);
I = CapFirstLetter(I);
I = ReplaceI(I);
I = ConcatYear(I);
db1.save(I, Sha1.hash(I));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("Couldn't hash String");
}
try {
String I = ReplaceE(pass);
I = ReplaceA(I);
I = ReplaceI(I);
db1.save(I, Sha1.hash(I));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("Couldn't hash String");
}
try {
String I = pass;
I = ReplaceE(I);
I = ReplaceI(I);
I = CapFirstLetter(I);
db1.save(I, Sha1.hash(I));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("Couldn't hash String");
}
try {
String I = pass;
// I = ReplaceE(I);
I = ReplaceA(I);
// I = ReplaceI(I);
I = CapFirstLetter(I);
// I = ConcatYear(I);
db1.save(I, Sha1.hash(I));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
System.out.println("Couldn't hash String");
}
}
}
//Class to augment onto Database
private String CapFirstLetter(String pass) {
return pass.substring(0, 1).toUpperCase() + pass.substring(1);
}
private String ConcatYear(String pass) {
return pass.concat("2018");
}
private String ReplaceA(String pass) {
return pass.replace('a', '@');
}
private String ReplaceE(String pass) {
return pass.replace('e', '3');
}
private String ReplaceI(String pass) {
return pass.replace('i', '1');
}
public String crackPassword(String cryptic, DatabaseInterface database) {
return database.decrypt(cryptic);
}
}