Sha256: 8a200d77f34bd683d543ec81ffcac1fa3ac1a6768b8a68096010609873dbf607

Contents?: true

Size: 1.83 KB

Versions: 2

Compression:

Stored size: 1.83 KB

Contents

require 'spec_helper'
require 'ronin/exploits/open_redirect'

describe Ronin::Exploits::OpenRedirect do
  module TestOpenRedirect
    class TestExploit < Ronin::Exploits::OpenRedirect
      base_path   '/showthread.asp'
      query_param 'id'
    end
  end

  let(:exploit_class) { TestOpenRedirect::TestExploit }
  let(:base_url)      { 'http://testasp.vulnweb.com' }
  let(:redirect_url)  { 'http://evil.com/' }

  subject do
    exploit_class.new(
      params: {
        base_url:     base_url,
        redirect_url: redirect_url
      }
    )
  end

  it "must inherite from Ronin::Exploits::ClientSideWebVuln" do
    expect(described_class).to be < Ronin::Exploits::ClientSideWebVuln
  end

  describe ".exploit_type" do
    subject { described_class }

    it { expect(subject.exploit_type).to eq(:open_redirect) }
  end

  describe "#initialize" do
    it "must default #payload to a Ronin::Payloads::Test::OpenRedirect payload" do
      expect(subject.payload).to be_kind_of(Ronin::Payloads::Test::OpenRedirect)
    end

    context "when given the payload: keyword argument" do
      let(:payload) { Ronin::Payloads::URLPayload.new }

      subject do
        exploit_class.new(
          payload: payload,
          params: {
            base_url: base_url
          }
        )
      end

      it "must set #payload" do
        expect(subject.payload).to be(payload)
      end
    end
  end

  describe "#vuln" do
    it "must return a Ronin::Vulns::OpenRedirect object" do
      expect(subject.vuln).to be_kind_of(Ronin::Vulns::OpenRedirect)
    end

    it "must set the #url attribute of the OpenRedirect vuln object" do
      expect(subject.vuln.url).to eq(subject.url)
    end

    it "must set the #test_url attribute of the OpenRedirect vuln object to the 'redirect_url' param" do
      expect(subject.vuln.test_url).to eq(redirect_url)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-exploits-1.0.0.beta2 spec/open_redirect_spec.rb
ronin-exploits-1.0.0.beta1 spec/open_redirect_spec.rb