o
    j                     @   s   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZ d dlmZmZmZmZmZ d dlmZ d d	lmZ d d
lmZ d dlmZmZmZmZmZmZmZm Z  d dl!m"Z" G dd de"Z#dd Z$e%dkrzd dl&Z&e&'e$  dS dS )    N)asyauthSecret)SPNEGOCredential)NTLMCredential)EPM)KNOWN_UUIDSKNOWN_PROTOCOLS)uuidtup_to_bingeneratestringver_to_binbin_to_uuidtupbin_to_string)
DCERPCAuth)DCERPC5Connection)NULL)RPC_C_AUTHN_LEVEL_NONERPC_C_AUTHN_LEVEL_CONNECTRPC_C_AUTHN_LEVEL_CALLRPC_C_AUTHN_LEVEL_PKTRPC_C_AUTHN_LEVEL_PKT_INTEGRITYRPC_C_AUTHN_LEVEL_PKT_PRIVACYDCERPCExceptionRPC_C_AUTHN_GSS_NEGOTIATE)NDRCALLc                   @   s   e Zd ZdZdZdS )DummyOp    N)__name__
__module____qualname__opnum	structurer   r   r   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiosmb/examples/epmtest.pyr      s    r   c                     s  z2g } d}t |}| I d H \}}|d ur|| I d H \}}|d ur*|| I d H  tt| |D ]Q}d|d d d d |d d d d f }t|d d d d }t||f}	t 	||	I d H \}
}t| |d urt
|d	d
krq9|| ||	|
f q9| D ]\}}	}
tdddtjd}t|g }t|}t||
}|t zxzW| I d H \}}|d ur|||	I d H \}}|d ur|t }||I d H \}}t
|dd
krd}|tv rt| }td|  td|  td|  t  W n ty  } z
t  W Y d }~nd }~ww W | I d H  q| I d H  w W d S  tyL } zt  W Y d }~d S d }~ww )Nz
10.10.10.2z%s.%stowerFloorsr   MajorVersionMinorVersionInterfaceUUIDept_s_not_registeredAdministratorTESTz
Passw0rd!1)usernamedomainsecretstyperpc_s_access_deniedUNKz	UUID : %sz	proto: %sz	err  : %s)r   from_addressconnectlookup
disconnectprintlenr   r   create_targetstrfindappendr   r   PASSWORDr   build_contextr   from_smb_gssapir   set_auth_levelr   bindr   requestr   	Exception	traceback	print_exc)targetsipepm_errxentryversionuuidstrservice_uuidtargetcredgssapiauth
connectionreqprotoer   r   r!   amain   s   
,


 'rV   __main__)(rB   asyauth.common.constantsr   !asyauth.common.credentials.spnegor   asyauth.common.credentials.ntlmr   'aiosmb.dcerpc.v5.interfaces.endpointmgrr   aiosmb.dcerpc.v5.epmr   r   aiosmb.dcerpc.v5.uuidr   r	   r
   r   r   1aiosmb.dcerpc.v5.common.connection.authenticationr   aiosmb.dcerpc.v5.connectionr   aiosmb.dcerpc.v5.dtypesr   aiosmb.dcerpc.v5.rpcrtr   r   r   r   r   r   r   r   aiosmb.dcerpc.v5.ndrr   r   rV   r   asynciorunr   r   r   r!   <module>   s$    (N