Class: Msf::PersistentStorage::Flatfile
- Inherits:
-
Msf::PersistentStorage
- Object
- Msf::PersistentStorage
- Msf::PersistentStorage::Flatfile
- 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 Attribute Summary collapse
-
#fd ⇒ Object
protected
:nodoc:.
-
#path ⇒ Object
protected
:nodoc:.
Instance Method Summary collapse
-
#initialize(path) ⇒ Flatfile
constructor
Initializes the flatfile for storage based on the parameters specified.
-
#store(framework) ⇒ void
This method stores the current state of the framework in human readable form to a flatfile.
-
#store_general(framework) ⇒ void
protected
This method stores general information about the current state of the framework instance.
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.
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 Attribute Details
#fd ⇒ Object (protected)
:nodoc:
41 42 43 |
# File 'lib/msf/base/persistent_storage/flatfile.rb', line 41 def fd @fd end |
#path ⇒ Object (protected)
:nodoc:
41 42 43 |
# File 'lib/msf/base/persistent_storage/flatfile.rb', line 41 def path @path 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 |
#store_general(framework) ⇒ void (protected)
This method returns an undefined value.
This method stores general information about the current state of the framework instance.
48 49 50 51 52 53 54 |
# File 'lib/msf/base/persistent_storage/flatfile.rb', line 48 def store_general(framework) fd.print( "\n" + "Metasploit Framework Report\n" + "===========================\n\n" + "Generated: #{Time.now}\n\n") end |