Sha256: eca218f907d47b19a71030e018d3d69d80191d2a17bb9fc8589fe736e994a2d6

Contents?: true

Size: 999 Bytes

Versions: 11

Compression:

Stored size: 999 Bytes

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

  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

11 entries across 11 versions & 1 rubygems

Version Path
metasploit-credential-0.14.8 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-0.14.7 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-0.14.6 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-1.0.0.pre.rails.pre.4.0c app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-1.0.0.pre.rails.pre.4.0b app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-1.0.0.pre.rails.pre.4.0 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-0.14.5 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-0.14.4 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-0.14.3 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-0.14.2 app/models/metasploit/credential/postgres_md5.rb
metasploit-credential-0.14.1 app/models/metasploit/credential/postgres_md5.rb