diff --git a/lib/msf/core/opt_http_rhost_url.rb b/lib/msf/core/opt_http_rhost_url.rb index d0c15048d9403..5ef2b523cc845 100644 --- a/lib/msf/core/opt_http_rhost_url.rb +++ b/lib/msf/core/opt_http_rhost_url.rb @@ -81,9 +81,6 @@ def single_rhost?(value) return false unless walker.valid? # if there is only a single ip then it's not a range walker.length == 1 - rescue ::Exception - # couldn't create a range therefore it isn't one - return true end end diff --git a/spec/lib/msf/core/opt_http_rhost_url_spec.rb b/spec/lib/msf/core/opt_http_rhost_url_spec.rb index 4400422cf9d3f..dceb3ba042ac4 100644 --- a/spec/lib/msf/core/opt_http_rhost_url_spec.rb +++ b/spec/lib/msf/core/opt_http_rhost_url_spec.rb @@ -21,15 +21,13 @@ it_behaves_like 'an option', valid_values, invalid_values, 'rhost http url' - describe '#calculate_value' do [ - { expected_url: 'http://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } }, - { expected_url: 'https://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 443, 'SSL' => true, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } }, - { expected_url: 'http://user:pass@example.com:1234/somePath', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 1234, 'SSL' => false, 'TARGETURI' => '/somePath', 'URI' => '/somePath', 'VHOST' => 'example.com', 'HttpUsername' => 'user', 'HttpPassword' => 'pass' } }, - { expected_url: 'http://127.0.0.1', datastore: { 'RHOSTS' => '127.0.0.1', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => nil, 'HttpUsername' => '', 'HttpPassword' => '' } } - ].each do | test | - + { expected_url: 'http://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } }, + { expected_url: 'https://example.com', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 443, 'SSL' => true, 'TARGETURI' => '', 'URI' => '', 'VHOST' => 'example.com', 'HttpUsername' => '', 'HttpPassword' => '' } }, + { expected_url: 'http://user:pass@example.com:1234/somePath', datastore: { 'RHOSTS' => 'example.com', 'RPORT' => 1234, 'SSL' => false, 'TARGETURI' => '/somePath', 'URI' => '/somePath', 'VHOST' => 'example.com', 'HttpUsername' => 'user', 'HttpPassword' => 'pass' } }, + { expected_url: 'http://127.0.0.1', datastore: { 'RHOSTS' => '127.0.0.1', 'RPORT' => 80, 'SSL' => false, 'TARGETURI' => '', 'URI' => '', 'VHOST' => nil, 'HttpUsername' => '', 'HttpPassword' => '' } } + ].each do |test| context test[:datastore].to_s do it "should return #{test[:expected_url]}" do expect(subject.calculate_value(test[:datastore])).to eq(test[:expected_url]) @@ -37,5 +35,4 @@ end end end - end