o
    Žõ±j«  ã                   @   s¦   d dl Z 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 d d	lmZ d
d„ Zdd„ ZedkrQeƒ  dS dS )é    N)Úlogger)Ú
__banner__)ÚSMBConnectionFactory)ÚICPRRPC)ÚDCERPC5Connection)Ú
DCERPCAuth)ÚEPM)ÚSAMRRPCc              
   Ã   s>  ��z�t dƒ t | ¡}| ¡  ¡ }t dƒ tj|tƒ j| ¡ j	| ¡ j
d�I d H \}}|d ur2|‚t dƒ t | ¡ ¡}t||ƒ}tj|dd�I d H \}}|d urT|‚t d¡ | ¡ 2 zH3 d H W \}}|dkrjq]| |¡I d H \}	}|d urz|‚t |	ƒ | |	¡I d H \}
}|d urŽ|‚| |
d	¡I d H \}}|d urŸ|‚t | ¡ ƒ q]6 | ¡ 2 zÐ3 d H W \}}|d ur¹|‚t |ƒ | |¡I d H \}	}|d urÍ|‚t |	ƒ | |	¡I d H \}
}|d urá|‚| |
¡I d H \}}|d urñ|‚t | ¡ ƒ | |
¡2 z}3 d H W \}}}|d u�r|‚t |ƒ | |
|¡I d H \}}|d u�r"|‚| |¡2 zP3 d H W \}}|d u�r6|‚t |ƒ | d
¡d }t d| ƒ | |
t|ƒ¡I d H \}}|d u�r[�q't dƒ | |¡I d H \}}|d u�rp|‚t | ¡ ƒ �q'6 qü6 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Údomainz![+] Connecting to WKST service...T)Úperform_dummyzService DCE Connected!ÚTESTÚAdministratorú-éÿÿÿÿzUser RID: %szOK!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_domainsÚget_domain_sidÚopen_domainÚget_user_by_nameÚdumpÚget_infoÚlist_aliasesÚ
open_aliasÚlist_alias_membersÚsplitÚ	open_userÚintÚget_user_infoÚ	ExceptionÚ	tracebackÚ	print_exc)ÚurlÚsuÚipÚtargetÚerrÚauthÚ
connectionÚrpcr   ÚdsidÚhdomainÚuserinfoÚdinfoÚgnameÚgsidÚhaliasÚmsidÚusidÚhuserÚuinfoÚe© r?   ú‰/root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/aiosmb/examples/dcesam.pyÚamain   sš   €
,

ï	




ð÷å6€þrA   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ÚrunrA   rF   )rI   ÚparserÚargsr?   r?   r@   Úmain{   s   
ÿÿrU   Ú__main__)rQ   r)   rO   ÚosÚaiosmbr   Úaiosmb._versionr   Ú!aiosmb.commons.connection.factoryr   Ú#aiosmb.dcerpc.v5.interfaces.icprmgrr   Úaiosmb.dcerpc.v5.connectionr   Ú1aiosmb.dcerpc.v5.common.connection.authenticationr   Ú'aiosmb.dcerpc.v5.interfaces.endpointmgrr   Ú#aiosmb.dcerpc.v5.interfaces.samrmgrr	   rA   rU   Ú__name__r?   r?   r?   r@   Ú<module>   s"   j
ÿ