Class: Metasploit::Framework::Credential
- Inherits:
-
Object
- Object
- Metasploit::Framework::Credential
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/metasploit/framework/credential.rb
Overview
This class provides an in-memory representation of a conceptual Credential
It contains the public, private, and realm if any.
Instance Attribute Summary collapse
-
#paired ⇒ Boolean
Whether BOTH a public and private are required (defaults to ‘true`).
-
#parent ⇒ Object
The parent object that had .to_credential called on it to create this object.
-
#private ⇒ String?
The private credential component (e.g. password).
-
#private_type ⇒ String
The type of private credential this object represents, e.g.
-
#public ⇒ String?
The public credential component (e.g. username).
-
#realm ⇒ String?
The realm credential component (e.g domain name).
-
#realm_key ⇒ String?
The type of #realm.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(attributes = {}) ⇒ Credential
constructor
A new instance of Credential.
- #inspect ⇒ Object
- #to_credential ⇒ Object
-
#to_h ⇒ Hash
This method takes all of the attributes of the Credential and spits them out in a hash compatible with the create_credential calls.
- #to_s ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Credential
Returns a new instance of Credential.
63 64 65 66 67 68 69 |
# File 'lib/metasploit/framework/credential.rb', line 63 def initialize(attributes={}) attributes.each do |attribute, value| public_send("#{attribute}=", value) end self.paired = true if self.paired.nil? end |
Instance Attribute Details
#paired ⇒ Boolean
Returns Whether BOTH a public and private are required (defaults to ‘true`).
14 15 16 |
# File 'lib/metasploit/framework/credential.rb', line 14 def paired @paired end |
#parent ⇒ Object
Returns the parent object that had .to_credential called on it to create this object.
17 18 19 |
# File 'lib/metasploit/framework/credential.rb', line 17 def parent @parent end |
#private ⇒ String?
The private credential component (e.g. password)
23 24 25 |
# File 'lib/metasploit/framework/credential.rb', line 23 def private @private end |
#private_type ⇒ String
The type of private credential this object represents, e.g. a password or an NTLM hash.
29 30 31 |
# File 'lib/metasploit/framework/credential.rb', line 29 def private_type @private_type end |
#public ⇒ String?
The public credential component (e.g. username)
35 36 37 |
# File 'lib/metasploit/framework/credential.rb', line 35 def public @public end |
#realm ⇒ String?
Returns The realm credential component (e.g domain name).
38 39 40 |
# File 'lib/metasploit/framework/credential.rb', line 38 def realm @realm end |
#realm_key ⇒ String?
Returns The type of #realm.
41 42 43 |
# File 'lib/metasploit/framework/credential.rb', line 41 def realm_key @realm_key end |
Instance Method Details
#==(other) ⇒ Object
85 86 87 88 89 |
# File 'lib/metasploit/framework/credential.rb', line 85 def ==(other) other.respond_to?(:public) && other.public == self.public && other.respond_to?(:private) && other.private == self.private && other.respond_to?(:realm) && other.realm == self.realm end |
#inspect ⇒ Object
71 72 73 |
# File 'lib/metasploit/framework/credential.rb', line 71 def inspect "#<#{self.class} \"#{self}\" >" end |
#to_credential ⇒ Object
91 92 93 94 |
# File 'lib/metasploit/framework/credential.rb', line 91 def to_credential self.parent = self self end |
#to_h ⇒ Hash
This method takes all of the attributes of the Metasploit::Framework::Credential and spits them out in a hash compatible with the create_credential calls.
100 101 102 103 104 105 106 107 108 |
# File 'lib/metasploit/framework/credential.rb', line 100 def to_h { private_data: private, private_type: private_type, username: public, realm_key: realm_key, realm_value: realm } end |
#to_s ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/metasploit/framework/credential.rb', line 75 def to_s if realm && realm_key == Metasploit::Model::Realm::Key::ACTIVE_DIRECTORY_DOMAIN "#{self.realm}\\#{self.public}:#{self.private}" elsif self.private "#{self.public}:#{self.private}#{at_realm}" else self.public end end |