add all the specs
parent
300baa577c
commit
873d6e5b99
|
@ -102,7 +102,7 @@ module Metasploit
|
||||||
cmd_string = binary_path
|
cmd_string = binary_path
|
||||||
raise JohnNotFoundError, 'No suitable John binary was found on the system' if cmd_string.blank?
|
raise JohnNotFoundError, 'No suitable John binary was found on the system' if cmd_string.blank?
|
||||||
|
|
||||||
cmd = [ cmd_string, '--session=' + john_session_id, '--nolog' ]
|
cmd = [ cmd_string, '--session=' + john_session_id, '--nolog', '--dupe-suppression' ]
|
||||||
|
|
||||||
if config.present?
|
if config.present?
|
||||||
cmd << ( "--config=" + config )
|
cmd << ( "--config=" + config )
|
||||||
|
@ -148,6 +148,36 @@ module Metasploit
|
||||||
@session_id ||= ::Rex::Text.rand_text_alphanumeric(8)
|
@session_id ||= ::Rex::Text.rand_text_alphanumeric(8)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# This method builds the command to show the cracked passwords.
|
||||||
|
#
|
||||||
|
# @raise [JohnNotFoundError] if a suitable John binary was never found
|
||||||
|
# @return [Array] An array set up for {::IO.popen} to use
|
||||||
|
def show_command
|
||||||
|
cmd_string = binary_path
|
||||||
|
raise JohnNotFoundError, 'No suitable John binary was found on the system' if cmd_string.blank?
|
||||||
|
|
||||||
|
pot_file = pot || john_pot_file
|
||||||
|
cmd = [cmd_string, "--show", "--pot=#{pot_file}", "--format=#{format}" ]
|
||||||
|
|
||||||
|
if config
|
||||||
|
cmd << "--config=#{config}"
|
||||||
|
end
|
||||||
|
|
||||||
|
cmd << hash_path
|
||||||
|
end
|
||||||
|
|
||||||
|
# This runs the show command in john to show cracked passwords.
|
||||||
|
#
|
||||||
|
# @yield [String] the output lines from the command
|
||||||
|
# @return [void]
|
||||||
|
def show_passwords
|
||||||
|
::IO.popen(show_command, "rb") do |fd|
|
||||||
|
fd.each_line do |line|
|
||||||
|
yield line
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# This method tries to identify the correct version of the pre-shipped
|
# This method tries to identify the correct version of the pre-shipped
|
||||||
|
|
|
@ -116,4 +116,38 @@ describe Metasploit::Framework::JtR::Cracker do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#show_command' do
|
||||||
|
before(:each) do
|
||||||
|
expect(cracker).to receive(:binary_path).and_return john_path
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'starts with the john binary path' do
|
||||||
|
expect(cracker.show_command[0]).to eq john_path
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'has the --show flag' do
|
||||||
|
expect(cracker.show_command).to include '--show'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'uses the user supplied john.pot if there is one' do
|
||||||
|
cracker.pot = pot
|
||||||
|
expect(cracker.show_command).to include "--pot=#{pot}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'uses default john.pot if the user did not supply one' do
|
||||||
|
expect(cracker).to receive(:john_pot_file).and_return other_pot
|
||||||
|
expect(cracker.show_command).to include "--pot=#{other_pot}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'uses the user supplied format directive' do
|
||||||
|
cracker.format = nt_format
|
||||||
|
expect(cracker.show_command).to include "--format=#{nt_format}"
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'puts the path to the has file at the end' do
|
||||||
|
cracker.hash_path = hash_path
|
||||||
|
expect(cracker.show_command.last).to eq hash_path
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue