@@ -76,6 +76,7 @@ def __init__(self, transport, ndr64=False, ndrendian="little", verb=True, **kwar
7676 self .ndr64 = ndr64
7777 self .ndrendian = ndrendian
7878 self .verb = verb
79+ self .host = None
7980 self .auth_level = kwargs .pop ("auth_level" , DCE_C_AUTHN_LEVEL .NONE )
8081 self .auth_context_id = kwargs .pop ("auth_context_id" , 0 )
8182 self .ssp = kwargs .pop ("ssp" , None ) # type: SSP
@@ -100,7 +101,7 @@ def from_smblink(cls, smbcli, smb_kwargs={}, **kwargs):
100101 )
101102 return client
102103
103- def connect (self , ip , port = None , timeout = 5 , smb_kwargs = {}):
104+ def connect (self , host , port = None , timeout = 5 , smb_kwargs = {}):
104105 """
105106 Initiate a connection
106107 """
@@ -113,14 +114,15 @@ def connect(self, ip, port=None, timeout=5, smb_kwargs={}):
113114 raise ValueError (
114115 "Can't guess the port for transport: %s" % self .transport
115116 )
117+ self .host = host
116118 sock = socket .socket ()
117119 sock .settimeout (timeout )
118120 if self .verb :
119121 print (
120122 "\u2503 Connecting to %s on port %s via %s..."
121- % (ip , port , repr (self .transport ))
123+ % (host , port , repr (self .transport ))
122124 )
123- sock .connect ((ip , port ))
125+ sock .connect ((host , port ))
124126 if self .verb :
125127 print (
126128 conf .color_theme .green (
@@ -313,6 +315,7 @@ def _bind(self, interface, reqcls, respcls):
313315 else 0
314316 )
315317 ),
318+ target_name = "host/" + self .host ,
316319 )
317320 if status not in [GSS_S_CONTINUE_NEEDED , GSS_S_COMPLETE ]:
318321 # Authentication failed.
@@ -349,6 +352,7 @@ def _bind(self, interface, reqcls, respcls):
349352 self .sspcontext , token , status = self .ssp .GSS_Init_sec_context (
350353 self .sspcontext ,
351354 token = resp .auth_verifier .auth_value ,
355+ target_name = "host/" + self .host ,
352356 )
353357 if status in [GSS_S_CONTINUE_NEEDED , GSS_S_COMPLETE ]:
354358 # Authentication should continue, in two ways:
@@ -390,6 +394,7 @@ def _bind(self, interface, reqcls, respcls):
390394 self .sspcontext , token , status = self .ssp .GSS_Init_sec_context (
391395 self .sspcontext ,
392396 token = resp .auth_verifier .auth_value ,
397+ target_name = "host/" + self .host ,
393398 )
394399 # Check context acceptance
395400 if (
0 commit comments