o
    Žõ±jª  ã                   @   s–   d dl Z d dlZ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 d dlmZ d dlmZmZ d	d
„ Zdd„ ZedkrIeƒ  dS dS )é    N)Úlogger)Ú
__banner__)ÚSMBConnectionFactory)ÚDCERPC5Connection)Ú
DCERPCAuth)ÚEPM)Ú	REMSVCRPCÚServiceStatusc           
   
   Ã   s"  �zut dƒ t | ¡}| ¡  ¡ }t dƒ tj|tƒ j| ¡ j	| ¡ j
d�I d H \}}|d ur1|‚t dƒ t | ¡ ¡}t||ƒ}tj|dd�I d H \}}|d urS|‚t d¡ | ¡ 2 z3 d H W \}}|d urj|‚t |ƒ q\6 t dƒ W d	S  ty� }	 zt ¡  d
|	fW  Y d }	~	S d }	~	ww )Nz$[+] Parsing connection parameters...z[+] Connecting to EPM...)Údc_ipÚdomainz3[+] Connecting to Remote Service Manager service...T)Úperform_dummyzService DCE Connected!z[+] Finished!)TNF)Úprintr   Úfrom_urlÚ
get_targetÚget_hostname_or_ipr   Úcreate_targetr   Úservice_uuidr
   r   r   Úfrom_smb_gssapiÚget_credentialr   Úfrom_rpcconnectionr   ÚdebugÚlistÚ	ExceptionÚ	tracebackÚ	print_exc)
ÚurlÚsuÚipÚtargetÚerrÚauthÚ
connectionÚrpcÚserviceÚe© r%   ú�/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiosmb/examples/dceservice.pyÚamain   s8   €
,


ý€þr'   c                  C   sn   dd l } | jdd�}|jddddd� |jdd	d
� | ¡ }ttƒ |jdkr-t t	j
¡ t t|jƒ¡ d S )Nr   z*Remore Registry Service client via DCE/RPC)Údescriptionz-vz	--verboseÚcount)ÚactionÚdefaultÚsmb_urlzƒConnection string that describes the authentication and target. Example: smb+ntlm-password://TEST\Administrator:password@10.10.10.2)Úhelpé   )ÚargparseÚArgumentParserÚadd_argumentÚ
parse_argsr   r   Úverboser   ÚsetLevelÚloggingÚDEBUGÚasyncioÚrunr'   r,   )r/   ÚparserÚargsr%   r%   r&   Úmain0   s   
ÿÿr;   Ú__main__)r7   r   r5   Úaiosmbr   Úaiosmb._versionr   Ú!aiosmb.commons.connection.factoryr   Úaiosmb.dcerpc.v5.connectionr   Ú1aiosmb.dcerpc.v5.common.connection.authenticationr   Ú'aiosmb.dcerpc.v5.interfaces.endpointmgrr   Ú*aiosmb.dcerpc.v5.interfaces.servicemanagerr   r	   r'   r;   Ú__name__r%   r%   r%   r&   Ú<module>   s   "
ÿ