Class: Mdm::Service

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Metasploit::Model::Search
Defined in:
app/models/mdm/service.rb

Overview

A service, such as an ssh server or web server, running on a #host.

Constant Summary collapse

STATES =

Valid values for #state.

['open', 'closed', 'filtered', 'unknown']

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#credsActiveRecord::Relation<Mdm::Cred>

Credentials gathered from this service.

Returns:



20
21
22
23
# File 'app/models/mdm/service.rb', line 20

has_many :creds,
class_name: 'Mdm::Cred',
dependent: :destroy,
inverse_of: :service

#exploit_attemptsActiveRecord::Relation<Mdm::ExploitAttempt>

Exploit attempts against this service.

Returns:



29
30
31
32
# File 'app/models/mdm/service.rb', line 29

has_many :exploit_attempts,
class_name: 'Mdm::ExploitAttempt',
dependent: :destroy,
inverse_of: :service

#exploited_hostsArray<Mdm::ExploitHost>

TODO:

MSP-2732

Returns:

  • (Array<Mdm::ExploitHost>)


37
38
39
40
# File 'app/models/mdm/service.rb', line 37

has_many :exploited_hosts,
class_name: 'Mdm::ExploitedHost',
dependent: :destroy,
inverse_of: :service

#hostMdm::Host

The host on which this service runs.

Returns:



46
47
48
49
# File 'app/models/mdm/service.rb', line 46

belongs_to :host,
class_name: 'Mdm::Host',
counter_cache: :service_count,
inverse_of: :services

#infoString

Additional information about the service that does not fit in the #name or #proto.

Returns:

  • (String)


# File 'app/models/mdm/service.rb', line 132

#lootsActiveRecord::Relation<Mdm::Loot>

Loot gathers from this service.

Returns:



55
56
57
58
# File 'app/models/mdm/service.rb', line 55

has_many :loots,
class_name: 'Mdm::Loot',
dependent: :destroy,
inverse_of: :service

#nameString

The name of the service.

Returns:

  • (String)


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

#notesActiveRecord::Relation<Mdm::Note>

Notes about this service.

Returns:



64
65
66
67
# File 'app/models/mdm/service.rb', line 64

has_many :notes,
class_name: 'Mdm::Note',
dependent: :destroy,
inverse_of: :service

#portInteger

The port on which this service runs on the #host.

Returns:

  • (Integer)


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

#protoString

The protocol used by this service

Returns:

  • (String)


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

#stateString

Whether this service is opened, closed, filtered, or in an unknown state.

Returns:

  • (String)

    element of STATES.



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

#task_servicesArray<Mdm::TaskService>

Details about what Tasks touched this service

Returns:



73
74
75
76
# File 'app/models/mdm/service.rb', line 73

has_many :task_services,
class_name: 'Mdm::TaskService',
dependent: :destroy,
inverse_of: :service

#tasksArray<Mdm::Task>

Tasks that touched this service

Returns:



104
# File 'app/models/mdm/service.rb', line 104

has_many :tasks, :through => :task_services, :class_name => 'Mdm::Task'

#vulnsActiveRecord::Relation<Mdm::Vuln>

Vulnerabilities found in this service.

Returns:



82
83
84
85
# File 'app/models/mdm/service.rb', line 82

has_many :vulns,
class_name: 'Mdm::Vuln',
dependent: :destroy,
inverse_of: :service

#web_formsArray<Mdm::WebForm> (readonly)

Form in the #web_sites on top of this service.

Returns:



120
# File 'app/models/mdm/service.rb', line 120

has_many :web_forms, :through => :web_sites, :class_name => 'Mdm::WebForm'

#web_pagesArray<Mdm::WebPages> (readonly)

Web pages in the #web_sites on top of this service.

Returns:

  • (Array<Mdm::WebPages>)


114
# File 'app/models/mdm/service.rb', line 114

has_many :web_pages, :through => :web_sites, :class_name => 'Mdm::WebPage'

#web_sitesActiveRecord::Relation<Mdm::WebSite>

Web sites running on top of this service.

Returns:



91
92
93
94
# File 'app/models/mdm/service.rb', line 91

has_many :web_sites,
class_name: 'Mdm::WebSite',
dependent: :destroy,
inverse_of: :service

#web_vulnsArray<Mdm::WebVuln> (readonly)

Vulnerabilities found in the #web_sites on top of this service.

Returns:



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

has_many :web_vulns, :through => :web_sites, :class_name => 'Mdm::WebVuln'

Instance Method Details

#normalize_host_osvoid

This method returns an undefined value.

Normalizes the host operating system whenever #info has changed.



199
200
201
202
203
# File 'app/models/mdm/service.rb', line 199

def normalize_host_os
  if info_changed?
    host.normalize_os
  end
end