Class: Rex::Proto::LDAP::AuthAdapter::RexNTLM::Encryptor
- Inherits:
-
Object
- Object
- Rex::Proto::LDAP::AuthAdapter::RexNTLM::Encryptor
- Defined in:
- lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb
Overview
Provide the ability to “wrap” LDAP comms in an NTLM encryption routine The methods herein are set up with the auth_context_setup call below, and are called when reading or writing needs to occur.
Instance Attribute Summary collapse
-
#ntlm_client ⇒ Object
Returns the value of attribute ntlm_client.
Instance Method Summary collapse
-
#initialize(ntlm_client) ⇒ Encryptor
constructor
A new instance of Encryptor.
-
#read(ciphertext) ⇒ Object
Decrypt the provided ciphertext.
-
#setup(ldap_connection) ⇒ Object
Configure our encryption, and tell the LDAP connection object that we now want to intercept its calls to read and write.
-
#write(data) ⇒ Object
Encrypt the provided plaintext.
Constructor Details
#initialize(ntlm_client) ⇒ Encryptor
Returns a new instance of Encryptor.
12 13 14 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 12 def initialize(ntlm_client) self.ntlm_client = ntlm_client end |
Instance Attribute Details
#ntlm_client ⇒ Object
Returns the value of attribute ntlm_client.
44 45 46 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 44 def ntlm_client @ntlm_client end |
Instance Method Details
#read(ciphertext) ⇒ Object
Decrypt the provided ciphertext
25 26 27 28 29 30 31 32 33 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 25 def read(ciphertext) = ntlm_client.session.(ciphertext[16..-1]) if ntlm_client.session.verify_signature(ciphertext[0..15], ) return else # Some error raise Rex::Proto::LDAP::LdapException.new('Received invalid message (NTLM signature verification failed)') end end |
#setup(ldap_connection) ⇒ Object
Configure our encryption, and tell the LDAP connection object that we now want to intercept its calls to read and write
19 20 21 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 19 def setup(ldap_connection) ldap_connection.wrap_read_write(self.method(:read), self.method(:write)) end |
#write(data) ⇒ Object
Encrypt the provided plaintext
37 38 39 40 41 42 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 37 def write(data) = ntlm_client.session.(data) signature = ntlm_client.session.(data) signature + end |