Sha256: 98f00dd257a8bb091403dfb1e0459472080b106c07dbd5791ca8db31dc215ac2

Contents?: true

Size: 1.64 KB

Versions: 2

Compression:

Stored size: 1.64 KB

Contents

require 'spec_helper'
require 'ronin/exploits/xss'

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

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

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

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

  it "must include Ronin::Exploits::Mixins::HTML" do
    expect(described_class).to include(Ronin::Exploits::Mixins::HTML)
  end

  describe ".exploit_type" do
    subject { described_class }

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

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

    context "when given the payload: keyword argument" do
      let(:payload) { Ronin::Payloads::JavaScriptPayload.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::ReflectedXSS object" do
      expect(subject.vuln).to be_kind_of(Ronin::Vulns::ReflectedXSS)
    end

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

Version data entries

2 entries across 2 versions & 1 rubygems

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