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)
23
23
# Decrypt the provided ciphertext
24
24
# @param ciphertext [String]
25
25
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 )
31
32
raise Rex ::Proto ::LDAP ::LdapException . new ( 'Received invalid message (NTLM signature verification failed)' )
32
33
end
34
+
35
+ return message
33
36
end
34
37
35
38
# Encrypt the provided plaintext
36
39
# @param data [String]
37
40
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 )
40
47
41
48
signature + emessage
42
49
end
You can’t perform that action at this time.
0 commit comments