Skip to content

Commit 4b4e7cc

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

File tree

1 file changed

+22
-22
lines changed
  • lib/metasploit/framework/password_crackers

1 file changed

+22
-22
lines changed

lib/metasploit/framework/password_crackers/cracker.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -300,33 +300,21 @@ 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-
309-
# Look in the Environment PATH for the john binary
310-
if cracker == 'john'
311-
path = Rex::FileUtils.find_full_path('john') ||
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 == ''
303+
case cracker
304+
when 'hashcat'
305+
path = get_hashcat
306+
when 'john'
307+
path = get_john
308+
when 'auto'
309+
path = get_hashcat || get_john
310+
else
317311
raise PasswordCrackerNotFoundError, 'No suitable Cracker was selected, so a binary could not be found on the system JOHN || HASHCAT'
318312
end
313+
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system' unless path && ::File.file?(path)
319314

320-
if path && ::File.file?(path)
321-
return path
322-
end
323-
315+
path
324316
end
325-
326-
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
327-
328317
end
329-
330318

331319
# This method runs the command from {#crack_command} and yields each line of output.
332320
#
@@ -585,6 +573,18 @@ def show_command
585573
cmd << hash_path
586574
end
587575

576+
def get_hashcat
577+
# Look in the Environment PATH for the hashcat binary
578+
Rex::FileUtils.find_full_path('hashcat') ||
579+
Rex::FileUtils.find_full_path('hashcat.exe')
580+
end
581+
582+
def get_john
583+
# Look in the Environment PATH for the john binary
584+
Rex::FileUtils.find_full_path('john') ||
585+
Rex::FileUtils.find_full_path('john.exe')
586+
end
587+
588588
end
589589
end
590590
end

0 commit comments

Comments
 (0)