Skip to content

Commit 99ac369

Browse files
authored
requested change resolved, PR #20418
1 parent 424e4fb commit 99ac369

File tree

1 file changed

+10
-39
lines changed

1 file changed

+10
-39
lines changed

modules/auxiliary/analyze/crack_linux.rb

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ def initialize
3232
'Actions' => [
3333
['john', { 'Description' => 'Use John the Ripper' }],
3434
['hashcat', { 'Description' => 'Use Hashcat' }],
35-
['auto', { 'Description' => 'Use either John the Ripper or Hashcat, if both are present, use Hashcat' }]
3635
],
37-
'DefaultAction' => 'auto',
36+
'DefaultAction' => 'john',
3837
'Notes' => {
3938
'Stability' => [CRASH_SAFE],
4039
'SideEffects' => [],
@@ -59,35 +58,30 @@ def initialize
5958
def show_command(cracker_instance)
6059
return unless datastore['ShowCommand']
6160

62-
newaction = getaction()
63-
64-
if newaction == 'john'
61+
if action.name == 'john'
6562
cmd = cracker_instance.john_crack_command
66-
elsif newaction == 'hashcat'
63+
elsif action.name == 'hashcat'
6764
cmd = cracker_instance.hashcat_crack_command
6865
end
6966
print_status(" Cracking Command: #{cmd.join(' ')}")
7067
end
7168

7269
def check_results(passwords, results, hash_type, method)
73-
74-
newaction = getaction()
75-
7670
passwords.each do |password_line|
7771
password_line.chomp!
7872
next if password_line.blank?
7973

8074
fields = password_line.split(':')
8175
cred = { 'hash_type' => hash_type, 'method' => method }
8276

83-
if newaction == 'john'
77+
if action.name == 'john'
8478
next unless fields.count >= 3 # If we don't have an expected minimum number of fields, this is probably not a hash line
8579

8680
cred['username'] = fields.shift
8781
cred['core_id'] = fields.pop
8882
4.times { fields.pop } # Get rid of extra :
8983
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'
9185
next unless fields.count >= 2 # If we don't have an expected minimum number of fields, this is probably not a hash line
9286

9387
cred['core_id'] = fields.shift
@@ -106,9 +100,6 @@ def check_results(passwords, results, hash_type, method)
106100
end
107101

108102
def run
109-
110-
newaction = getaction()
111-
112103
tbl = tbl = cracker_results_table
113104

114105
# array of hashes in jtr_format in the db, converted to an OR combined regex
@@ -124,7 +115,7 @@ def run
124115

125116
# build our job list
126117
hash_types_to_crack.each do |hash_type|
127-
job = hash_job(hash_type, newaction)
118+
job = hash_job(hash_type, action.name)
128119
if job.nil?
129120
print_status("No #{hash_type} found to crack")
130121
else
@@ -142,7 +133,7 @@ def run
142133
# Inner array format: db_id, hash_type, username, password, method_of_crack
143134
results = []
144135

145-
cracker = new_password_cracker(newaction)
136+
cracker = new_password_cracker(action.name)
146137

147138
# generate our wordlist and close the file handle.
148139
wordlist = wordlist_file
@@ -167,7 +158,7 @@ def run
167158
cracker_instance = cracker.dup
168159
cracker_instance.format = format
169160

170-
if newaction == 'john'
161+
if action.name == 'john'
171162
cracker_instance.fork = datastore['FORK']
172163
end
173164

@@ -178,7 +169,7 @@ def run
178169
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
179170
next if job['cred_ids_left_to_crack'].empty?
180171

181-
if newaction == 'john'
172+
if action.name == 'john'
182173
print_status "Cracking #{format} hashes in single mode..."
183174
cracker_instance.mode_single(wordlist.path)
184175
show_command cracker_instance
@@ -220,7 +211,7 @@ def run
220211
print_status "Cracking #{format} hashes in wordlist mode..."
221212
cracker_instance.mode_wordlist(wordlist.path)
222213
# Turn on KoreLogic rules if the user asked for it
223-
if newaction == 'john' && datastore['KORELOGIC']
214+
if action.name == 'john' && datastore['KORELOGIC']
224215
cracker_instance.rules = 'KoreLogicRules'
225216
print_status 'Applying KoreLogic ruleset...'
226217
end
@@ -244,24 +235,4 @@ def run
244235
end
245236
end
246237
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
267238
end

0 commit comments

Comments
 (0)