Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/base/persistent_storage/flatfile.rb
Views: 11783
# -*- coding: binary -*-1module Msf2class PersistentStorage34# This class persists the state of the framework to a flatfile in a human5# readable format. At the moment, the level of information it conveys is6# rather basic and ugly, but this is just a prototype, so it will be improved.7# Oh yes, it will be improved.8class Flatfile < PersistentStorage910# Initializes the flatfile for storage based on the parameters specified.11# The hash must contain a FilePath attribute.12#13# @overload initialize(path)14# Initializes the flatfile with the set path.15# @param path [String] path of the flatfile.16def initialize(*params)17raise ArgumentError, "You must specify a file path" if (params.length == 0)1819self.path = params[0]20end2122# This method stores the current state of the framework in human readable23# form to a flatfile. This can be used as a reporting mechanism.24#25# @param framework [Msf:::Framework] the Framework to store.26# @return [void]27def store(framework)28# Open the supplied file path for writing.29self.fd = File.new(self.path, "w")3031begin32store_general(framework)33ensure34self.fd.close35end36end3738protected3940attr_accessor :fd, :path # :nodoc:4142# This method stores general information about the current state of the43# framework instance.44#45# @param framework [Msf::Framework] the Framework to store.46# @return [void]47def store_general(framework)48fd.print(49"\n" +50"Metasploit Framework Report\n" +51"===========================\n\n" +52"Generated: #{Time.now}\n\n")53end5455Msf::PersistentStorage.add_storage_class('flatfile', self)5657end5859end60end616263