Class: Metasploit::Credential::Login
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- Metasploit::Credential::Login
- Extended by:
- ActiveSupport::Autoload
- Includes:
- Model::Search
- Defined in:
- app/models/metasploit/credential/login.rb
Overview
The use of a core credential against a service.
Instance Attribute Summary collapse
-
#access_level ⇒ String?
A free-form text field that the user can use annotate the access level of this login, such as ‘’admin’‘.
-
#core ⇒ Metasploit::Credential::Core
The core credential used to authenticate to #service.
-
#created_at ⇒ DateTime
When this login was created.
-
#host ⇒ Mdm::Host
The host on which #service runs.
-
#last_attempted_at ⇒ DateTime
#status does not change, then normally #updated_at would be updated as the record would not save.
-
#service ⇒ Mdm::Service
The service that either accepted the core credential as valid, invalid, or on which the core credential should be tested to see if it is valid.
-
#status ⇒ String
The status of this login, such as whether it is ‘Metasploit::Model::Login::Status::DENIED_ACCESS`, `Metasploit::Model::Login::Status::DISABLED`, `Metasploit::Model::Login::Status::LOCKED_OUT`, `Metasploit::Model::Login::Status::SUCCESSFUL`, `Metasploit::Model::Login::Status::UNABLE_TO_CONNECT`, `Metasploit::Model::Login::Status::UNTRIED`.
-
#tasks ⇒ ActiveRecord::Relation<Mdm::Task>
The ‘Mdm::Task`s using this to track what tasks interacted with a given core.
-
#updated_at ⇒ DateTime
The last time this login was updated.
Class Method Summary collapse
-
.failed_logins_by_public(host_id) ⇒ Hash{String => Array}
Each username that is related to a login on the passed host and the logins of particular statuses that are related to that public, ordered by the login last attempt date.
-
.status_set ⇒ Set<String>
The valid values for search #status.
Instance Method Summary collapse
-
#in_workspace_including_hosts_and_services ⇒ ActiveRecord::Relation
Finds all Login objects that are associated with a given ‘Mdm::Workspace`.
Instance Attribute Details
#access_level ⇒ String?
An empty string is converted to ‘nil` before saving.
A free-form text field that the user can use annotate the access level of this login, such as ‘’admin’‘.
|
# File 'app/models/metasploit/credential/login.rb', line 54
|
#core ⇒ Metasploit::Credential::Core
The core credential used to authenticate to #service.
24 25 26 27 |
# File 'app/models/metasploit/credential/login.rb', line 24 belongs_to :core, class_name: 'Metasploit::Credential::Core', inverse_of: :logins, counter_cache: true |
#created_at ⇒ DateTime
When this login was created.
|
# File 'app/models/metasploit/credential/login.rb', line 62
|
#host ⇒ Mdm::Host
The host on which #service runs.
46 47 48 |
# File 'app/models/metasploit/credential/login.rb', line 46 has_one :host, class_name: 'Mdm::Host', through: :service |
#last_attempted_at ⇒ DateTime
This is the last time this login was attempted and should be updated even if #status does not change. If
#status does not change, then normally #updated_at would be updated as the record would not save.
The last time a login was attempted.
|
# File 'app/models/metasploit/credential/login.rb', line 67
|
#service ⇒ Mdm::Service
The service that either accepted the core credential as valid, invalid, or on which the core credential should be tested to see if it is valid.
34 35 36 |
# File 'app/models/metasploit/credential/login.rb', line 34 belongs_to :service, class_name: 'Mdm::Service', inverse_of: :logins |
#status ⇒ String
The status of this login, such as whether it is ‘Metasploit::Model::Login::Status::DENIED_ACCESS`, `Metasploit::Model::Login::Status::DISABLED`, `Metasploit::Model::Login::Status::LOCKED_OUT`, `Metasploit::Model::Login::Status::SUCCESSFUL`, `Metasploit::Model::Login::Status::UNABLE_TO_CONNECT`, `Metasploit::Model::Login::Status::UNTRIED`
|
# File 'app/models/metasploit/credential/login.rb', line 75
|
#tasks ⇒ ActiveRecord::Relation<Mdm::Task>
The ‘Mdm::Task`s using this to track what tasks interacted with a given core.
15 16 17 18 |
# File 'app/models/metasploit/credential/login.rb', line 15 has_and_belongs_to_many :tasks, -> { distinct }, class_name: "Mdm::Task", join_table: "credential_logins_tasks" |
#updated_at ⇒ DateTime
The last time this login was updated.
|
# File 'app/models/metasploit/credential/login.rb', line 86
|
Class Method Details
.failed_logins_by_public(host_id) ⇒ Hash{String => Array}
Each username that is related to a login on the passed host and the logins of particular statuses that are related to that public, ordered by the login last attempt date.
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'app/models/metasploit/credential/login.rb', line 181 def self.failed_logins_by_public(host_id) select( [ Metasploit::Credential::Login[Arel.star], Metasploit::Credential::Public[:username] ] ).order(:last_attempted_at). joins( Metasploit::Credential::Login.join_association(:core), Metasploit::Credential::Core.join_association(:public, Arel::Nodes::OuterJoin) ).where( Metasploit::Credential::Core[:id].in( # We are concerned with per-username access attempts. This # can be across any of the cores on a host: Metasploit::Credential::Core.cores_from_host(host_id) ).and( Metasploit::Credential::Login[:status].in( [ Metasploit::Model::Login::Status::DENIED_ACCESS, Metasploit::Model::Login::Status::DISABLED, Metasploit::Model::Login::Status::INCORRECT, ] )) ).group_by(&:username) end |
.status_set ⇒ Set<String>
The valid values for search #status.
213 214 215 |
# File 'app/models/metasploit/credential/login.rb', line 213 def self.status_set @status_set ||= Set.new(Metasploit::Model::Login::Status::ALL) end |
Instance Method Details
#in_workspace_including_hosts_and_services ⇒ ActiveRecord::Relation
Finds all Metasploit::Credential::Login objects that are associated with a given ‘Mdm::Workspace`
161 162 163 164 |
# File 'app/models/metasploit/credential/login.rb', line 161 scope :in_workspace_including_hosts_and_services, ->(workspace) { host_workspace_column = Mdm::Host.arel_table[:workspace_id] joins(service: :host).includes(core: [:public, :private], service: :host).where(host_workspace_column.eq(workspace.id)) } |