Skip to content

Adds auto selection of cracker for password crackers #20418

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Aug 5, 2025

Conversation

H4k1l
Copy link
Contributor

@H4k1l H4k1l commented Jul 26, 2025

Description

The changes satisfy the requests made in issue number #20396.

The first change was made in the file “lib/metasploit/framework/password_crackers/cracker.rb”
to the “binary_path” function. In the issue, the user reported that if John The Ripper was not detected by Metasploit, it would not check if Hashcat was installed, so I modified the function so that there are four concatenated if statements rather than an if-elsif-else statement.

The second change is in “modules/auxiliary/analyze/” in the files:

  • crack_aix.rb
  • crack_databases.rb
  • crack_linux.rb
  • crack_osx.rb
  • crack_webapps.rb
  • crack_windows.rb

They received the same change with the same implementation. I added an action, “auto.” If this action is used, the module will see if either Hashcat or John The Ripper is installed and will choose one of the two, preferring Hashcat.

Verification

  • Start msfconsole
  • use auxiliary/analyze/crack_databases
  • set action auto
  • Insert something to crack(example: creds add user:test_user postgres:md55d41402abc4b2a76b9719d911017c592
  • run

@msutovsky-r7 msutovsky-r7 changed the title Fix issue #20396 and "auto" implementation Adds auto selection of cracker for password crackers Jul 29, 2025
Comment on lines 226 to 244
def getaction
newaction = action.name
if action.name == 'auto'
path = Rex::FileUtils.find_full_path('hashcat') ||
Rex::FileUtils.find_full_path('hashcat.exe')
if path
newaction = 'hashcat'
else
path = Rex::FileUtils.find_full_path('john') ||
Rex::FileUtils.find_full_path('john.exe')
if path
newaction = 'john'
else
raise PasswordCrackerNotFoundError, 'No suitable john/hashcat binary was found on the system'
end
end
end
return newaction
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This just does exactly what is in cracker.rb - I think we should keep the logic there and not move it separately into each module.

@@ -25,8 +25,9 @@ def initialize
'Actions' => [
['john', { 'Description' => 'Use John the Ripper' }],
['hashcat', { 'Description' => 'Use Hashcat' }],
['auto', { 'Description' => 'Auto-selection of cracker' ]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
['auto', { 'Description' => 'Auto-selection of cracker' ]}
['auto', { 'Description' => 'Auto-selection of cracker' }]

@msutovsky-r7 msutovsky-r7 added the rn-enhancement release notes enhancement label Aug 5, 2025
@msutovsky-r7 msutovsky-r7 merged commit 8914520 into rapid7:master Aug 5, 2025
18 checks passed
@msutovsky-r7
Copy link
Contributor

msutovsky-r7 commented Aug 5, 2025

Release Notes

Updates the password cracking modules to now automatically detect the presence of JohnTheRipper or Hashcat binaries on the host filesystem when attempting to crack credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature library rn-enhancement release notes enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants