Sha256: e95b196fb28898e7afebcde2a6af69356bc2692fb9f5828acd17345f4e51b534

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

require 'ronin/exploits/local'
require 'ronin/exploits/helpers/file_based'

require 'spec_helper'

describe Exploits::Helpers::FileBased do
  before(:each) do
    @exploit = Exploits::Local.new do
      helper :file_based

      self.name = 'file exploit'
      self.output_file_name = 'file_exploit.dat'

      def build
        build_file do |file|
          file << 'some data'
        end
      end
    end
  end

  it "should have an absolute path for the file to be built" do
    @exploit.output_file_path.should_not be_empty
  end

  it "should sanitize the output_file_name used in the absolute path" do
    @exploit.output_file_name = '../evil.txt'

    @exploit.output_file_path.should == File.join(
      @exploit.output_dir,
      'evil.txt'
    )
  end

  it "should have a default output directory" do
    @exploit.output_dir.should == Ronin::Config::TMP_DIR
  end

  it "should have a default output_file_name, based on the exploit name" do
    @exploit.output_file_name.should == 'file_exploit.dat'
  end

  it "should build a file" do
    @exploit.build!

    File.read(@exploit.output_file_path).should == 'some data'
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-exploits-0.3.1 spec/exploits/file_based_exploit_spec.rb
ronin-exploits-0.3.0 spec/exploits/file_based_exploit_spec.rb