Merge branch 'staging/electro-release' into feature/MSP-10656/unify-ssh-scanners

bug/bundler_fix
David Maloney 2014-07-07 16:32:39 -05:00
commit 2c13ff4038
No known key found for this signature in database
GPG Key ID: DEDBA9DC3A913DB2
3 changed files with 2 additions and 45 deletions

View File

@ -48,7 +48,8 @@ module Metasploit
# These values should be #demodularized from subclasses of # These values should be #demodularized from subclasses of
# `Metasploit::Credential::Private` # `Metasploit::Credential::Private`
validates :private_type, validates :private_type,
inclusion: { in: [ :password, :ntlm_hash, :ssh_key ] } inclusion: { in: [ :password, :ntlm_hash, :ssh_key ] },
if: "private_type.present?"
# If we have no private we MUST have a public # If we have no private we MUST have a public
validates :public, validates :public,

View File

@ -18,9 +18,6 @@ module Metasploit
# @!attribute cred_details # @!attribute cred_details
# @return [CredentialCollection] Collection of Credential objects # @return [CredentialCollection] Collection of Credential objects
attr_accessor :cred_details attr_accessor :cred_details
# @!attribute failures
# @return [Array<Result>] Array of failing {Result results}
attr_accessor :failures
# @!attribute host # @!attribute host
# @return [String] The IP address or hostname to connect to # @return [String] The IP address or hostname to connect to
attr_accessor :host attr_accessor :host
@ -33,9 +30,6 @@ module Metasploit
# @!attribute stop_on_success # @!attribute stop_on_success
# @return [Boolean] Whether the scanner should stop when it has found one working Credential # @return [Boolean] Whether the scanner should stop when it has found one working Credential
attr_accessor :stop_on_success attr_accessor :stop_on_success
# @!attribute successes
# @return [Array<Result>] Array of successful {Result results}
attr_accessor :successes
validates :connection_timeout, validates :connection_timeout,
presence: true, presence: true,
@ -68,8 +62,6 @@ module Metasploit
attributes.each do |attribute, value| attributes.each do |attribute, value|
public_send("#{attribute}=", value) public_send("#{attribute}=", value)
end end
self.successes = []
self.failures = []
set_sane_defaults set_sane_defaults
end end
@ -88,8 +80,6 @@ module Metasploit
# Attempt to login with every {Credential credential} in # Attempt to login with every {Credential credential} in
# {#cred_details}, by calling {#attempt_login} once for each. # {#cred_details}, by calling {#attempt_login} once for each.
# #
# All {Result results} are stored in {#successes} and {#failures}.
#
# @yieldparam result [Result] The {Result} object for each attempt # @yieldparam result [Result] The {Result} object for each attempt
# @yieldreturn [void] # @yieldreturn [void]
# @return [void] # @return [void]
@ -109,11 +99,9 @@ module Metasploit
yield result if block_given? yield result if block_given?
if result.success? if result.success?
successes << result
consecutive_error_count = 0 consecutive_error_count = 0
break if stop_on_success break if stop_on_success
else else
failures << result
if result.status == :connection_error if result.status == :connection_error
consecutive_error_count += 1 consecutive_error_count += 1
total_error_count += 1 total_error_count += 1

View File

@ -44,12 +44,10 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do
it { should respond_to :connection_timeout } it { should respond_to :connection_timeout }
it { should respond_to :cred_details } it { should respond_to :cred_details }
it { should respond_to :failures }
it { should respond_to :host } it { should respond_to :host }
it { should respond_to :port } it { should respond_to :port }
it { should respond_to :proxies } it { should respond_to :proxies }
it { should respond_to :stop_on_success } it { should respond_to :stop_on_success }
it { should respond_to :successes }
context 'validations' do context 'validations' do
context 'port' do context 'port' do
@ -238,14 +236,6 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do
) )
} }
let(:failure) {
::Metasploit::Framework::LoginScanner::Result.new(
credential: pub_pri,
proof: nil,
status: :failed
)
}
before(:each) do before(:each) do
login_scanner.host = '127.0.0.1' login_scanner.host = '127.0.0.1'
login_scanner.port = 22 login_scanner.port = 22
@ -270,27 +260,6 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do
my_scanner.scan! my_scanner.scan!
end end
it 'adds the failed results to the failures attribute' do
my_scanner = login_scanner
my_scanner.should_receive(:valid!)
my_scanner.should_receive(:attempt_login).once.with(pub_blank).and_return failure_blank
my_scanner.should_receive(:attempt_login).once.with(pub_pub).and_return success
my_scanner.should_receive(:attempt_login).once.with(pub_pri).and_return failure
my_scanner.scan!
expect(my_scanner.failures).to include failure_blank
expect(my_scanner.failures).to include failure
end
it 'adds the success results to the successes attribute' do
my_scanner = login_scanner
my_scanner.should_receive(:valid!)
my_scanner.should_receive(:attempt_login).once.with(pub_blank).and_return failure_blank
my_scanner.should_receive(:attempt_login).once.with(pub_pub).and_return success
my_scanner.should_receive(:attempt_login).once.with(pub_pri).and_return failure
my_scanner.scan!
expect(my_scanner.successes).to include success
end
context 'when stop_on_success is true' do context 'when stop_on_success is true' do
before(:each) do before(:each) do
login_scanner.host = '127.0.0.1' login_scanner.host = '127.0.0.1'
@ -307,7 +276,6 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do
my_scanner.should_receive(:attempt_login).once.with(pub_pub).and_return success my_scanner.should_receive(:attempt_login).once.with(pub_pub).and_return success
my_scanner.should_not_receive(:attempt_login).with(pub_pri) my_scanner.should_not_receive(:attempt_login).with(pub_pri)
my_scanner.scan! my_scanner.scan!
expect(my_scanner.failures).to_not include failure
end end
end end