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