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.
51 52 53 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 51 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 34 35 36 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 25 def read(ciphertext) if (session = ntlm_client.session).nil? raise Rex::Proto::LDAP::LdapException.new('Can not unseal data (no NTLM session is established)') end = session.(ciphertext[16..-1]) unless session.verify_signature(ciphertext[0..15], ) raise Rex::Proto::LDAP::LdapException.new('Received invalid message (NTLM signature verification failed)') end return 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
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rex/proto/ldap/auth_adapter/rex_ntlm/encryptor.rb', line 40 def write(data) if (session = ntlm_client.session).nil? raise Rex::Proto::LDAP::LdapException.new('Can not seal data (no NTLM session is established)') end = session.(data) signature = session.(data) signature + end |