@@ -49,6 +49,9 @@ def __init__(self, target:MSLDAPTarget, credential:UniCredential, auth=None):
49
49
self .message_table_notify = {}
50
50
self .encryption_sequence_counter = 0 # this will be set by the inderlying auth algo
51
51
self .cb_data = None #for channel binding
52
+ self ._disable_channel_binding = False # putting it here for scanners to be able to turn it off
53
+ self ._disable_signing = False
54
+ self ._null_channel_binding = False
52
55
53
56
if self .credential .protocol == asyauthProtocol .NONE :
54
57
self .is_anon = True
@@ -187,12 +190,15 @@ async def connect(self):
187
190
self .connection_closed_evt = asyncio .Event ()
188
191
packetizer = LDAPPacketizer ()
189
192
client = UniClient (self .target , packetizer )
190
- self .network = await client .connect ()
193
+ self .network = await asyncio . wait_for ( client .connect (), timeout = self . target . timeout )
191
194
192
195
# now processing channel binding options
193
- if self .target .protocol == UniProto .CLIENT_SSL_TCP :
194
- certdata = self .network .get_peer_certificate ()
195
- self .cb_data = b'tls-server-end-point:' + sha256 (certdata ).digest ()
196
+ if self .target .protocol == UniProto .CLIENT_SSL_TCP and self ._disable_channel_binding is False :
197
+ if self ._null_channel_binding is True :
198
+ self .cb_data = b'tls-server-end-point:' + sha256 (b'' ).digest ()
199
+ else :
200
+ certdata = self .network .get_peer_certificate ()
201
+ self .cb_data = b'tls-server-end-point:' + sha256 (certdata ).digest ()
196
202
197
203
self .handle_incoming_task = asyncio .create_task (self .__handle_incoming ())
198
204
self .status = MSLDAPClientStatus .CONNECTED
@@ -250,6 +256,12 @@ async def bind(self):
250
256
flags = ISC_REQ .CONNECTION | ISC_REQ .CONFIDENTIALITY | ISC_REQ .INTEGRITY
251
257
if self .target .protocol == UniProto .CLIENT_SSL_TCP :
252
258
flags = ISC_REQ .CONNECTION
259
+
260
+ # this switch is for the case when we are using NTLM and we want to disable signing
261
+ # useful for testing if the server supports it
262
+ if self ._disable_signing is True :
263
+ flags = ISC_REQ .CONNECTION
264
+
253
265
data , to_continue , err = await self .auth .authenticate (None , spn = self .target .to_target_string (), flags = flags , cb_data = self .cb_data )
254
266
if err is not None :
255
267
return None , err
@@ -385,6 +397,11 @@ async def bind(self):
385
397
if self .target .protocol == UniProto .CLIENT_SSL_TCP :
386
398
flags = ISC_REQ .CONNECTION
387
399
400
+ # this switch is for the case when we are using NTLM and we want to disable signing
401
+ # useful for testing if the server supports it
402
+ if self .credential .protocol == asyauthProtocol .NTLM and self ._disable_signing is True :
403
+ flags = ISC_REQ .CONNECTION
404
+
388
405
data , to_continue , err = await self .auth .authenticate (challenge , cb_data = self .cb_data , spn = self .target .to_target_string (), flags = flags )
389
406
if err is not None :
390
407
raise err
0 commit comments