Module: Ronin::Exploits::Helpers::FileBased

Defined in:
lib/ronin/exploits/helpers/file_based.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.clean!true

Will forcibly delete the files listed in FileBased.clean_files.

Returns:

  • (true)

    The all files were successfully deleted.



66
67
68
69
70
71
72
73
# File 'lib/ronin/exploits/helpers/file_based.rb', line 66

def FileBased.clean!
  FileBased.clean_files.each do |path|
    FileUtils.rm(path, :force => true)
  end

  FileBased.clean_files.clear
  return true
end

.clean_filesSet

List of files to delete upon exit.

Returns:

  • (Set)

    The list of files to delete upon exit.



56
57
58
# File 'lib/ronin/exploits/helpers/file_based.rb', line 56

def FileBased.clean_files
  @@ronin_exploits_file_based_clean_files ||= Set[]
end

.extended(obj) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/ronin/exploits/helpers/file_based.rb', line 31

def self.extended(obj)
  obj.instance_eval do
    # The output directory for file creation
    parameter :output_dir,
              :default => Config::TMP_DIR,
              :description => 'Directory to save built file in'

    # The name of the output file
    parameter :output_file_name,
              :default => 'exploit',
              :description => 'Name of the file'

    # Whether or not to delete the output file at exit
    parameter :clean_file,
              :default => true,
              :description => 'Delete the file on exit'
  end
end

Instance Method Details

#output_file_pathString

Returns The absolute path of the file to be built.

Returns:

  • (String)

    The absolute path of the file to be built.



81
82
83
84
85
# File 'lib/ronin/exploits/helpers/file_based.rb', line 81

def output_file_path
  sanitized_name = File.expand_path(File.join('',@output_file_name))

  return File.expand_path(File.join(@output_dir,sanitized_name))
end