Class: Metasploit::Credential::Login
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- 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.
-
#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 tasks 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 42
|
#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 50
|
#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 55
|
#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 63
|
#tasks ⇒ ActiveRecord::Relation<Mdm::Task>
The tasks 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, class_name: "Mdm::Task", join_table: "credential_logins_tasks", uniq: true |
#updated_at ⇒ DateTime
The last time this login was updated.
|
# File 'app/models/metasploit/credential/login.rb', line 74
|
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.
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'app/models/metasploit/credential/login.rb', line 164 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: Arel::Nodes::SqlLiteral.new(Metasploit::Credential::Core.cores_from_host_sql(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.
196 197 198 |
# File 'app/models/metasploit/credential/login.rb', line 196 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`
144 145 146 147 |
# File 'app/models/metasploit/credential/login.rb', line 144 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)) } |