Sha256: 0c445bf1f5d24b7557f2a7eba9506a1c49015a8ef6e2639d778d6c5583da8b1b

Contents?: true

Size: 1.06 KB

Versions: 44

Compression:

Stored size: 1.06 KB

Contents

# A {Metasploit::Credential::PasswordHash password hash} that can be {Metasploit::Credential::ReplayableHash replayed}
# to authenticate to PostgreSQL servers. It is composed of a hexadecimal string of 32 charachters prepended by the string
# 'md5'
class Metasploit::Credential::PostgresMD5 < Metasploit::Credential::ReplayableHash
  #
  # CONSTANTS
  #

  # Valid format for {Metasploit::Credential::Private#data}
  DATA_REGEXP = /md5([a-f0-9]{32})/

  #
  # Callbacks
  #

  before_validation :normalize_data

  #
  # Validations
  #

  validate :data_format

  private

  # Normalizes {#data} by making it all lowercase so that the unique validation and index on
  # ({Metasploit::Credential::Private#type}, {#data}) catches collision in a case-insensitive manner without the need
  # to use case-insensitive comparisons.
  def normalize_data
    if data
      self.data = data.downcase
    end
  end

  def data_format
    unless DATA_REGEXP.match(data)
      errors.add(:data, 'is not in Postgres MD5 Hash format')
    end
  end

  public

  Metasploit::Concern.run(self)

end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
metasploit-credential-6.0.4 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-6.0.3 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-6.0.2 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-6.0.1 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-6.0.0 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.9 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.8 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.7 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.6 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.5 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.4 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.3 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.2 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.1 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-5.0.0 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-4.0.5 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-4.0.4 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-4.0.3 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-4.0.2 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-4.0.1 app/models/metasploit/credential/postgres_md5.rb