@@ -300,33 +300,21 @@ def binary_path
300
300
if cracker_path && ::File . file? ( cracker_path )
301
301
return cracker_path
302
302
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
317
311
raise PasswordCrackerNotFoundError , 'No suitable Cracker was selected, so a binary could not be found on the system JOHN || HASHCAT'
318
312
end
313
+ raise PasswordCrackerNotFoundError , 'No suitable john/hashcat binary was found on the system' unless path && ::File . file? ( path )
319
314
320
- if path && ::File . file? ( path )
321
- return path
322
- end
323
-
315
+ path
324
316
end
325
-
326
- raise PasswordCrackerNotFoundError , 'No suitable john/hashcat binary was found on the system'
327
-
328
317
end
329
-
330
318
331
319
# This method runs the command from {#crack_command} and yields each line of output.
332
320
#
@@ -585,6 +573,18 @@ def show_command
585
573
cmd << hash_path
586
574
end
587
575
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
+
588
588
end
589
589
end
590
590
end
0 commit comments