Skip to content

Commit f454954

Browse files
authored
requested change resolved, PR #20418
1 parent 9c03306 commit f454954

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

modules/auxiliary/analyze/crack_windows.rb

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ def initialize
3030
'Actions' => [
3131
['john', { 'Description' => 'Use John the Ripper' }],
3232
['hashcat', { 'Description' => 'Use Hashcat' }],
33-
['auto', { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' }]
3433
],
35-
'DefaultAction' => 'auto',
34+
'DefaultAction' => 'john',
3635
'Notes' => {
3736
'Stability' => [CRASH_SAFE],
3837
'SideEffects' => [],
@@ -63,11 +62,9 @@ def half_lm_regex
6362
def show_command(cracker_instance)
6463
return unless datastore['ShowCommand']
6564

66-
newaction = getaction()
67-
68-
if newaction == 'john'
65+
if action.name == 'john'
6966
cmd = cracker_instance.john_crack_command
70-
elsif newaction == 'hashcat'
67+
elsif action.name == 'hashcat'
7168
cmd = cracker_instance.hashcat_crack_command
7269
end
7370
print_status(" Cracking Command: #{cmd.join(' ')}")
@@ -99,16 +96,13 @@ def process_cracker_results(results, cred)
9996
end
10097

10198
def check_results(passwords, results, hash_type, method)
102-
103-
newaction = getaction()
104-
10599
passwords.each do |password_line|
106100
password_line.chomp!
107101
next if password_line.blank?
108102

109103
fields = password_line.split(':')
110104
cred = { 'hash_type' => hash_type, 'method' => method }
111-
if newaction == 'john'
105+
if action.name == 'john'
112106
# If we don't have an expected minimum number of fields, this is probably not a hash line
113107
next unless fields.count > 2
114108

@@ -142,7 +136,7 @@ def check_results(passwords, results, hash_type, method)
142136
cred['password'] = john_lm_upper_to_ntlm(password, nt_hash)
143137
end
144138
next if cred['password'].nil?
145-
elsif newaction == 'hashcat'
139+
elsif action.name == 'hashcat'
146140
next unless fields.count >= 2
147141

148142
cred['core_id'] = fields.shift
@@ -169,9 +163,6 @@ def check_results(passwords, results, hash_type, method)
169163
end
170164

171165
def run
172-
173-
newaction = getaction()
174-
175166
tbl = cracker_results_table
176167

177168
# array of hashes in jtr_format in the db, converted to an OR combined regex
@@ -187,7 +178,7 @@ def run
187178

188179
# build our job list
189180
hash_types_to_crack.each do |hash_type|
190-
job = hash_job(hash_type, newaction)
181+
job = hash_job(hash_type, action.name)
191182
if job.nil?
192183
print_status("No #{hash_type} found to crack")
193184
else
@@ -205,7 +196,7 @@ def run
205196
# Inner array format: db_id, hash_type, username, password, method_of_crack
206197
results = []
207198

208-
cracker = new_password_cracker(newaction)
199+
cracker = new_password_cracker(action.name)
209200

210201
# generate our wordlist and close the file handle.
211202
wordlist = wordlist_file
@@ -229,7 +220,7 @@ def run
229220
# dupe our original cracker so we can safely change options between each run
230221
cracker_instance = cracker.dup
231222
cracker_instance.format = format
232-
if newaction == 'john'
223+
if action.name == 'john'
233224
cracker_instance.fork = datastore['FORK']
234225
end
235226

@@ -240,7 +231,7 @@ def run
240231
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
241232
next if job['cred_ids_left_to_crack'].empty?
242233

243-
if newaction == 'john'
234+
if action.name == 'john'
244235
print_status "Cracking #{format} hashes in single mode..."
245236
cracker_instance.mode_single(wordlist.path)
246237
show_command cracker_instance
@@ -283,7 +274,7 @@ def run
283274
print_status "Cracking #{format} hashes in wordlist mode..."
284275
cracker_instance.mode_wordlist(wordlist.path)
285276
# Turn on KoreLogic rules if the user asked for it
286-
if newaction == 'john' && datastore['KORELOGIC']
277+
if action.name == 'john' && datastore['KORELOGIC']
287278
cracker_instance.rules = 'KoreLogicRules'
288279
print_status 'Applying KoreLogic ruleset...'
289280
end
@@ -308,24 +299,4 @@ def run
308299
end
309300
end
310301
end
311-
312-
def getaction
313-
newaction = action.name
314-
if action.name == 'auto'
315-
path = Rex::FileUtils.find_full_path('hashcat') ||
316-
Rex::FileUtils.find_full_path('hashcat.exe')
317-
if path
318-
newaction = 'hashcat'
319-
else
320-
path = Rex::FileUtils.find_full_path('john') ||
321-
Rex::FileUtils.find_full_path('john.exe')
322-
if path
323-
newaction = 'john'
324-
else
325-
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
326-
end
327-
end
328-
end
329-
return newaction
330-
end
331302
end

0 commit comments

Comments
 (0)