class Mdm::Module::Detail

Details about an Msf::Module. Metadata that can be an array is stored in associations in modules under the {Mdm::Module} namespace.

Constants

DIRECTORY_BY_TYPE

The directory for a given {#mtype} is a not always the pluralization of {#mtype}, so this maps the {#mtype} to the type directory that is used to generate the {#file} from the {#mtype} and {#refname}.

PRIVILEGES

{#privileged} is Boolean so, valid values are just `true` and `false`, but since both the validation and factory need an array of valid values, this constant exists.

RANK_BY_NAME

Converts {#rank}, which is an Integer, to the name used for that rank.

STANCES

Valid values for {#stance}.

Public Instance Methods

add_action(name) click to toggle source

Adds an {Mdm::Module::Action} with the given {Mdm::Module::Action#name} to {#actions} and immediately saves it to the database.

@param name [String] {Mdm::Module::Action#name}. @return [true] if save was successful. @return [false] if save was unsucessful.

# File app/models/mdm/module/detail.rb, line 235
def add_action(name)
  self.actions.build(:name => name).save
end
add_arch(name) click to toggle source

Adds an {Mdm::Module::Arch} with the given {Mdm::Module::Arch#name} to {#archs} and immediately saves it to the database.

@param name [String] {Mdm::Module::Arch#name}. @return [true] if save was successful. @return [false] if save was unsuccessful.

# File app/models/mdm/module/detail.rb, line 245
def add_arch(name)
  self.archs.build(:name => name).save
end
add_author(name, email=nil) click to toggle source

Adds an {Mdm::Module::Author} with the given {Mdm::Module::Author#name} and {Mdm::Module::Author#email} to {#authors} and immediately saves it to the database.

@param name [String] {Mdm::Module::Author#name}. @param email [String] {Mdm::Module::Author#email}. @return [true] if save was successful. @return [false] if save was unsuccessful.

# File app/models/mdm/module/detail.rb, line 256
def add_author(name, email=nil)
  self.authors.build(:name => name, :email => email).save
end
add_mixin(name) click to toggle source

Adds an {Mdm::Module::Mixin} with the given {Mdm::Module::Mixin#name} to {#mixins} and immediately saves it to the database.

@param name [String] {Mdm::Module::Mixin#name}. @return [true] if save was successful. @return [false] if save was unsuccessful.

# File app/models/mdm/module/detail.rb, line 266
def add_mixin(name)
  self.mixins.build(:name => name).save
end
add_platform(name) click to toggle source

Adds an {Mdm::Module::Platform} with the given {Mdm::Module::Platform#name} to {#platforms} and immediately saves it to the database.

@param name [String] {Mdm::Module::Platform#name}. @return [true] if save was successful. @return [false] if save was unsuccessful.

# File app/models/mdm/module/detail.rb, line 276
def add_platform(name)
  self.platforms.build(:name => name).save
end
add_ref(name) click to toggle source

Adds an {Mdm::Module::Ref} with the given {Mdm::Module::Ref#name} to {#refs} and immediately saves it to the database.

@param name [String] {Mdm::Module::Ref#name}. @return [true] if save was successful. @return [false] if save was unsuccessful.

# File app/models/mdm/module/detail.rb, line 286
def add_ref(name)
  self.refs.build(:name => name).save
end
add_target(index, name) click to toggle source

Adds an {Mdm::Module::Target} with the given {Mdm::Module::Target#index} and {Mdm::Module::Target#name} to {#targets} and immediately saves it to the database.

@param index [Integer] index of target among other {#targets}. @param name [String] {Mdm::Module::Target#name}. @return [true] if save was successful. @return [false] if save was unsuccessful.

# File app/models/mdm/module/detail.rb, line 297
def add_target(index, name)
  self.targets.build(:index => index, :name => name).save
end
supports_stance?() click to toggle source

Returns whether this module supports a {#stance}. Only modules with {#mtype} `'auxiliary'` and `'exploit'` support a non-nil {#stance}.

@return [true] if {#mtype} is `'auxiliary'` or `'exploit'` @return [false] otherwise @see github.com/rapid7/metasploit-framework/blob/a6070f8584ad9e48918b18c7e765d85f549cb7fd/lib/msf/core/db_manager.rb#L423 @see github.com/rapid7/metasploit-framework/blob/a6070f8584ad9e48918b18c7e765d85f549cb7fd/lib/msf/core/db_manager.rb#L436

# File app/models/mdm/module/detail.rb, line 308
def supports_stance?
  supports_stance = false

  if ['auxiliary', 'exploit'].include? mtype
    supports_stance = true
  end

  supports_stance
end