File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
lib/rex/proto/ldap/auth_adapter/rex_ntlm Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -23,20 +23,27 @@ def setup(ldap_connection)
2323 # Decrypt the provided ciphertext
2424 # @param ciphertext [String]
2525 def read ( ciphertext )
26- message = ntlm_client . session . unseal_message ( ciphertext [ 16 ..-1 ] )
27- if ntlm_client . session . verify_signature ( ciphertext [ 0 ..15 ] , message )
28- return message
29- else
30- # Some error
26+ if ( session = ntlm_client . session ) . nil?
27+ raise Rex ::Proto ::LDAP ::LdapException . new ( 'Can not unseal data (no NTLM session is established)' )
28+ end
29+
30+ message = session . unseal_message ( ciphertext [ 16 ..-1 ] )
31+ unless session . verify_signature ( ciphertext [ 0 ..15 ] , message )
3132 raise Rex ::Proto ::LDAP ::LdapException . new ( 'Received invalid message (NTLM signature verification failed)' )
3233 end
34+
35+ return message
3336 end
3437
3538 # Encrypt the provided plaintext
3639 # @param data [String]
3740 def write ( data )
38- emessage = ntlm_client . session . seal_message ( data )
39- signature = ntlm_client . session . sign_message ( data )
41+ if ( session = ntlm_client . session ) . nil?
42+ raise Rex ::Proto ::LDAP ::LdapException . new ( 'Can not seal data (no NTLM session is established)' )
43+ end
44+
45+ emessage = session . seal_message ( data )
46+ signature = session . sign_message ( data )
4047
4148 signature + emessage
4249 end
You can’t perform that action at this time.
0 commit comments