Class: Metasploit::Framework::Command::Base
- Inherits:
-
Object
- Object
- Metasploit::Framework::Command::Base
- Defined in:
- lib/metasploit/framework/command/base.rb
Overview
Based on pattern used for lib/rails/commands in the railties gem.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#parsed_options ⇒ Object
readonly
Returns the value of attribute parsed_options.
Class Method Summary collapse
- .parsed_options ⇒ Object
- .parsed_options_class ⇒ Object
- .parsed_options_class_name ⇒ Object
-
.require_environment! ⇒ Object
Parses
ARGVfor command line arguments to configure theRails.application. - .start ⇒ Object
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Base
constructor
A new instance of Base.
-
#start ⇒ void
abstract
Starts this command.
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
94 95 96 97 |
# File 'lib/metasploit/framework/command/base.rb', line 94 def initialize(attributes={}) @application = attributes.fetch(:application) @parsed_options = attributes.fetch(:parsed_options) end |
Instance Attribute Details
#application ⇒ Object (readonly)
Returns the value of attribute application.
25 26 27 |
# File 'lib/metasploit/framework/command/base.rb', line 25 def application @application end |
#parsed_options ⇒ Object (readonly)
Returns the value of attribute parsed_options.
31 32 33 |
# File 'lib/metasploit/framework/command/base.rb', line 31 def @parsed_options end |
Class Method Details
.parsed_options ⇒ Object
68 69 70 |
# File 'lib/metasploit/framework/command/base.rb', line 68 def self. .new end |
.parsed_options_class ⇒ Object
72 73 74 |
# File 'lib/metasploit/framework/command/base.rb', line 72 def self. @parsed_options_class ||= .constantize end |
.parsed_options_class_name ⇒ Object
76 77 78 |
# File 'lib/metasploit/framework/command/base.rb', line 76 def self. @parsed_options_class_name ||= "#{module_parent.module_parent}::ParsedOptions::#{name.demodulize}" end |
.require_environment! ⇒ Object
require_environment! should be called to load
config/application.rb to so that the RAILS_ENV can be set from the
command line options in ARGV prior to Rails.env being set.
After returning, Rails.application will be defined and configured.
Parses ARGV for command line arguments to configure the
Rails.application.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/metasploit/framework/command/base.rb', line 46 def self.require_environment! = self. # RAILS_ENV must be set before requiring 'config/application.rb' .environment! ARGV.replace(.positional) # allow other Rails::Applications to use this command if !defined?(Rails) || Rails.application.nil? # @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/commands.rb#L39-L40 require Pathname.new(__FILE__).parent.parent.parent.parent.parent.join('config', 'application') end # have to configure before requiring environment because # config/environment.rb calls initialize! and the initializers will use # the configuration from the parsed options. .configure(Rails.application) Rails.application.require_environment! end |
.start ⇒ Object
80 81 82 83 |
# File 'lib/metasploit/framework/command/base.rb', line 80 def self.start = require_environment! new(application: Rails.application, parsed_options: ).start end |
Instance Method Details
#start ⇒ void
Use #application to start this command.
This method returns an undefined value.
Starts this command.
105 106 107 |
# File 'lib/metasploit/framework/command/base.rb', line 105 def start raise NotImplementedError end |