Skip to content

Commit 9c03306

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

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

modules/auxiliary/analyze/crack_webapps.rb

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ def initialize
2424
'Actions' => [
2525
['john', { 'Description' => 'Use John the Ripper' }],
2626
['hashcat', { 'Description' => 'Use Hashcat' }],
27-
['auto', { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' }]
2827
],
29-
'DefaultAction' => 'auto',
28+
'DefaultAction' => 'john',
3029
'Notes' => {
3130
'Stability' => [CRASH_SAFE],
3231
'SideEffects' => [],
@@ -49,34 +48,29 @@ def initialize
4948
def show_command(cracker_instance)
5049
return unless datastore['ShowCommand']
5150

52-
newaction = getaction()
53-
54-
if newaction == 'john'
51+
if action.name == 'john'
5552
cmd = cracker_instance.john_crack_command
56-
elsif newaction == 'hashcat'
53+
elsif action.name == 'hashcat'
5754
cmd = cracker_instance.hashcat_crack_command
5855
end
5956
print_status(" Cracking Command: #{cmd.join(' ')}")
6057
end
6158

6259
def check_results(passwords, results, hash_type, method)
63-
64-
newaction = getaction()
65-
6660
passwords.each do |password_line|
6761
password_line.chomp!
6862
next if password_line.blank?
6963

7064
fields = password_line.split(':')
7165
cred = { 'hash_type' => hash_type, 'method' => method }
7266
# If we don't have an expected minimum number of fields, this is probably not a hash line
73-
if newaction == 'john'
67+
if action.name == 'john'
7468
next unless fields.count >= 3
7569

7670
cred['username'] = fields.shift
7771
cred['core_id'] = fields.pop
7872
cred['password'] = fields.join(':') # Anything left must be the password. This accounts for passwords with semi-colons in it
79-
elsif newaction == 'hashcat'
73+
elsif action.name == 'hashcat'
8074
next unless fields.count >= 2
8175

8276
cred['core_id'] = fields.shift
@@ -95,9 +89,6 @@ def check_results(passwords, results, hash_type, method)
9589
end
9690

9791
def run
98-
99-
newaction = getaction()
100-
10192
tbl = tbl = cracker_results_table
10293

10394
hash_types_to_crack = []
@@ -109,7 +100,7 @@ def run
109100

110101
# build our job list
111102
hash_types_to_crack.each do |hash_type|
112-
job = hash_job(hash_type, newaction)
103+
job = hash_job(hash_type, action.name)
113104
if job.nil?
114105
print_status("No #{hash_type} found to crack")
115106
else
@@ -127,7 +118,7 @@ def run
127118
# Inner array format: db_id, hash_type, username, password, method_of_crack
128119
results = []
129120

130-
cracker = new_password_cracker(newaction)
121+
cracker = new_password_cracker(action.name)
131122

132123
# generate our wordlist and close the file handle.
133124
wordlist = wordlist_file
@@ -151,7 +142,7 @@ def run
151142
# dupe our original cracker so we can safely change options between each run
152143
cracker_instance = cracker.dup
153144
cracker_instance.format = format
154-
if newaction == 'john'
145+
if action.name == 'john'
155146
cracker_instance.fork = datastore['FORK']
156147
end
157148

@@ -162,7 +153,7 @@ def run
162153
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
163154
next if job['cred_ids_left_to_crack'].empty?
164155

165-
if newaction == 'john'
156+
if action.name == 'john'
166157
print_status "Cracking #{format} hashes in single mode..."
167158
cracker_instance.mode_single(wordlist.path)
168159
show_command cracker_instance
@@ -203,7 +194,7 @@ def run
203194
print_status "Cracking #{format} hashes in wordlist mode..."
204195
cracker_instance.mode_wordlist(wordlist.path)
205196
# Turn on KoreLogic rules if the user asked for it
206-
if newaction == 'john' && datastore['KORELOGIC']
197+
if action.name == 'john' && datastore['KORELOGIC']
207198
cracker_instance.rules = 'KoreLogicRules'
208199
print_status 'Applying KoreLogic ruleset...'
209200
end
@@ -227,24 +218,4 @@ def run
227218
end
228219
end
229220
end
230-
231-
def getaction
232-
newaction = action.name
233-
if action.name == 'auto'
234-
path = Rex::FileUtils.find_full_path('hashcat') ||
235-
Rex::FileUtils.find_full_path('hashcat.exe')
236-
if path
237-
newaction = 'hashcat'
238-
else
239-
path = Rex::FileUtils.find_full_path('john') ||
240-
Rex::FileUtils.find_full_path('john.exe')
241-
if path
242-
newaction = 'john'
243-
else
244-
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
245-
end
246-
end
247-
end
248-
return newaction
249-
end
250221
end

0 commit comments

Comments
 (0)