Skip to content

Commit 87d7dec

Browse files
authored
requested change resolved, PR #20418
1 parent 4b4e7cc commit 87d7dec

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

modules/auxiliary/analyze/crack_aix.rb

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def initialize
2525
'Actions' => [
2626
['john', { 'Description' => 'Use John the Ripper' }],
2727
['hashcat', { 'Description' => 'Use Hashcat' }],
28-
['auto', { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' }]
2928
],
30-
'DefaultAction' => 'auto',
29+
'DefaultAction' => 'john',
3130
'Notes' => {
3231
'Stability' => [CRASH_SAFE],
3332
'SideEffects' => [],
@@ -45,21 +44,16 @@ def initialize
4544

4645
def show_command(cracker_instance)
4746
return unless datastore['ShowCommand']
48-
49-
newaction = getaction()
5047

51-
if newaction == 'john'
48+
if action.name == 'john'
5249
cmd = cracker_instance.john_crack_command
53-
elsif newaction == 'hashcat'
50+
elsif action.name == 'hashcat'
5451
cmd = cracker_instance.hashcat_crack_command
5552
end
5653
print_status(" Cracking Command: #{cmd.join(' ')}")
5754
end
5855

5956
def check_results(passwords, results, hash_type, method)
60-
61-
newaction = getaction()
62-
6357
passwords.each do |password_line|
6458
password_line.chomp!
6559
next if password_line.blank?
@@ -69,12 +63,12 @@ def check_results(passwords, results, hash_type, method)
6963
next unless fields.count >= 3
7064

7165
cred = { 'hash_type' => hash_type, 'method' => method }
72-
if newaction == 'john'
66+
if action.name == 'john'
7367
cred['username'] = fields.shift
7468
cred['core_id'] = fields.pop
7569
4.times { fields.pop } # Get rid of extra :
7670
cred['password'] = fields.join(':') # Anything left must be the password. This accounts for passwords with semi-colons in it
77-
elsif newaction == 'hashcat'
71+
elsif action.name == 'hashcat'
7872
cred['core_id'] = fields.shift
7973
cred['hash'] = fields.shift
8074
cred['password'] = fields.join(':') # Anything left must be the password. This accounts for passwords with semi-colons in it
@@ -91,17 +85,14 @@ def check_results(passwords, results, hash_type, method)
9185
end
9286

9387
def run
94-
95-
newaction = getaction()
96-
9788
tbl = tbl = cracker_results_table
9889

9990
hash_types_to_crack = ['descrypt']
10091
jobs_to_do = []
10192

10293
# build our job list
10394
hash_types_to_crack.each do |hash_type|
104-
job = hash_job(hash_type, newaction)
95+
job = hash_job(hash_type, action.name)
10596
if job.nil?
10697
print_status("No #{hash_type} found to crack")
10798
else
@@ -119,7 +110,7 @@ def run
119110
# Inner array format: db_id, hash_type, username, password, method_of_crack
120111
results = []
121112

122-
cracker = new_password_cracker(newaction)
113+
cracker = new_password_cracker(action.name)
123114

124115
# generate our wordlist and close the file handle. max length of DES is 8
125116
wordlist = wordlist_file(8)
@@ -145,7 +136,7 @@ def run
145136
cracker_instance = cracker.dup
146137
cracker_instance.format = format
147138

148-
if newaction == 'john'
139+
if action.name == 'john'
149140
cracker_instance.fork = datastore['FORK']
150141
end
151142

@@ -156,7 +147,7 @@ def run
156147
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
157148
next if job['cred_ids_left_to_crack'].empty?
158149

159-
if newaction == 'john'
150+
if action.name == 'john'
160151
print_status "Cracking #{format} hashes in single mode..."
161152
cracker_instance.mode_single(wordlist.path)
162153
show_command cracker_instance
@@ -198,7 +189,7 @@ def run
198189
print_status "Cracking #{format} hashes in wordlist mode..."
199190
cracker_instance.mode_wordlist(wordlist.path)
200191
# Turn on KoreLogic rules if the user asked for it
201-
if newaction == 'john' && datastore['KORELOGIC']
192+
if action.name == 'john' && datastore['KORELOGIC']
202193
cracker_instance.rules = 'KoreLogicRules'
203194
print_status 'Applying KoreLogic ruleset...'
204195
end
@@ -222,24 +213,4 @@ def run
222213
end
223214
end
224215
end
225-
226-
def getaction
227-
newaction = action.name
228-
if action.name == 'auto'
229-
path = Rex::FileUtils.find_full_path('hashcat') ||
230-
Rex::FileUtils.find_full_path('hashcat.exe')
231-
if path
232-
newaction = 'hashcat'
233-
else
234-
path = Rex::FileUtils.find_full_path('john') ||
235-
Rex::FileUtils.find_full_path('john.exe')
236-
if path
237-
newaction = 'john'
238-
else
239-
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
240-
end
241-
end
242-
end
243-
return newaction
244-
end
245216
end

0 commit comments

Comments
 (0)