@@ -32,9 +32,8 @@ def initialize
32
32
'Actions' => [
33
33
[ 'john' , { 'Description' => 'Use John the Ripper' } ] ,
34
34
[ 'hashcat' , { 'Description' => 'Use Hashcat' } ] ,
35
- [ 'auto' , { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' } ]
36
35
] ,
37
- 'DefaultAction' => 'auto ' ,
36
+ 'DefaultAction' => 'john ' ,
38
37
'Notes' => {
39
38
'Stability' => [ CRASH_SAFE ] ,
40
39
'SideEffects' => [ ] ,
@@ -59,35 +58,30 @@ def initialize
59
58
def show_command ( cracker_instance )
60
59
return unless datastore [ 'ShowCommand' ]
61
60
62
- newaction = getaction ( )
63
-
64
- if newaction == 'john'
61
+ if action . name == 'john'
65
62
cmd = cracker_instance . john_crack_command
66
- elsif newaction == 'hashcat'
63
+ elsif action . name == 'hashcat'
67
64
cmd = cracker_instance . hashcat_crack_command
68
65
end
69
66
print_status ( " Cracking Command: #{ cmd . join ( ' ' ) } " )
70
67
end
71
68
72
69
def check_results ( passwords , results , hash_type , method )
73
-
74
- newaction = getaction ( )
75
-
76
70
passwords . each do |password_line |
77
71
password_line . chomp!
78
72
next if password_line . blank?
79
73
80
74
fields = password_line . split ( ':' )
81
75
cred = { 'hash_type' => hash_type , 'method' => method }
82
76
83
- if newaction == 'john'
77
+ if action . name == 'john'
84
78
next unless fields . count >= 3 # If we don't have an expected minimum number of fields, this is probably not a hash line
85
79
86
80
cred [ 'username' ] = fields . shift
87
81
cred [ 'core_id' ] = fields . pop
88
82
4 . times { fields . pop } # Get rid of extra :
89
83
cred [ 'password' ] = fields . join ( ':' ) # Anything left must be the password. This accounts for passwords with semi-colons in it
90
- elsif newaction == 'hashcat'
84
+ elsif action . name == 'hashcat'
91
85
next unless fields . count >= 2 # If we don't have an expected minimum number of fields, this is probably not a hash line
92
86
93
87
cred [ 'core_id' ] = fields . shift
@@ -106,9 +100,6 @@ def check_results(passwords, results, hash_type, method)
106
100
end
107
101
108
102
def run
109
-
110
- newaction = getaction ( )
111
-
112
103
tbl = tbl = cracker_results_table
113
104
114
105
# array of hashes in jtr_format in the db, converted to an OR combined regex
@@ -124,7 +115,7 @@ def run
124
115
125
116
# build our job list
126
117
hash_types_to_crack . each do |hash_type |
127
- job = hash_job ( hash_type , newaction )
118
+ job = hash_job ( hash_type , action . name )
128
119
if job . nil?
129
120
print_status ( "No #{ hash_type } found to crack" )
130
121
else
@@ -142,7 +133,7 @@ def run
142
133
# Inner array format: db_id, hash_type, username, password, method_of_crack
143
134
results = [ ]
144
135
145
- cracker = new_password_cracker ( newaction )
136
+ cracker = new_password_cracker ( action . name )
146
137
147
138
# generate our wordlist and close the file handle.
148
139
wordlist = wordlist_file
@@ -167,7 +158,7 @@ def run
167
158
cracker_instance = cracker . dup
168
159
cracker_instance . format = format
169
160
170
- if newaction == 'john'
161
+ if action . name == 'john'
171
162
cracker_instance . fork = datastore [ 'FORK' ]
172
163
end
173
164
@@ -178,7 +169,7 @@ def run
178
169
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
179
170
next if job [ 'cred_ids_left_to_crack' ] . empty?
180
171
181
- if newaction == 'john'
172
+ if action . name == 'john'
182
173
print_status "Cracking #{ format } hashes in single mode..."
183
174
cracker_instance . mode_single ( wordlist . path )
184
175
show_command cracker_instance
@@ -220,7 +211,7 @@ def run
220
211
print_status "Cracking #{ format } hashes in wordlist mode..."
221
212
cracker_instance . mode_wordlist ( wordlist . path )
222
213
# Turn on KoreLogic rules if the user asked for it
223
- if newaction == 'john' && datastore [ 'KORELOGIC' ]
214
+ if action . name == 'john' && datastore [ 'KORELOGIC' ]
224
215
cracker_instance . rules = 'KoreLogicRules'
225
216
print_status 'Applying KoreLogic ruleset...'
226
217
end
@@ -244,24 +235,4 @@ def run
244
235
end
245
236
end
246
237
end
247
-
248
- def getaction
249
- newaction = action . name
250
- if action . name == 'auto'
251
- path = Rex ::FileUtils . find_full_path ( 'hashcat' ) ||
252
- Rex ::FileUtils . find_full_path ( 'hashcat.exe' )
253
- if path
254
- newaction = 'hashcat'
255
- else
256
- path = Rex ::FileUtils . find_full_path ( 'john' ) ||
257
- Rex ::FileUtils . find_full_path ( 'john.exe' )
258
- if path
259
- newaction = 'john'
260
- else
261
- raise PasswordCrackerNotFoundError , 'No suitable john/hashcat binary was found on the system'
262
- end
263
- end
264
- end
265
- return newaction
266
- end
267
238
end
0 commit comments