1- from impacket import uuid
21from impacket .dcerpc .v5 import transport , rprn , even , epm
32from impacket .dcerpc .v5 .ndr import NDRCALL , NDRSTRUCT , NDRPOINTER , NDRUniConformantArray , NDRPOINTERNULL
43from impacket .dcerpc .v5 .dtypes import LPBYTE , USHORT , LPWSTR , DWORD , ULONG , NULL , WSTR , LONG , BOOL , PCHAR , RPC_SID
54from impacket .dcerpc .v5 .rpcrt import RPC_C_AUTHN_GSS_NEGOTIATE , RPC_C_AUTHN_LEVEL_PKT_PRIVACY
65
76from impacket .uuid import uuidtup_to_bin
7+ import contextlib
88
99
1010def get_dynamic_endpoint (interface : bytes , target : str , timeout : int = 5 ) -> str :
@@ -13,8 +13,8 @@ def get_dynamic_endpoint(interface: bytes, target: str, timeout: int = 5) -> str
1313 rpctransport .set_connect_timeout (timeout )
1414 dce = rpctransport .get_dce_rpc ()
1515 dce .connect ()
16- endpoint = epm .hept_map (target , interface , protocol = "ncacn_ip_tcp" , dce = dce )
17- return endpoint
16+ return epm .hept_map (target , interface , protocol = "ncacn_ip_tcp" , dce = dce )
17+
1818
1919class NXCModule :
2020 name = "coerce_plus"
@@ -539,10 +539,8 @@ def connect(self, username, password, domain, lmhash, nthash, aesKey, target, do
539539
540540 # activates EFS
541541 # https://specterops.io/blog/2025/08/19/will-webclient-start/
542- try :
542+ with contextlib . suppress ( Exception ) :
543543 get_dynamic_endpoint (uuidtup_to_bin (("df1941c5-fe89-4e79-bf10-463657acf44d" , "0.0" )), target , timeout = 1 )
544- except :
545- pass
546544
547545 rpctransport = transport .DCERPCTransportFactory (binding_params [pipe ]["stringBinding" ])
548546 rpctransport .set_dport (445 )
0 commit comments