Sha256: 9a3ae5baec2284cf33ffcd51a17465a0e37f8abf2c9bde08aadb123eb171bfb8

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

require 'ronin/exploits/exploit'

require 'spec_helper'

describe Exploits::Exploit do
  before(:each) do
    @exp = Exploits::Exploit.new(:name => 'test') do
      def builder
        'result'
      end
    end
  end

  it "should require a name attribute" do
    exp2 = Exploits::Exploit.new(:object_path => 'test.rb')
    exp2.should_not be_valid

    exp2.name = 'test'
    exp2.should be_valid
  end

  it "should have a unique name and version" do
    first_exp = Exploits::Exploit.create(
      :object_path => 'test.rb',
      :name => 'test',
      :version => '0.0.1'
    )
    first_exp.should be_valid

    second_exp = Exploits::Exploit.new(
      :object_path => 'other.rb',
      :name => 'test',
      :version => '0.0.1'
    )
    second_exp.should_not be_valid

    third_exp = Exploits::Exploit.new(
      :object_path => 'other.rb',
      :name => 'test',
      :version => '0.0.2'
    )
    third_exp.should be_valid
  end

  it "should be able to switch between payloads" do
    @exp.payload = 'payload1'

    @exp.switch_payload('payload2') do
      @exp.payload.should == 'payload2'
    end

    @exp.payload.should == 'payload1'
  end

  it "should have 'unbuilt' and 'built' states" do
    @exp.should_not be_built
    @exp.build
    @exp.should be_built
  end

  it "should return the result of the builder" do
    @exp.build.should == 'result'
  end

  it "should require the exploit is built before being deployed" do
    lambda { @exp.deploy }.should raise_error(Exploits::ExploitNotBuilt)
  end

  it "should have a default deployer method" do
    @exp.build

    @exp.deploy do |exploit|
      @exp.should == exploit
    end
  end

  it "should return the name and the version when calling to_s" do
    @exp.to_s.should == 'test 0.1'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-exploits-0.1.0 spec/exploits/exploit_spec.rb
ronin-exploits-0.1.1 spec/exploits/exploit_spec.rb