Method: Metasploit::Credential::Login.failed_logins_by_public

Defined in:
app/models/metasploit/credential/login.rb

.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.

Parameters:

  • host_id (Integer)

    the host to filter cores by

Returns:

  • (Hash{String => Array})


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::[Arel.star],
      Metasploit::Credential::Public[:username]
    ]
  ).order(:last_attempted_at).
    joins(
    Metasploit::Credential::.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::[:status].in(
        [
          Metasploit::Model::::Status::DENIED_ACCESS,
          Metasploit::Model::::Status::DISABLED,
          Metasploit::Model::::Status::INCORRECT,
        ]
      ))
  ).group_by(&:username)
end