Class: Msf::PersistentStorage::Flatfile

Inherits:
Msf::PersistentStorage show all
Defined in:
lib/msf/base/persistent_storage/flatfile.rb

Overview

This class persists the state of the framework to a flatfile in a human readable format. At the moment, the level of information it conveys is rather basic and ugly, but this is just a prototype, so it will be improved. Oh yes, it will be improved.

Instance Method Summary collapse

Methods inherited from Msf::PersistentStorage

add_storage_class, create, #fetch

Constructor Details

#initialize(path) ⇒ Flatfile

Initializes the flatfile for storage based on the parameters specified. The hash must contain a FilePath attribute.

Initializes the flatfile with the set path.

Raises:

  • (ArgumentError)

17
18
19
20
21
# File 'lib/msf/base/persistent_storage/flatfile.rb', line 17

def initialize(*params)
  raise ArgumentError, "You must specify a file path" if (params.length == 0)

  self.path = params[0]
end

Instance Method Details

#store(framework) ⇒ void

This method returns an undefined value.

This method stores the current state of the framework in human readable form to a flatfile. This can be used as a reporting mechanism.


28
29
30
31
32
33
34
35
36
37
# File 'lib/msf/base/persistent_storage/flatfile.rb', line 28

def store(framework)
  # Open the supplied file path for writing.
  self.fd = File.new(self.path, "w")

  begin
    store_general(framework)
  ensure
    self.fd.close
  end
end