Module: Ronin::Exploits::Mixins::FileBuilder

Defined in:
lib/ronin/exploits/mixins/file_builder.rb

Overview

Adds methods for building exploit files. Also adds a filename param and a default_filename class method.

Examples

include Mixins::FileBuilder

default_filename 'exploit.docx'

def build
  # ...

  build_file do |file|
    # ...
    file.write(buffer)
    # ...
  end

  # ...
end

Since:

  • 1.0.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(exploit) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Includes Params::Filename into the exploit including Ronin::Exploits::Mixins::FileBuilder.

Parameters:

Since:

  • 1.0.0



64
65
66
# File 'lib/ronin/exploits/mixins/file_builder.rb', line 64

def self.included(exploit)
  exploit.include Params::Filename
end

Instance Method Details

#build_file(name = filename) {|file| ... } ⇒ String

Opens the file to be built.

Examples:

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

Generate a specifically named file.

build_file('file1.xml') do |file|
  file << "<evil />"
end

Parameters:

  • name (String) (defaults to: filename)

    Optional name of the file to build.

Yields:

  • (file)

    If a block is given, it will be passed the newly opened file. After the block has returned, the file will be closed.

Yield Parameters:

  • file (Tempfile, File)

    The newly opened file.

Returns:

  • (String)

    Path to the built file.

Since:

  • 1.0.0



94
95
96
97
98
99
# File 'lib/ronin/exploits/mixins/file_builder.rb', line 94

def build_file(name=filename,&block)
  path = File.expand_path(name)

  File.open(name,'wb',&block)
  return path
end