Class: Ronin::Credential

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/ronin/credential.rb

Overview

Represents Credentials used to access services or websites.

Direct Known Subclasses

ServiceCredential, WebCredential

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

included

Class Method Details

.for_user(name) ⇒ Array<Credential>

Searches for all credentials for a specific user.

Parameters:

  • name (String)

    The name of the user.

Returns:

  • (Array<Credential>)

    The credentials for the user.

Since:

  • 1.0.0



54
55
56
# File 'lib/ronin/credential.rb', line 54

def self.for_user(name)
  all('user_name.name' => name)
end

.with_password(password) ⇒ Array<Credential>

Searches for all credentials with a common password.

Parameters:

  • password (String)

    The password to search for.

Returns:

  • (Array<Credential>)

    The credentials with the common password.

Since:

  • 1.0.0



71
72
73
# File 'lib/ronin/credential.rb', line 71

def self.with_password(password)
  all('password.clear_text' => password)
end

Instance Method Details

#clear_textString

The clear-text password of the credential.

Returns:

  • (String)

    The clear-text password.

Since:

  • 1.0.0



99
100
101
# File 'lib/ronin/credential.rb', line 99

def clear_text
  self.password.clear_text if self.password
end

#to_aryArray<String>

Splits the credential to multiple variables.

Examples:

user, password = cred

user
# => "alice"
password
# => "secret"

Returns:

  • (Array<String>)

    The user and the password.

Since:

  • 1.0.0



135
136
137
# File 'lib/ronin/credential.rb', line 135

def to_ary
  [self.user_name.name, self.password.clear_text]
end

#to_sString

Converts the credentials to a String.

Returns:

  • (String)

    The user name and the password.

Since:

  • 1.0.0



113
114
115
# File 'lib/ronin/credential.rb', line 113

def to_s
  "#{self.user_name}:#{self.password}"
end

#userString

The user the credential belongs to.

Returns:

  • (String)

    The user name.

Since:

  • 1.0.0



85
86
87
# File 'lib/ronin/credential.rb', line 85

def user
  self.user_name.name if self.user_name
end