Skip to content

Commit 7450d72

Browse files
authored
Fix issue #20396
1 parent 86d5d52 commit 7450d72

File tree

1 file changed

+16
-7
lines changed
  • lib/metasploit/framework/password_crackers

1 file changed

+16
-7
lines changed

lib/metasploit/framework/password_crackers/cracker.rb

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,24 +300,33 @@ def binary_path
300300
if cracker_path && ::File.file?(cracker_path)
301301
return cracker_path
302302
else
303+
# Look in the Environment PATH for the hashcat binary
304+
if cracker == 'hashcat'
305+
path = Rex::FileUtils.find_full_path('hashcat') ||
306+
Rex::FileUtils.find_full_path('hashcat.exe')
307+
end
308+
303309
# Look in the Environment PATH for the john binary
304310
if cracker == 'john'
305311
path = Rex::FileUtils.find_full_path('john') ||
306-
Rex::FileUtils.find_full_path('john.exe')
307-
elsif cracker == 'hashcat'
308-
path = Rex::FileUtils.find_full_path('hashcat') ||
309-
Rex::FileUtils.find_full_path('hashcat.exe')
310-
else
311-
raise PasswordCrackerNotFoundError, 'No suitable Cracker was selected, so a binary could not be found on the system'
312+
Rex::FileUtils.find_full_path('john.exe')
313+
end
314+
315+
# If neither john nor hashcat is found, raise an error
316+
if path == ''
317+
raise PasswordCrackerNotFoundError, 'No suitable Cracker was selected, so a binary could not be found on the system JOHN || HASHCAT'
312318
end
313319

314320
if path && ::File.file?(path)
315321
return path
316322
end
317323

318-
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
319324
end
325+
326+
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
327+
320328
end
329+
321330

322331
# This method runs the command from {#crack_command} and yields each line of output.
323332
#

0 commit comments

Comments
 (0)