From dceaf1d47cca1ed0bd926adaf454c49ad65832a7 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Mon, 28 Sep 2020 15:20:04 -0500 Subject: [PATCH 1/4] force res and expected encoding in smb tests --- .travis.yml | 1 + .../lib/msf/core/exploit/smb/server/share/command/close_spec.rb | 2 +- .../msf/core/exploit/smb/server/share/command/negotiate_spec.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 167b76f254..79774cf828 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ language: ruby rvm: - '2.5.8' - '2.6.6' + - '2.7.1' env: - CMD='bundle exec rake rspec-rerun:spec SPEC_OPTS="--tag content"' 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 f8a451fef8..07539ee696 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 @@ -45,7 +45,7 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do it "sends a valid SMB_COM_CLOSE response to the client" do mod.send_close_res(msf_io) res = msf_io.read - expect(res).to eq(valid_response) + expect(res.force_encoding("ASCII-8BIT")).to eq(valid_response.force_encoding("ASCII-8BIT")) end end 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 a1315a7853..527cadb65e 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 @@ -66,7 +66,7 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do it "sends a valid SMB_COM_NEGOTIATE response to the client" do mod.send_negotitate_res(msf_io) res = msf_io.read - expect(res).to eq(default_response) + expect(res.force_encoding("ASCII-8BIT")).to eq(default_response.force_encoding("ASCII-8BIT")) end end From 2b223798c784b4144f66b3364b87f89b5810d9f0 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Tue, 29 Sep 2020 09:47:58 -0500 Subject: [PATCH 2/4] no longer restrict rubygems version --- .travis.yml | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 79774cf828..e2013b0fe7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ before_install: - ls -la ./.git/hooks - ./.git/hooks/post-merge # Update the bundler - - gem update --system 3.0.6 + - gem update --system - gem install bundler before_script: - cp config/database.yml.travis config/database.yml diff --git a/Gemfile.lock b/Gemfile.lock index 3115dddf08..b7392e55fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -462,4 +462,4 @@ DEPENDENCIES yard BUNDLED WITH - 1.17.3 + 2.1.4 From 66f04a95b7c96f48118593fa7250e33180f23936 Mon Sep 17 00:00:00 2001 From: Jeffrey Martin Date: Thu, 1 Oct 2020 11:44:32 -0500 Subject: [PATCH 3/4] better enforcement of binary mode on test fixtures --- .../smb/server/share/command/close_spec.rb | 14 +++--- .../server/share/command/negotiate_spec.rb | 44 ++++++++++--------- spec/support/shared/contexts/msf/string_io.rb | 1 + 3 files changed, 33 insertions(+), 26 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 07539ee696..b614f047f5 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 @@ -19,11 +19,13 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:response_length) { 39 } let(:valid_response) do - "\x00\x00\x00\x23\xff\x53\x4d\x42" + - "\x04\x00\x00\x00\x00\x88\x01\xc8" + - "\x00\x00\x00\x00\x00\x00\x00\x00" + - "\x00\x00\x00\x00\x00\x00\x48\x47" + - "\x00\x00\x44\x43\x00\x00\x00" + value = + "\x00\x00\x00\x23\xff\x53\x4d\x42" + + "\x04\x00\x00\x00\x00\x88\x01\xc8" + + "\x00\x00\x00\x00\x00\x00\x00\x00" + + "\x00\x00\x00\x00\x00\x00\x48\x47" + + "\x00\x00\x44\x43\x00\x00\x00" + value.b end before(:example) do @@ -45,7 +47,7 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do it "sends a valid SMB_COM_CLOSE response to the client" do mod.send_close_res(msf_io) res = msf_io.read - expect(res.force_encoding("ASCII-8BIT")).to eq(valid_response.force_encoding("ASCII-8BIT")) + expect(res).to eq(valid_response) end end 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 527cadb65e..1e54545dfb 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 @@ -20,27 +20,31 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do let(:default_response_length) { 73 } let(:default_response) do - "\x00\x00\x00\x45\xff\x53\x4d\x42" + - "\x72\x00\x00\x00\x00\x88\x01\xc8" + - "\x00\x00\x00\x00\x00\x00\x00\x00" + - "\x00\x00\x00\x00\x00\x00\x48\x47" + - "\x00\x00\x44\x43\x11\x00\x00\x00" + - "\x00\x00\x00\x00\x00\x00\x00\x00" + - "\x00\x00\x00\x00\x00\x00\x00\x00" + - "\x00\x00\x00\x00\x00\x00\x00\x00" + - "\x00\x00\x00\x00\x00\x00\x00\x00" + - "\x00" + value = + "\x00\x00\x00\x45\xff\x53\x4d\x42" + + "\x72\x00\x00\x00\x00\x88\x01\xc8" + + "\x00\x00\x00\x00\x00\x00\x00\x00" + + "\x00\x00\x00\x00\x00\x00\x48\x47" + + "\x00\x00\x44\x43\x11\x00\x00\x00" + + "\x00\x00\x00\x00\x00\x00\x00\x00" + + "\x00\x00\x00\x00\x00\x00\x00\x00" + + "\x00\x00\x00\x00\x00\x00\x00\x00" + + "\x00\x00\x00\x00\x00\x00\x00\x00" + + "\x00" + value.b end let(:valid_request) do - "\x00\x00\x00\x85\xff\x53\x4d\x42\x72\x00\x00\x00\x00\x18\x43\xc8" + - "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe" + - "\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4e\x45\x54\x57\x4f" + - "\x52\x4b\x20\x50\x52\x4f\x47\x52\x41\x4d\x20\x31\x2e\x30\x00\x02" + - "\x4c\x41\x4e\x4d\x41\x4e\x31\x2e\x30\x00\x02\x57\x69\x6e\x64\x6f" + - "\x77\x73\x20\x66\x6f\x72\x20\x57\x6f\x72\x6b\x67\x72\x6f\x75\x70" + - "\x73\x20\x33\x2e\x31\x61\x00\x02\x4c\x4d\x31\x2e\x32\x58\x30\x30" + - "\x32\x00\x02\x4c\x41\x4e\x4d\x41\x4e\x32\x2e\x31\x00\x02\x4e\x54" + - "\x20\x4c\x4d\x20\x30\x2e\x31\x32\x00" + value = + "\x00\x00\x00\x85\xff\x53\x4d\x42\x72\x00\x00\x00\x00\x18\x43\xc8" + + "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xfe" + + "\x00\x00\x00\x00\x00\x62\x00\x02\x50\x43\x20\x4e\x45\x54\x57\x4f" + + "\x52\x4b\x20\x50\x52\x4f\x47\x52\x41\x4d\x20\x31\x2e\x30\x00\x02" + + "\x4c\x41\x4e\x4d\x41\x4e\x31\x2e\x30\x00\x02\x57\x69\x6e\x64\x6f" + + "\x77\x73\x20\x66\x6f\x72\x20\x57\x6f\x72\x6b\x67\x72\x6f\x75\x70" + + "\x73\x20\x33\x2e\x31\x61\x00\x02\x4c\x4d\x31\x2e\x32\x58\x30\x30" + + "\x32\x00\x02\x4c\x41\x4e\x4d\x41\x4e\x32\x2e\x31\x00\x02\x4e\x54" + + "\x20\x4c\x4d\x20\x30\x2e\x31\x32\x00" + value.b end let(:valid_response_length) { 81 } let(:challenge_length) { 8 } @@ -66,7 +70,7 @@ RSpec.describe Msf::Exploit::Remote::SMB::Server::Share do it "sends a valid SMB_COM_NEGOTIATE response to the client" do mod.send_negotitate_res(msf_io) res = msf_io.read - expect(res.force_encoding("ASCII-8BIT")).to eq(default_response.force_encoding("ASCII-8BIT")) + expect(res).to eq(default_response) end end diff --git a/spec/support/shared/contexts/msf/string_io.rb b/spec/support/shared/contexts/msf/string_io.rb index 880f6eeb36..25eedbe909 100644 --- a/spec/support/shared/contexts/msf/string_io.rb +++ b/spec/support/shared/contexts/msf/string_io.rb @@ -13,6 +13,7 @@ RSpec.shared_context 'Msf::StringIO' do end s.msf_data = '' + s.binmode s end From 919e5212e72031aadfdbdd4a133995991c5395b3 Mon Sep 17 00:00:00 2001 From: Adam Cammack Date: Fri, 2 Oct 2020 11:25:24 -0500 Subject: [PATCH 4/4] Update 2.7 tests to 2.7.2 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e2013b0fe7..a5f8535c51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,7 @@ language: ruby rvm: - '2.5.8' - '2.6.6' - - '2.7.1' + - '2.7.2' env: - CMD='bundle exec rake rspec-rerun:spec SPEC_OPTS="--tag content"'