@@ -34,8 +34,9 @@ def initialize
34
34
'Actions' => [
35
35
[ 'john' , { 'Description' => 'Use John the Ripper' } ] ,
36
36
[ 'hashcat' , { 'Description' => 'Use Hashcat' } ] ,
37
+ [ 'auto' , { 'Description' => 'Auto-selection of cracker' } ]
37
38
] ,
38
- 'DefaultAction' => 'john ' ,
39
+ 'DefaultAction' => 'auto ' ,
39
40
'Notes' => {
40
41
'Stability' => [ CRASH_SAFE ] ,
41
42
'SideEffects' => [ ] ,
@@ -58,29 +59,29 @@ def initialize
58
59
def show_command ( cracker_instance )
59
60
return unless datastore [ 'ShowCommand' ]
60
61
61
- if action . name == 'john'
62
+ if cracker_instance . cracker == 'john'
62
63
cmd = cracker_instance . john_crack_command
63
- elsif action . name == 'hashcat'
64
+ elsif cracker_instance . cracker == 'hashcat'
64
65
cmd = cracker_instance . hashcat_crack_command
65
66
end
66
67
print_status ( " Cracking Command: #{ cmd . join ( ' ' ) } " )
67
68
end
68
69
69
- def check_results ( passwords , results , hash_type , method )
70
+ def check_results ( passwords , results , hash_type , method , cracker_type )
70
71
passwords . each do |password_line |
71
72
password_line . chomp!
72
73
next if password_line . blank?
73
74
74
75
fields = password_line . split ( ':' )
75
76
cred = { 'hash_type' => hash_type , 'method' => method }
76
77
77
- if action . name == 'john'
78
+ if cracker_type == 'john'
78
79
next unless fields . count >= 3
79
80
80
81
cred [ 'username' ] = fields . shift
81
82
cred [ 'core_id' ] = fields . pop
82
83
cred [ 'password' ] = fields . join ( ':' ) # Anything left must be the password. This accounts for passwords with semi-colons in it
83
- elsif action . name == 'hashcat'
84
+ elsif cracker_type == 'hashcat'
84
85
next unless fields . count >= 2
85
86
86
87
cred [ 'core_id' ] = fields . shift
@@ -109,7 +110,8 @@ def check_results(passwords, results, hash_type, method)
109
110
end
110
111
111
112
def run
112
- tbl = tbl = cracker_results_table
113
+ tbl = cracker_results_table
114
+ cracker = new_password_cracker ( action . name )
113
115
114
116
# array of hashes in jtr_format in the db, converted to an OR combined regex
115
117
hash_types_to_crack = [ ]
@@ -128,7 +130,7 @@ def run
128
130
129
131
# hashcat requires a format we dont have all the data for
130
132
# in the current dumper, so this is disabled in module and lib
131
- if action . name == 'john'
133
+ if cracker . cracker == 'john'
132
134
hash_types_to_crack << 'oracle'
133
135
hash_types_to_crack << 'dynamic_1506'
134
136
end
@@ -143,7 +145,7 @@ def run
143
145
144
146
# build our job list
145
147
hash_types_to_crack . each do |hash_type |
146
- job = hash_job ( hash_type , action . name )
148
+ job = hash_job ( hash_type , cracker . cracker )
147
149
if job . nil?
148
150
print_status ( "No #{ hash_type } found to crack" )
149
151
else
@@ -161,8 +163,6 @@ def run
161
163
# Inner array format: db_id, hash_type, username, password, method_of_crack
162
164
results = [ ]
163
165
164
- cracker = new_password_cracker ( action . name )
165
-
166
166
# generate our wordlist and close the file handle.
167
167
wordlist = wordlist_file
168
168
unless wordlist
@@ -187,25 +187,25 @@ def run
187
187
cracker_instance = cracker . dup
188
188
cracker_instance . format = format
189
189
190
- if action . name == 'john'
190
+ if cracker . cracker == 'john'
191
191
cracker_instance . fork = datastore [ 'FORK' ]
192
192
end
193
193
194
194
# first check if anything has already been cracked so we don't report it incorrectly
195
195
print_status "Checking #{ format } hashes already cracked..."
196
- results = check_results ( cracker_instance . each_cracked_password , results , format , 'Already Cracked/POT' )
196
+ results = check_results ( cracker_instance . each_cracked_password , results , format , 'Already Cracked/POT' , cracker . cracker )
197
197
vprint_good ( append_results ( tbl , results ) ) unless results . empty?
198
198
job [ 'cred_ids_left_to_crack' ] = job [ 'cred_ids_left_to_crack' ] - results . map { |i | i [ 0 ] . to_i } # remove cracked hashes from the hash list
199
199
next if job [ 'cred_ids_left_to_crack' ] . empty?
200
200
201
- if action . name == 'john'
201
+ if cracker . cracker == 'john'
202
202
print_status "Cracking #{ format } hashes in single mode..."
203
203
cracker_instance . mode_single ( wordlist . path )
204
204
show_command cracker_instance
205
205
cracker_instance . crack do |line |
206
206
vprint_status line . chomp
207
207
end
208
- results = check_results ( cracker_instance . each_cracked_password , results , format , 'Single' )
208
+ results = check_results ( cracker_instance . each_cracked_password , results , format , 'Single' , cracker . cracker )
209
209
vprint_good ( append_results ( tbl , results ) ) unless results . empty?
210
210
job [ 'cred_ids_left_to_crack' ] = job [ 'cred_ids_left_to_crack' ] - results . map { |i | i [ 0 ] . to_i } # remove cracked hashes from the hash list
211
211
next if job [ 'cred_ids_left_to_crack' ] . empty?
@@ -216,7 +216,7 @@ def run
216
216
cracker_instance . crack do |line |
217
217
vprint_status line . chomp
218
218
end
219
- results = check_results ( cracker_instance . each_cracked_password , results , format , 'Normal' )
219
+ results = check_results ( cracker_instance . each_cracked_password , results , format , 'Normal' , cracker . cracker )
220
220
vprint_good ( append_results ( tbl , results ) ) unless results . empty?
221
221
job [ 'cred_ids_left_to_crack' ] = job [ 'cred_ids_left_to_crack' ] - results . map { |i | i [ 0 ] . to_i } # remove cracked hashes from the hash list
222
222
next if job [ 'cred_ids_left_to_crack' ] . empty?
@@ -229,7 +229,7 @@ def run
229
229
cracker_instance . crack do |line |
230
230
vprint_status line . chomp
231
231
end
232
- results = check_results ( cracker_instance . each_cracked_password , results , format , 'Incremental' )
232
+ results = check_results ( cracker_instance . each_cracked_password , results , format , 'Incremental' , cracker . cracker )
233
233
vprint_good ( append_results ( tbl , results ) ) unless results . empty?
234
234
job [ 'cred_ids_left_to_crack' ] = job [ 'cred_ids_left_to_crack' ] - results . map { |i | i [ 0 ] . to_i } # remove cracked hashes from the hash list
235
235
next if job [ 'cred_ids_left_to_crack' ] . empty?
@@ -239,7 +239,7 @@ def run
239
239
print_status "Cracking #{ format } hashes in wordlist mode..."
240
240
cracker_instance . mode_wordlist ( wordlist . path )
241
241
# Turn on KoreLogic rules if the user asked for it
242
- if action . name == 'john' && datastore [ 'KORELOGIC' ]
242
+ if cracker . cracker == 'john' && datastore [ 'KORELOGIC' ]
243
243
cracker_instance . rules = 'KoreLogicRules'
244
244
print_status 'Applying KoreLogic ruleset...'
245
245
end
@@ -248,7 +248,7 @@ def run
248
248
vprint_status line . chomp
249
249
end
250
250
251
- results = check_results ( cracker_instance . each_cracked_password , results , format , 'Wordlist' )
251
+ results = check_results ( cracker_instance . each_cracked_password , results , format , 'Wordlist' , cracker . cracker )
252
252
vprint_good ( append_results ( tbl , results ) ) unless results . empty?
253
253
job [ 'cred_ids_left_to_crack' ] = job [ 'cred_ids_left_to_crack' ] - results . map { |i | i [ 0 ] . to_i } # remove cracked hashes from the hash list
254
254
next if job [ 'cred_ids_left_to_crack' ] . empty?
0 commit comments