Class: Mdm::Module::Detail

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/mdm/module/detail.rb

Overview

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

Constant Summary collapse

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.

{
    'auxiliary' => 'auxiliary',
    'encoder' => 'encoders',
    'exploit' => 'exploits',
    'nop' => 'nops',
    'payload' => 'payloads',
    'post' => 'post'
}
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.

[
    false,
    true
]
RANK_BY_NAME =

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

{
    'Manual' => 0,
    'Low' => 100,
    'Average' => 200,
    'Normal' => 300,
    'Good' => 400,
    'Great' => 500,
    'Excellent' => 600
}
STANCES =

Valid values for #stance.

[
    'aggressive',
    'passive'
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actionsArray<Mdm::Module::Action>

Auxiliary actions to perform when this running this module.

Returns:



53
# File 'app/models/mdm/module/detail.rb', line 53

has_many :actions,   :class_name => 'Mdm::Module::Action',   :dependent => :destroy

#archsArray<Mdm::Module::Arch>

Architectures supported by this module.

Returns:



59
# File 'app/models/mdm/module/detail.rb', line 59

has_many :archs,     :class_name => 'Mdm::Module::Arch',     :dependent => :destroy

#authorsArray<Mdm::Module::Mixin>

Authors (and their emails) of this module. Usually includes the original discoverer who wrote the proof-of-concept and then the people that ported the proof-of-concept to metasploit-framework.

Returns:



66
# File 'app/models/mdm/module/detail.rb', line 66

has_many :authors,   :class_name => 'Mdm::Module::Author',   :dependent => :destroy

#default_actionString

Name of the default action in #actions.

Returns:

  • (String)

    Action#name.



# File 'app/models/mdm/module/detail.rb', line 96

#default_targetString

Name of the default target in #targets.

Returns:

  • (String)

    Target#name.



# File 'app/models/mdm/module/detail.rb', line 101

#descriptionString

A long, paragraph description of what the module does.

Returns:

  • (String)


# File 'app/models/mdm/module/detail.rb', line 106

#disclosure_dateDateTime

The date the vulnerability exploited by this module was disclosed to the public.

Returns:

  • (DateTime)


# File 'app/models/mdm/module/detail.rb', line 111

#fileString

The full path to the module file on-disk.

Returns:

  • (String)


# File 'app/models/mdm/module/detail.rb', line 116

#fullnameString

The full name of the module. The full name is "#mtype/#refname".

Returns:

  • (String)


# File 'app/models/mdm/module/detail.rb', line 121

#licenseString

The name of the software license for the module's code.

Returns:

  • (String)


# File 'app/models/mdm/module/detail.rb', line 126

#mixinsArray<Mdm::Module::Mixin>

Mixins used by this module.

Returns:



72
# File 'app/models/mdm/module/detail.rb', line 72

has_many :mixins,    :class_name => 'Mdm::Module::Mixin',    :dependent => :destroy

#mtimeDateTime

The modification time of the module file on-disk.

Returns:

  • (DateTime)


# File 'app/models/mdm/module/detail.rb', line 131

#mtypeString

The type of the module.

Returns:



# File 'app/models/mdm/module/detail.rb', line 136

#nameString

The human readable name of the module. It is unrelated to #fullname or #refname and is better thought of as a short summary of the #description.

Returns:

  • (String)


# File 'app/models/mdm/module/detail.rb', line 141

#platformsArray<Mdm::Module::Platform>

Platforms supported by this module.

Returns:



78
# File 'app/models/mdm/module/detail.rb', line 78

has_many :platforms, :class_name => 'Mdm::Module::Platform', :dependent => :destroy

#privilegedBoolean

Whether this module requires priveleged access to run.

Returns:

  • (Boolean)


# File 'app/models/mdm/module/detail.rb', line 147

#rankInteger

The reliability of the module and likelyhood that the module won't knock over the service or host being exploited. Bigger values is better.

Returns:

  • (Integer)


# File 'app/models/mdm/module/detail.rb', line 152

#readyfalse, true

Boolean indicating whether the metadata for the module has been updated from the on-disk module.

Returns:

  • (false)

    if the associations are still being updated.

  • (true)

    if this detail and its associations are up-to-date.



# File 'app/models/mdm/module/detail.rb', line 158

#refnameString

The reference name of the module.

Returns:

  • (String)


# File 'app/models/mdm/module/detail.rb', line 164

#refsArray<Mdm::Module::Ref>

External references to the vulnerabilities this module exploits.

Returns:



84
# File 'app/models/mdm/module/detail.rb', line 84

has_many :refs,      :class_name => 'Mdm::Module::Ref',      :dependent => :destroy

#stance'active', ...

Whether the module is active or passive. nil if the module type does not support stances.

Returns:

  • ('active', 'passive', nil)


# File 'app/models/mdm/module/detail.rb', line 169

#targetsArray<Mdm::Module::Target>

Names of targets with different configurations that can be exploited by this module.

Returns:



90
# File 'app/models/mdm/module/detail.rb', line 90

has_many :targets,   :class_name => 'Mdm::Module::Target',   :dependent => :destroy

Instance Method Details

#add_action(name) ⇒ true, false

Adds an Action with the given Action#name to #actions and immediately saves it to the database.

Parameters:

  • name (String)

    Action#name.

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsucessful.



215
216
217
# File 'app/models/mdm/module/detail.rb', line 215

def add_action(name)
  self.actions.build(:name => name).save
end

#add_arch(name) ⇒ true, false

Adds an Arch with the given Arch#name to #archs and immediately saves it to the database.

Parameters:

  • name (String)

    Arch#name.

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



225
226
227
# File 'app/models/mdm/module/detail.rb', line 225

def add_arch(name)
  self.archs.build(:name => name).save
end

#add_author(name, email = nil) ⇒ true, false

Adds an Author with the given Author#name and Author#email to #authors and immediately saves it to the database.

Parameters:

  • name (String)

    Author#name.

  • email (String) (defaults to: nil)

    Author#email.

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



236
237
238
# File 'app/models/mdm/module/detail.rb', line 236

def add_author(name, email=nil)
  self.authors.build(:name => name, :email => email).save
end

#add_mixin(name) ⇒ true, false

Adds an Mixin with the given Mixin#name to #mixins and immediately saves it to the database.

Parameters:

  • name (String)

    Mixin#name.

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



246
247
248
# File 'app/models/mdm/module/detail.rb', line 246

def add_mixin(name)
  self.mixins.build(:name => name).save
end

#add_platform(name) ⇒ true, false

Adds an Platform with the given Platform#name to #platforms and immediately saves it to the database.

Parameters:

  • name (String)

    Platform#name.

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



256
257
258
# File 'app/models/mdm/module/detail.rb', line 256

def add_platform(name)
  self.platforms.build(:name => name).save
end

#add_ref(name) ⇒ true, false

Adds an Ref with the given Ref#name to #refs and immediately saves it to the database.

Parameters:

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



266
267
268
# File 'app/models/mdm/module/detail.rb', line 266

def add_ref(name)
  self.refs.build(:name => name).save
end

#add_target(index, name) ⇒ true, false

Adds an Target with the given Target#index and Target#name to #targets and immediately saves it to the database.

Parameters:

  • index (Integer)

    index of target among other #targets.

  • name (String)

    Target#name.

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



277
278
279
# File 'app/models/mdm/module/detail.rb', line 277

def add_target(index, name)
  self.targets.build(:index => index, :name => name).save
end

#supports_stance?true, false

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



288
289
290
291
292
293
294
295
296
# File 'app/models/mdm/module/detail.rb', line 288

def supports_stance?
  supports_stance = false

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

  supports_stance
end