diff --git a/lib/metasploit/framework/ftp/client.rb b/lib/metasploit/framework/ftp/client.rb index a1e3794549..9e6bcdacec 100644 --- a/lib/metasploit/framework/ftp/client.rb +++ b/lib/metasploit/framework/ftp/client.rb @@ -4,6 +4,7 @@ module Metasploit module Framework module Ftp module Client + extend ActiveSupport::Concern include Metasploit::Framework::Tcp::Client # diff --git a/lib/metasploit/framework/login_scanner/base.rb b/lib/metasploit/framework/login_scanner/base.rb index fc093984ab..03af7e4b38 100644 --- a/lib/metasploit/framework/login_scanner/base.rb +++ b/lib/metasploit/framework/login_scanner/base.rb @@ -88,6 +88,7 @@ module Metasploit def each_credential cred_details.each do |raw_cred| + # This could be a Credential object, or a Credential Core, or an Attempt object # so make sure that whatever it is, we end up with a Credential. credential = raw_cred.to_credential @@ -101,6 +102,11 @@ module Metasploit credential.realm_key = self.class::REALM_KEY yield credential elsif credential.realm.blank? && self.class::REALM_KEY.present? && self.class::DEFAULT_REALM.present? + # XXX: This is messing up the display for mssql when not using + # Windows authentication, e.g.: + # [+] 10.0.0.53:1433 - LOGIN SUCCESSFUL: WORKSTATION\sa:msfadmin + # Realm gets ignored in that case, so it still functions, it + # just gives the user bogus info credential.realm_key = self.class::REALM_KEY credential.realm = self.class::DEFAULT_REALM yield credential @@ -144,8 +150,10 @@ module Metasploit successful_users = Set.new each_credential do |credential| - # For Pro bruteforce Reuse and Guess we need to note that we skipped an attempt. + # Skip users for whom we've have already found a password if successful_users.include?(credential.public) + # For Pro bruteforce Reuse and Guess we need to note that we + # skipped an attempt. if credential.parent.respond_to?(:skipped) credential.parent.skipped = true credential.parent.save! diff --git a/lib/metasploit/framework/login_scanner/http.rb b/lib/metasploit/framework/login_scanner/http.rb index d01fcc7bfd..ae49430656 100644 --- a/lib/metasploit/framework/login_scanner/http.rb +++ b/lib/metasploit/framework/login_scanner/http.rb @@ -139,8 +139,6 @@ module Metasploit # like timeouts and TCP evasion options def set_sane_defaults self.connection_timeout ||= 20 - self.max_send_size = 0 if self.max_send_size.nil? - self.send_delay = 0 if self.send_delay.nil? self.uri = '/' if self.uri.blank? self.method = 'GET' if self.method.blank? diff --git a/lib/metasploit/framework/login_scanner/rex_socket.rb b/lib/metasploit/framework/login_scanner/rex_socket.rb index da92873a02..d8fa26eeaf 100644 --- a/lib/metasploit/framework/login_scanner/rex_socket.rb +++ b/lib/metasploit/framework/login_scanner/rex_socket.rb @@ -12,12 +12,6 @@ module Metasploit included do - # @!attribute max_send_size - # @return [Fixnum] The max size of the data to encapsulate in a single packet - attr_accessor :max_send_size - # @!attribute send_delay - # @return [Fixnum] The delay between sending packets - attr_accessor :send_delay # @!attribute ssl # @return [Boolean] Whether the socket should use ssl attr_accessor :ssl @@ -25,21 +19,6 @@ module Metasploit # @return [String] The version of SSL to implement attr_accessor :ssl_version - validates :max_send_size, - presence: true, - numericality: { - only_integer: true, - greater_than_or_equal_to: 0 - } - - validates :send_delay, - presence: true, - numericality: { - only_integer: true, - greater_than_or_equal_to: 0 - } - - private def chost diff --git a/lib/metasploit/framework/login_scanner/telnet.rb b/lib/metasploit/framework/login_scanner/telnet.rb index 552e72b2e0..c227a82187 100644 --- a/lib/metasploit/framework/login_scanner/telnet.rb +++ b/lib/metasploit/framework/login_scanner/telnet.rb @@ -105,12 +105,12 @@ module Metasploit # like timeouts and TCP evasion options def set_sane_defaults self.connection_timeout ||= 30 - self.max_send_size ||= 0 self.port ||= DEFAULT_PORT - self.send_delay ||= 0 self.banner_timeout ||= 25 self.telnet_timeout ||= 10 self.connection_timeout ||= 30 + self.max_send_size ||= 0 + self.send_delay ||= 0 # Shim to set up the ivars from the old Login mixin create_login_ivars end diff --git a/lib/metasploit/framework/login_scanner/vnc.rb b/lib/metasploit/framework/login_scanner/vnc.rb index 5c2b4292b6..61f6069116 100644 --- a/lib/metasploit/framework/login_scanner/vnc.rb +++ b/lib/metasploit/framework/login_scanner/vnc.rb @@ -56,7 +56,6 @@ module Metasploit # Create our VNC client overtop of the socket vnc = Rex::Proto::RFB::Client.new(sock, :allow_none => false) - if vnc.handshake if vnc_auth(vnc,credential.private) result_options[:status] = Metasploit::Model::Login::Status::SUCCESSFUL @@ -77,6 +76,8 @@ module Metasploit proof: e.message, status: Metasploit::Model::Login::Status::UNABLE_TO_CONNECT ) + ensure + disconnect end ::Metasploit::Framework::LoginScanner::Result.new(result_options) diff --git a/lib/metasploit/framework/mssql/client.rb b/lib/metasploit/framework/mssql/client.rb index a196daa19f..9db3cc34fc 100644 --- a/lib/metasploit/framework/mssql/client.rb +++ b/lib/metasploit/framework/mssql/client.rb @@ -5,6 +5,7 @@ module Metasploit module MSSQL module Client + extend ActiveSupport::Concern include Metasploit::Framework::Tcp::Client NTLM_CRYPT = Rex::Proto::NTLM::Crypt @@ -725,4 +726,4 @@ module Metasploit end end -end \ No newline at end of file +end diff --git a/lib/metasploit/framework/tcp/client.rb b/lib/metasploit/framework/tcp/client.rb index 9320936192..ce001f3a30 100644 --- a/lib/metasploit/framework/tcp/client.rb +++ b/lib/metasploit/framework/tcp/client.rb @@ -40,6 +40,33 @@ module Metasploit module Client + extend ActiveSupport::Concern + + # @!attribute max_send_size + # @return [Fixnum] The max size of the data to encapsulate in a single packet + attr_accessor :max_send_size + # @!attribute send_delay + # @return [Fixnum] The delay between sending packets + attr_accessor :send_delay + + included do + include ActiveModel::Validations + validates :max_send_size, + presence: true, + numericality: { + only_integer: true, + greater_than_or_equal_to: 0 + } + + validates :send_delay, + presence: true, + numericality: { + only_integer: true, + greater_than_or_equal_to: 0 + } + + end + # # Establishes a TCP connection to the specified RHOST/RPORT # @@ -64,7 +91,6 @@ module Metasploit 'Proxies' => proxies, 'Timeout' => (opts['ConnectTimeout'] || connection_timeout || 10).to_i ) - # enable evasions on this socket set_tcp_evasions(nsock) @@ -121,14 +147,6 @@ module Metasploit # ## - def max_send_size - raise NotImplementedError - end - - def send_delay - raise NotImplementedError - end - # # Returns the target host # diff --git a/lib/metasploit/framework/telnet/client.rb b/lib/metasploit/framework/telnet/client.rb index 7b88dcf2bf..7e2471db4b 100644 --- a/lib/metasploit/framework/telnet/client.rb +++ b/lib/metasploit/framework/telnet/client.rb @@ -4,6 +4,7 @@ module Metasploit module Framework module Telnet module Client + extend ActiveSupport::Concern include Metasploit::Framework::Tcp::Client include Msf::Auxiliary::Login @@ -216,4 +217,4 @@ module Metasploit end end end -end \ No newline at end of file +end diff --git a/modules/auxiliary/scanner/afp/afp_login.rb b/modules/auxiliary/scanner/afp/afp_login.rb index e01122e1ab..0cc90634bb 100644 --- a/modules/auxiliary/scanner/afp/afp_login.rb +++ b/modules/auxiliary/scanner/afp/afp_login.rb @@ -63,7 +63,9 @@ class Metasploit3 < Msf::Auxiliary proxies: datastore['PROXIES'], cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], - connection_timeout: 30 + connection_timeout: 30, + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], ) scanner.scan! do |result| diff --git a/modules/auxiliary/scanner/db2/db2_auth.rb b/modules/auxiliary/scanner/db2/db2_auth.rb index 6f074deaa6..56a27fcea5 100644 --- a/modules/auxiliary/scanner/db2/db2_auth.rb +++ b/modules/auxiliary/scanner/db2/db2_auth.rb @@ -61,7 +61,9 @@ class Metasploit3 < Msf::Auxiliary proxies: datastore['PROXIES'], cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], - connection_timeout: 30 + connection_timeout: 30, + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], ) scanner.scan! do |result| diff --git a/modules/auxiliary/scanner/ftp/ftp_login.rb b/modules/auxiliary/scanner/ftp/ftp_login.rb index 185b750ebb..04740c9f06 100644 --- a/modules/auxiliary/scanner/ftp/ftp_login.rb +++ b/modules/auxiliary/scanner/ftp/ftp_login.rb @@ -75,6 +75,8 @@ class Metasploit3 < Msf::Auxiliary proxies: datastore['PROXIES'], cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], connection_timeout: 30 ) diff --git a/modules/auxiliary/scanner/mysql/mysql_login.rb b/modules/auxiliary/scanner/mysql/mysql_login.rb index a0c7bc9f17..8964a586d1 100644 --- a/modules/auxiliary/scanner/mysql/mysql_login.rb +++ b/modules/auxiliary/scanner/mysql/mysql_login.rb @@ -60,7 +60,9 @@ class Metasploit3 < Msf::Auxiliary proxies: datastore['PROXIES'], cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], - connection_timeout: 30 + connection_timeout: 30, + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], ) scanner.scan! do |result| @@ -74,7 +76,7 @@ class Metasploit3 < Msf::Auxiliary credential_data[:core] = credential_core create_credential_login(credential_data) - print_good "#{ip}:#{rport} - LOGIN SUCCESSFUL: #{result.credential}" + print_brute :level => :good, :ip => ip, :msg => "Success: '#{result.credential}'" else invalidate_login(credential_data) vprint_error "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status}: #{result.proof})" diff --git a/modules/auxiliary/scanner/pop3/pop3_login.rb b/modules/auxiliary/scanner/pop3/pop3_login.rb index 8295919c1f..173c1ab8b6 100644 --- a/modules/auxiliary/scanner/pop3/pop3_login.rb +++ b/modules/auxiliary/scanner/pop3/pop3_login.rb @@ -71,6 +71,8 @@ class Metasploit3 < Msf::Auxiliary ssl: datastore['SSL'], cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], ) scanner.scan! do |result| diff --git a/modules/auxiliary/scanner/smb/smb_login.rb b/modules/auxiliary/scanner/smb/smb_login.rb index e140709428..c671ebf947 100644 --- a/modules/auxiliary/scanner/smb/smb_login.rb +++ b/modules/auxiliary/scanner/smb/smb_login.rb @@ -74,6 +74,8 @@ class Metasploit3 < Msf::Auxiliary port: rport, stop_on_success: datastore['STOP_ON_SUCCESS'], connection_timeout: 5, + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], ) bogus_result = @scanner.attempt_bogus_login(domain) diff --git a/modules/auxiliary/scanner/telnet/telnet_login.rb b/modules/auxiliary/scanner/telnet/telnet_login.rb index ab0755311d..7f14dc0ee4 100644 --- a/modules/auxiliary/scanner/telnet/telnet_login.rb +++ b/modules/auxiliary/scanner/telnet/telnet_login.rb @@ -7,7 +7,6 @@ require 'msf/core' require 'metasploit/framework/credential_collection' require 'metasploit/framework/login_scanner/telnet' - class Metasploit3 < Msf::Auxiliary include Msf::Exploit::Remote::Telnet @@ -27,7 +26,7 @@ class Metasploit3 < Msf::Auxiliary logins and hosts so you can track your access. }, 'Author' => 'egypt', - 'References' => + 'References' => [ [ 'CVE', '1999-0502'] # Weak password ], @@ -66,6 +65,8 @@ class Metasploit3 < Msf::Auxiliary cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], connection_timeout: datastore['Timeout'], + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], banner_timeout: datastore['TelnetBannerTimeout'], telnet_timeout: datastore['TelnetTimeout'] ) diff --git a/modules/auxiliary/scanner/vmware/vmauthd_login.rb b/modules/auxiliary/scanner/vmware/vmauthd_login.rb index 97314ce115..418e0b808c 100644 --- a/modules/auxiliary/scanner/vmware/vmauthd_login.rb +++ b/modules/auxiliary/scanner/vmware/vmauthd_login.rb @@ -72,7 +72,9 @@ class Metasploit3 < Msf::Auxiliary proxies: datastore['PROXIES'], cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], - connection_timeout: 30 + connection_timeout: 30, + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], ) scanner.scan! do |result| diff --git a/modules/auxiliary/scanner/vnc/vnc_login.rb b/modules/auxiliary/scanner/vnc/vnc_login.rb index 874aff6cbe..a9c780c19d 100644 --- a/modules/auxiliary/scanner/vnc/vnc_login.rb +++ b/modules/auxiliary/scanner/vnc/vnc_login.rb @@ -77,7 +77,9 @@ class Metasploit3 < Msf::Auxiliary proxies: datastore['PROXIES'], cred_details: cred_collection, stop_on_success: datastore['STOP_ON_SUCCESS'], - connection_timeout: datastore['ConnectTimeout'] + connection_timeout: datastore['ConnectTimeout'], + max_send_size: datastore['TCP::max_send_size'], + send_delay: datastore['TCP::send_delay'], ) scanner.scan! do |result| diff --git a/spec/lib/metasploit/framework/login_scanner/afp_spec.rb b/spec/lib/metasploit/framework/login_scanner/afp_spec.rb index 2fc30ea51f..617d28f0d7 100644 --- a/spec/lib/metasploit/framework/login_scanner/afp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/afp_spec.rb @@ -8,6 +8,7 @@ describe Metasploit::Framework::LoginScanner::AFP do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' + it_behaves_like 'Metasploit::Framework::Tcp::Client' it { should respond_to :login_timeout } diff --git a/spec/lib/metasploit/framework/login_scanner/db2_spec.rb b/spec/lib/metasploit/framework/login_scanner/db2_spec.rb index 519a1f38a8..d682445de8 100644 --- a/spec/lib/metasploit/framework/login_scanner/db2_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/db2_spec.rb @@ -11,6 +11,7 @@ describe Metasploit::Framework::LoginScanner::DB2 do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: true it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' + it_behaves_like 'Metasploit::Framework::Tcp::Client' context '#attempt_login' do diff --git a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb index 83de8cc1cf..1b7acf5053 100644 --- a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb @@ -47,6 +47,7 @@ describe Metasploit::Framework::LoginScanner::FTP do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' + it_behaves_like 'Metasploit::Framework::Tcp::Client' diff --git a/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb b/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb index cd870ccd11..593f8fbd8c 100644 --- a/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb @@ -119,4 +119,4 @@ describe Metasploit::Framework::LoginScanner::IPBoard do end -end \ No newline at end of file +end diff --git a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb index d2cbe410be..4acf939fce 100644 --- a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb @@ -35,6 +35,7 @@ describe Metasploit::Framework::LoginScanner::MSSQL do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: true it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' it_behaves_like 'Metasploit::Framework::LoginScanner::NTLM' + it_behaves_like 'Metasploit::Framework::Tcp::Client' it { should respond_to :windows_authentication } diff --git a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb index e77fad96b5..ce686c4d07 100644 --- a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb @@ -6,6 +6,7 @@ describe Metasploit::Framework::LoginScanner::POP3 do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' + it_behaves_like 'Metasploit::Framework::Tcp::Client' context "#attempt_login" do diff --git a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb index 27ffff08ad..2986b3ef99 100644 --- a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb @@ -35,6 +35,7 @@ describe Metasploit::Framework::LoginScanner::SMB do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: true it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' it_behaves_like 'Metasploit::Framework::LoginScanner::NTLM' + it_behaves_like 'Metasploit::Framework::Tcp::Client' it { should respond_to :smb_chunk_size } it { should respond_to :smb_name } diff --git a/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb b/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb index 70e8c2cf28..efbae0ff92 100644 --- a/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb @@ -7,6 +7,7 @@ describe Metasploit::Framework::LoginScanner::Telnet do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' + it_behaves_like 'Metasploit::Framework::Tcp::Client' it { should respond_to :banner_timeout } it { should respond_to :telnet_timeout } diff --git a/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb b/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb index 4ce999a439..07851d7266 100644 --- a/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb @@ -6,6 +6,7 @@ describe Metasploit::Framework::LoginScanner::VMAUTHD do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' + it_behaves_like 'Metasploit::Framework::Tcp::Client' context "#attempt_login" do diff --git a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb index f2b6b62c22..a0c268468d 100644 --- a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb @@ -14,6 +14,7 @@ describe Metasploit::Framework::LoginScanner::VNC do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' + it_behaves_like 'Metasploit::Framework::Tcp::Client' context '#attempt_login' do diff --git a/spec/lib/metasploit/framework/login_scanner/wordpress_rpc_spec.rb b/spec/lib/metasploit/framework/login_scanner/wordpress_rpc_spec.rb index 00b7e29e9d..474d52a9bf 100644 --- a/spec/lib/metasploit/framework/login_scanner/wordpress_rpc_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/wordpress_rpc_spec.rb @@ -8,4 +8,4 @@ describe Metasploit::Framework::LoginScanner::WordpressRPC do it_behaves_like 'Metasploit::Framework::LoginScanner::HTTP' -end \ No newline at end of file +end diff --git a/spec/support/shared/examples/metasploit/framework/login_scanner/rex_socket.rb b/spec/support/shared/examples/metasploit/framework/login_scanner/rex_socket.rb index 6cf9eeb9fb..f3f958664a 100644 --- a/spec/support/shared/examples/metasploit/framework/login_scanner/rex_socket.rb +++ b/spec/support/shared/examples/metasploit/framework/login_scanner/rex_socket.rb @@ -1,60 +1,7 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::RexSocket' do subject(:login_scanner) { described_class.new } - it { should respond_to :send_delay } - it { should respond_to :max_send_size } it { should respond_to :ssl } it { should respond_to :ssl_version } - context 'send_delay' do - it 'is not valid for a non-number' do - login_scanner.send_delay = "a" - expect(login_scanner).to_not be_valid - expect(login_scanner.errors[:send_delay]).to include "is not a number" - end - - it 'is not valid for a floating point' do - login_scanner.send_delay = 5.76 - expect(login_scanner).to_not be_valid - expect(login_scanner.errors[:send_delay]).to include "must be an integer" - end - - it 'is not valid for a negative number' do - login_scanner.send_delay = -8 - expect(login_scanner).to_not be_valid - expect(login_scanner.errors[:send_delay]).to include "must be greater than or equal to 0" - end - - it 'is valid for a legitimate number' do - login_scanner.send_delay = rand(1000) + 1 - expect(login_scanner.errors[:send_delay]).to be_empty - end - end - - context 'max_send_size' do - it 'is not valid for a non-number' do - login_scanner.max_send_size = "a" - expect(login_scanner).to_not be_valid - expect(login_scanner.errors[:max_send_size]).to include "is not a number" - end - - it 'is not valid for a floating point' do - login_scanner.max_send_size = 5.76 - expect(login_scanner).to_not be_valid - expect(login_scanner.errors[:max_send_size]).to include "must be an integer" - end - - it 'is not valid for a negative number' do - login_scanner.max_send_size = -8 - expect(login_scanner).to_not be_valid - expect(login_scanner.errors[:max_send_size]).to include "must be greater than or equal to 0" - end - - it 'is valid for a legitimate number' do - login_scanner.max_send_size = rand(1000) + 1 - expect(login_scanner.errors[:max_send_size]).to be_empty - end - end - - end diff --git a/spec/support/shared/examples/metasploit/framework/tcp/client.rb b/spec/support/shared/examples/metasploit/framework/tcp/client.rb new file mode 100644 index 0000000000..9264d39643 --- /dev/null +++ b/spec/support/shared/examples/metasploit/framework/tcp/client.rb @@ -0,0 +1,58 @@ + +shared_examples_for 'Metasploit::Framework::Tcp::Client' do + subject(:login_scanner) { described_class.new } + + it { should respond_to :send_delay } + it { should respond_to :max_send_size } + + context 'send_delay' do + it 'is not valid for a non-number' do + login_scanner.send_delay = "a" + expect(login_scanner).to_not be_valid + expect(login_scanner.errors[:send_delay]).to include "is not a number" + end + + it 'is not valid for a floating point' do + login_scanner.send_delay = 5.76 + expect(login_scanner).to_not be_valid + expect(login_scanner.errors[:send_delay]).to include "must be an integer" + end + + it 'is not valid for a negative number' do + login_scanner.send_delay = -8 + expect(login_scanner).to_not be_valid + expect(login_scanner.errors[:send_delay]).to include "must be greater than or equal to 0" + end + + it 'is valid for a legitimate number' do + login_scanner.send_delay = rand(1000) + 1 + expect(login_scanner.errors[:send_delay]).to be_empty + end + end + + context 'max_send_size' do + it 'is not valid for a non-number' do + login_scanner.max_send_size = "a" + expect(login_scanner).to_not be_valid + expect(login_scanner.errors[:max_send_size]).to include "is not a number" + end + + it 'is not valid for a floating point' do + login_scanner.max_send_size = 5.76 + expect(login_scanner).to_not be_valid + expect(login_scanner.errors[:max_send_size]).to include "must be an integer" + end + + it 'is not valid for a negative number' do + login_scanner.max_send_size = -8 + expect(login_scanner).to_not be_valid + expect(login_scanner.errors[:max_send_size]).to include "must be greater than or equal to 0" + end + + it 'is valid for a legitimate number' do + login_scanner.max_send_size = rand(1000) + 1 + expect(login_scanner.errors[:max_send_size]).to be_empty + end + end + +end