Class: Mdm::Module::Detail

Inherits:
ApplicationRecord
  • 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',
    'evasion' => 'evasion'
}
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

#actionsActiveRecord::Relation<Mdm::Module::Action>

Auxiliary actions to perform when this running this module.

Returns:



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

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

#archsActiveRecord::Relation<Mdm::Module::Arch>

Architectures supported by this module.

Returns:



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

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

#authorsActiveRecord::Relation<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:



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

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

#default_actionString

Name of the default action in #actions.

Returns:



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

#default_targetString

Name of the default target in #targets.

Returns:



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

#descriptionString

A long, paragraph description of what the module does.

Returns:

  • (String)


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

#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 132

#fileString

The full path to the module file on-disk.

Returns:

  • (String)


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

#fullnameString

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

Returns:

  • (String)


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

#licenseString

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

Returns:

  • (String)


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

#matchesActiveRecord::Relation<MetasploitDataModels::AutomaticExploitation::Match>

Matches for this module

Returns:



73
74
75
76
77
# File 'app/models/mdm/module/detail.rb', line 73

has_many :matches,
:class_name => 'MetasploitDataModels::AutomaticExploitation::Match',
:primary_key => :fullname,
:foreign_key => :module_fullname,
:inverse_of => :module_detail

#mixinsActiveRecord::Relation<Mdm::Module::Mixin>

Mixins used by this module.

Returns:



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

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

#module_runsActiveRecord::Relation<MetasploitDataModels::ModuleRun>

Records of times when this module has been used

Returns:



89
90
91
92
93
# File 'app/models/mdm/module/detail.rb', line 89

has_many :module_runs,
:class_name => 'MetasploitDataModels::ModuleRun',
:primary_key => :fullname,
:foreign_key => :module_fullname,
:inverse_of => :module_detail

#mtimeDateTime

The modification time of the module file on-disk.

Returns:

  • (DateTime)


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

#mtypeString

The type of the module.

Returns:



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

#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 162

#platformsActiveRecord::Relation<Mdm::Module::Platform>

Platforms supported by this module.

Returns:



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

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 168

#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 173

#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 179

#refnameString

The reference name of the module.

Returns:

  • (String)


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

#refsActiveRecord::Relation<Mdm::Module::Ref>

External references to the vulnerabilities this module exploits.

Returns:



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

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 190

#targetsActiveRecord::Relation<Mdm::Module::Target>

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

Returns:



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

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:

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsucessful.



304
305
306
# File 'app/models/mdm/module/detail.rb', line 304

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:

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



314
315
316
# File 'app/models/mdm/module/detail.rb', line 314

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:

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



325
326
327
# File 'app/models/mdm/module/detail.rb', line 325

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:

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



335
336
337
# File 'app/models/mdm/module/detail.rb', line 335

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:

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



345
346
347
# File 'app/models/mdm/module/detail.rb', line 345

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.



355
356
357
# File 'app/models/mdm/module/detail.rb', line 355

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:

Returns:

  • (true)

    if save was successful.

  • (false)

    if save was unsuccessful.



366
367
368
# File 'app/models/mdm/module/detail.rb', line 366

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.



377
378
379
380
381
382
383
384
385
# File 'app/models/mdm/module/detail.rb', line 377

def supports_stance?
  supports_stance = false

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

  supports_stance
end